akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	ll N; cin>>N;
	set<ll> fact;
	for(ll i = 1; i*i<=N; ++i){
		if(N%i == 0){
			fact.insert(i);
			fact.insert(N/i);
		}
	}
	ll ans = 0;
	for(auto x: fact){
		if(x == 1)continue;
		if(N/x == N/(x-1LL)){
			ans += x-1LL;
		}
	}
	cout<<ans<<endl;
	return 0;
}

// int main(){
// 	ll N; cin>>N;
// 	REP(i,N){
// 		printf("[%2d]:[%2lld / %2lld]\n", i, N/i, N%i);
// 	}
// 	return 0;
// }

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

int main() {
  int a,b=0,c=0,d=0,e=0;
  cin >> a;
  vector<string> vec(a);
  for(int i=0;i<a;i++){
    cin >> vec.at(i);
  if(vec.at(i)=="AC"){
    b++;
  }
    else if(vec.at(i)=="WA"){
      c++;
    }
    else if(vec.at(i)=="TLE"){
      d++;
    }
    else{
      e++;
    }
  }
	cout << "AC x " << b << endl;
	cout << "WA x " << c << endl;
	cout << "TLE x " << d << endl;
	cout << "RE x " << e << endl;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long n;
  vector<long> a(5);
  cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  long ans;
  long min = a[0];
  int num=0;
  for(int i=1;i<5;i++){
    if(a[i]<min){
      min = a[i];
      num=i;
    }
  }
  if(min>=n){
    cout << 5;
    return 0;
  }
  ans=(n+(min-1))/min+4;
  cout << ans;
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int S=0;
  
  for (int i=A; i<=B; i++) {
    if (i/10000==i%10 && ((i/1000)%10==(i/10)%10))
      S++;
  } 
  cout << S << endl;
}

Measured memory_bytes: 256
dp=[[[[0]*4 for i in range(4)] for i in range(4)] for i in range(101)]
dp[0][3][3][3]=1
mod=10**9+7

for length in range(100):
  for c1 in range(4):
    for c2 in range(4):
      for c3 in range(4):
        if dp[length][c1][c2][c3]==0:
          continue
        for a in range(4):
          if c2==0 and c3==1 and a==2:
            continue
          if c2==1 and c3==0 and a==2:
            continue
          if c2==0 and c3==2 and a==1:
            continue
          if c1==0 and c3==1 and a==2:
            continue
          if c1==0 and c2==1 and a==2:
            continue
          dp[length+1][c2][c3][a]+=dp[length][c1][c2][c3]
          dp[length+1][c2][c3][a]%mod

n=int(input())
ans=0
for c1 in range(4):
    for c2 in range(4):
      for c3 in range(4):
        ans+=dp[n][c1][c2][c3]
        ans%=mod
print(ans)

Measured memory_bytes: 3440
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
	vector < vector<int> > adj(n);
    vector <int> heights(n + 1);
    for(int i = 0; i < n; i ++)
    {
    	cin >> heights[i];
    }

    for(int i = 0; i < m; i ++)
    {
    	int u, v;
    	cin >> u >> v;
    	u --;
    	v --;

    	adj[u].push_back(v);
    	adj[v].push_back(u);
    }

    int ans = 0;
    for(int i = 0; i < n; i ++)
    {
    	int count = 0;
    	for(int u : adj[i])
    	{
    		if(heights[u] < heights[i])
    			count ++;
    	}
    	if(count == adj[i].size())
    		ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8804
N = int(input())
x = list(map(int, input().split()))

y=sorted(x)
width=[0,0]
height=[0,0]


for i in range(0,len(y)-1):
    if (y[len(y)-1-i]==y[len(y)-2-i] and width[0]==0):
        width[0]=y[len(y)-1-i]
        width[1]=len(y)-1-i
        continue
    if (width!=0 and y[len(y)-1-i]==y[len(y)-2-i]):
        if(len(y)-1-i==width[1]-1):
            continue
        height[0]=y[len(y)-1-i]
        break



print('{0}'.format(int(width[0])*int(height[0])))



quit()


Measured memory_bytes: 14672
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                int a = sc.nextInt();
                int b = sc.nextInt();
                int x = sc.nextInt();
                sc.close();
                if(a <= x && a + b >= x) System.out.println("YES");
                else System.out.println("NO");
        }
}

Measured memory_bytes: 35636
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    string right, left;
    bool rev = false;
    ll q; cin >> q;
    rep(i,q){
        ll query; cin >> query;
        if(query == 1)rev = rev ^ 1;
        else{
            ll t; cin >> t;
            char ch; cin >> ch;
            t--;
            if(t ^ rev == 1)right += ch;
            else left += ch;
        }
    }
    reverse(all(left));
    s = left + s + right;

    if(rev)reverse(all(s));
    cout << s << endl;
}

