akhauriyash/Code-Regression huggingface dataset:
import random

import numpy as np

global NN
NN = 26


class Contest:
    """
    d: ある日付
    i: テストの種類
    self.day: 最後にテストiを開催した日
    """

    def __init__(self, c, s, D):
        self.test = [i % NN for i in range(D)]
        self.last = [0 for _ in range(NN)]
        self.C = c
        self.S = s
        self.score = 0

    def minus_score(self, d, i):
        m = self.C[i] * (d - self.last[i])
        return m

    def sum_minus_scores(self, d):
        m = 0
        for i in range(NN):
            m += self.minus_score(d, i)

        return m

    # テストiを開催したときのスコア
    def update_score(self, i, d):
        s = self.score
        self.last[i] = d
        s += S[d][i]
        s -= self.sum_minus_scores(d)
        return s

    # 日付を更新せずにスコアを計算
    def calc_score(self, i, d):
        s = self.score
        last_d = self.last[i]
        self.last = d
        s += S[d][i]
        s -= self.sum_minus_scores(d)
        self.last = last_d

        return s


D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

T = Contest(C, S, D)

# 各日付で最大のSを選び実行する
tests = []
for s in S:
    ss = np.array(s)
    tests.append(np.argmax(ss))


ans = [i + 1 for i in tests]
print(*ans)


"""
+ 方針
  + Cの大きいテストは定期的に開催する
  + Cの小さいテストはまれに開催する
    + d = 1, 2, 3, 4, 5 ....
    + d-last[d] = 1, 3, 6, 10, 15 ...
    + 結構緩やか？

+ スコアを伸ばす方法
  + プラスを大きくする
  + マイナスを小さくする

"""


Measured memory_bytes: 27436
package main

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

var sc = NewScanner(os.Stdin, 1000000)

