akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
// #define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

ll mod;
// 繰り返し二乗法 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,p;cin>>n>>p;mod=p;
    string s;cin>>s;

    if(p==2){
        ll ans=0;
        reverse(ALL(s));
        rep(i,n){
            if((s[i]-'0')%2==0){
                ans+=n-i;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    if(p==5){
        ll ans=0;
        reverse(ALL(s));
        rep(i,n){
            if((s[i]-'0')%5==0){
                ans+=n-i;
            }
        }
        cout<<ans<<endl;
        return 0;
    }



    reverse(ALL(s));
    ll num=0;
    vector<ll> a(n+1);a[0]=0;
    rep(i,n){
        num=num+pow_mod(10%p,i)*(s[i]-'0')%mod;
        num%=mod;
        a[i+1]=num;
    }
    vector<ll> cnt(p+1,0);
    rep(i,n+1) cnt[a[i]]++;
    ll ans=0;
    rep(i,p){
        ans+=cnt[i]*(cnt[i]-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

/*
6 7 
389675
*/


Measured memory_bytes: 2196
import sys
from collections import defaultdict

def fill(s):
    while len(s) < 6: s = '0' + s
    return s

def create_id(p, o):
    return fill(str(p)) + fill(str(o))

n, m, *py = map(int, sys.stdin.read().split())
py = zip(*[iter(py)] * 2)

def main():
    db = defaultdict(list)
    i = 0
    for p, y in py:
        db[p].append((y, i))
        i += 1

    res = [None] * m
    for p in db:
        db[p].sort()
        for i in range(len(db[p])):
            res[db[p][i][1]] = create_id(p, i + 1)
    print(*res, sep='\n')

if __name__ ==  '__main__':
    main()

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

int main() {
    string S;
    cin >> S; // a 4-digit code
    bool A = true;
    if (S[0] == S[1]) A = false;
    if (S[1] == S[2]) A = false;
    if (S[2] == S[3]) A = false;
    if (A) cout << "Good" <<endl;
      else cout << "Bad" <<endl;   
    
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<P, Int> T;
Int n, k, v,m;
Int a[216000];
Int b[216000];
Int c[216000];
Int u[216000];
Int us[216000];
Int vs[216000];
Int sum[216000];

vector<P> edges;
vector<Int> child[108000];
Int init(){
	for(Int i = 0;i < 216000;i++)u[i] = i;
}

Int r(Int x){
	if(u[x] == x)return x;
	return u[x] = r(u[x]);
}

Int unite(Int x, Int y){
	x = r(x);
	y = r(y);
	if(x != y)u[y]= x;
}

Int dp(Int x){
	sum[x] = b[x];
	Int ans = c[x];
	for(Int i = 0;i < child[x].size();i++){
		Int to = child[x][i];
		Int tmp = dp(to);
		ans = min(ans, -sum[to] + max(c[x], tmp));
		sum[x] += sum[to];
	}
	ans += sum[x];
	return ans;
}

int main(){
	init();
	cin >> n >> m;
	for(Int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
		a[i] = max(a[i], b[i]);
		c[i] = a[i] - b[i];
	}
	for(Int i = 0;i < m;i++){
		cin >> us[i] >> vs[i];us[i]--,vs[i]--;
		edges.push_back(P(max(c[us[i]],c[vs[i]]),i));
	}
	sort(edges.begin(), edges.end());
	for(Int i = 0;i < edges.size();i++){
		Int cost = edges[i].first;
		Int ind = edges[i].second;
		Int u = us[ind], v = vs[ind];
		if(r(u) == r(v))continue;
		if(c[u] < c[v])swap(u,v);
		child[r(u)].push_back(r(v));
		unite(u, v);
	}
	cout << dp(r(0)) << endl;
	return 0;
}

Measured memory_bytes: 23024
N = gets.to_i
S = gets.chomp
E = Array.new(N + 1, 0)
W = Array.new(N + 1, 0)

(1 .. N).each do |i|
  if S[i - 1] == 'E'
    E[i] = E[i - 1] + 1
    W[i] = W[i - 1]
  else
    E[i] = E[i - 1]
    W[i] = W[i - 1] + 1
  end
end
puts (1 .. N).map{|i| W[i - 1] + E[N] - E[i]}.min




Measured memory_bytes: 9484
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int n,a;
    cin >> n >> a;
    int surplus = n%500;
    if(surplus<=a) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define AC 0
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	const int mod=1e9+7;
	int n;
	cin>>n;
	vector<int> a(n),sum(n+1);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=n-1;i>=0;i--) sum[i]=(sum[i+1]+a[i])%mod;
	int ans=0;
	for(int i=0;i<n-1;i++) ans=(ans+1ll*a[i]*sum[i+1]%mod)%mod;
	cout<<ans<<'\n';
	return AC;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;



int main() {
	ll n;
	cin >> n;

	if (n % 1000 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1000 - n % 1000 << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
import itertools
n = int(input())
l = [list(v) for v in itertools.permutations(range(1, n + 1))]

p = list(map(int, input().split()))
p_index = l.index(p)

q = list(map(int, input().split()))
q_index = l.index(q)

print(abs(p_index - q_index))

Measured memory_bytes: 10228
/*input

*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

ll dp[3001][3001][4], a[3001][3001];
int r, c, k;

ll slv(int i, int j, int used) {
	if(3<used) return LLONG_MIN;
	if(i>r || j>c) return 0;
	if(dp[i][j][used]!=-1) return dp[i][j][used];
	return dp[i][j][used]=max({
		a[i][j]+slv(i, j+1, used+1),
		(used<3?a[i][j]:0)+slv(i+1, j, 0),
		slv(i, j+1, used),
		slv(i+1, j, 0)
	});
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	cin >> r >> c >> k;
	memset(dp, -1, sizeof(dp));
	memset(a, 0, sizeof(a));
	rep(i, k) {
		int ri, ci, vi;
		cin >> ri >> ci >> vi;
		a[ri][ci]=vi;
	}
	cout << slv(0, 0, 0);
	return 0;
}

Measured memory_bytes: 356252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

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

	int n;
	cin >> n;
	vll a(n);
	rep(i, n)cin >> a[i];

	ll ans = INF;
	rep(i, n) {
		repr(j, i + 1, n) {
			if (a[i] > a[j]) {
				continue;
			}
			
		}
	}

	ll t = INF;
	int x = 0;
	t = INF;
	bool f = true;
	while (f) {
		t = INF;
		rep(i, n) {
			if (a[i] == 0) continue;
			if (a[i] < t) {
				t = min(a[i], t);
				x = i;
			}
		}
		rep(i, n) {
			if (i == x) continue;
			a[i] = a[i] % t;
		}
		rep(i, n) {
			//cout << a[i] << ' ';
		}

		int c = 0;
		rep(i, n) {
			if (a[i] != 0) {
				c++;
				ans = a[i];
			}
		}
		if (c == 1) {
			f = false;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1024
// C - Build Stairs
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  lli now = -1;
  rep(i, 0, n)
  {
    // cout << "i: " << i << " now: " << now << endl;
    if (d[i] == now)
      continue;
    if (d[i] - 1 >= now)
      now = d[i] - 1;
    else
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var (
		d [5]int
		k int
	)
	for i := 0; i < 5; i++ {
		fmt.Scanln(&d[i])
	}
	fmt.Scanln(&k)

	if d[4]-d[0] > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws Exception{
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    
    new Solution(a,b,c,d);
  }
}

class Solution {
  public Solution(int a, int b, int c, int d) {
    int first = (int)((double)c / b) + (c % b == 0 ? 0 : 1);
    int second = (int)((double)a / d) + (a % d == 0 ? 0 : 1);
    if(first <= second) System.out.println("Yes");
    else System.out.println("No");
    // System.out.println(res);
  }
}


class FastScanner {
  private final InputStream in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  public FastScanner(InputStream source) {
    in = source;
  }

  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;
  }

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

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

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    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: 32512
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

string s, t;
map<char,int> tem;
map<char, set<int> > pos;

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

  cin >> s >> t;
  
  for(int i=0;i<sz(s);i++){
    tem[s[i]] = 1;
    pos[s[i]].insert(i+1);
  }

  lli ans = 0, ult = 0;

  for(auto i : t){
    if(!tem[i]){
      cout << -1 << endl;
      return 0;
    }
  }

  for(int j=0;j<sz(t);j++){
    char i = t[j];
    auto atual = pos[i].upper_bound(ult);
    // cout << i << " - " << *atual << endl;
    if(atual == pos[i].end()){
      ans += sz(s) - ult;
      ult = *pos[i].begin();
      ans += ult;
    } else {
      ans += *atual - ult;
      ult = *atual;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    string abc = "ABC";
    int ans = 0;
    for(int i = 0; i < N-2; i++) {
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define DIVISOR 1000000007
#define NUM_MAX 200000
// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

struct point2d {
    int row;
    int col;
};

struct pair {
    int x;
    int y;
};

struct pair gcdext(int a, int b) {
    if(a==0) { return (struct pair){0, 1}; }
    struct pair p = gcdext(b%a, a);
    return (struct pair){p.y - (b/a)*p.x, p.x};
}
static int64_t factorial[NUM_MAX+1];
static int64_t inv_factorial[NUM_MAX+1];
void init_combi(int size) {
    factorial[0] = factorial[1] = 1;
    inv_factorial[0] = inv_factorial[1] = 1;
    int i;
    for(i = 2; i <= size; i++) {
        factorial[i] = (factorial[i-1] * i)%DIVISOR;
        struct pair p = gcdext(i, DIVISOR);
        int inv = (p.x + DIVISOR)%DIVISOR;
        inv_factorial[i] = (inv_factorial[i-1] * inv)%DIVISOR;
    }
    return;
}

int64_t calc_combi(int n, int k) {
    if(k > n) return 0;
    int64_t ans = 1;
    ans = (ans * factorial[n])%DIVISOR;
    ans = (ans * inv_factorial[n-k])%DIVISOR;
    ans = (ans * inv_factorial[k])%DIVISOR;
    return ans;
}


int64_t calc_routes(struct point2d p1, struct point2d p2) {
    int rs = p2.row - p1.row;
    int cs = p2.col - p1.col;
    return calc_combi(rs+cs, rs);
}

int main(void) {
    int rows, cols;
    get_int2(&rows, &cols);
    // edge
    rows--; cols--;
    int a, b;
    get_int2(&a, &b);
    init_combi(rows+cols);

    int64_t ans = 0;
    // usually, calc_combi(rows-1+cols-1, cols-1)
    int r;
    struct point2d boundary = (struct point2d){rows-a, b};
    for(r = 0; r <= boundary.row; r++) {
        int64_t res = 1;
        // lefttop
        struct point2d start1 = (struct point2d){0, 0};
        struct point2d end1 = (struct point2d){r, boundary.col};
        res = (res * calc_routes(start1, end1));
        // rows-i-i
        // rightbottom: rows-i, cols-b-1
        struct point2d start2;
        if(r == boundary.row) {
            start2 = (struct point2d){r, boundary.col};
        } else {
            start2 = (struct point2d){r, boundary.col+1};
        }
        struct point2d end2 = (struct point2d){rows, cols};
        res = (res * calc_routes(start2, end2))%DIVISOR;
#ifdef DEBUG
        printf("topleft: (%d %d) -> (%d %d)  ",
            start1.row, start1.col,
            end1.row, end1.col
        );
        printf("bottomright: (%d %d) -> (%d %d)",
            start2.row, start2.col,
            end2.row, end2.col
        );
        printf(" -> %lld\n", res);
#endif
        ans = (ans + res)%DIVISOR;
    }
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <math.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  string sunny = "Sunny";
  string cloudy = "Cloudy";
  string rainy = "Rainy";
  if(s == sunny){
    cout << cloudy << endl;
  } else if(s == cloudy){
    cout << rainy << endl;
  } else {
    cout << sunny << endl;
  }
  
  return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    vl a(n); rep(i, n) std::cin >> a[i];
    sort(rrng(a));
    ll ans = a[0];
    int remain = n-2, i = 1;
    while (remain) {
        if (remain > 1) remain -= 2, ans += a[i] * 2;
        else remain--, ans += a[i];
        i++;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 4780
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n = int(rl())
	ans = 1
	lim = 10**18
	flag = False
	for a in rli():
		if flag:
			if a == 0:
				ans = 0
				print(0)
				return
			continue
		ans *= a
		if ans > lim:
			flag = True
	print(ans if not flag else -1)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 82696
def calc(a,b,c,d,e,f):
	A=2*(c-a)
	B=2*(d-b)
	C=a*a-c*c+b*b-d*d
	D=2*(e-a)
	E=2*(f-b)
	F=a*a-e*e+b*b-f*f
	N=(A*E-D*B)
	X=(B*F-E*C)/N
	Y=(C*D-F*A)/N
	R=((X-a)**2+(Y-b)**2)**0.5
	return tuple(map(round,[X,Y,R],[3]*3))
l=[map(float,raw_input().split())for i in range(input())]
for k in l:print"%.3f %.3f %.3f"%(calc(*k))

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

int main()
{
    int x; cin >> x;
    if(x == 1) cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 3528
n, k = map(int, input().split())
s = input()

prev = s[0]
cnt = 0
l = []
for c in s:
    if c == prev:
        cnt += 1
    else:
        l.append(cnt)
        prev = c
        cnt = 1
l.append(cnt)

if s[0] == "0":
    l = [0] + l
if s[-1] == "0":
    l.append(0)

cumsum = [0]
for i in l:
    cumsum.append(cumsum[-1]+i)


k = min(len(l), 2*k+1)
ans = max(l[::2])
for i in range(len(l) - k + 1):
    if i % 2 == 1:
        continue
    ans = max(ans, cumsum[i+k]- cumsum[i])
print(ans)

Measured memory_bytes: 8308
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    int p, q;
    while(cin >> p >> q) {
        bool div = false;
        vector<int> vec;
        map<int, int> dict;
        dict[p % q] = 0;
        int col = 1;
        while(true) {
            p *= 10;
            vec.push_back(p / q);
            if(p % q == 0) {
                div = true;
                break;
            }

            if(dict.count(p % q)) {
                col = dict[p % q];
                break;
            }
            else {
                dict[p % q] = col;
            }
            col++;
            p %= q;
        }

        if(div) {
            for(int i = 0; i < (int)vec.size(); ++i) {
                cout << vec[i];
            }
            cout << endl;
        }
        else {
            for(int i = 0; i < (int)vec.size(); i++) {
                cout << vec[i];
            }
            cout << endl;
            for(int i = 0; i < col; i++) {
                cout << ' ';
            }
            for(int i = 0; i < (int)vec.size() - col; i++) {
                cout << '^';
            }
            cout << endl;
        }

    }
}

Measured memory_bytes: 1224
#include <stdio.h>
int main(void)
{
  char str[256];
  scanf("%s", str);
  int j = 0;
  for(int i = 0;str[i] != '\0';i++){
    if(i % 2 == 0){if(str[i] == 'L'){j++;}}
    if(i % 2 == 1){if(str[i] == 'R'){j++;}}
   }
  if(j == 0){printf("Yes");}
  if(j != 0){printf("No");}
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	
	cin>>n;
	int x;
	int cont=0;
	int y=0;
	for(int i=0;i<n;i++) 
	{
		cin>>x;
		if(x>=y){
			 cont++;
			 y=x;
		}
		
	}
	cout<<cont;
	
	return 0;
}



Measured memory_bytes: 256
use v5.18;
use warnings;
use utf8;
use Data::Dumper;
use constant INF => 999999;
sub line { chomp(my $str = <>); $str; }
sub split_line { (split / /, line) }

main();

sub solve {
  my ($grid, $h, $w) = @_;
  # return -1 if $start->{color} eq '#';
  my @directions = (
    { x => 1, y => 0 },
    { x => 0, y => 1 },
    { x => -1, y => 0 },
    { x => 0, y => -1 },
  );
  my $start = $grid->[0][0];
  $start->{distance} = 1;
  my @queue = ($start);
  while (my $mass = pop @queue) {
    for my $direction (@directions) {
      my $point = {
        x => $mass->{x} + $direction->{x},
        y => $mass->{y} + $direction->{y},
      };
      my $adjacent = $grid->[ $point->{y} ][ $point->{x} ];
      if ( $point->{x} >= 0
        && $point->{y} >= 0
        && $point->{x} < $w
        && $point->{y} < $h
        && $adjacent->{color} eq '.' 
        && $adjacent->{distance} == INF )
      {
        $adjacent->{distance} = $mass->{distance} + 1;
        unshift @queue, $adjacent;
      }
    }
  }
  my $black_num = 0;
  for my $y (0 .. $h - 1) {
    for my $x (0 .. $w - 1) {
      $black_num++ if $grid->[$y][$x]->{color} eq '#'
    }
  }
  my $goal = $grid->[$h - 1][$w - 1];
  if ($goal->{distance} == INF) {
    -1;
  } else {
    ($h * $w - $goal->{distance}) - $black_num;
  }
}

sub main {
  my ($h, $w) = split_line;
  my $grid = [];
  for my $y (0 .. $h - 1) {
    my @line = split //, line;
    $grid->[$y] = [
      map {
        +{
          y => $y,
          x => $_,
          color => $line[$_],
          distance => INF,
        }
      } (0 .. $w - 1)
    ];
  }
  say solve($grid, $h, $w);
}



Measured memory_bytes: 2944
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
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; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    ll min_n = LL_INF;
    ll max_n = -LL_INF;
    ll sum = 0;
    for(ll a : A){
        chmin(min_n, a);
        chmax(max_n, a);
        sum+=a;
    }
    cout << min_n << ' ' << max_n << ' ' << sum << endl;
}


Measured memory_bytes: 3196
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String x=sc.next();
            if(x.equals("0"))break;
            int sum=0;
            for(int i=0;i<x.length();i++){
                sum+=(x.charAt(i)-'0')%10;
            }
            System.out.println(sum);
        }
    }
}




Measured memory_bytes: 26352
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
    int n,x,count=0,ans=0,a,b,c;
    string s;
    vector<int> v;
        cin>>a>>b>>c;
        if(a==5)count++;
         if(b==5)count++;
         if(c==5)count++;
         if(a==7)ans++;
          if(b==7)ans++;
          if(c==7)ans++;
        if(count==2&&ans==1)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
}

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

vector< vector<pair<int,int>> > graph(1, vector<pair<int,int> > () ) ;
int main()
{
	
	int n ; scanf("%d",&n) ;
	graph = vector< vector<pair<int,int> > > (n+1,vector<pair<int,int> > ()) ;

	vector<int> indegree(n+1) , extra(n+1) ;

	for(int i = 1 ; i < n; i++){
		int x , y ; scanf("%d%d",&x,&y) ;
		indegree[x] ++;
		indegree[y] ++;
		graph[x].emplace_back(y,i) ;
		graph[y].emplace_back(x,i) ;

	}
	vector<int> color(n+1 , -1) ;

	for(int i = 1 ; i <= n ; i ++){
		if(indegree[i] == extra[i]) continue ;
		bool ase[n+1] = {} ;
		int point = 1 ;
		vector<int> t_point ;
		for(auto x : graph[i]){
			int t = x.second ;
			if(color[t] != -1){
				ase[color[t]] = true ;  
			}
			else t_point.emplace_back(t) , extra[x.first]++;
		}
		for(auto x : t_point){

			while(ase[point]){
				point ++ ;
			}
			color[x] = point ++ ;

		}
	}

	cout << *max_element(color.begin() , color.end() ) << endl ;
	for(int i = 1; i < n ; i++){
		cout << color[i] << endl ;
	}


    return 0;
}


Measured memory_bytes: 7808
#include<stdio.h>

int main(void)
{
	int i,i2,a;
	for(i=1;i<=9;i++)
	{
		for(i2=1;i2<=9;i2++)
		{
			a=i*i2;
			printf("%dx%d=%d\n",i,i2,a);
		}
	}
	return 0;
}

Measured memory_bytes: 924
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // string s;
    // cin>>s;
   	// int flag=1;
    // for(int i=0;i<s.size();++i){
    // 	for(int j=i+1;j<s.size();++j){
    // 		if(s[i]==s[j]){
    // 			flag=0;
    // 			break;
    // 		}
    // 	}
    // }
    // cout<<((flag)?"yes":"no");



    // string s;
    // cin>>s;
    // set<char>c;
    // for(char k:s) c.insert(k);
    // cout<<((s.size()==c.size())?"yes":"no");
    


    // string s;
    // cin>>s;
    // map<char,int>m;
    // for(int i=0;i<s.size();++i){
    // 	if(m[s[i]]>0){
    // 		cout<<"no";
    // 		return 0;
    // 	}
    // 	++m[s[i]];
    // }
    // cout<<"yes";

    // int a,b;
    // cin>>a>>b;
    // int ans=a+b;
    // (ans>=10)?cout<<"error":cout<<ans;
    

    // int n;
    // cin>>n;
    // int a,mx=0,mi=1000;
    // for(int i=0;i<n;++i){
    // 	cin>>a;
    // 	if(mx<a) mx=a;
    // 	if(mi>a) mi=a;
    // }


    // int n;
    // cin>>n;
    // int ar[n];
    // for(int i=0;i<n;++i) cin>>ar[i];
   	// cout<<*max_element(ar,ar+n)-*min_element(ar,ar+n);
    

    // int n,m;
    // cin>>n>>m;
    // n+=2;
    // m+=2;
    // for(int i=0;i<n;++i){
    // 	for(int j=0;j<m;++j){
    // 		if(i==0 || i==n-1 || j==0 || j==m-1) cout<<"#";
    // 		else{
    // 			char c;
    // 			cin>>c;
    // 			cout<<c;
    // 		}
    // 	}
    // 	cout<<'\n';
    // }

    // int x,y;
    // cin>>x>>y;
    // int ar[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    // cout<<((ar[x]==ar[y])?"Yes":"No");
    

    // string a,b,c;
    // cin>>a>>b>>c;
    // cout<<(((a.back()==b.front()) && (b.back()==c.front()))?"YES":"NO");
    
    // int a,b,c;
    // cin>>a>>b>>c;
    // cout<<((a<=c && c<=b)?"Yes":"No");
   
	// string s(3,'0');
	// for(int i=0;i<3;++i) cin>>s.at(i);
	// int x=stoi(s);
	// cout<<((x%4==0)?"YES":"NO");       

    // int a,b,c;
    // cin>>a>>b>>c;
    // cout<<(((b*10+c)%4==0)?"YES":"NO");

    int n,m;
    cin>>n>>m;
    m*=2;
    int ar[m];
    for(int i=0;i<m;++i) cin>>ar[i];
    for(int i=1;i<=n;++i) cout<<count(ar,ar+m,i)<<'\n'; 
    return 0;
}

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

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

	int z;
	z=a*100+b*10+c;

	if(z%4==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
if(N<=111)cout<<"111";
else if(N>111&&N<=222)cout<<"222";
else if(N>222&&N<=333)cout<<"333";
else if(N>333&&N<=444)cout<<"444";
else if(N>444&&N<=555)cout<<"555";
else if(N>555&&N<=666)cout<<"666";
else if(N>666&&N<=777)cout<<"777";
else if(N>777&&N<=888)cout<<"888";
else if(N>888&&N<=999)cout<<"999";

return 0;
}


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

s=list(input())

ans = 0

for i in range(1000):
    i = str(i)
    keta = len(list(i))
    code = '0'*(3-keta)+i
    code = list(code)
    index = 0
    for j in s:
        if j == code[index]:
            index += 1
        if index == 3:
            break
    if index == 3:
        #print(code)
        ans += 1
print(ans)

Measured memory_bytes: 74160
#include <stdio.h>

int main(int argv, char *argc[]){
    int input, loop, checker;
    
    scanf("%d", &input);
    
    for(loop=1; input>=loop; loop++){
        if((loop%3) == 0){    
            printf(" %d", loop);
            continue;
        }
        
        for(checker=loop; 0<checker; checker/=10){
            if(((checker%10) == 3)){
                printf(" %d", loop);
                break;
            }
        }
        
    }
    
    printf("\n");
    return 0;
}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

#define M 210000

vector<ll> fac(M), finv(M), inv(M);

ll pow2mod(ll n)
{
    ll p = 1;

    REP(i,0,n/10) p = p * 1024 % MOD;
    REP(i,0,n%10) p = p * 2 % MOD;

    return p;
}

void combinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,M) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll combmod(ll n, ll r)
{
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    ll c = 1;
    REP(i,0,r) c = c * (n-i) % MOD;
    c = c * finv[r] % MOD;
    return c;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    combinit();

    ll res;
    res = (pow2mod(n) - 1 - combmod(n, a) - combmod(n, b)) % MOD;
    if (res < 0) res += MOD;

    _PR(res);

    return 0;
}

/*



*/

Measured memory_bytes: 5120
import java.util.*;
import java.util.regex.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        // 文字列反転処理
        StringBuffer sb = new StringBuffer(s);
        String reversedStr = sb.reverse().toString();
        
        // 文字列反転リスト
        List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser");
        List<String> reversedList = new ArrayList<>();
        for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        }

        // 正規表現
        String ptnStr = "^(" + String.join("|", reversedList) + ")+$";
        Pattern pattern = Pattern.compile(ptnStr);
        Matcher matcher = pattern.matcher(reversedStr);

        if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 37264
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;
void warps(vector<vector<string>> s, vector<vector<int>> warp, int kaisuu, int h, int w, int x, int y);
//
//void walk(vector<vector<string>> s,vector<vector<int>> warp,int kaisuu,int h,int w,int x,int y) {
//	int flag = 0;
//	warp[x][y] = kaisuu;
//	if (x != 0) {
//		if (s[x - 1][y] == "." && warp[x - 1][y] != kaisuu) {
//			warp[x - 1][y] = kaisuu;
//			walk(s, warp, kaisuu, h, w, x - 1, y);
//		}
//		else if (s[x - 1][y] == "#") {
//			flag = 1;
//		}
//	
//	}
//	if (y != 0) {
//		if (s[x][y - 1] == "." && warp[x][y - 1] != kaisuu) {
//			warp[x][y - 1] = kaisuu;
//			walk(s, warp, kaisuu, h, w, x, y - 1);
//		}
//		else if (s[x][y - 1] == "#") {
//			flag = 1;
//		}
//	}
//	if (x != h - 1) {
//		if (s[x + 1][y] == "." && warp[x + 1][y] != kaisuu) {
//			warp[x + 1][y] = kaisuu;
//			walk(s, warp, kaisuu, h, w, x + 1, y);
//		}
//		else if (s[x + 1][y] == "#") {
//			flag = 1;
//		}
//	}
//	if (y != w - 1) {
//		if (s[x][y + 1] == "." && warp[x][y + 1] != kaisuu) {
//			warp[x][y + 1] = kaisuu;
//			walk(s, warp, kaisuu, h, w, x, y + 1);
//		}
//		else if (s[x][y + 1] == "#") {
//			flag = 1;
//		}
//	}
//
//}
//
//void warps(vector<vector<string>> s, vector<vector<int>> warp, int kaisuu, int h, int w, int x, int y) {
//	for (int i = x - 2;i <= x + 2;i++) {
//		if (i < 0 || i >= h)continue;
//		for (int j = y - 2;j <= y + 2;j++) {
//			if (j < 0 || j >= w)continue;
//			if (warp[i][j] == -1 && s[i][j] == ".") {
//				warp[i][j] = kaisuu;
//			}
//		}
//	}
//}
//
//int main() {
//	int h, w;
//	cin >> h >> w;
//	int ch, cw, dh, dw;
//	cin >> ch >> cw >> dh >> dw;
//	vector<vector<string>> s(h,vector<string> (w));
//	vector<vector<int>> warp(h, vector<int>(w));
//	for (int i = 0;i < h;i++) {
//		for (int j = 0;j < w;j++) {
//			cin >> s[i][j];
//			warp[i][j] = -1;
//		}
//	}
//
//	walk(s, warp, 0, h, w, ch, cw);
//
//	cout << warp[dh][dw] << endl;
//
//	return 0;
//}

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

	if (a - b * 2 > 0) {
		cout << a - b * 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int cost[3][33]; // あまりがiのマスをjにするのに必要なコスト
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, C; cin >> N >> C;
  int D[C+1][C+1];
  FOR(i,1,C+1){
    FOR(j,1,C+1){
      cin >> D[i][j];
    }
  }
  int c[N][N];
  FOR(i,0,N){
    FOR(j,0,N){
      cin >> c[i][j];
    }
  }
  FOR(col,1,C+1){
    FOR(i,0,N){
      FOR(j,0,N){
        int co = D[c[i][j]][col];
        cost[(i+j)%3][col] += co;
      }
    }
  }
  int ans = 2e9;
  FOR(i,1,C+1){
    FOR(j,1,C+1){
      FOR(k,1,C+1){
        if(i == j || j == k || k == i) continue;
        ans = min(ans, cost[0][i]+cost[1][j]+cost[2][k]);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long int lli;

lli bs(lli l, lli r, const vector<lli> &logs, const lli K){
	if (l>r) return l;
    lli mid = (l+r)/2;
    lli k = K;
    for (int i = 0; i < logs.size(); i++){
    	lli x = 0;
    	if (logs[i]>mid){
    		if ((logs[i]%mid)==0) x = logs[i]/mid -1;
    		else x = logs[i]/mid;
    		k-=x;
    		if (k<0) return bs(mid+1, r, logs, K);
    	}
    }
    if (k>=0) return bs(l, mid-1, logs, K);
}

int main(){
//	while(cin){
		
    int N = 0;
    lli K = 0;
    lli Ai = 0;
    lli sum = 0;
    lli max = 0;
    vector<lli> logs;
    cin >> N >> K;
    while(N--){
        cin >> Ai;
        logs.push_back(Ai);   
        sum += Ai;     
        if (Ai>max) max = Ai;
    }
    N = logs.size();
    lli min_possible = 0;
    lli max_possible = 0;
    
    if (N>1) min_possible = ceil(sum/(K+N-1));
    
    else if (K>0) min_possible = ceil(sum/(K+1));
    
    else min_possible = sum;
    
    if (min_possible>max) min_possible = max;
    if (min_possible==0) min_possible = 1;
    max_possible = max;
//	cout << "sum: " << sum << "   " << "min_possible: " << min_possible << "   max_possible: " << max_possible << endl;
    
    cout << bs(min_possible, max_possible, logs, K) << endl;
//}
    return 0;
}

Measured memory_bytes: 4892
n = int(input())
s = []
for i in range(0, n):
    s.append(input())
 
c = 0
a = 0
b = 0
ab = 0
 
for i in range(0, n):
    for j in range(1, len(s[i])):
        if s[i][j-1:j+1] == "AB":
            c += 1
    if s[i][-1] == "A" and s[i][0] == "B":
        ab += 1
    else: 
        if s[i][0] == "B":
            b += 1
        if s[i][-1] == "A":
            a += 1
            
s = c
 
if ab > 0:
    s += ab - 1
    if a > 0:
        s += 1
        a -= 1
    if b > 0:
        s += 1
        b -= 1
 
s += min(a, b)
 
print(s)

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int a ,b,c;
		cin >>a >>b >>c;
		int lhs = 4*a*b ; 
		int rhs = (c-a-b) * (c-a-b);
		cout << (lhs < rhs && c>a+b ? "Yes":"No")  <<endl;
		
	}
	return 0;
}


Measured memory_bytes: 256
#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); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<ll> a(n+1), sum(n+1);
  a[0] = 0, sum[0] = 0;
  REP(i, 1, n) cin >> a[i];

  ll cnt1 = 0;
  REP(i, 1, n){
    sum[i] = sum[i-1] + a[i];
    if(i%2 == 1 && sum[i] >= 0){
      cnt1 += sum[i] - (-1);
      sum[i] = -1;
    }
    else if(i%2 == 0 && sum[i] <= 0){
      cnt1 += 1 - sum[i];
      sum[i] = 1;
    }
  }

  ll cnt2 = 0;
  REP(i, 1, n){
    sum[i] = sum[i-1] + a[i];
    if(i%2 == 0 && sum[i] >= 0){
      cnt2 += sum[i] - (-1);
      sum[i] = -1;
    }
    else if(i%2 == 1 && sum[i] <= 0){
      cnt2 += 1 - sum[i];
      sum[i] = 1;
    }
  }

  cout << min(cnt1, cnt2) << endl;

  return 0;
}


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

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true; 
    }

    int size(int x) {
        return -r[root(x)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    
    UnionFind UF(n);
    for (int i = 0; i < m; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
 
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4056
#include <iostream>
using namespace std;
int main(){

  long long n;
  cin>>n;
  if(n%4==0){
    cout<<n/4*3<<" "<<n/4*3<<" "<<n/4*3<<endl;
    return 0;
  }
  if(n%2==0){
    cout<<n/2<<" "<<n<<" "<<n<<endl;
    return 0;
  }
  for(int i=2;i<=3500;i+=2){
    for(int j=2;j<=3500;j+=2){
      if(4*i*j-n*i-n*j>0) if((n*i*j)%(4*i*j-n*i-n*j)==0){
        cout<<i<<" "<<j<<" "<<(n*i*j)/(4*i*j-n*i-n*j)<<endl;
        return 0;
      }
    }
  }

  return 0;

}






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

int main()
{
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c; 
  	return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c;
    cin >> c;
    int d;
    cin >> d;
if ( ( a >= b ) && ( c >= d ) ) {
        cout << ( b + d ) << endl;
}
 else if ( ( a >= b ) && ( c < d ) ) {
	cout << ( b + c ) << endl;
}
 else if ( ( a < b ) && ( c >= d ) ) {
        cout << ( a + d ) << endl;
}
 else {
	cout << ( a + c ) << endl;
} 
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		String result = "0";
		StringBuilder sb = new StringBuilder();
		while(n != 1 && n != 0){
		    if(n > 0){
		        int m = n;
		        n /= -2;
		        sb.append(m-n*(-2));
		    }else{
		        int m = n;
		        n = (n-1)/(-2);
		        sb.append(m-n*(-2));
		    }
		}
		sb.append(1);
		if(n != 0) result = sb.reverse().toString();
		
		// 出力
		System.out.println(result);
	}
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int length = S.size();
  if (T.size() - S.size() != 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < length; i++) {
    if (S.at(i) != T.at(i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3628