Measured memory_bytes: 1348
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>

using namespace std;

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

    for(int i=1; i<=320; i++){
        if(to_string(i*i)==a+b){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::marker::*;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let res = solve(n);
    println!("{}", res);
}

fn solve(n: usize) -> String {
    let mut ret = "".to_string();
    for _ in 0..n {
        ret.push_str("ACL");
    }
    ret
}


Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> L(N);
  for (auto &l:L)
    std::cin >> l;
  auto max_l = *(std::max_element(L.begin(), L.end()));
  auto sum_l = std::accumulate(L.begin(), L.end(),0);
  std::cout << ((sum_l - 2*max_l)>0?"Yes":"No") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

using i64 = long long;

struct Graph {
  struct edge {
    int to;
    i64 cap;
    i64 rev;
  };

  int n;
  vector<vector<edge>> edges;

  Graph(int N) {
    n = N;
    edges.resize(n, vector<edge>());
  }

  int size() const { return n; }

  vector<edge> &operator[](int v) { return edges[v]; }
};

struct Dinic {
  int N;
  vector<int> level;
  vector<int> itr;
  Graph G;

  Dinic(int n) : G(n) { N = n; }

  void add_edge(int from, int to, i64 cap, i64 rev_cap) {
    G[from].push_back({to, cap, (int)G[to].size()});
    G[to].push_back({from, rev_cap, (int)G[from].size() - 1});
  }

  bool g_level(int s, int t) {
    level.assign(N, -1);
    queue<int> que;
    que.push(s);
    level[s] = 0;
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      for (auto &e : G[v]) {
        if (e.cap > 0 && level[e.to] == -1) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
    return level[t] >= 0;
  }

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

    for (int &i = itr[v]; i < G[v].size(); i++) {
      auto &e = G[v][i];
      if (e.cap > 0 && level[e.to] > level[v]) {
        i64 mi_f = dfs(e.to, t, min(f, e.cap));
        if (mi_f > 0) {
          e.cap -= mi_f;
          G[e.to][e.rev].cap += mi_f;
          return mi_f;
        }
      }
    }
    return 0;
  }

  i64 max_flow(int s, int t) {
    i64 result = 0;
    i64 flow;
    while (g_level(s, t)) {
      itr.assign(N, 0);
      while ((flow = dfs(s, t, 1e9)) > 0) result += flow;
    }
    return result;
  }
};

/*

   checked
http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2723921#1
*/

int N;

int a[101],b[101],c[101],d[101] ;


int main(){
  cin >> N;
  Dinic dinic(2 * N + 100);
  int s = N * 2 + 1;
  int t = N * 2 + 2;
  rep(i,0,N - 1){
    cin >> a[i] >> b[i];
    dinic.add_edge(s,i,1,0);
  }
  rep(i,0,N - 1){
    cin >> c[i] >> d[i];
    dinic.add_edge(i + N,t,1,0);
  }
  rep(i,0,N - 1){
    rep(j,0,N - 1){
      if(a[i] < c[j] && b[i] < d[j]){
        dinic.add_edge(i,j + N,1,0);
      }
    }
  }

  cout << dinic.max_flow(s,t) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define MaxN 200003

int N;
int hi[MaxN];
long long f[MaxN], ans;

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void ChkMax(long long &aa, long long bb) {
	if(aa < bb) aa = bb;
	return;
}

long long BIT[200003];
inline void upd(int d, long long val) {
	while(d <= N)
		ChkMax(BIT[d], val), d += d & -d;
	return;
}
inline long long query(int d) {
	long long r = 0;
	while(d)
		ChkMax(r, BIT[d]), d ^= d & -d;
	return r;
}

int main() {
	N = Rd();
	for(reg int i = 1; i <= N; ++i)
		hi[i] = Rd();
	long long val;
	for(reg int i = 1; i <= N; ++i) {
		val = Rd();
		f[i] = query(hi[i]) + val, upd(hi[i], f[i]);
		ChkMax(ans, f[i]);
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
    int N, M, x;
    cin >> N >> M;
    vector<int> a(M), b(M), c(M, 0);
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            cin >> x;
            x--;
            c[i] += (1 << x);
        }
        //cout << c[i] << endl;
    }
    int P = 1 << N;
    vector<vector<int>> dp(M + 1, vector<int>(P, INF));
    dp[0][0] = 0;
    rep(i, M) {
        rep(j, P) {
            dp[i + 1][j] = min(dp[i][j], dp[i][~c[i] & j] + a[i]);
        }
    }
    int ans = dp[M][P - 1];
    if (ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 16384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
long double chg_DegRad(long double deg) {
	return deg * PI / 180.0;
}

//radian → degree
long double chg_RadDeg(long double rad) {
	return rad * 180.0 / PI;
}
 
//桁数
ll CountDigit(ll n) {
	ll digit = 1;
	while ((n /= 10) != 0) digit++;
	return digit;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}

//abs()平均
//pow(,)累乗


//提出コード↓

int a, b, c, n;



int main() {
	cin >> a >> b >> c;
	n = b;
	b = a;
	a = c;
	c = n;
	cout << a << ' ' << b << ' ' << c << endl;



	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    t += t;
    for (int i = 0; i < n; ++i) {
        if (t.substr(i, n) == s) {
            cout << "Yes"
                 << "\n";
            return 0;
        }
    }
    cout << "No"
         << "\n";

    return 0;
}

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

int main() {
  double r,s,l;
  cin >> r;
  s = r*r*3.141592653589;
  l = 2*r*3.141592653589;
  cout << fixed << setprecision(8) << s << " " << l << endl;
  return 0;
}


Measured memory_bytes: 3236
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
ar = [a,b,c,d,e]
ar.sort
if ar[4]-ar[0] > k
  puts ":("
else
  puts "Yay!"
end

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair
#define ll long long

inline int get_int()
{
	int x=0,f=1;
	char c;
	for(c=getchar();(!isdigit(c))&&(c!='-');c=getchar());
	if(c=='-') f=-1,c=getchar();
	for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}

int n,m,v,p;
int a[100000];
bool ok(int i){
	int _v = max(0, v - (n - i) - (p - 1));
	ll cnt_v = 1ll * m * _v;
	int j = i - 1;
	while(cnt_v > 0 && j >= p){
		if (a[i] + m - a[j] >= 0){
			cnt_v -= a[i] + m - a[j];
		}else{
			break;
		}
		j--;
	}
	return (max(0ll,cnt_v) + a[p-1] <= a[i]+m);
}
int main(int argc, char const *argv[])
{
	n = get_int();
	m = get_int();
	v = get_int();
	p = get_int();
	rep(i,n) a[i] = get_int();
	sort(a, a + n);
	reverse(a, a + n);
	int l = p - 1, r = n, mid;
	while (l+1<r){
		mid = (l+r)/2;
		if (ok(mid)){
			l = mid;
		}else{
			r = mid;
		}
	}
	cout << (l+1) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];
  vector<vector<Int> > c(n);
  for(Int i=0;i<n;i++){
    function<void(Int,Int,Int)> dfs=[&](Int x,Int k,Int v){
      //cout<<x<<" "<<k<<" "<<v<<endl;
      if(v==b[i]){
	c[i].emplace_back(x);
	return;
      }
      if(v<b[i]) return;
      if(v>=k&&v%k>=b[i]) dfs(x|(1LL<<k),k-1,v%k);
      if(k-1>b[i]) dfs(x,k-1,v);
    };
    dfs(0,60,a[i]);
    sort(c[i].begin(),c[i].end());
    c[i].erase(unique(c[i].begin(),c[i].end()),c[i].end());
    //for(Int j:c[i]) cout<<bitset<30>(j)<<endl;
  }
  
  for(Int i=0;i<n;i++){
    if(c[i].empty()){
      cout<<-1<<endl;
      return 0;
    }
  }
  
  Int ans=0;
  for(Int k=60;k>0;k--){
    Int ng=0;
    for(Int i=0;i<n;i++){
      Int ok=0;
      for(Int j:c[i]){
	Int tmp=((ans|j)>>k)<<k;
	ok|=ans==tmp;
      }
      ng|=!ok;
      if(ng) break;
    }
    ans|=ng<<k;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }

void solve(){
    ll res = 0;
    ll m; cin >> m;
    vector<pll> ps(m);
    for(int i = 0; i < m;i++) cin >> ps[i].first >> ps[i].second;
    
    map<pii,vector<int>> angle;
    for(int i = 0; i < m; i++){
        for(int j = i+1; j < m;j++){
            pii vec = {ps[j].first-ps[i].first,ps[j].second-ps[i].second};
            ll GCD = gcd(abs(vec.first),abs(vec.second));
            vec.first /= GCD;
            vec.second /= GCD;
            
            if(vec.second < 0){
                vec.first *= -1;
                vec.second *= -1;
            }
            if(vec.second == 0) vec.first = 1;
            if(vec.first == 0) vec.second = 1;
            angle[{vec.second,vec.first}].push_back((1<<i)|(1<<j));
        }
    }
    vector<int> dp(1<<m,-1);
    dp[0] = 0;
    for(int b = 0; b < (1<<m); b++){
        if(dp[b] == -1) continue;
        for(auto P:angle){
            vector<int> T;
            T.push_back(0);
            for (int mask : P.second) {
                if (b & mask) continue;
                for (int i = (int)T.size(); i --; ) {
                    int t = T[i] | mask;
                    int k = __builtin_popcount(t) / 2;
                    dp[b|t]  = max(dp[b|t],dp[b] + k*(k-1)/2);
                    T.push_back(t);
                }
            }
        }
    }
    cout << dp[(1<<m)-1] << endl;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
string s;
cin>>s;
if(s=="ABC"){
    cout<<"ARC"<<endl;
}else{
    cout<<"ABC"<<endl;
}


    
return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  char a;
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<H;i++){
    cout << "#";
	for(int j=0;j<W;j++){
      cin >> a;
      cout << a;
    }
    cout << "#" << endl;
  }
  for(int i=0;i<W+2;i++){
    cout << "#";
    }
}


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

int main() {
	int H,W,i,j;
	while(1){
	cin >> H >> W;
	if(H == 0 && W == 0)break;
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(i%2 == 0 && j%2 == 0)cout << "#";
			else if(i%2 == 0 && j%2 == 1)cout << ".";
			else if(i%2 == 1 && j%2 == 0)cout << ".";
			else if(i%2 == 1 && j%2 == 1)cout << "#";
		}
		cout << endl;
	}
	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n, m;
const int N = 200000;
vector <int> bi[N], bb[N];
int col[N], cnt[3], all;
LL ans; int nw;
void dfs(int t, int c)
{
    if (col[t] == -1)
    {
        col[t] = c;
        cnt[c] ++;
    }
    else
    {
        if (col[t] != c) all = 1;
        return;
    }
    for (int i = 0; i < bi[t].size(); ++ i)
        dfs(bi[t][i], (c + 1) % 3), nw ++;
    for (int i = 0; i < bb[t].size(); ++ i)
        dfs(bb[t][i], (c + 2) % 3);
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++ i)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        bi[a].push_back(b);
        bb[b].push_back(a);
    }
    for (int i = 1; i <= n; ++ i) col[i] = -1;
    for (int i = 1; i <= n; ++ i) if (col[i] == -1)
    {
        cnt[0] = cnt[1] = cnt[2] = 0;
        all = nw = 0;
        dfs(i, 0);
        if (all) ans += 1ll * (cnt[0] + cnt[1] + cnt[2]) * (cnt[0] + cnt[1] + cnt[2]);
        else if (cnt[0] && cnt[1] && cnt[2])
            ans += 1ll * cnt[0] * cnt[1] + 1ll * cnt[0] * cnt[2] + 1ll * cnt[1] * cnt[2];
        else ans += nw;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 22528
n = int(input())
time = list(map(int, input().split()))
m = int(input())
l = []
for _ in range(m):
    l.append(list(map(int, input().split())))
total = sum(time)
for i in range(m):
    ans = total + l[i][1] - time[l[i][0]-1]
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>

using namespace std;

vector<int> ans;
vector<int> prime;

void prime_list(){
    prime.push_back(2);
    for(int i=3;i<=55555;i++){
        bool is_prime = true;
        for(int j=0;prime[j]*prime[j]<=i;j++){
            if(i%prime[j]==0){
                is_prime = false;
                break;
            }
        }
        if(is_prime)prime.push_back(i);
    }
}

void solve(int n){
    int cnt = 0;
    for(int j=0;j<prime.size();j++){
        if(prime[j]%5 == 1){
            ans.push_back(prime[j]);
            cnt++;
        }
        if(cnt == n)break;
    }
}

int main(){
    int n;
    cin >> n;
    prime_list();
    solve(n);
    for(int i=0;i<n;i++){
        cout << ans[i] << (i==n-1?'\n': ' ');
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>

#define MOD 998244353

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

typedef long long int64;

int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A<=C&&C<=B){
        printf("Yes");
    }else if(B<=C&&C<=A){
        printf("Yes");
    }else{
        printf("No");
    }
    
    
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")


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


typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int

const int hell=1000000007;


int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;
    a%=10000000000LL;}
  return a;
}



int gcd(int a,int b)
{   
  
  if(b==0)return a;
  return gcd(b-a%b,a%b);
}

bool cmp(pii a,pii b)
{
  return a.SS<b.SS;
}


int sum(int a,int b )
{
   int ans=a-a/b; 
   return ans;
}
int solve()
{  
 
int a,b,c,d;

cin>>a>>b>>c>>d;
 
 if(a>b)swap(a,b);

 int ans=sum(a-1,c)+sum(a-1,d)-sum(a-1,(c*d)/gcd(c,d));
 int ans1=sum(b,c)+sum(b,d)-sum(b,(c*d)/gcd(c,d));
  cout<<ans1-ans;
    return 0;
}


signed main()
{  int t=1;
//pri();
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    




  clock_t time_req;

    // Without ung pow function
                                                                                                                   

  //cin>>t;

    int k=1;
   while(t--)
     {
      // cout<<"Case #"<<k<<":"<<" ";k++;
      solve();
     

     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){

	int x, y;
	while(1){
		cin >> x >> y;
		int tmp = max(x, y);
		y = min(x, y);
		x = tmp;
		if(x == y && x == 0)break;
		int cnt = 1;
		while(1){
			int ab = x % y;
			if(ab == 0){
				cout << y << " " << cnt << endl;
				break;
			}
			x = y;
			y = ab;
			cnt++;
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
using System;

class Program
{
    static void Main()
    {
        for (;;)
        {
            string[] str = Console.ReadLine().Split(' ');
            int H = int.Parse(str[0]);
            int W = int.Parse(str[1]);
            if (W == 0 && H == 0) { break; }
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if ((i + j) % 2 == 1)
                    {
                        Console.Write(".");
                    }
                    else
                    {
                        Console.Write("#");
                    }
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 17904
#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}

int main(int argc, char **argv) {
    int n = get_uint();
    int a;
    char b[50000] = {1};
    for(int i = 0; i < n; ++i) {
        a = get_uint();
        for(int j = 40000; j >= 0; --j) {
            b[j] ? b[j + a] = 1 : 0;
        }
    }
    int q = get_uint();
    for(int i = 0; i < q; ++i) {
        a = get_uint();
        puts(b[a] ? "yes" : "no");
    }
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int a,b;
    cin>>a>>b;
    if((a*b)%2){
        cout<<"Odd"<<endl;
    }else{
        cout<<"Even"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using namespace atcoder;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  

  int n, m; cin >> n >> m;
  vector<vector<char>> s(n, vector<char>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> s[i][j];
    }
  }


  int source = n * m;
  int sink = n * m + 1;

  mf_graph<lint> g(n * m + 2);

  // source -> even, odd -> sink
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '#') continue;
      if ((i + j) % 2 == 0) {
        g.add_edge(source, i * m + j, 1);
      } else {
        g.add_edge(i * m + j, sink, 1);
      }
    }
  }

  // 4 dir, even -> odd
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ((i + j) % 2 == 1) continue;
      if (s[i][j] == '#') continue;

      int di[] = {0, 1, 0, -1};
      int dj[] = {1, 0, -1, 0};
      for (int d = 0; d < 4; d++) {
        int ni = i + di[d];
        int nj = j + dj[d];
        if (ni < 0) continue;
        if (n <= ni) continue;
        if (nj < 0) continue;
        if (m <= nj) continue;
        if (s[ni][nj] == '#') continue;

        g.add_edge(i * m + j, ni * m + nj, 1);
      }
    }
  }

  cout << g.flow(source, sink) << endl;


  // 復元
  auto edges = g.edges();
  for (auto e : edges) {
    int from = e.from;
    int to = e.to;
    if (from == source) continue;
    if (from == sink) continue;
    if (to == source) continue;
    if (to == sink) continue;
    int f = e.flow;
    if (f == 0) continue;

    int i = from / m;
    int j = from % m;
    if (s[i][j] != '.') continue;

    int ii = to / m;
    int jj = to % m;

    // cerr << i << " " << j << " " << ii << " " << jj << endl;
    if (j == jj + 1) {
      s[i][j] = '<';
      s[ii][jj] = '>';
    }
    if (jj == j + 1) {
      s[i][j] = '>';
      s[ii][jj] = '<';
    }
    if (i == ii + 1) {
      s[i][j] = '^';
      s[ii][jj] = 'v';
    }
    if (ii == i + 1) {
      s[i][j] = 'v';
      s[ii][jj] = '^';
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 5936
#include <atcoder/convolution>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<long long> a(n), b(m);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &(a[i]));
    }
    for (int i = 0; i < m; i++) {
        scanf("%lld", &(b[i]));
    }

    vector<long long> c = convolution(a, b);
    // or: vector<long long> c = convolution<998244353>(a, b);

    for (int i = 0; i < n + m - 1; i++) {
        printf("%lld ", c[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 27276
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
  
    if(a>=1&&a<=9&&b>=1&&b<=9)
        cout<<a*b<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    int N;
    cin >> N;

    vector<ll> H(N);

    rep(i,N)    cin >> H[i];

    for(int i=1; i<N-1; i++){
        if(H[i-1] < H[i])   H[i]--;
        
        if((H[i-1] <= H[i]) && (H[i] <= H[i+1])){

        }else{
            show("No");
            return 0;
        }
    }

    show("Yes");

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        int n = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int[] a = new int[m];
        for(int i=0;i<a.length;i++)
        {
            a[i] = scan.nextInt();
        }
        int[] b = new int[n];
        for(int i=0;i<b.length;i++)
        {
            b[i] = scan.nextInt();
        }
        int x_max = MaxInt(x,a);
        int y_min = MinInt(y,b);
        CheckWar(x_max,y_min);
    }
    
    static int MaxInt(int x,int[] a){
        int bignum=x;
        for(int i=0;i<a.length;i++)
        {
            bignum=Math.max(bignum,a[i]);
        }
        return bignum;
    }
    
    static int MinInt(int y,int[] b){
        int smallnum=y;
        for(int i=0;i<b.length;i++)
        {
            smallnum=Math.min(smallnum,b[i]);
        }
        return smallnum;
    }
    
    static void CheckWar(int a,int b){
        if(a>=b)
        {
            System.out.println("War");
        }
        else
        {
            System.out.println("No War");
        }
    }
}

Measured memory_bytes: 23764
fn read<T: std::str::FromStr>() -> T {
    let mut s  = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main(){
    let r:f64 = read();
    println!("{} {}", r*r*std::f64::consts::PI, 2.0*r*std::f64::consts::PI )
}



Measured memory_bytes: 5060
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 6666;

char s[MAX];
int w[MAX];
string f[MAX];
string g[MAX];
int h[MAX];
int bio[MAX];
int cookie;

int main(void) {
  int N;
  scanf("%d", &N);
  scanf("%s", s);

  vector<int> a, b;
  REP(i, 2 * N) {
    if (s[i] == 'a') {
      w[i] = a.size();
      a.push_back(i);
    } else {
      w[i] = b.size();
      b.push_back(i);
    }
  }

  REP(i, 2 * N) {
    if (s[i] == 'b' && a[w[i]] > i) {
      cookie++;

      int e = i, j = i;
      while (j <= e) {
        if (s[j] == 'b' && a[w[j]] > j) {
          if (a[w[j]] > j) {
            bio[a[w[j]]] = cookie;
            e = max(e, a[w[j]]);
          }
          g[i].push_back(s[j]);
        } else if (bio[j] == cookie) {
          if (s[j] == 'a') {
            if (b[w[j]] > i) {
              bio[b[w[j]]] = cookie;
            }
          }
          g[i].push_back(s[j]);
        }
        j++;
      }
      h[i] = e;

      while (j < 2 * N) {
        if (bio[j] == cookie) g[i].push_back(s[j]);
        j++;
      }

    }
  }

  f[N] = "";
  for (int i = 2 * N - 1; i >= 0; --i) {
    f[i] = f[i + 1];
    if (s[i] == 'a') {
      if (b[w[i]] > i) {
        f[i] = max(f[i], "ab" + f[b[w[i]] + 1]);
      }
    } else {
      if (a[w[i]] > i) {
        f[i] = max(f[i], g[i] + f[h[i] + 1]);
      }
    }
  }

  puts(f[0].c_str());
  return 0;
}


Measured memory_bytes: 16384
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

ll solve (ll n) {
	if (n & 1) return 0;
	ll k = 10, ans = 0;
	while (k <= n) {
		ans += n / k;
		k *= 5;
	}
	return ans;
}

int main() {
	ll n;
	scanf("%lld", &n);
	printf("%lld\n", solve(n));
}



Measured memory_bytes: 256
//  __      __       .__           .____________                   __________        __ ________   __                 
// /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
// \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//  \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//   \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//        \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
    ll k;
    cin >> k;
    ll ans = 0;
    for(ll i = 1; i <= k; i++)
        for(ll j = 1; j <= k; j++)
            for(ll l = 1; l <= k; l++)
            {
                ll tans = __gcd(i, j);
                tans = __gcd(tans, l);
                ans += tans;
            }
    cout << ans << endl;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int h[101];
    cin>>n;
    for(int i=0;i<n;i++) cin>>h[i];
    int cnt=0;
    int flag=0;
    while(!flag){
        flag=1;
        for(int i=0;i<n;i++){
            if(flag){
                if(h[i]==0) continue;
                else{
                    flag=0;
                    h[i]--;
                }
            }
            else{
                if(h[i]==0) break;
                else{
                    h[i]--;
                }
            }
        }
        cnt++;
    }
    
    cout<<cnt-1<<endl;
    return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import chain
from bisect import bisect_right

# from collections import Counter
# import numpy as np


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]"):
    A = [0] + A
    for i in range(1, N + 1):
        A[i] = A[i] + A[i - 1]
    B = [0] + B
    for i in range(1, M + 1):
        B[i] = B[i] + B[i - 1]

    answer = 0
    for n in range(N+1):
        ka = A[n]
        if ka > K:
            break
        kb = K - ka  # ak > K だから kb >= 0  bisect_right > 0
        m = bisect_right(B, kb) - 1
        if n + m > answer:
            answer = n + m

    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, M, K, A, B = map(int, line.split())
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    answer = solve(N, M, K, A, B)
    print(answer)


if __name__ == "__main__":
    main()


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

int main() {
  int N,M;
  cin >> N >> M;
  int countt = 0;
  
  vector<int>L(M);
  vector<int>R(M);
  
  for (int i = 0; i < M; i++) {
    cin >> L.at(i) >> R.at(i);
  }
  
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  
  if (R.at(0) - L.at(M-1) + 1 > 0){
    cout << R.at(0) - L.at(M-1) + 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

ll f(ll x){
    if(x%4==0)
        return x;
    if(x%4==1)
        return 1;
    if(x%4==2)
        return x+1;
    return 0;
}

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    ll a,b;
    cin >> a >> b;

    cout << (f(b)^f(a-1)) << endl;

    return 0;
}


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

int main(){

  int n,j,i;
  int a[100];
   cin >> n;
  for(j=n-1;j>=0;j--){
    cin >> a[j];
  }

  for (i=0;i<n;i++){
    cout << a[i];
    if(i!=n-1){
      cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 3080
#include <stdio.h>
long gcd(long a, long b){
        // not zero
        char p=0;
        while(1){
        if(a%2==0){
                a/=2;
                if(b%2==0){
                        b/=2;
                        p++;
                }
        }else{
                if(b%2==0){
                        b/=2;
                }else{
                        if(a>b){
                                a-=b;
                                if(a==0) return b<<p;
                        }else{
                                b-=a;
                                if(b==0) return a<<p;
                        }
                }
        }
        }
}
int main(void){ 
        long a, b, c;
        scanf("%ld%ld", &a, &b);
        c = gcd(a, b);
        printf("%ld\n", a*b/c);
}


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

#define INFTY (1 << 30)

//???????????????
enum Color {
	WHITE,
	GRAY,
	BLACK,
};


//SSSP
void Dijkstra(vector<pair<int, int>> *v_w_m, int verNum) {

	//???????¨????
	priority_queue<pair<int, int>> pQ;
	int distance[10000];
	Color color[10000];
	int parent[10000];
	for (int i = 0; i < verNum; i++) {
		color[i] = WHITE;
		distance[i] = INFTY;
		parent[i] = -1;
	}
	distance[0] = 0;
	pQ.push(make_pair(0, 0));


	//SSSP??????
	while (!pQ.empty()) {

		//??°??¬????????????????????????????°?????????????????????¶
//		int min_cost = INFTY;
		int subScript;
		pair<int, int> wei_sub_map = pQ.top();
		pQ.pop();
		subScript = wei_sub_map.second;
		//for (int i = 0; i < verNum; i++) {
		//	if (color[i] != BLACK && distance[i] < min_cost) {
		//		min_cost = distance[i];
		//		subScript = i;
		//	}
		//}

		//?????????????????????
		color[subScript] = BLACK;

		//???????????????????????°??????????????????????????????????????????
		//?????????????????¨4169407B?????¨??????0.01sec????????????
		if (distance[subScript] < wei_sub_map.first * -1)
			continue;

		//??£??\?????°??¬??????
		for (int i = 0; i < v_w_m[subScript].size(); i++) {
			int outV = v_w_m[subScript][i].first;
			if (color[outV] == BLACK) continue;
			if (distance[outV] < distance[subScript] + v_w_m[subScript][i].second) continue;

			distance[outV] = distance[subScript] + v_w_m[subScript][i].second;
			parent[outV] = subScript;
			color[outV] = GRAY;
			pQ.push(make_pair(distance[outV] * -1, outV));
		}
	}

	//??????
	int weight_sum = 0;
	for (int i = 0; i < verNum; i++) {
		cout << i << " " << distance[i] << endl;
	}
}


int main() {

	int verNum;
//	int verValWeight[100][100];
	vector<pair<int, int>> v_w_m[10000];
	int parent[10000];

	//???????¨????
//	v_w_m = new vector<pair<int, int>>();
	cin >> verNum;
	//for (int i = 0; i < verNum; i++)
	//	for (int j = 0; j < verNum; j++)
	//		verValWeight[i][j] = INFTY;

	//??\?????????
	for (int i = 0; i < verNum; i++) {
		int verVal, outNum;
		cin >> verVal >> outNum;
		for (int j = 0; j < outNum; j++) {
			int outVerVal, weight;
			cin >> outVerVal >> weight;
//			v_w_m[verVal].push_back(make_pair(outVerVal, weight));
			v_w_m[verVal].push_back(make_pair(outVerVal, weight));
			//			verValWeight[i][outVerVal] = weight;
		}
	}

	//SSSP
	Dijkstra(v_w_m, verNum);

	return 0;
}

Measured memory_bytes: 8004
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
S = list(input())

tmp = S.count(".")
num = [0]*N
num_sharp = 0
num_peri = 0
for i in range(len(S)):
	if S[i] == "#":
		num_sharp += 1
	else:
		num_peri += 1
	num[i] = num_sharp + tmp-num_peri

print(min(tmp, min(num)))

Measured memory_bytes: 14740
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
X = inputlist()
X.sort()
if N >= M:
    print(0)
    exit()
d = []
for i in range(1,M):
    d.append(X[i]-X[i-1])
d.sort(reverse=True)
da = d[(N-1):]
print(sum(da))

Measured memory_bytes: 13832
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n;
  cin >> n;
    
  ll ans = 0;
  vector<int> p(n+1);
  rep(i,n+1){
  cin>>p[i];
  ans+=p[i];
  }
  
  vector<int> q(n);
  rep(i,n){
  cin>>q[i];
    if(p[i]>=q[i]){
    ans-=p[i]-q[i];
    }
    else{
    p[i+1]=max(0,p[i+1]-q[i]+p[i]);
    }
  }
  ans-=p[n];
  
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
'''
Daiki Suyam
一旦、奇数なら右に移し、その後、右列を下に移す
'''
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
ans=[]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            a[i][j]-=1
            ans.append([i+1,j+1,i+1,j+2])
for i in range(h-1):
    if a[i][w-1]%2==1:
        #if i!=h-1:
            a[i+1][w-1]+=1
            a[i][w-1]-=1
            ans.append([i+1,w,i+2,w])
l=len(ans)
print(l)
for i in range(l):
    print(" ".join(map(str,ans[i])))

Measured memory_bytes: 30608
#include <cstdio>
char s[51][51];
bool used[51][51];
int H,W,cnt;
bool f;
void dfs(int x,int y)
{
    if(x<0||x>=H||y<0||y>=W||used[x][y]||s[x][y]=='.')
        return;
    used[x][y]=true;
    cnt++;
    dfs(x-1,y);
    dfs(x+1,y);
    dfs(x,y-1);
    dfs(x,y+1);
    return;
}
int main()
{
    scanf("%d%d",&H,&W);
    for(int i=0;i<H;i++)
        scanf("%s",s[i]);
    cnt=0;
    f=true;
    for(int i=0;i<H&&f;i++)
        for(int j=0;j<W&&f;j++)
            if(!used[i][j]&&s[i][j]=='#')
            {
                cnt=0;
                dfs(i,j);
                if(cnt<2)
                    f=false;
            }
    if(f)
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  
  int x=1;
  
  for(int i=0 ; i<N ; i++){
    
    if( x+K <= x*2 ){
      x += K;}
    
    else{
      x *= 2;}
    
    if( i == N-1 ){
      cout << x << endl;}
  }
}
    

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

using namespace std;

#define ll long long
#define nn '\n'
#define db(x) cout << "(DB)-> " << x << nn

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x;
  cin >> x;
  if (x >= 30)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007
//main
signed main(){
  int N,M,O,P,count=0,count2=mod,count3=0,stack=0;
  str S,T;
  cin>>N;
  while(true){
    if(count*count==N){cout<<count*count<<endl;break;}
    elif(count*count>N){
      cout<<(count-1)*(count-1)<<endl;
      break;
    }
    count+=1;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	unsigned long H, count, num;
	count = 0;
	num = 1;

	scanf("%lu", &H);

	while(H > 0) {
		H /= 2;
		count++;
	}

	while(count-- > 0) {
		num *= 2;
	}

	printf("%lu", num - 1);

	return 0;
}

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

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

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

Measured memory_bytes: 256