func main() {
	A := sc.readInt()
	B := sc.readInt()
	if B%A == 0 {
		fmt.Println(A + B)
	} else {
		fmt.Println(B - A)
	}
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	double d, t, s;
	cin >> d >> t >> s;
	
	if(s*t >= d)cout << "Yes";
	else cout << "No";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3732
/**
 * auther: moririn_cocoa
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second

int main(void) {
  
  int A;
  int B;
  int C;
  
  cin >> A;
  cin >> B;
  cin >> C;
  
  if ( A == B && B != C ) {
    
    cout << C << endl;
  }
  
  else if ( A == C && A != B ) {
    
    cout << B << endl;
  }
  
  else {
    
    cout << A << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<20

using namespace std;

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

int cost[105][105];
int mincost[105];
bool used[105];

int prim (int n )
{
	memset (used, false, sizeof (used ) );
	rep (i, n ) mincost[i] = INF;

	mincost[0] = 0;
	int res = 0;

	while (true ){
		int v = -1;
		// X  に属さない頂点のうち X からの辺のコストが最小になる頂点を探す
		rep (u, n )
			if (!used[u] && (v == -1 || mincost[u] < mincost[v] ) ) v = u;

		if (v == -1 ) break;

		used[v] = true;
		res += mincost[v];

		rep (u, n ) mincost[u] = min (mincost[u], cost[v][u] );
	} // end while

	return res;
}

int main()
{
	memset (cost, -1, sizeof (cost ) );
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	rep (i, n ) rep (j, n ) cost[i][j] = INF;

	rep (i, n ) rep (j, n ){
		int in; cin >> in;
		if (in == -1 ) in = INF;
		cost[i][j] = in;
	} // end rep

	int res = prim(n );
	cout << res << endl;
		
	return 0;
}

Measured memory_bytes: 1248
#include<stdio.h>
#include<string.h>
int main(void){
	char s[50],t[50];
	scanf("%s %s",s,t);
	int a=strlen(s),b=strlen(t);
	int len,m=-1,i,j;
	for(i=a-b;0<=i;i--){
		len=0;
		for(j=0;t[j]!='\0';j++){
			if(s[i+j]!=t[j]&&s[i+j]!='?'){break;}
			len++;
		}
		if(len==b){m=i;break;}
	}
	if(m<0){printf("UNRESTORABLE");return 0;}
	for(i=0;s[i]!='\0';i++){
		if(m<=i&&i<m+b){s[i]=t[i-m];}
		if(s[i]=='?'){s[i]='a';}
	}
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>

using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s;
	cin >> s;
	int k;
	cin >> k;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != 'a' && s[i] + k > 'z') {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	s[s.length() - 1] = 'a' + ((s[s.length() - 1] - 'a') + k % 26) % 26;
	cout << s << endl;
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) {
    if (s[i] == 'R') a[i] = 0;
    if (s[i] == 'G') a[i] = 1;
    if (s[i] == 'B') a[i] = 2;
  }
  vector<ll> cnt(3);
  rep(i,n) cnt[a[i]]++;
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  rep(j,n)rep(i,j) {
    int k = j*2 - i;
    if (k < n) {
      if (s[i] == s[j]) continue;
      if (s[i] == s[k]) continue;
      if (s[k] == s[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

bool flag[100];

int main() {
  int N;
  cin >> N;
  int h[N];
  for (int i = 0; i < N; i++) cin >> h[i];

  int maxi = 0;
  for (int i = 0; i < N; i++) maxi = max(maxi, h[i]);

  ll ans = 0;
  for (int i = 1; i <= maxi; i++) {
    int cnt = 0;
    if (h[0] >= i) {
      ans++;
      cnt = 1;
    }
    for (int j = 1; j < N; j++) {
      if (cnt == 1 && h[j] < i) {
        cnt = 0;
        continue;
      }
      if (cnt == 0 && h[j] >= i) {
        cnt = 1;
        ans++;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
L, R = map(int,input().split())
tmp = 2020
if R // 2019 != L // 2019 or R % 2019 == 0 or L % 2019 == 0:
    print('0')
else:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            modmin = i * j % 2019 
            if tmp > modmin:
                tmp = modmin
    print(tmp)

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

int main()
{
    int a, b;
    cin >> a >> b;
    int d, r;
    double f;

    d = a / b;
    r = a % b;
    f = (double)a / b;

    cout << d << " " << r << " ";
    cout << fixed;
    cout << setprecision(5) << f << endl;
}


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

int main(int argc, char** argv) {
    int size;
    scanf("%d\n", &size);
    int array[size];
    
    for(int i = 0; i < size; i++)
        scanf("%d", &array[i]);
    
    int count = 0;
    int primeCount = 0;
    for(int i = 0; i < size; i++){
        for(int k = 1; k <= array[i]/k; k++){
            if(array[i]==1)
                break;
            else if(array[i]%k == 0)
                count++;
        }
        if(count==1)
            primeCount++;
        count = 0;
    }
    printf("%d\n", primeCount);
    return (EXIT_SUCCESS);
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  I(N);
  vl B(N);
  ll X = 0;
  REP(i, N) {
    I(B[i]);
    X = X ^ B[i];
  }
  REP(i, N) {
    cout << (X ^ B[i]) << " ";
  }
  cout << endl;

}


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

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

  map<int, set<int> > p;
  vector<int> ans(m + 1);
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    p[a].insert(b);
    p[b].insert(a);
  }

  int i = 1;
  queue<int> q;

  while (p.size() != 0) {
    while (p[i].size() != 0) {
      int x = *begin(p[i]);
      if (ans[x] == 0) {
        ans[x] = i;
        q.push(x);
      }
      p[i].erase(x);
    }
    p.erase(i);
    i = q.front();
    q.pop();
  }

  cout << "Yes" << endl;
  for (int i = 2; i <= n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 32544
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int r; cin >> r;
    cout << 2*M_PI*r << endl;
}

Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a[26];
	for (int i = 0; i < 26; i++){
		a[i] = 0;
	}
	string w; cin >> w;
	for (int i = 0; i < w.size(); i++){
		if (w[i] == 'a')a[0]++;
		else if (w[i] == 'b')a[1]++;
		else if (w[i] == 'c')a[2]++;
		else if (w[i] == 'd')a[3]++;
		else if (w[i] == 'e')a[4]++;
		else if (w[i] == 'f')a[5]++;
		else if (w[i] == 'g')a[6]++;
		else if (w[i] == 'h')a[7]++;
		else if (w[i] == 'i')a[8]++;
		else if (w[i] == 'j')a[9]++;
		else if (w[i] == 'k')a[10]++;
		else if (w[i] == 'l')a[11]++;
		else if (w[i] == 'm')a[12]++;
		else if (w[i] == 'n')a[13]++;
		else if (w[i] == 'o')a[14]++;
		else if (w[i] == 'p')a[15]++;
		else if (w[i] == 'q')a[16]++;
		else if (w[i] == 'r')a[17]++;
		else if (w[i] == 's')a[18]++;
		else if (w[i] == 't')a[19]++;
		else if (w[i] == 'u')a[20]++;
		else if (w[i] == 'v')a[21]++;
		else if (w[i] == 'w')a[22]++;
		else if (w[i] == 'x')a[23]++;
		else if (w[i] == 'y')a[24]++;
		else if (w[i] == 'z')a[25]++;
	}
	for (int i = 0; i < 26; i++){
		if (a[i] % 2 == 1) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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

using P = pair<int, int>;

struct edge {
    int to; 
    long long cost;

    edge(int t, long long c): to(t), cost(c) {}
};

const long long INF = 1ll << 60;
const int MAX_V = 100000;
int V;
vector<vector<edge>> yG(MAX_V);
vector<vector<edge>> sG(MAX_V);
vector<long long> yd(MAX_V, INF);
vector<long long> sd(MAX_V, INF);

void dijkstra(int s, const vector<vector<edge>> &G, vector<long long> &d) {
    priority_queue<P, vector<P>, greater<P>> que;
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < (int)G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    V = n;
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        yG[u].push_back(edge(v, a));
        yG[v].push_back(edge(u, a));
        sG[u].push_back(edge(v, b));
        sG[v].push_back(edge(u, b));
    }

    dijkstra(s, yG, yd);
    dijkstra(t, sG, sd);

    const long long money = 1000000000000000ll;
    long long maximum = money - yd.at(n - 1) - sd.at(n - 1);
    vector<long long> ans(n);
    ans.at(n - 1) = maximum;
    for (int i = n - 2; i >= 0; i--) {
        long long m = money - yd.at(i) - sd.at(i);
        maximum = max(maximum, m);
        ans.at(i) = maximum;
    }
    
    for (int i = 0; i < n; i++) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 19256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    if (s[n - 1] == '1' || (s[0] == '0' || s[n - 2] == '0')) {
        cout << -1 << endl;
        return 0;
    }
    {
        bool check = true;
        REP(i, 0, n - 1) {
            if (s[i] != s[n - i - 2]) {
                check = false;
            }
        }
        if (!check) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> a, b;
    int lastone = 1;
    REP(i, 0, n - 1) {
        a.push_back(lastone);
        b.push_back(i + 2);
        if (s[i] == '1') {
            lastone = i + 2;
        }
    }
    REP(i, 0, n - 1) {
        cout << a[i] << " " << b[i] << endl;
    }
    return 0;
}


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

int main(){
	int n, x, y;
	cin >> n;
	int a[100][2], c[100][100] = {0};
	for ( int i = 0; i < n; i++ ) 
		cin >> a[i][0] >> a[i][1];
	for (int i = 2; i <= n; i++){
		for (int j = 0; j <= n - i; j++){
			for (int k = 1; k < i; k++){
				y = c[j][k] + c[j+k][i-k] + a[j][0]*a[j+k][0]*a[j+i-1][1];
				x = (x == 0 || x > y) ? y : x;
			}
			c[j][i] = x;
      x = 0;
		}
	}
	cout << c[0][n] << endl;
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

using namespace std;


int main(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   vector<char> c;

   char tmp='A';
   rep(i,n){
      if(tmp==s[i]){
         continue;
      }
      else{
         c.push_back(s[i]);
         tmp=s[i];
      }
   }

   cout<<c.size();
   

return 0;
}



Measured memory_bytes: 640
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int x,y;
  cin>>x>>y;
  int len=0;
  while(x<=y){
	  x<<=1;
	  len++; 
	 }
  cout<<len<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < N / 2; i++) {
        if (S.at(i) != S.at(i + N / 2)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  int count =0;
  long long sum =0;


  for(int i=0; i<N; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  double ans = (double)sum/(4*M);
  for(int i=0; i<N; i++){
    if(a.at(i) >= ans) count++;
  }
  if(count >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  A--; B--; C--; D--;
  string S;
  cin >> S;

  bool ans = true;
  char pre;
  int brank = 0;
  int max_brank = 0;
  int gorl = max(C, D);
  for(int i=A; i<=gorl; i++){
    if(i == A){
      if(i == B-1){
        brank++;
      }
    }
    else if(i < B && i > C){
      pre = S.at(i);
      continue;
    }
    else{
      if(S.at(i) == '#'){
        if(pre == '.'){
          max_brank = max(max_brank, brank);
          brank = 0;
        }
        else{ //pre == '#'
          ans = false;
          break;
        }
      }
      else{
        if(i >= B-1 && i <= D+1){
          brank++;
        }
      }
      if(i == D+1 || i == gorl){
        max_brank = max(max_brank, brank);
      }
    }
    pre = S.at(i);
  }
  
  
  if(C > D){
    if(max_brank < 3){
      ans = false;
    }
  }

  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<ll>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);


void solve()
{
    ll n, m;
    char c;
    cin>>c;
    if(isupper(c))
        cout<<"A";
    else
        cout<<"a";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007LL
#define REP(i, n) for(int i=0;i<(n);++i)
typedef long long ll;

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

	int n, a[100000]; cin >> n;
	REP(i, n) cin >> a[i];
	sort(a, a+n);
	int num = -1, cnt = 0;
	REP(i, n){
		if(a[i] == num) cnt++;
		else num = a[i];
	}
	cout << n - 2*((cnt+1)/2) << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	string s; cin >> s;
	string ans;
	rep(i, 0, s.length()) {
		if (s[i] == '0')ans.push_back('0');
		else if (s[i] == '1')ans.push_back('1');
		else if (s[i] == 'B' && ans.length() > 0)ans.pop_back();
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc094_a.cpp
 * time   : Thu Apr 30 18:23:31 2020
 * quest  : A - Cats and Dogs
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, x;
  cin >> a >> b >> x;
  if (a > x)
    cout << "NO\n";
  else
    cout << ((a + b) >= x ? "YES" : "NO") << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, i, t, l=1, result=0;
  
  scanf("%d", &n);
  
  scanf("%d", &t);
  
  while(t % 2 == 0){
    l *= 2;
    result++;
    t /= 2;
  }
  
  for(i=1; i<n; i++){
    scanf("%d", &t);
    while(t % l != 0){
      l /= 2;
      result--;
    }
  }
  
  printf("%d", result);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 K;
  cin >> K;
  set<i64> s;
  i64 t = 7;
  for (i64 i = 1;; i++)
  {
    if (t % K == 0)
    {
      cout << i << endl;
      return 0;
    }
    if (s.count(t % K) == 1)
    {
      cout << -1 << endl;
      return 0;
    }
    s.insert(t % K);
    (t = t * 10 + 7)%=K;
  }
  return 0;
}


Measured memory_bytes: 50472
N = int(input())
A = [int(ai) - 1 for ai in input().split()]
B = [int(bi) for bi in input().split()]
C = [int(ci) for ci in input().split()]

sat = B[A[0]]
for i in range(1, len(A)):
    sat += B[A[i]]
    if A[i] == A[i - 1] + 1:
        sat += C[A[i - 1]]
print(sat)


Measured memory_bytes: 38524
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
using LL = long long;
int main()
{
    int n,q,a,b,c;
    LL ss1, ss2, cons;
    multiset<int> s1,s2;
    while (~scanf("%d", &q)) {
        n = 0;
        s1.clear();
        s2.clear();
        ss1 = 0;
        ss2 = 0;
        cons = 0;

        
        while (q--) {
            scanf("%d",&c);
            if (c==1) {
                n++;
                scanf("%d %d",&a,&b);
                cons += b;

                if ((int)s1.size()==0 || a<=*s1.rbegin()) {
                    s1.insert(a);
                    ss1 += a;
                } else {
                    s2.insert(a);
                    ss2 += a;
                }

                int small = (n+1)/2;
                int big = n - small;
                int tmp = 0;
                while ((int)s1.size() > small) {
                    tmp = *s1.rbegin();
                    s1.erase(s1.find(tmp));
                    ss1 -= tmp;
                    s2.insert(tmp);
                    ss2 += tmp;
                }
                while ((int)s2.size() > big) {
                    tmp = *s2.begin();
                    s2.erase(s2.find(tmp));
                    ss2 -= tmp;
                    s1.insert(tmp);
                    ss1 += tmp;
                }
                //assert(s1.size()==small && s2.size()==big);

            }
            if (c==2) {
                int small = (n+1)/2;
                int big = n-small;
                int a1 = *s1.rbegin();
                LL ans = (LL)small*a1 - ss1;
                ans += ss2 - (LL)big*a1;
                printf("%d %lld\n",a1, ans + cons);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 9600
N = int(input())
m = a = r = c = h = 0
for _ in range(N):
  s_in = input()
  if s_in[0] == "M": m += 1
  elif s_in[0] == "A": a += 1
  elif s_in[0] == "R": r+= 1
  elif s_in[0] == "C": c += 1
  elif s_in[0] == "H": h += 1

all_l = [m, a, r, c, h]
ans = 0
import itertools
for v in itertools.combinations(all_l, 3):
  if v[0] * v[1] * v[2] > 0:
    ans += v[0] * v[1] * v[2]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

ll a[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll v=0;
	for (int i=1;i<=n;i++){
		v+=a[i]/2ll;
		if (a[i]%2==1&&a[i+1]>0) {
			v++;
			a[i+1]--;
		}
	}
	cout<<v<<endl;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
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 string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */


int n;
vi arr;
void in(){
    cin >> n;
    rep(i,0,n)arr.push_back(input());
}

void solve(){
    
    sort(all(arr));
    vi tmp = cut(arr, 0, sz(arr) - 1);

    if(arr.back() < sum(tmp)){
        print("Yes");
    }else{
        print("No");
    }

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}


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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(n, b - 1);
  cout << a * x / b - a * (x / b) << '\n';
  return 0;
}


