akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    int a = n;
    int ans = 0;
    while(a!=0)
    {
        int b = a%10;
        if(b==2) ans++;
        a/=10;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), Sorted(N);
    map<int, int> m;
    rep(i,N) {
        cin >> A[i];
        Sorted[i] = A[i];
    }
    sort(Sorted.begin(), Sorted.end());
    rep(i,N) {
        m.insert(make_pair(Sorted[i], i));
    }
    int ans = 0;
    rep(i,N) {
        if (i % 2 != m.at(A[i]) % 2) ans++;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    int n;
    cin >> n;
    vector<int> as(n); 
    rep(i, n) cin >> as[i]; 
    bool isreset = true, preup;
    int ret = 1;
    rep(i, n-1) {
        int d = as[i+1] - as[i];
        if (d==0) continue;
        if(isreset) {
            isreset = false;
            preup = d > 0;
        }
        else {
            if (d>0 ^ preup) {
                ++ret;
                preup = d > 0;
                isreset = true;
            }
        }
    } 
    cout << ret << endl;
    return 0;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    vector<int> dp(n,INT_MAX);

    dp[0]=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=1;j<=k;j++)
        {
            int index=i+j;
            if(index<n)
            {
                dp[index]=min(dp[index],abs(v[i]-v[index])+dp[i]);
            }
        }
    }
   
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int N, M;
string s;
int dist[(int)1e5 + 1];
vector<int> ans;

