akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
#define PI 3.14159265359
typedef pair<ll, ll> pll;
const ll MAX = 1000000000000000000;
const char END = '\n';


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

	ll a;
	string s;

	cin >> a >> s;

	if (a >= 3200)
		cout << s << END;
	else
		cout << "red" << END;

	return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
	string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	int N;
	string S;
	cin >> N >> S;

	rep(i, S.length())
	{
		rep(j, alpha.length())
		{
			if (S[i] == alpha[j])
			{
				int num = j + N;
				if (num >= alpha.length())
					num -= alpha.length();

				cout << alpha[num];
			}
		}
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

void dfs(vvi g,int v, int &time,vb &seen,vi &first_time,vi &last_time) {
  first_time[v]=++time;
  seen[v]=true;
  for(auto next_v:g[v]) {
    if(seen[next_v]) continue;
    dfs(g,next_v,time,seen,first_time,last_time);
  }
  last_time[v]=++time;
}
void xdfs(vvi c,int h, int w,int y,int x,vvb &seen) {
  if(seen[y][x]) return;
  seen[y][x]=true;
  REP(i,8) {
    int cx=x+dx[i];
    int cy=y+dy[i];
    if(cx<0||cy<0||cx>=w||cy>=h) continue;
    if(c[cy][cx]!=1) continue;
    xdfs(c,h,w,cy,cx,seen);
  }
}


int main() {
  while (1)
  {
    int w,h;
    cin >> w >> h;
    if(w==0&&h==0) break;
    vvi c(h,vi(w,0));
    REP(i,h) {
      REP(j,w) {
        cin >> c[i][j];
      }
    }
    vvb seen(h,vb(w,false));
    int ans=0;
    REP(i,h) {
      REP(j,w) {
        if(c[i][j]!=1) continue;
        if(seen[i][j]) continue;
        xdfs(c,h,w,i,j,seen);
        ans++;
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 28940
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    FOR(i, 1, N) {
        int j;
        j = N - i;
        if (i < j)
            ans++;
    }
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
var n,i,j,k:integer;
hh:longint;f:boolean;
a:array[1..100,1..2]of integer;
h:array[1..100]of longint;
function max(o,p:longint):longint;
begin 
	if o>p then exit(o)
    else exit(p);
end;
begin 
	read(n);
    for i:=1 to n do
    	read(a[i,1],a[i,2],h[i]);
    k:=1;
    while h[k]=0 do inc(k);
    i:=a[k,1];a[k,1]:=a[1,1];a[1,1]:=i;
    i:=a[k,2];a[k,2]:=a[1,2];a[1,2]:=i;
    i:=h[k];h[k]:=h[1];h[1]:=i;
    for i:=0 to 100 do
    	for j:=0 to 100 do
       	begin 
        	hh:=h[1]+abs(i-a[1,1])+abs(j-a[1,2]);
            k:=2;f:=true;
            while (k<=n) and (f) do
            begin 
            	if h[k]<>max(0,hh-abs(i-a[k,1])-abs(j-a[k,2])) then f:=false
                else inc(k);
            end;
            if k>n then begin write(i,' ',j,' ',hh);exit;end;
        end;
end.
    


Measured memory_bytes: 128
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
  total = 0
  for b in range(B+1):
    for c in range(C+1):
      total = 500*a + 100*b + 50*c
      if total == X:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

ll N;
ll a[100];
string s;
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            swap(a[i],a[j]);
            bool f=true;
            for(int k=0;k<N-1;k++){
                if(a[k]>a[k+1]){
                    f=false;
                    break;
                }
            }
            if(f){
                cout<<"YES";
                return 0;
            }
            swap(a[i],a[j]);
        }
    }
    cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
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 main(){
    ll l, r; cin >> l >> r;
    ll ans = INFINITY;
    ll L = l % 2019;
    ll R = r % 2019;
    if(r - l >= 2019){
        cout << 0 << endl;
        return 0;
    }else{
        if(L <= R){
            for(ll i = L; i <= R; i++){
                for(ll j = i + 1; j <= R; j++){
                    ans = min(ans, (i * j) % 2019);
                }
            }
            cout << ans << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }
}

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

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

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

	int max_A = Y /10000 + 1;
	int max_B = Y /5000 + 1;

	int A = -1;
	int B = -1;
	int C = -1;
	bool halt = false;

	FOR(i,0,max_A){
		FOR(j,0,max_B){
			int k = (Y - 10000* i - 5000* j)/1000;
			if (i + j + k == N && k >= 0){
				A = i;
				B = j;
				C = k;
				halt = true;
				break;
			}
		}
		if (halt) break;
	}

	cout << A << " " << B << " " << C << endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define nil -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u){
	int i,c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	
	if ( T[u].p == nil ) cout << "root, ";
	else if ( T[u].l == nil ) cout << "leaf, ";
	else cout << "internal node, ";
	
	cout << "[";
	
	for ( i = 0, c = T[u].l; c != nil; i++, c = T[c].r ){
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int rec(int u, int p){
	D[u] = p;
	if ( T[u].r != nil ) rec( T[u].r, p );//右の番号は兄弟　同じ深さに設定
	if ( T[u].l != nil ) rec( T[u].l, p+1 );//T[u]の子供の一番左が存在する。その深さを一つ増やして再帰
}

int main(){
	int i,j,d,v,c,l,r;
	cin >> n;
	for( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = nil;
	
	for ( i = 0; i < n; i++ ){
		cin >> v >> d;
		for ( j = 0; j < d; j++ ){
			cin >> c;
			if ( j == 0 ) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for ( i = 0; i < n; i++ ){
		if (T[i].p == nil) r = i;
	}
	
	rec(r, 0);
	
	for ( i = 0; i < n; i++ ) print(i);
	
	return 0;
}


Measured memory_bytes: 7800
import static java.lang.System.out;
import java.lang.Math;
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Collections;

public class Main {
    public static void main(String args[]) {
        new Main().run();
    }

    MyInput in = new MyInput();
    public void run() {
        int R = in.nextInt();
        int G = in.nextInt();
        int ans = 2*(G - R) + R;
        out.println(ans);
    }
}

class MyInput {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr= 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if(ptr < buflen) {
            return true;
        }else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch(IOException e) {
                e.printStackTrace();
            }
            if(buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    public int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <=126;
    }

    private void skipUnprintable() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
        if('0' <= b && b <= '9') {
            n *= 10;
            n += b - '0';
        }else if(b == -1 || !isPrintableChar(b)) {
            return minus ? -n : n;
        }else {
            throw new NumberFormatException();
        }
            b = readByte();
        }
	}

    public int nextInt() {
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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



Measured memory_bytes: 21076
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	edges := map[int][]Edge{}
	for i := 0; i < n-1; i++ {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		if _, ok := edges[a]; !ok {
			edges[a] = []Edge{}
		}
		edges[a] = append(edges[a], Edge{Id: i, Dest: b})
	}

	edgeColor := make([]int, n-1)
	incommingColor := make([]int, n+1)
	queue := []int{1}

	maxColor := 1
	incommingColor[1] = 0
	for len(queue) > 0 {
		src := queue[0]
		queue = queue[1:]
		es := edges[src]

		color := 1
		for _, e := range es {
			if color == incommingColor[src] {
				color++
			}
			queue = append(queue, e.Dest)
			edgeColor[e.Id] = color
			incommingColor[e.Dest] = color
			if color > maxColor {
				maxColor = color
			}
			color++
		}
	}

	fmt.Printf("%d\n", maxColor)
	for _, c := range edgeColor {
		fmt.Printf("%d\n", c)
	}
}

type Edge struct {
	Id   int
	Dest int
}


Measured memory_bytes: 12288
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    string S;
    cin>>N>>S;
    if(N%2 == 1){
        cout<<"No"<<endl;
        return 0;
    }
    if(S.substr(0,N/2) == S.substr(N/2, N)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::vector<std::string> strings;
  int JOI_counter = 0;
  int IOI_counter = 0;

  // Inputs
  while (true) {
    int counter = 0;
    std::string buffer;
    std::cin >> buffer;
    if (std::cin.eof())
      break;
    strings.push_back(buffer);
    counter = counter + 1;
  }
  // Inputs End

  for (int i = 0; i < strings.size(); i++) {
    for (int j = 0; j < strings[i].length() - 2; j++) {
      if (strings[i][j] == 'J' && strings[i][j + 1] == 'O' &&
          strings[i][j + 2] == 'I')
        JOI_counter = JOI_counter + 1;
      if (strings[i][j] == 'I' && strings[i][j + 1] == 'O' &&
          strings[i][j + 2] == 'I')
        IOI_counter = IOI_counter + 1;
    }
    std::cout << JOI_counter << std::endl << IOI_counter << std::endl;
    JOI_counter = 0;
    IOI_counter = 0;
  }
}



Measured memory_bytes: 3004
arr1 = []
arr2 = []
g = gets.split.map(&:to_i)
arr1 = gets.chop.split.map(&:to_i)
# arr1 = [a, b, c]
arr2 = gets.chop.split.map(&:to_i)
# arr2 = [d, e, f]
h = [arr1, arr2].transpose
# h.map(&:to_i)

first = 0
h.each do |ele|
  if ele[0] > ele[1]
    #p ele[0]
    diff = ele[0] - ele[1]
    first += diff
  end
end
p first

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n , dp[5005][5005];
pair<ll,ll> a[5005];
bool cmp(pair<ll,ll> x,pair<ll,ll> y){
    return x.first+x.second < y.first+y.second;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=0;i<n;i++)cin>>a[i].first>>a[i].second;
    sort(a,a+n,cmp);
    memset(dp,0x3f,sizeof(dp));
    dp[0][0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=i;j++){
            if(dp[i][j]<=a[i].first)
                dp[i+1][j+1]=min(dp[i+1][j+1] , dp[i][j] + a[i].second);
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        }
    }
    for(ll i=n;i>=0;i--)if(dp[n][i]<(1e16))return cout<<i , 0;
}

Measured memory_bytes: 196096
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  vector<int> sum(201);
  for(int i=-100;i<101;i++){
    int tmp = 0;
    for(int j=0;j<N;j++){
      tmp += (i-a[j])*(i-a[j]);
    }
    sum.at(i+100) = tmp;
  }
  sort(sum.begin(),sum.end());
  cout << sum[0] << endl;
  return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int a, b;
  cin >> a >> b;
  if (a + b == 3)
    cout << 3 << '\n';
  else if (a + b == 4)
    cout << 2 << '\n';
  else 
    cout << 1 << '\n';
  return 0;
}

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

typedef long long ll;

using namespace std;
int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> lef,rig;
    for (auto i=0; i<n; ++i){
        ll in;
        cin >> in;
        if (in<0) lef.push_back(-in);
        else if(in==0) --k;
        else rig.push_back(in);
    }
    reverse(lef.begin(),lef.end());
    if (k==0){
        cout << '0' << endl;
        return 0;
    }
    if (lef.size()<1){
        cout << rig[k-1] << endl;
        return 0;
    }
    if (rig.size()<1){
        cout << lef[k-1] << endl;
        return 0;
    }
    vector<ll> sc;
    for (auto i=0; i<lef.size(); ++i){
        if (i+1+rig.size() < k)continue;
        if (i>=k) break;
        if((i+1)==k){
            sc.push_back(+lef[i]);
            continue;
        }
        auto j = k-i-2;
        ll score = 2*lef[i]+rig[j];
        sc.push_back(score);
    }
    for (auto i=0; i<rig.size(); ++i){
        if (i+1+lef.size() < k)continue;
        if (i>=k) break;
        if((i+1)==k){
            sc.push_back(rig[i]);
            continue;
        }
        auto j = k-i-2;
        ll score = 2*rig[i]+lef[j];
        sc.push_back(score);
    }
    auto ret = *min_element(sc.begin(),sc.end());
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 2548
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    string s;
    cin >> s;
    long cnt = 0;
    long res = 0;
    for (char c : s) {
        if (c == 'B') {
            cnt++;
        } else {
            res += cnt;
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(int& val: arr)
        cin >> val;
    int a = *max_element(arr.begin(), arr.end());
    int b = *min_element(arr.begin(), arr.end());
    double dis = fabs(double(b)-double(a)/2.0);
    for(int val: arr) {
        if (val == a) continue;
        if (fabs(double(val)-double(a)/2.0) < dis) {
            dis = fabs(double(val)-double(a)/2.0);
            b = val;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int a, b, c;
  while (input(a,b,c)) {
    cout << (a == b && b == c ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5056;
const ll inf = 1e18;
int n,p[N];
ll dp[N],a,b;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        --p[i];
    }
    ll ans = inf;
    for (int i = 0; i < n; ++i) {
        ll s = 0;
        dp[i] = inf;
        for (int j = i - 1; j >= 0; --j)  {
            if (p[j] < p[i])
                dp[i] = min(dp[i], dp[j] + s);
            s += p[j] < p[i] ? b : a;
        }
        dp[i] = min(dp[i], s);
        s = 0;
        for (int j = i + 1; j < n; ++j)
            if (p[j] < p[i])
                s += b;
            else
                s = inf;
//        cerr << i << ' ' << dp[i]  << ' '<< s << endl;
        ans = min(ans, dp[i] + s);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func max(nums ...int) int {
    if len(nums) == 0 {
        panic("funciton max() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Max(float64(res), float64(nums[i])))
    }
    return res
}

func main() {
	var a int
	var b int
	fmt.Scan(&a,&b)
	fmt.Println(max(a+b,a-b,a*b))
}

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

// int n;
// vector<vector<int>> a(100,vector<int>(100, -1)); // 各頂点間の重みを表す隣接行列
// vector<int> d(100, -1);

// void dijkstra(int start) {
//     vector<int> s;
    
//     s.push_back(start);
//     d[start] = 0;
//     while (s.size() < n) {
//         int min_v = 10000001, min_i;
//         rep(i, s.size()) {
//             int cur = s[i];
//             rep(j, n) {
//                 int adj = a[cur][j];
//                 if (adj != -1 && d[j] == -1 && d[cur] + adj < min_v) {
//                     min_v = d[cur] + adj;
//                     min_i = j;
//                 }
//             }
//         }
//         s.push_back(min_i);
//         d[min_i] = min_v;
//     }
// }

// int main() {
//     scanf("%d", &n);
//     rep(i, n) {
//         int u, k;
//         scanf("%d %d", &u, &k);
//         rep(j, k) {
//             int v, c;
//             scanf("%d %d", &v, &c);
//             a[u][v] = c;
//         }
//     }
//     dijkstra(0);
//     rep(i, n) {
//         printf("%d %d\n", i, d[i]);
//     }
// }

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

const int INF = 1000000000;
int n;
vector<vector<pair<int,int>>> e;
vector<int> d;
vector<bool> t;
void dijkstra(int start) {
    d[start] = 0;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
    pq.push({d[start],start});
    while (not pq.empty()) {
        int u = pq.top().second; // uは最短経路木に含まれない頂点のうちd[u]が最小であるもの
        pq.pop();
        t[u] = true; // uを最短経路木に含ませる
        rep(j, e[u].size()) {
            int v = e[u][j].first; // uの隣接点
            if (t[v] == false) { // 隣接点のうち最短経路木に含まれないもの
                if (d[u] + e[u][j].second < d[v]) { // e[u][j].secondはuから隣接点までの距離
                    d[v] = d[u] + e[u][j].second;
                    pq.push({d[v],v});
                }
            }
        }
    }
}

int main() {
    cin >> n;
    e.resize(n);
    rep(i, n) {
        int u, k;
        cin >> u >> k;
        rep(j, k) {
            int v, c;
            cin >> v >> c;
            e[u].push_back({v,c});
        }
    }
    d.resize(n,INF);
    t.resize(n,false);
    dijkstra(0);
    rep(i, n) {
        printf("%d %d\n", i, d[i]);
    }
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,t;
	cin>>n>>t;
	int ans=INT_MAX;
	For(i,n){
		int k,l;
		cin>>k>>l;
		if(l<=t){
			ans=min(ans,k);
		}
	}
	if(ans==INT_MAX){
		cout<<"TLE"<<endl;
	}else{
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a == 5 && b == 5 && c == 7 || a == 5 && b == 7 && c == 5 || a == 7 && b == 5 && c == 5)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
    }
}

Measured memory_bytes: 128
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	// var ap [100000]int
	// var bp [100000]int
	// var x, y, c, p int

	io := NewIo()
	defer io.Flush()
	a := io.NextInt()
	b := io.NextInt()
	c := io.NextInt()

	res := "Yes"
	r := c - a - b
	if r < 0 {
		res = "No"
	} else {
		l := 4 * a * b
		r = a*a + b*b + c*c - 2*a*c - 2*b*c + 2*a*b
		// l := float64(2.0) * math.Sqrt(float64(a*b))
		// // fmt.Printf("%v %v\n", l, r)
		// // fmt.Printf("ab %v\n", int(math.Sqrt(float64(2*a*b))))
		if l < r {
			res = "Yes"
		} else {
			res = "No"
		}
	}

	// if H == 1 || M == 1 {
	// 	res = 1
	// } else if (H%2) == 1 && (M%2) == 1 {
	// 	res = H*M/2 + 1
	// } else {
	// 	res = H * M / 2
	// }
	// fmt.Printf("%v %v %v\n", H, M, res)
	io.PrintLn(res)

	// amin := 10000000
	// for i := 0; i < A; i++ {
	// 	ap[i] = io.NextInt()
	// 	if amin > ap[i] {
	// 		amin = ap[i]
	// 	}
	// }

	// bmin := 100000000
	// for i := 0; i < B; i++ {
	// 	bp[i] = io.NextInt()
	// 	if bmin > bp[i] {
	// 		bmin = bp[i]
	// 	}
	// }

	// min := amin + bmin

	// for i := 0; i < M; i++ {
	// 	x = io.NextInt()
	// 	y = io.NextInt()
	// 	c = io.NextInt()
	// 	p = ap[x-1] + bp[y-1] - c
	// 	if min > p {
	// 		min = p
	// 	}
	// }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()


using namespace std;

const ll N = 1;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

int main() {
    speed;
    ll n;
    cin >> n;
    n %= 10;
    if(n == 3) {
    	cout << "bon\n";
	}
	else if(n == 0 || n == 1 || n == 6 || n == 8)
		cout << "pon\n";
	else
		cout << "hon\n";

}

/*
*/



Measured memory_bytes: 3584
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	int n;
	int p=0,w=0,g=0,y=0;
	char s[101];
	cin>>n;

	for(int i=0; i<n; ++i){
		cin>>s[i];
		if(s[i]=='P'){
			p++;
		}
		if(s[i]=='W'){
			w++;
		}
		if(s[i]=='G'){
			g++;
		}
		if(s[i]=='Y'){
			y++;
		}
	}
		if(p>0&&w>0&&g>0&&y>0){
			cout<<"Four"<<endl;
		}else{
			cout<<"Three"<<endl;
		}




	return 0;



}




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

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

#define pb push_back
#define fr first
#define sc second

const ll MOD = 1000000007;

int main(){
	static ll N,M;
	static ll l[302],r[302],x[302];
	scanf("%lld%lld",&N,&M);
	for(int i = 1 ; i <= M ; i ++){
		scanf("%lld%lld%lld",&l[i],&r[i],&x[i]);
	}
	
	static ll dp[2][302][302] = {};
	static ll t = 0, t_ = 1;
	dp[t][0][0] = 1;
	for(int i = 1 ; i <= N ; i ++){
		for(int j = 0 ; j < 302 ; j ++){
			for(int k = 0 ; k < 302 ; k ++){
				dp[t_][j][k] = 0;
			}
		}
		for(int j = 0 ; j < i ; j ++){
			for(int k = 0 ; k < i ; k ++){
				dp[t_][j][k] += dp[t][j][k];
				dp[t_][i-1][k] += dp[t][j][k];
				dp[t_][i-1][j] += dp[t][j][k];
			}
		}
		for(int j = 0 ; j < 302 ; j ++){
			for(int k = 0 ; k < 302 ; k ++){
				while(dp[t_][j][k] >= MOD)dp[t_][j][k] -= MOD;
			}
		}
		for(int j = 1 ; j <= M ; j ++){
			if(r[j] == i){
				if(x[j] == 1){
					for(int u = 0 ; u < 302 ; u ++){
						for(int v = 0 ; v < 302 ; v ++){
							if(u >= l[j] || v >= l[j])dp[t_][u][v] = 0;
						}
					}
				}
				else if(x[j] == 2){
					for(int u = 0 ; u < 302 ; u ++){
						for(int v = 0 ; v < 302 ; v ++){
							if(u < l[j] || v >= l[j])dp[t_][u][v] = 0;
						}
					}
				}
				else {
					for(int u = 0 ; u < 302 ; u ++){
						for(int v = 0 ; v < 302 ; v ++){
							if(u < l[j] || v < l[j])dp[t_][u][v] = 0;
						}
					}
				}
			}
		}
		swap(t,t_);
	}
	
	ll ret = 0;
	for(int i = 0 ; i < 302 ; i ++)for(int j = 0 ; j < 302 ; j ++)ret += dp[t][i][j];
	cout << ret%MOD << endl;
}
	



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/04/13  Problem: ABC 124 B / Link: http://abc124.contest.atcoder.jp/tasks/abc124_b  ----- */


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

	LL N; 
	cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	LL ans = 0LL;
	FOR(i, 0, N) {
		int ok = 1;
		FOR(j, 0, i) {
			ok &= a[i] >= a[j];
		}
		ans += ok;
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define N 10
using namespace std;
 
int d[N];
 
int main(void)
{
  int u, v;
  int i;
  
  for(i = 0; i < 3; i ++)
  {
    scanf("%d %d", &u, &v);
    ++ d[u];
    ++ d[v];
  }
  
  sort(d + 1, d + 5);
  
  puts(d[1] == 1 && d[2] == 1 & d[3] == 2 && d[4] == 2 ? "YES" : "NO");
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int K,T;
  cin>>K>>T;
  VI A(T);
  rep(i,T) cin>>A[i];
  sort(all(A));
  cout<<max(0,A[T-1]*2-K-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                push_back
#define mp              make_pair
#define sz(a)           a.size()
#define mods(a, m)          ((a % m + m) % m)
#define md(a)               mods(a, MOD)
#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 (int i = b; i < e; i++)
#define forr(i, b, e)     for (int  i = b; i < e; i++)
#define endl '\n'
int faster_in(){int 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 long double       ld;

typedef pair<int, int>  ii;
typedef pair<int,ii> iii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const int MOD = 1e9+7;
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 1000003 
int main()
{    
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    int valor;
    set<int> s;
    forr(i,0,n)
    {
        cin>>valor;
        s.insert(valor);
    }
    if (s.size()==n)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}   
// PLUS ULTRA!


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

int main() {
	int n;
	cin >> n;
	vector < int > a(n + 2);
	long long total = 0;
	for ( int i = 1; i <= n; i++ ) {
		cin >> a[i];
	}
	for ( int i = 1; i <= n + 1; i++ ) {
		total += abs( a[i - 1] - a[i] );
	}
	for ( int i = 1; i <= n; i++ ) {
		long long t = total;
		t -= abs( a[i - 1] - a[i] );
		t -= abs( a[i + 1] - a[i] );
		t += abs( a[i - 1] - a[i + 1] );
		cout << t << '\n';
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=9223372036854775806;
const int inf=2147483646;
int n,a[10][10],ans=0,d;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n>>d;
	for (int i=0;i<n;i++)
		for (int j=0;j<d;j++)
			cin>>a[i][j];
	for (int i=0;i<n;i++){
		for (int j=i+1;j<n;j++){
			int s=0;
			for (int k=0;k<d;k++){
				s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			int t=sqrt(s);
			if (t*t==s)
				ans++;
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int N,A;
  cin >> N >> A;
  if(N << 500 && N <= A){
    cout << "Yes" << endl;
  }
  else if (N << 500 && N >> A){
    cout << "No" << endl;
  }
  else if ((N%500) <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    vint x(N);
    REP(i,N) cin>>x[i];

    int ans=1e18;
    REP(l,N-K+1){
        int r=l+K-1;
        int dist=(x[r]-x[l])+min(abs(x[l]),abs(x[r]));
        ans=min(ans,dist);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
N = int(input())
A = [int(T) for T in input().split()]
RevA = A[::-1]
SumA = [0]*(N+1)
for TN in range(0,N):
    SumA[TN+1] = SumA[TN]+RevA[TN]
SumA = SumA[::-1]
Sum = 0
Mod = 10**9+7
for TA in range(1,N):
    Sum += (A[TA-1]*SumA[TA])%Mod
print(Sum%Mod)

Measured memory_bytes: 31564
#include<stdio.h>

int main(){
  int time;
  scanf("%d",&time);
  int h;
  int m;
  int s;
  h = time/60/60;
  m = time/60-60*h;
  s = time - h*60*60 - m*60;
  printf("%d:%d:%d\n",h,m,s);
}



Measured memory_bytes: 2144
#include<iostream>
#include<cmath>
#include<iomanip> 
using namespace std;
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double x1=h*30+m*0.5;
    double x2=m*6;
    double x=fabs(x1-x2);
    if(x>180)
     x=360-x;
    double ans=sqrt(a*a+b*b-2*a*b*cos(x*acos(-1.0)/180));
    cout<<fixed<<setprecision(20)<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int nodes,edges;
	cin >> nodes >> edges;
	vector<int> adj[nodes+1];
	vector<bool> visited(nodes+1);
	vector<int> ans(nodes+1);
	for(int i=1;i<=edges;i++)
	{
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	queue<int> q;
	q.push(1);
	ans[1] = 1;
	visited[1] = true;
	while(!q.empty())
	{
		int cur = q.front();
		q.pop();
		for(int next : adj[cur])
		{
			if(!visited[next])
			{
				q.push(next);
				visited[next] = true;
				ans[next] = cur;
			}
		}
	}
	cout << "Yes\n";
	for(int i=2;i<=nodes;i++)
		cout << ans[i] << "\n";
}	


Measured memory_bytes: 10084
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// a < b
ll f(ll a, ll b){
    // cout << "a, b " << a << " " << b << endl;
    if(a > b){
        swap(a, b);
    }
    
    if(a==b){
        return a;
    }
    else if(b%a==0){
        ll num = (b/a)*2 - 1;
        return a * num;
    }
    else{
        return 2 * (b/a) * a + f(a, b%a);
    }
}

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

    // input
    ll N, X;
    cin >> N >> X;

    p(N + f(N-X, X));

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	static final int sum = 196665;
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		String string;
		
		int n = Integer.valueOf(reader.readLine()), day;
		for(int i = 0; i < n; i++){
			string = reader.readLine();
			day = app.solve(string.split(" "));
			System.out.println(sum - day);
		}
		reader.close();
	}
	
	public int solve(String str[]){
		int res = 0, y, m, d;
		y = Integer.valueOf(str[0]);
		m = Integer.valueOf(str[1]) - 1;
		d = Integer.valueOf(str[2]) - 1;
		
		for(int i = 1; i <= y; i++){
			if(i % 3 == 0) res += 200;
			else           res += 195;
		}
		if(y % 3 == 0) res += m * 20 - 5;
		else
			for(int i = 1; i <= m; i++){
				if(i % 2 != 0) res += 20;
				else		   res += 19;
			}
		return res + d;
	}
	
}

Measured memory_bytes: 24320
/*
Author : Vidish Joshi
*/

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

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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define FOR1(i, m, n) for(i=m; i<n; i++)
#define FOR2(i, n, m) for(i=n-1; i>=m; i--)
#define v(v) ll v; cin>>v
#define mod 1000000007
#define mod2 998244353
#define mp make_pair
#define pb push_back
#define fill(a) memset(a, 0, sizeof(a))
#define start ll t; cin>>t; while(t--)

void re() {}
template <typename T, typename... args>
void re(T &x, args &... tail)
{
    cin >> x;
    re(tail...);
}
void pr() {}
template <typename T>
void pr(const T &x)
{
    cout << x;
}
template <typename T, typename... args>
void pr(const T &x, const args &... tail)
{
    cout << x << " ";
    pr(tail...);
}
template <typename... args>
void prln(const args &... tail)
{
    pr(tail...);
    cout << "\n";
}

int numOfDigits(ll n){
	return floor(log10(n)) + 1;
}

int main(){
	FIO;
	ll last[10][10];
	ll first[10][10];
	
	for(ll i=0; i<10; i++){
		for(ll j=0; j<10; j++){
			last[i][j] = 0; first[i][j] = 0;
		}
	}
	ll n; cin>>n;
	for(ll i=1; i<=n; i++){
		int x = numOfDigits(i);
		ll y = i%10;
		ll z = (i/((pow(10, x-1))));
		
		first[z][y]++;
		last[y][z]++;
			
	}
	
	ll ans = 0;
	for(ll i=0; i<10; i++){
		for(ll j=0; j<10; j++){
			ans += last[i][j] * first[i][j];
		}
	}
	cout<<ans;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int Tsukasa[1000];  //parent
int Hizikata[1000]; //left-child
int Yuuma[1000];    //right-child  May Be Yuma
bool used[1000];
int counter=0,n,Pos;
bool finfin=false;
 
void Init(int n){
  for(int i=0;i<n;i++){
    Tsukasa[i]=-1;
    Hizikata[i]=-1;
    Yuuma[i]=-1;
    used[i]=false;
  }
}
 
int SRoot(int n){ // root search
  for(int i=0;i<n;i++)if(Tsukasa[i] == -1)return i;
  return -2;
}
 
void Print(int s){ // print s and count number of used node
  printf("%d",s);
  counter++;
  if(counter != n)printf(" ");
  used[s]=true;
}
void BInit(int n){ // init of array
  for(int i=0;i<n;i++){
    used[i] = false;
  }
}
 
int Pre(int s){ // Preorder
  if(s!= -1){
    Print(s);
    Pre(Hizikata[s]);
    Pre(Yuuma[s]);
  }
}
 
 
int In(int s){ // Inorder
  if(s != -1){
    In(Hizikata[s]);
    Print(s);
    In(Yuuma[s]);
  }
}
 
int Po(int s){ //Postorder
  if(s != -1){
    Po(Hizikata[s]);
    Po(Yuuma[s]);
    Print(s);
  }
}
 
int main(){ // most important function. perhaps we cannot take "accepted" without this.
  int id,lef,rig,rn;
  
  scanf("%d\n",&n);
  
  Init(n); 
  rn = n;
  while(rn-- > 0){
    scanf("%d %d %d\n",&id,&lef,&rig);
    Tsukasa[lef] = Tsukasa[rig] = id;
    Hizikata[id] = lef;
    Yuuma[id] = rig;
  }
  // Tsukasa-array is used to store datas about parent
  // if node doesnt have parent, it is -1
  
  printf("Preorder\n");
  counter=0;
  printf(" ");
  Pre(SRoot(n));
  printf("\n");
 
  BInit(n);
  counter=0;
  printf("Inorder\n");
  printf(" ");
  In(SRoot(n));
  printf("\n");
 
  BInit(n);
  counter=0;
  printf("Postorder\n");
  finfin=false;
  BInit(n);
  printf(" ");
  Po(SRoot(n));
  printf("\n");
  return 0;
}



Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		try (Scanner cin = new Scanner(System.in)) {

			int N = cin.nextInt();
			int K = cin.nextInt();
			int x = 0;
			int ans = 0;

			for (int i = 0; i < N; i++) {
				x = cin.nextInt();
				ans += 2 * Math.min(x, K - x);
			}

			System.out.println(ans);

		} finally {
		}
	}

}


Measured memory_bytes: 22356
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

#define REP(i, N) for(int i = 0; i < N; ++i)
#define FOR(i, M, N) for(int i = M; i < N; ++i)

using namespace std;

int main() {
	long long numberOfBiscuits = 1;
	long long havingMoney = 0;
	long long K, A, B;
	cin >> K >> A >> B;

	for (long long i = 0;;) {
		if (havingMoney != 0) {
			numberOfBiscuits += B;
			--havingMoney;
			++i;
		}
		else if (havingMoney == 0 && numberOfBiscuits >= A && K - i > 1 && (B - A) > 1) {
			numberOfBiscuits -= A;
			++havingMoney;
			++i;
		}
		else{
			++numberOfBiscuits;
			++i;
		}
		if (i == K)break;
	}

	cout << numberOfBiscuits << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504