Measured memory_bytes: 3564
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = readline().decode().rstrip()
R_cnt = S.count('R')
G_cnt = S.count('G')
B_cnt = S.count('B')
ans1 = R_cnt * G_cnt * B_cnt
cnt  = 0
d_max = N // 2 +1
for d in range(1,d_max):
    for i in range(N):
        if i+2*d >= N:
            break
        if (S[i] != S[i+d]) and (S[i+d] != S[i+2*d]) and (S[i] !=S[i+2*d]):
           cnt += 1
ans = ans1 - cnt
print(ans)

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

ll sum(ll n){
    if (n == 1){
        return 1;
    }

    ll count = sum(n / 2);
    return count * 2 + 1;
}

int main() {
    ll n;
    cin >> n;
      
    cout << sum(n) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  string s;cin>>s;long cnt=0,ans=0;
  for(auto x:s)
  {
    if(x=='B')cnt++;
    else ans+=cnt;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int K, S; cin >> K >> S;
  int ans = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int Z = S - X - Y;
      if (Z >= 0 && Z <= K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
      
}


Measured memory_bytes: 256
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

k=int(input())

sum=0;

for a in range(1,k+1):
    sum+=a

for a in range(1,k+1):
    for b in range(1,a):
        sum+=gcd(a,b)*6

for a in range(1,k+1):
    for b in range(1,a):
        for c in range(1,b):
            sum+=gcd(a,gcd(b,c))*6

print(sum)


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main(){
 
    int N;
    scanf("%d",&N);
 
    vector<int> V;
    int tmp;
 
    for(int loop = 0; loop < N; loop++){
        scanf("%d",&tmp);
        V.push_back(tmp);
    }
 
    int num_query;
    scanf("%d",&num_query);
 
    int command,left,right;
 
    for(int loop = 0; loop < num_query; loop++){
 
        scanf("%d %d %d",&command,&left,&right);
 
        if(command == 0){
            printf("%d\n",*min_element(V.begin()+left,V.begin()+right));
        }else{
            printf("%d\n",*max_element(V.begin()+left,V.begin()+right));
        }
    }
 
    return 0;
}




Measured memory_bytes: 3288
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;















signed main(){
    double n;
    cin >> n;
    cout << fixed << setprecision(10) << (n/3) * (n /3) * (n / 3);




}


Measured memory_bytes: 256
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		int n, i;
		cin >> n;
		double ans = 0;
		int a[n];
		
		for(i = 0; i < n; i++){
			cin >> a[i];
			ans += double(1./a[i]);
		}
		cout << double(1./ans);
		
    return 0;
} // What is to be written here?


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String str1 = input.nextLine();
        String str2 = input.nextLine();
        String str3 = reverse2(str1);
        if (str2.equals(str3)){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
    public static String reverse2(String str) {
        char[] chars = str.toCharArray();
        String reverse = "";
        for (int i = chars.length - 1; i >= 0; i--) {
            reverse += chars[i];
        }
        return reverse;
    }
}

Measured memory_bytes: 21972
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List
import Data.Monoid
import Control.Monad
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  tasks <- fmap (sortBy (\(a,b) (a',b') -> compare b b' <> compare a a')) $ replicateM n $ do
    [a,b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a,b)
  let xs = tail $ scanl' (+) 0 $ map fst tasks
  putStrLn $ if and $ zipWith (<=) xs (map snd tasks)
             then "Yes"
             else "No"


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

using namespace std;
using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll dp[1001][1LL<<12];
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> c(m);
    REP(i, m) {
        ll b;
        cin >> a[i] >> b;
        REP(j, b) {
            ll x;
            cin >> x;
            x--;
            c[i] |= 1LL<<x;
        }
    }

    // REP(i, m) cerr << a[i] << " " << bitset<12>(c[i]) << endl;

    const ll inf = 1LL<<60;
    REP(i, m+1) REP(j, 1LL<<n) dp[i][j] = inf;
    dp[0][0] = 0;
    REP(i, m) REP(j, 1LL<<n) {
        chmin(dp[i+1][j], dp[i][j]);
        chmin(dp[i+1][j|c[i]], dp[i][j] + a[i]);
    }

    if(dp[m][(1LL<<n)-1] == inf) cout << -1 << endl;
    else cout << dp[m][(1LL<<n)-1] << endl;

    return 0;
}

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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