int main() {
    cin >> N >> M >> s;
    fill(dist, dist + N + 1, (int)1e9);
    dist[N] = 0;
    int p = N - 1;
    for (int i = N; i >= 0; i--) {
        if (s[i] == '1')
            continue;
        for (p = min(p, i - 1); p >= max(0, i - M); p--) {
            if (s[p] == '1')
                continue;
            dist[p] = min(dist[p], dist[i] + 1);
        }
    }
    
    if (dist[0] == (int)1e9) {
        cout << -1 << endl;
        return 0;
    }

    p = 0;
    while (p < N) {
        for (int i = p + 1; i <= min(N, p + M); i++) {
            if (dist[i] == dist[p] - 1) {
                ans.push_back(i - p);
                p = i;
                break;
            }
        }
    }

    for (int v : ans) {
        cout << v << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
long long m,n,a[343434];
int main(){
	cin>>m>>n;
	for(long long i=1;i<=m;i++)
	cin>>a[i];
	sort(a+1,a+1+m);
	if(n>=m) cout<<0;
	else { long long sum=0;
		for(long long i=m-n;i>=1;i--)
		sum+=a[i];
		cout<<sum;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
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(a>b){a=b;return 1;}return 0;}
#define cut(n, Min, Max) max(min(n,Max),Min)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    int n,k;
    cin>>n>>k;
    YES((n+1)/2>=k);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

typedef vector<int> vecint;
typedef vector<vecint> table;
typedef vector<table> cube;

bool isok(cube t, int n, int m,bool blk) {
  int di[] = {1,1,1,1,1,1,1,1,1,0,0,0,0};
  int dj[] = {1,1,1,0,0,0,-1,-1,-1,1,1,1,0};
  int dk[] = {1,0,-1,1,0,-1,1,0,-1,1,0,-1,1};
  REP(i,n)REP(j,n)REP(k,n) {
    REP(l,13){
      bool ok = true;
      REP(o,m){
        int ni = i+di[l]*o;
        int nj = j+dj[l]*o;
        int nk = k+dk[l]*o;
        if (ni<0||nj<0||nk<0||ni>=n||nj>=n||nk>=n) {
          ok = false;
          break;
        }
        if (t[ni][nj][nk] == 0) {
          ok = false;
          break;
        }
        if ((t[ni][nj][nk] != 1) == blk) {
          ok = false;
          break;
        }
      }
      if (ok) return true;
    }
  }
  return false;
}

int main() {
  while(1){
    int n,m,p;
    cin>>n>>m>>p;
    if(!n)break;
    cube c(n,table(n,vecint(n)));
    string res = "Draw";
    int wini = 0;
    bool blk = true;
    REP(i,p) {
      int x,y;
      cin>>x>>y;
      --x;--y;
      REP(j,n) {
        if (c[x][y][j] == 0) {
          c[x][y][j] = blk ? 1 : 2;
          break;
        }
      }
      if (isok(c, n, m, blk)) {
        if (res == "Draw") {
          res = (blk ? "Black" : "White");
          wini = i + 1;
        }
      }
      blk = !blk;
    }
    cout << res;
    if (res != "Draw") {
      cout << ' ' << wini;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

 
int vector_finder(std::vector<int> vec, int number) {
  size_t index = std::distance( vec.begin(), std::find(vec.begin(), vec.end(), number) );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}



int N;

int main()
{
	cin >> N;
	int h[N];
	int l[N];
	REP(i, N)
	{
		cin >> h[i];

	}
	l[0] = h[0];
	int sum = 0;
	REP(i, N)
	{
		if(i>0){
		l[i] = h[i] - h[i - 1];
		}
		if(l[i]>0){
		sum += l[i];
		}
		
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ve <ll> fac;
    ll ans=100000000000000000;
    rep (i,1,sqrt(n)+1)
    {
        if (n%i==0)
        {
            ll xd=n/i;
            ans=min(ans,i+xd-2);
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
int m,n,ans;
int ice[90][90];
int dx[]={-1,0,0,1},dy[]={0,-1,1,0};
int dfs(int x,int y){
	int res=-1;
	bool flag=false;
	if(ice[x][y]==0)return res;
	ice[x][y]=0;
	for(int i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(0<=nx&&nx<m&&0<=ny&&ny<=n&&ice[nx][ny]==1){
			res=max(res,dfs(nx,ny)+1);
			flag=true;
		}
	}
	if(!flag)res=1;
	ice[x][y]=1;
	return res;
}
int main()
{
	while(cin>>m>>n&&(m||n)){
		ans=-1;
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
				cin>>ice[j][i];
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
				ans=max(ans,dfs(j,i));
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1192
#![allow(non_snake_case)]

use std::io;

fn multi(a: &Vec<Vec<i32>>, b: &Vec<i32>) -> Vec<i32> {
    let n = a.len();
    let m = b.len();

    let mut c: Vec<i32> = vec![0; n];

    for i in 0..n {
        for j in 0..m {
            c[i] += a[i][j] * b[j];
        }
    }

    c
}

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let mut ws = buf.split_whitespace();
    let n: usize = ws.next().unwrap().parse().unwrap();
    let m: usize = ws.next().unwrap().parse().unwrap();

    let mut a: Vec<Vec<i32>> = vec![vec![0; m]; n];
    let mut b: Vec<i32> = vec![0; m];

    for i in 0..n {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        for (j, v) in buf.split_whitespace().enumerate() {
            a[i][j] = v.parse::<i32>().unwrap();
        }
    }

    for i in 0..m {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        b[i] = buf.trim().parse().unwrap();
    }
    
    // println!("{:?}", &a);
    // println!("{:?}", &b);
    let c = multi(&a, &b);

    for v in &c {
        println!("{}", v);
    }
}



Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w;
vvi a;

int dfs(int x,int y){
	int t=1;
	a[x][y]++;
	for(int i=0;i<4;i++){
		int X=x+dx[i],Y=y+dy[i];
		if(!a[X][Y]) t+=dfs(X,Y);
	}
	return t;
}

int main(){
	while(1){
		cin>>w>>h;
		if(!h) break;
		int s,t;
		a=vvi(h+2,vi(w+2,1));
		for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
			char c;
			cin>>c;
			if(c!='#') a[i][j]--;
			if(c=='@') s=i,t=j;
		}
		cout<<dfs(s,t)<<endl;
	}
}


Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;

  vector<int> W(N+1);
  int cnt = 0;
  rep(i, N) {
    if (S.at(i) == 'W') {
      ++cnt;
    }
    W.at(i+1) = cnt;
  }
  int min_n = N;
  rep(i, N) {
    int num = W.at(i) + N - i - 1 - (W.at(N) - W.at(i+1));
    min_n = min(min_n, num);
  }
  cout << min_n << endl;
}


Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <string>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define fors(i, a, b) for(int i = a; i < b; i++)
#define fori(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<string, int> > vpsi;
typedef map<string, int> msi;
int main()
{
    ios::sync_with_stdio(false);
    int k;
    string s;
    cin >> k;
    cin >> s;
    if(s.length()<=k)
        cout << s;
    else
    {
        string p;
        for(int i = 0; i < k; i++)
            p += s[i];
        p+="...";
        cout << p << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
int main(void)
{
   int n;cin>>n;
   // int t = 10;
   int ans = 0;
   int nn = n;
  int  tt =0;
   while(nn > 0)
   	tt++,nn /= 10;
   for(int i = 1;i < tt; i += 2){
   	ans += qpow(10,i)-qpow(10,i-1);
   }
   if(tt&1)
   	ans += n-qpow(10,tt-1)+1;

   cout<<ans<<endl;

   return 0;
}


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

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

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define X first
#define Y second

using namespace std;
typedef pair<int,int> pii;

vector<int> edge[200005];
int N, ans[200005];
pii sum[200005];

pii dfs(int n, int b=-1, pii mx={}){
	for(auto t: edge[n]) if( t != b ){
		auto ret = dfs(t, n, max(mx, {n, mx.X}));
		if( mx.X < n ) ret = pii(ret.Y, 0);
		if( t < mx.X ) sum[n].X += ret.X + 1;
		if( t < mx.Y ) sum[n].Y += ret.Y + 1;
	}
	return sum[n];
}

void dfs2(int n, int b=-1, pii mx={}, int s=0){
	ans[n] = s + sum[n].X;
	for(auto t: edge[n]) if( t != b ){
		int cost = s + sum[n].X + 1;
		if( t < mx.X ) cost -= (mx.X < n ? sum[t].Y : sum[t].X) + 1;
		dfs2(t, n, max(mx, {n, mx.X}), cost);
	}
}

int main(){
	ios_base::sync_with_stdio(false);

	cin >> N;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	dfs(0);
	dfs2(0);

	rep(i,N-1) cout << ans[i+1] << " "; cout << endl;

	return 0;
}

Measured memory_bytes: 33664
#include <stdio.h>
#include <string.h>

int main(void){
    int i,cntS,cntT,flg1=1,flg2=0;
    char S[20],T[20];
    scanf("%s",S);
    scanf("%s",T);
    for(cntS=0;S[cntS]!='\0';++cntS);
    for(cntT=0;T[cntT]!='\0';++cntT);
    for(i=0;i<cntS;i++){
        if(S[i] != T[i]){
            flg1 = 0;
            break;
        }
    }
    if(cntS+1 == cntT){
        flg2 = 1;
    }
    if(flg1 == 1 && flg2 == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 1644
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

int h[100'000];

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

    for (int i = n - 2; i >= 0; i--)
    {
        if (h[i] > h[i + 1])
        {
            h[i]--;
        }
        if (h[i] > h[i + 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


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

	int N; cin >> N;
	int a[N];
	rep(i, N) cin >> a[i];
	int b[N + 1];
	rep(i, N) b[a[i]] = i + 1;
	set<int> st;
	st.insert(0);
	st.insert(N+1);
	ll ans = 0;
	rep(i, N) {
		auto itr = st.lower_bound(b[i + 1]);
		int r = *itr;
		--itr;
		int l = *itr;
		ans += (ll)(i + 1) * (ll)(b[i + 1] - l) * (ll)(r - b[i + 1]);
		st.insert(b[i + 1]);
	}
	cout << ans << endl;


    return 0;
}


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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

#define MOD 1000000007

char m[111][111];
bool fr[111];
bool fc[111];

signed main()
{
	int H, W;
	cin >> H>> W;
	rep(i, H) {
		rep(j, W) {
			cin >> m[i][j];
		}
	}
	rep(i, H) {
		rep(j, W) {
			if (m[i][j] == '#') {
				fr[i] = fc[j] = true;
			}
		}
	}
	rep(i, H) {
		rep(j, W) {
			if (fr[i] && fc[j]) cout << m[i][j];
		}
		if (fr[i]) cout << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  char s[4] = {0};
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1')
      s[i] = '9';
    else if (s[i] == '9')
      s[i] = '1';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
function ABC_C()
    #aa=IOBuffer(IJulia.In[1])
    readints()=parse.(Int,split(readline()))
    #readints()=parse.(Int,split(readline(aa)))

    N,M,K=readints()
    A=readints()
    B=readints()
    Asum=zeros(Int,N)
    Bsum=zeros(Int,M)
    Asum[1]=A[1]
    for i in 2:N
        Asum[i]=Asum[i-1]+A[i]
    end
    Bsum[1]=B[1]
    for i in 2:M
        Bsum[i]=Bsum[i-1]+B[i]
    end

    Nmax=N+M
    kazu=0

    AA(n)= n==0 ? 0 : Asum[n]
    BB(n)= n==0 ? 0 : Bsum[n]

    Mmin=M
    for i in 0:N
        for j in Mmin:-1:0
            if AA(i)+BB(j)<=K
                kazu < i+j  && (kazu= i+j)
                Mmin=j
                break
            end
        end
    end

    print(kazu)
end
ABC_C()

Measured memory_bytes: 208444
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  string s;
  int64_t k;
  cin >> s >> k;
  for (int i = 0; ; ++i) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
    --k;
    if (k == 0) {
      cout << 1 << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
 
#define ff first
#define ss second
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define mem(a) memset(a , 0 ,sizeof a)
#define rep(i,a,b) for(int i=a ; i<b ; ++i)
#define deb(x) cout << #x << " - " << x << "\n";
#define deb2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define D2(x) { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define clz(x) __builtin_clzll(x)
#define bit(x) __builtin_popcount(x)
//(a / b) + ((a % b) != 0);
 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 10000000000000000;
const ll MAX_N = 1e5 + 7;

int main() {
    IOS;
    string s,t; cin>>s>>t;
    int len  = s.length();
    bool flag=true;
    rep(i,0,len){
        if(s[i]!=t[i]){
            flag=false; break;
        }
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> X(N), Y(N);
	for(int i=0; i<N; i++){
		cin >> X[i] >> Y[i];
	}

	vector<pair<ll, int>> xi(N), yi(N);
	for(int i=0; i<N; i++){
		xi[i] = {X[i], i};
		yi[i] = {Y[i], i};
	}
	sort(xi.begin(), xi.end());
	sort(yi.begin(), yi.end());
	vector<int> xc(N), yc(N);
	for(int i=0; i<N; i++){
		xc[xi[i].second] = i;
		yc[yi[i].second] = i;
	}

	vector<vector<int>> cnt(N+1, vector<int>(N+1));
	for(int i=0; i<N; i++){
		cnt[xc[i]+1][yc[i]+1]++;
	}
	for(int i=1; i<=N; i++){
		for(int j=1; j<=N; j++){
			cnt[i][j] += cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1];
		}
	}

	ll ans = 4e18;
	for(int xl=0; xl<N; xl++) for(int xh=xl+1; xh<N; xh++){
		for(int yl=0; yl<N; yl++) for(int yh=yl+1; yh<N; yh++){
			int n = cnt[xh+1][yh+1]-cnt[xh+1][yl]-cnt[xl][yh+1]+cnt[xl][yl];
			if(n<K) continue;
			ans = min(ans, (xi[xh].first-xi[xl].first)*(yi[yh].first-yi[yl].first));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    boolean bl = false;
    for(int i = 0; i<3 ; i++){
      bl |= (str.charAt(i) == str.charAt(i+1));
    }
    if(bl){
      System.out.println("Bad");
    }else{
      System.out.println("Good");
    }
  }
}

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

int main() {
  string S;
  cin >> S;
  
  if (S[2]==S[3]){
    if(S[4]==S[5]){
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
  
  return 0;
}


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

arr = map(int,raw_input().split())

counter = collections.Counter(arr)

ans = 0 

for item in counter.items() :
	if item[0] == item[1]:
		next

	elif item[1] < item[0]:
		ans += item[1]

	else :
		ans += item[1]-item[0]

print ans


Measured memory_bytes: 19864
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int map[100][100];

int main(){
	int h, w;
	
	cin >> h >> w;
	
	REP(i,h){
		int cnt = -1;
		int flag = 0;
		
		REP(j,w){
			char c;
			scanf(" %c", &c);
			
			if (c == 'c'){
				cnt = -1;
				flag = 1;
			}
			
			if (flag) cnt++;
			
			map[i][j] = cnt;
		}
	}
	
	REP(i,h){
		REP(j,w){
			if (j > 0 && j < w) printf(" ");
			printf("%d", map[i][j]);
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[10010],t[10010];
	scanf("%s%s",s,t);
	int ls=strlen(s),lt=strlen(t);
	for(int i=ls-lt;i>=0;i--){
		if(s[i]==t[0]||s[i]=='?'){
			bool flag=true;
			for(int j=0;j<lt;j++){
				if(t[j]!=s[j+i]&&s[j+i]!='?'){
					flag=false;
					break;
				}
			}
			if(flag==true){
				for(int j=0;j<lt;j++)s[j+i]=t[j];
				for(int j=0;j<ls;j++){
					if(s[j]=='?')cout<<'a';
					else cout<<s[j];
				}
				return 0;
			}
		}
	}
	cout<<"UNRESTORABLE";
	return 0;
} 

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

template<typename T>
vector<T> Divisors(T n) {
	vector<T> res;
	for(T i = 1; i * i <= n; ++i) {
		if( n % i == 0 ) {
			res.push_back(i);
			
			if( i < n / i ) res.push_back(n / i);
		}
	}
	
	sort(res.begin(), res.end());
	
	return res;
}

int main(void) {
	ll n;
	cin >> n;
	
	vector<ll> div = Divisors(n);
	ll ans = 0LL;
	
	for(auto& a : div) {
		if( a >= (n - a) / a ) break;
		
		ans += (n - a) / a;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

int main() {
    int h, w, n;
    cin >> h >> w >> n;

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

    vector<vector<int>> grid(h, vector<int>(w));
    for (int i = 0, ih = 0, iw = 0; i < n; i++) {
        for (int j = 0; j < a[i]; j++) {
            grid[ih][iw] = i + 1;

            if (ih % 2 == 0) {
                if (iw == w - 1) {
                    ih++;
                } else {
                    iw++;
                }
            } else {
                if (iw == 0) {
                    ih++;
                } else {
                    iw--;
                }
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << (j == 0 ? "" : " ") << grid[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
# 数字の入力
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            sum = 500*i + 100*j + 50*k
            if sum == X:
                ans = ans+1
                #print(str(i)+" "+str(j)+" "+str(k)
                break
            elif sum > X:
                break

print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double p = 3.141592653589;
		double s = 1.00000 * p * r * r;
		double l = 1.00000 * 2 * p * r;
		System.out.print(String.format("%6f", s) + " ");
		System.out.println(String.format("%6f", l));
	}
}


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

int fn(int n) { // nを100で割り切れる回数
    int count = 0;
    while (1) {
        if (n % 100 == 0) {
            n /= 100;
            count++;
        } else {
            break;
        }
    }
    return count;
}

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

    int i = 0; int num = 0;
    while (num != n) {
        if (fn(i+1) == d) num++;
        i++;
    }
    cout << i << endl;
}

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

int main()
{
    vector<int>vec;
   int a,b,c,d,e;
   cin>>a>>b>>c>>d>>e;
   vec.push_back(a);
   vec.push_back(b);
   vec.push_back(c);
   vec.push_back(d);
   vec.push_back(e);
   for(int i=0;i<vec.size();i++)
   {
       if(vec[i]==0)
       {
           cout<<i+1<<endl;
           break;
       }
   }
   return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef vector<int> VE;
#define int long long
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 1000000007
#define pb push_back
#define MAXN 100005

int n;
string ans;


signed main()
{
    cin >> n;
    if(n == 0){
        printf("0\n");
        return 0;
    }
    while(n){
        if(n % 2 != 0){
            n--;
            ans = "1" + ans;
        }
        else{
            ans = "0" + ans;
        }
        n /= -2;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
n, y = list(map(int, input().split()))
ansFlg = False
for a in range(n+1):
    for b in range(n+1):
        if 9000*a + 4000*b == y-1000*n:
            c = n - a - b
            if c>=0:
                print(a, b, c)
                exit()
print("-1 -1 -1")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

vector<pair<int, int>> primeFact(int n) {
  vector<pair<int, int>> res;
  for (int i = 2; i * i <= n; i++) {
    int divcnt = 0;
    if (n % i == 0) {
      do {
        divcnt++;
        n /= i;
      } while (n % i == 0);
      res.emplace_back(i, divcnt);
    }
  }
  if (n != 1)
    res.emplace_back(n, 1);
  return res;
}

signed main() {
  int N; 
  cin >> N;

  if(N < 10){
    cout << 0 << endl;
    return 0;
  }

  map<int, int> m;
  FOR(i, 2, N+1){
    auto v = primeFact(i);
    for(auto p : v){
      m[p.first] += p.second;
    }
  }

  int M = m.size();

  int cnt = 0;
  vector<int> vec(M);
  for(auto p : m){
    vec[cnt++] = p.second;
  }

  int ans = 0;
  int a = 0, b = 0, c = 0;

  REP(i, M){
    if(vec[i] >= 74) a++;
  }
  REP(i, M) REP(j, M) REP(k, M){
    if(i == j || j == k || k == i) continue;
    if(vec[i] >= 2 && vec[j] >= 4 && vec[k] >= 4) b++;
    if(vec[i] >= 4 && vec[j] >= 2 && vec[k] >= 4) b++;
    if(vec[i] >= 4 && vec[j] >= 4 && vec[k] >= 2) b++;
  }
  REP(i, M) REP(j, M){
    if(i == j) continue;
    if(vec[i] >= 2 && vec[j] >= 24) c++;
    if(vec[i] >= 4 && vec[j] >= 14) c++;
  }

  cout << a+b/6+c << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	if(n<2){
		if(m<2)cout<<0<<endl;
		else {
			cout<<m*(m-1)/2<<endl;
		}
	}
	else{
		if(m<2)cout<<n*(n-1)/2<<endl;
		else{
			int a=n*(n-1)/2;
			int b=m*(m-1)/2;
			cout<<a+b<<endl;
		}
	}
	return 0;
} 

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

int main() {
  string s, ans = "Yes";
  cin >> s;
  int N = s.size();
  
  for (int i = 0; i < N; i++) {
    if (i%2 == 0) {
      if (s[i] == 'L') ans = "No";
    } else {
      if (s[i] == 'R') ans = "No";
    }
  }
  
  cout << ans << endl;;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> cells(H);
    REP(h, H) {
        cin >> cells[h];
    }

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

    bool ans = true;
    REP(h, H) {
        REP(w, W) {
            if (cells[h][w] == '#') {
                bool ok = false;
                REP(d, 4) {
                    int h2 = h + dy[d];
                    int w2 = w + dx[d];
                    if (0 <= h2 && h2 < H && 0 <= w2 && w2 < W) {
                        ok |= cells[h2][w2] == '#';
                    }
                }
                if (!ok) ans = false;
            }
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    s,t = LI()
    e = collections.defaultdict(list)
    for _ in range(m):
        u,v,d = LI()
        e[u].append((v,d))
        e[v].append((u,d))

    def search(s,t):
        d = collections.defaultdict(lambda: inf)
        dc = collections.defaultdict(int)
        d[s] = 0
        dc[s] = 1
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            if u == t:
                return (d,dc)

            uc = dc[u]

            for uv, ud in e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] < vd:
                    continue
                if d[uv] > vd:
                    d[uv] = vd
                    dc[uv] = uc
                    heapq.heappush(q, (vd, uv))
                elif d[uv] == vd:
                    dc[uv] += uc

        return (d,dc)

    d1,dc1 = search(s,t)
    d2,dc2 = search(t,s)
    rd = d1[t]
    kk = rd / 2.0

    r = dc1[t] ** 2 % mod
    for k in list(d1.keys()):
        t = d1[k]
        c = dc1[k]
        if t > kk:
            continue
        if t == kk:
            if d2[k] == t:
                r -= (c**2 * dc2[k]**2) % mod
            continue

        for uv, ud in e[k]:
            if d2[uv] >= kk or t + ud + d2[uv] != rd:
                continue
            r -= (c**2 * dc2[uv]**2) % mod

    return r % mod




print(main())


Measured memory_bytes: 154724
n = int(input())
h = []
for _ in range(n):
    h.append(list(map(int, input().split())))
dp = [[0 for _ in range(3)] for _ in range(n)]
for day in range(n):
    if day == 0:
        for act in range(3):
            dp[day][act] = h[day][act]
    else:
        for act in range(3):
            if act == 0:
                dp[day][act] = max(dp[day-1][1], dp[day-1][2]) + h[day][act]
            elif act == 1:
                dp[day][act] = max(dp[day-1][0], dp[day-1][2]) + h[day][act]
            elif act == 2:
                dp[day][act] = max(dp[day-1][0], dp[day-1][1]) + h[day][act]
print(max(dp[n-1]))


Measured memory_bytes: 47368
#include<stdio.h>
#define N 100

int main(){
  int i = 0,j = 0, flag = 1,n = 0,a = 0,b = 0;
  int A[N];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    scanf("%d",&A[i]);

  i = 0;
  
  while(flag == 1){
    flag = 0;
    for(j = n - 1 ; j >= i+1 ; j--){
      if(A[j] < A[j-1]){
	a = 0;
	a = A[j];
	A[j] = A[j-1];
	A[j-1] = a;
	flag = 1;
	b++;
      }
    }
    i++;
  }

  for(j = 0 ; j < n ; j++){
    printf("%d",A[j]);
    if(j <= n-2) printf(" ");
  }
  printf("\n");
  printf("%d\n",b);

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define p cout<<"\n";
using namespace std;

int main()
{
    string s,t;
    int n;
    cin>>n;
    cin>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i];
        cout<<t[i];
    }
    p;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

string S;

int ind;
int state = 0;
bool parse(){
  if(ind == S.size()) return false;
  bool ret = true;
  if(S[ind] == 'm'){
    ind++;
    while(S[ind]!='w'){
      state = 1;
      bool tmp = parse();
      if(!tmp) return false;
    }
    ind++;
  }else if(state == 1 && S[ind] == 'e'){
    state = 2;
    ind++;
    ret = true;
  }else if(state == 2 && S[ind] == 'w'){
    state = 0;
    ind++;
    ret = true;
  }else{
    ret = false;
  }
  return ret;
}

int main(){
  cin>>S;
  ind = 0;
  if(parse() && ind == S.size()) cout<<"Cat"<<endl;
  else cout<<"Rabbit"<<endl;
  return 0;
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



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

	int ans = 1;
	int b = a;
	ans *= a;
	a *= b;
	ans += a;
	a *= b;
	ans += a;
	cout << ans << endl;

}

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

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

int main(){
	int n;
	cin>>n;
	vector<ll>a(n);
	int res=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		res+=a[i];
	}
	int tmp=1e9,ans;
	for(int i=n;i>=0;i--){
		if(tmp>=abs(res-a[i]*n)){
			ans=i;
			tmp=abs(res-a[i]*n);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
# 2019/09/20
from collections import deque

n=int(input())
s=list(input())

l=s.count('(')
r=s.count(')')

cnt=0
cntL=0

def solve(w,r,s):
    cnt=0
    res=0
    for i in range(n):
        if s[i]==w:
            if cnt:
                cnt-=1
            else:res+=1
        else:
            cnt+=1    
    return list(r*res)




pre=solve(')','(',s)
suf=solve('(',')',s[::-1])
ans=pre+s+suf
print(''.join(ans))

Measured memory_bytes: 3316
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int main()
{
    _fast_
    ll t = 1;
   // cin>>t;
    while(t--){
    ll n,m;
    cin>>n>>m;
    ll ans = 0;
    ans +=( n*(n-1))/2;
    ans += (m*(m-1))/2;
    cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)


n = int(input())
a = list(map(int,input().split()))

#取り除く候補
del_list = [0]

#a[0]~a[i]までのgcd
g = a[0]
for i,x in enumerate(a):
    p = gcd(g,x)
    if p<g:
        g = p
        del_list.append(i)

res = -1
for ind in del_list:
    kouho = -1
    for i,x in enumerate(a):
        if i==ind:
            continue
        if kouho < 0:
            kouho = x
            continue
        kouho = gcd(kouho,x)
    res = max(res,kouho)
print(res)


Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
int main(){
    int n = 5;
    vector<LL> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    for(int i = 0; i < n; i++) {
        if(x[i] == 0) {
            cout << i+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = nsn(3)
cnt = [0, 0, 0]
t = 0
while cnt[t] < len(s[t]):
    if s[t][cnt[t]] == 'a':
        cnt[t] += 1
        t = 0
    elif s[t][cnt[t]] == 'b':
        cnt[t] += 1
        t = 1
    else:
        cnt[t] += 1
        t = 2

print(chr(ord('A') + t))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

using namespace std;

int main(){
    int N;  cin >> N;
    int cnt = 0, m=2000000000;
    ll s = 0;
    rep(i,N){
        int a;  cin >> a;
        if(a < 0)    cnt++;
        m = min(m,abs(a));
        s += abs(a);
    }
    if(cnt%2==0)    cout << s;
    else    cout << s - 2*m;
}

Measured memory_bytes: 3636
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, a*n);

}

Measured memory_bytes: 256