int main(){
  string s; cin >> s;
  int N = s.size();
  int p = 0;
  for(int i = 0; i < N; i++){
    if(s[i] == 'p') p++;
  }
  int p2 = N / 2;
  cout << p2 - p << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

using namespace std;

typedef long long int lli;

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

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))

int main() {
	char str[101];
	int N;
	scanf("%d", &N);
	scanf("%s", str);
	int x_s[26];
	int y_s[26];
	int max = 0;

	for (int i = 1; i < N; i++) {
		SET_ZERO(x_s);
		SET_ZERO(y_s);

		for (int x = 0; x < i; x++) {
			x_s[ str[x] - 'a' ]++;
		}
		for (int y = i; y < N; y++) {
			y_s[ str[y] - 'a' ]++;
		}
		int cnt = 0;
		for (int j = 0; j < 26; j++) {
			if (x_s[j] && y_s[j]) {
				cnt++;
			}
		}
		if ( cnt > max ) max = cnt;
	}

	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    bool odd = false;
    REP(i,n) if(a[i]%2!=0) odd = true;
    if(odd) cout << "first" << endl;
    else cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
//これはWA
int main(){

    long a[100001]={};
    long b[100000]={};
    long N=0;
    long sum=0;
    long temp=0;
    long cs=0;
    scanf("%ld",&N);
    for(int i=0;i<N+1;i++){
        scanf("%ld",&a[i]);
    }
    for(int i=0;i<N;i++){
        scanf("%ld",&b[i]);
    }


    for(int i=0;i<N;i++){
        cs=b[i]+temp;
    //    printf("cs%ld\n",cs);
        if(a[i]>=cs){
            sum+=cs;
            temp=0;
           // printf("tekiooi sum%ld kurikosi%ld\n",sum,temp);
        }else{
            if(a[i]<temp){
                sum+=a[i];
                temp=b[i];
              //  printf("maenogataosita sum%ld temp%ld\n",sum,temp);
            }else{
                sum+=a[i];
                temp=b[i]-a[i]+temp;
              //  printf("kyoryokusitetaosita sum%ld temp%ld\n",sum,temp);
            }
            
        }
    }
  //  printf("temp%ld\n",temp);
    if(temp>0){
        if(a[N]>temp){
            sum+=temp;
        }else{
            sum+=a[N];
        }
    }
    printf("%ld",sum);



    return 0;
}

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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int r;
    cin >> r;

    cout << 3*r*r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long n;
    vector<long long> x, sorted_x;
    
    cin >> n;
    for(long long i = 0; i < n; i++){
        long long temp;
        cin >> temp;
        x.push_back(temp);
        sorted_x.push_back(temp);
    }
    
    sort(sorted_x.begin(), sorted_x.end());
    
    vector<long long> output;
    for(long long i = 0; i < n; i++){
        if(x[i] >= sorted_x[n-1])
            output.push_back(sorted_x[n-2]);
        else
            output.push_back(sorted_x[n-1]);
    }
    
    for(long long i = 0; i < n; i++)
        cout << output[i] << endl;
    
    return 0;
    
}

Measured memory_bytes: 6500
#include <bits/stdc++.h>
using namespace std;
int mp[3][3];
bool flag[3][3],check=false;
int main(){
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++){
			cin>>mp[i][j];
		}
	int n,a;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		for(int i=0;i<3;i++)
		for(int j=0;j<3;j++){
			if(a==mp[i][j]) flag[i][j]=true;
		}
	} 
	for(int i=0;i<3;i++){
		if(flag[i][0]&&flag[i][1]&&flag[i][2]){
			check=true;break;
		} 
		if(flag[0][i]&&flag[1][i]&&flag[2][i]){
			check=true;break;
		} 
		if(flag[0][0]&&flag[1][1]&&flag[2][2]){
			check=true;break;
		} 
		if(flag[0][2]&&flag[1][1]&&flag[2][0]){
			check=true;break;
		} 
	}
	if(check) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main () {
	long long n, k, ans;
	cin>>n>>k;
	if (n% k == 0) {
		ans = 0;
	}
	else if (k > n) {
		ans = min(n, k-n);
	} else {
		ans = n %k;
		n%=k;
		long long mn = ans+1;
		while (ans < mn) {
			mn =ans;
			ans = abs(ans-k);
		}
		ans = min(ans, mn);
	}
	
	cout<<ans<<endl;
}

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

#include<random> 

#define int long long 

#define pp pair<int,int> 

#define ss second 

#define ff first 

#define pb push_back 

#define mod 1000000007 

using namespace std; 

void fastio() 

{ 

    #ifndef ONLINE_JUDGE 

        freopen("INPUT.txt","r",stdin); 

            freopen("OUTPUT.txt","w",stdout); 

                #endif 

                    ios_base :: sync_with_stdio(false); 

                        cin.tie(NULL) ; 

                            cout.tie(NULL); 

                            }

signed main() 

{ 

    fastio(); 

        int t=1;

            //cin>>t;

                while(t--)

                    {

                       int n,s=0;

                       cin>>n;

                       int a[n],b[n],c[n-1];

                       for(int i=0;i<n;i++)

                       cin>>a[i];

                      

                       for(int i=0;i<n;i++)

                       {cin>>b[i];s+=b[i];}

                       

                       for(int i=0;i<n-1;i++)

                       cin>>c[i];

                       

                       for(int i=0;i<n-1;i++)

                       {

                       	if(a[i]==a[i+1]-1)                       	s+=c[a[i]-1];

                       	

                       }

                       

                       cout<<s;

                       

    }

    }

    

Measured memory_bytes: 3624
N = int(input())
count = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    s = str(i)
    count[int(s[0])][int(s[-1])] += 1
ans = sum(count[i][j] * count[j][i] for i in range(1, 10) for j in range(1, 10))
print(ans)


Measured memory_bytes: 9060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;
#define ARRAY_MAX 100005

vector<int> par(ARRAY_MAX);//親
vector<int> ran(ARRAY_MAX);//木の深さ

typedef struct edge{

    int u;
    int v;
    int cost;

}EDGE;

typedef struct where{

    int num;
    int x;
    int y;

}WHERE;

bool comp(const EDGE& e1,const EDGE& e2){
    return e1.cost < e2.cost;
}


bool compx(const WHERE& e1,const WHERE& e2){
    return e1.x < e2.x;
}


bool compy(const WHERE& e1,const WHERE& e2){
    return e1.y < e2.y;
}


//n要素で初期化
void init(int n){
    for(int i = 0;i < n;i++){
        par[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
        ran[i] = 0;/*各ノード自体の高さは0*/
    }
}
//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;/*根ならそのノードの番号を返す*/
    }else{
        return par[x] = find(par[x]);/*根でないならさらにノードの根を探す*/
    }
}

//xとyの属する集合を併合する
void unite(int x,int y){
    x = find(x);//xの根の番号を探す
    y = find(y);//yの根の番号を探す
    if(x == y){//一致すればつながっている
        return;
    }
    if(ran[x] < ran[y]){//xの高さが低いなら高いほうにつなぐ、そして高さは大きい方(y)になる
        par[x] = y;
    }else{
        par[y] = x;//yの高さが低いなら高いほうにつなぐ、そして高さは大きいほう(x)になる
        if(ran[x] == ran[y]){//高さが一致しているなら併合の高さは1増える
            ran[x]++;
        }
    }
}

//xとyが同じ集合に属するか判定
bool same(int x,int y){
    return find(x) == find(y);//同じ集合なら1、違うなら0が返る
}

int kruskal(int n,int count,vector<EDGE>& es){

    sort(es.begin(),es.end(),comp);
    init(n);
    int res = 0;
    for(int i = 0;i < count;i++){
        EDGE e = es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res += e.cost;
        }
    }
    return res;
}



int main(){

    int n;
    cin >> n;
    vector<EDGE> es;
    vector<WHERE> map(n);
    int count = 0;

    REP(i,n){
        map[i].num = i;
        cin >> map[i].x >> map[i].y;
    }

    sort(map.begin(),map.end(),compx);

    for(int i = 0;i < n-1;i++){
        EDGE e;
        e.u = map[i].num;
        e.v = map[i+1].num;
        e.cost = map[i+1].x - map[i].x;/*昇順ソート済み*/
        es.push_back(e);
        count++;
    }


    sort(map.begin(),map.end(),compy);
    
    for(int i = 0;i < n-1;i++){
        EDGE e;
        e.u = map[i].num;
        e.v = map[i+1].num;
        e.cost = map[i+1].y - map[i].y;/*昇順ソート済み*/
        es.push_back(e);
        count++;
    }
    
    /*
    cout << count << endl;
    REP(i,es.size()){
        cout << es[i].u << " " << es[i].v << " " << es[i].cost << endl;
    }
    */


    int ans = kruskal(n,count,es);
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 6900
#include <stdio.h>


int main(void) {
	int input_num = 0;
	int YYMM_flag1 = 0;
	int YYMM_flag2 = 0;
	int MMYY_flag1 = 0;
	int MMYY_flag2 = 0;

	
	if(scanf("%d", &input_num)==1);

	if (0 <= (input_num % 100) && (input_num % 100) <= 99) {
		MMYY_flag1 = 1;
		if (1 <= (input_num / 100) && (input_num / 100) <= 12) {
			MMYY_flag2 = 1;
		}
	}
	if (1 <= (input_num % 100) && (input_num % 100) <= 12) {
		YYMM_flag1 = 1;
		if (0 <= (input_num / 100) && (input_num / 100) <= 99) {
			YYMM_flag2 = 1;
		}
	}
	if (MMYY_flag1 == 1 && MMYY_flag2 == 1 && YYMM_flag1 == 1 && YYMM_flag2 == 1) {
		printf("AMBIGUOUS\n");
	}
	else if (MMYY_flag1 == 1 && MMYY_flag2 == 1 && (YYMM_flag1 == 0 || YYMM_flag2 == 0)) {
		printf("MMYY\n");
	}
	else if ((MMYY_flag1 == 0 || MMYY_flag2 == 0) && YYMM_flag1 == 1 && YYMM_flag2 == 1) {
		printf("YYMM\n");
	}
	else {
		printf("NA\n");
	}

}



Measured memory_bytes: 1624