akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    string S;
    size_t size;
    cin >> S;
    size = S.size();
    for (int i=0; i<size; i++) {
        cout << "x";
    }
    std::cout << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n/10==9||n%10==9) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = [int(s) for s in input().split()]

    pos = 1
    order = [-1] * (N+1)
    order[1] = 0
    s = [1]
    for i in range(1, N + 1):
        npos = A[pos-1]
        if order[npos] != -1:
            l = order[npos]
            c = i - order[npos]
            break

        order[npos] = i
        s.append(npos)
        pos = npos

    if (K < l):
        print(s[K])
    else:
        print(s[l + (K - l) % c])

    return


if __name__ == '__main__':
    main()


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

int main()
{
    string w;
    cin >> w;

    if(w == "Sunny")cout << "Cloudy";
    if(w == "Cloudy")cout << "Rainy";
    if(w == "Rainy")cout << "Sunny";
    cout << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200 * 1000 + 10;

int a[N];
int cnt[N];

vector<int> work(int m, vector<int> action) {
    set<int> all;
    for (int a : action)
        all.insert(a);
    //reverse(action.begin(), action.end());
    vector<int> res = action;
    for (int i = 0; i < m; i++)
        if (all.find(i) == all.end())
            res.push_back(i);
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> pref;
    map<int, int> pos;
    int last = 0;
    cnt[0] = n;
    for (int i = 0; i < q; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = q - 1; i >= 0; i--) {
        if (pos.find(a[i]) == pos.end()) {
            pos[a[i]] = pref.size();
            cnt[last]--;
            last++;
            cnt[last]++;
            pref.push_back(a[i]);
        } else {
            if (cnt[pos[a[i]]] > 0) {
                cnt[pos[a[i]]]--;
                cnt[pos[a[i]] + 1]++;
            }
        }
    }    
    int minP = last;
    for (int i = 0; i <= last; i++)
        if (cnt[i]) {
            minP = i;
            break;
        }
    vector<int> r1 = work(m, pref);
    pref.resize(minP);
    vector<int> r2 = work(m, pref);
    cout << (r1 == r2 ? "Yes" : "No") << endl;        
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	ll l[n];
	rep (i, n) {
		cin >> l[i];
	}

	if (n < 3) {
		cout << 0 << endl;
		return 0;
	}

	int cnt = 0;
	rep(i, n)rep(j, i)rep(k, j) {
		if (l[i] == l[j]) continue;
		if (l[j] == l[k]) continue;
		if (l[k] == l[i]) continue;
		if (l[i] >= (l[j]+l[k]))  continue;
		if (l[j] >= (l[k]+l[i]))  continue;
		if (l[k] >= (l[i]+l[j]))  continue;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

#define int long long

vector<int> A;
int pd[3002][3002][2];
int dp(int l,int r,bool fl){
	if(r<l) return 0;
	if(pd[l][r][fl]!=-1) return pd[l][r][fl];
	if(fl)
		return pd[l][r][fl] = max(A[l]+dp(l+1,r,!fl),A[r]+dp(l,r-1,!fl));
	return pd[l][r][fl] = min(-A[l]+dp(l+1,r,!fl),-A[r]+dp(l,r-1,!fl));
}

int32_t main(){
	memset(pd,-1,sizeof pd);
	int n;
	cin >> n;
	A = vector<int> (n);
	for(auto &a:A) cin >> a;
	cout << dp(0,n-1,true) << '\n';
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,a[4],sum=0;
  cin>>A;
  for(int i=3;i>=0;i--){
    a[i]=A%10;
    A/=10;
  }
  sum=a[0]+a[1]+a[2]+a[3];
  if(sum==7){
    cout<<a[0]<<'+'<<a[1]<<'+'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
    return 0;
  }
  sum=a[0]+a[1]+a[2]-a[3];
  if(sum==7){
    cout<<a[0]<<'+'<<a[1]<<'+'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
    return 0;
  }
  sum=a[0]+a[1]-a[2]+a[3];
  if(sum==7){
    cout<<a[0]<<'+'<<a[1]<<'-'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
    return 0;
  }
  sum=a[0]+a[1]-a[2]-a[3];
  if(sum==7){
    cout<<a[0]<<'+'<<a[1]<<'-'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
    return 0;
  }
  sum=a[0]-a[1]+a[2]+a[3];
  if(sum==7){
    cout<<a[0]<<'-'<<a[1]<<'+'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
    return 0;
  }
  sum=a[0]-a[1]+a[2]-a[3];
  if(sum==7){
    cout<<a[0]<<'-'<<a[1]<<'+'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
    return 0;
  }
  sum=a[0]-a[1]-a[2]+a[3];
  if(sum==7){
    cout<<a[0]<<'-'<<a[1]<<'-'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
    return 0;
  }
  sum=a[0]-a[1]-a[2]-a[3];
  if(sum==7){
    cout<<a[0]<<'-'<<a[1]<<'-'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

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

    cout << max(0,a-b*2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<long,long> pll;

int n;
pll ab[200010];
long a, b, t;
bool f;

bool compare(const pll& a, const pll& b){
	return a.second < b.second || (a.second == b.second && a.first < b.first);
}

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> a >> b;
		ab[i] = {a, b};
	}
	sort(ab, ab+n, compare);
	t = 0;
	f = true;
	for (int i = 0; i < n; ++i){
		a = ab[i].first;
		b = ab[i].second;
		t += a;
		if (t > b){
			f = false;
			break;
		}
	}
	cout << (f ? "Yes" : "No");
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int ret, cnt, n;

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		int x; scanf("%d",&x);
		if(x == i){
			cnt++;
		}
		else{
			ret += (cnt + 1) / 2;
			cnt = 0;
		}
	}
	ret += (cnt + 1) / 2;
	cout << ret << endl;
}


Measured memory_bytes: 256
// C - Chocolate Bar
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)

ll check1(int Y, int X){//"||||"
	ll s1,s2,s3;
	ll minDiff = LLONG_MAX;
	ll e = (X+3-1)/3;
	for(ll x1=1; x1<=e; ++x1){
		ll x2 = (X-x1)/2;
		ll x3 = X - x1 - (X-x1)/2;
		s1 = Y * x1;
		s2 = Y * x2;
		s3 = Y * x3;
		ll diff = max({s1, s2, s3}) - min({s1, s2, s3});
		minDiff = min(minDiff, diff);
	}
	return minDiff;
}

ll check2(int Y, int X){//"T"
	ll s1,s2,s3;
	ll minDiff = LLONG_MAX;
	ll e = (Y+2-1)/2;
	for(ll y1=1; y1<=e; ++y1){
		ll y2 = Y-y1;
		ll x1 = X;
		ll x2 = X/2;
		ll x3 = X-x2;
		s1 = y1 * x1;
		s2 = y2 * x2;
		s3 = y2 * x3;
		ll diff = max({s1, s2, s3}) - min({s1, s2, s3});
		minDiff = min(minDiff, diff);
	}
	return minDiff;
}

int main(){
	int H,W; cin>>H>>W;
	ll ans = LLONG_MAX;
	ans = min({ans, check1(H, W), check1(W, H)});
	ans = min({ans, check2(H, W), check2(W, H)});
	cout<< ans <<endl;
}

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

using namespace std;

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

  int k, x;

  cin >> k >> x;

  int min = x - (k - 1);
  if (min < -1000000) {
    min = -1000000;
  }

  int max = x + (k - 1);
  if (max > 1000000) {
    max = 1000000;
  }

  for (int i = min; i <= max; i++) {
    if (i != min) {
      cout << " ";
    }
    cout << i;
  }

  cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n;
  scanf("%d", &n);
  long L[n];
  L[0]=2;L[1]=1;
  for(int i=2;i<=n;i++){
   L[i]=L[i-1]+L[i-2];
  }
  printf("%ld\n", L[n]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long h,w;
    cin>>h>>w;
    char a[h][w];
    vector<long long> H(h,0),W(w,0);
    f(i,0,h){
        long long c=0;
        f(j,0,w){
            cin>>a[i][j];
            if(a[i][j]=='.'){
                c++;
            }
        }
        if(c==w){
            H[i]=1;
        }
    }
    f(j,0,w){
        long long c=0;
        f(i,0,h){
            cin>>a[i][j];
            if(a[i][j]=='.'){
                c++;
            }
        }
        if(c==h){
            W[j]=1;
        }
    }
    f(i,0,h){
        if(H[i]==0){
            f(j,0,w){
                if(W[j]==0){
                    cout<<a[i][j];
                }
            }
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    multiset<int,greater<int>> st;
    for (int i=0;i<n;i++)
    {
        int ele;
        scanf("%d",&ele);
        st.insert(ele);
    }
    for (int i=0;i<m;i++)
    {
        int val=*(st.begin());
        st.erase(st.begin());
        st.insert(val/2);
    }
    ll sum1=0LL;
    for (int x: st)
    sum1=sum1+1LL*x;
    printf("%lld\n",sum1);
    return 0;
}

Measured memory_bytes: 8376
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define x first
#define y second

const int sz = 2.5e7;
int d1[sz];
long long d2[sz];

signed main() {
	int n, ga, sa, ba, gb, sb, bb;
	cin >> n;
	cin >> ga >> sa >> ba;
	cin >> gb >> sb >> bb;
	for (int i = 1; i <= n; i++) {
		d1[i] = i;
		if (i >= ga) {
			d1[i] = max(d1[i], d1[i - ga] + gb);
		}
		if (i >= sa) {
			d1[i] = max(d1[i], d1[i - sa] + sb);
		}
		if (i >= ba) {
			d1[i] = max(d1[i], d1[i - ba] + bb);
		}
	}
	for (int i = 1; i <= sz; i++) {
		d2[i] = i;
		if (i >= gb) {
			d2[i] = max(d2[i], d2[i - gb] + ga);
		}
		if (i >= sb) {
			d2[i] = max(d2[i], d2[i - sb] + sa);
		}
		if (i >= bb) {
			d2[i] = max(d2[i], d2[i - bb] + ba);
		}
	}
	cout << d2[d1[n]];
	return 0;
}


Measured memory_bytes: 196864
using System;
class Program
{
  static void Main(string[] args)
  {
    string a = Console.ReadLine();
    string b = Console.ReadLine();
    int length = a.Length;
    if( a == b.Substring(0,length) ){
      Console.WriteLine("Yes");
    }else{
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 17388
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {

    int n; cin >> n;
    if(n >= 30) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3624
H, W, K = map(int, input().split())

C = [[0 if c == '.' else 1 for c in input()] for i in range(H)]
ans = 0

for i in range(2 ** H):
    T = [A[::] for A in C]
    t = 1
    for k in range(H):
        if t & i > 0:
            for x in range(W):
                T[k][x] = 2
        t <<= 1

    for j in range(2 ** W):
        Q = [A[::] for A  in T]
        s = 1
        for u in range(W):
            if s & j > 0:
                for y in range(H):
                    Q[y][u] = 2
            s <<= 1

        if sum([A.count(1) for A in Q]) == K:
            ans += 1

print(ans)


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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)

typedef pair<int, int> P;

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int n;
int x[100], y[100], h[100];

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i] >> h[i];
	
	rep(cx, 101) {
		rep(cy, 101) {
			int H;
			rep(i, n) {
				if (h[i] != 0) {
					H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					break;
				}
			}
			
			bool complete = true;
			rep(i, n) {
				if (max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) {
					complete = false;
				}
			}
			
			if (complete) {
				cout << cx << " " << cy << " " << H << endl;
				return 0;
			}
		}
	}
	
	return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


ll dpm[100] = {0};
vector<pair<ll,ll>> dps(100,{0,0});
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  dpm[0] = 1000;
  for(int i(0);i<N;i++){
    dpm[i+1] = max(dpm[i],dps[i].first*A[i]+dps[i].second);
    if(dps[i].first == dpm[i]/A[i]){
      dps[i+1].first = dps[i].first;
      dps[i+1].second = max(dps[i].second,dpm[i]%A[i]);
    }else if(dps[i].first > dpm[i]/A[i]){
      dps[i+1] = dps[i];
    }else{
      dps[i+1].first = dpm[i]/A[i];
      dps[i+1].second = dpm[i]%A[i];
    }
    //dp[i+1][0] = max(dp[i+1][0],dp[i][0]+A[i])
    // for(int j(0);j<=20;j++){
    //   if(dp[i][j] == -1) continue;
    //   for(int k(0);k<=20;k++){ //買う
    //     if(j+k <= 20 && dp[i][j] - A[i]*k >= 0){
    //       dp[i+1][j+k] = max(dp[i+1][j+k],dp[i][j] - A[i]*k);
    //     }
    //   }
    //   for(int k(1);k<=j;k++){ //売る
    //     dp[i+1][j-k] = max(dp[i+1][j-k],dp[i][j] + A[i]*k);
    //   }
    // }
  }
  cout << dpm[N] << endl;
  return 0;
}



Measured memory_bytes: 3572
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
state = [1] * (n+1)

for _ in range(m):
  state[int(input())] = 0
  
f = [1, 1]

for i in range(2, n+1):
  f_nm1 = f[i-1] if state[i-1]==1 else 0
  f_nm2 = f[i-2] if state[i-2]==1 else 0
  f.append(f_nm1 + f_nm2)

print(f[-1]%1000000007)

Measured memory_bytes: 460788
package main

import (
  "fmt"
)

func main() {
  var w string
  fmt.Scanf("%s", &w)
  
  alpha := map[rune]int{}
  for _, v := range w {
    alpha[v]++
  }
  
  ans := "Yes"
  for _, v := range alpha {
    if v % 2 != 0 {
      ans = "No"
    }
  }

  fmt.Printf("%s", ans)
}

Measured memory_bytes: 1844
use std::collections::BTreeSet;

use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }

    let mut s = BTreeSet::<i32>::new();
    for ai in a {
        if s.contains(&ai) {
            s.remove(&ai);
        } else {
            s.insert(ai);
        }
    }

    println!("{}", s.iter().count());
}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(),a.end());
    ll count=0;
    ll budget=0;
    ll idx=0;
    while(count<m) {
        if(a[idx].second+count<m){
            count+=a[idx].second;
            budget+=a[idx].first*a[idx].second;
            idx++;
        }
        else{
            budget+=a[idx].first*(m-count);
            count=m;
        }
    }
    cout << budget << "\n";
    return 0;
}

Measured memory_bytes: 1792
h,w=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(input()))
i=0
while i<len(l):
    for j in range(len(l[0])):
        if l[i][j]!='.':
            i+=1
            break
    else:
        del(l[i])

i=0    
while i<len(l[0]):
    for j in range(len(l)):
        if  l[j][i]!='.':
            i+=1
            break
    else:
        for k in range(len(l)):
            del l[k][i]
i=0
for i in range(len(l)):
    s=''
    for j in range(len(l[0])):
        s=s+l[i][j]
    print(s)    

Measured memory_bytes: 3188
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    string s;
    cin >> s;
    LL n = s.length();
    vector<LL> left(n, 0);
    vector<LL> right(n, 0);
    bool flag = true;
    int cur = 0;
    int pre = 0;
    rep(i, n) {
        if (s[i] == 'R') {
            if (flag == true) {
                cur++;
                flag = false;
            } else {
                pre++;
                flag = true;
            }
        } else {
            if (flag == true) {
                left[i] += cur;
                left[i - 1] += pre;
            } else {
                left[i] += pre;
                left[i - 1] += cur;
            }
            flag = true;
            cur = 0;
            pre = 0;
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'L') {
            if (flag == true) {
                cur++;
                flag = false;
            } else {
                pre++;
                flag = true;
            }
        } else {
            if (flag == true) {
                right[i] += cur;
                right[i + 1] += pre;
            } else {
                right[i] += pre;
                right[i + 1] += cur;
            }
            flag = true;
            cur = 0;
            pre = 0;
        }
    }
    // for (auto x : left) {
    //     cout << x << " ";
    // }
    // cout << endl;
    //     for (auto x : right) {
    //     cout << x << " ";
    // }
    // cout << endl;
    rep(i, n) {
        if (i == n - 1) {
            cout << left[i] + right[i] << endl;
        } else {
            cout << left[i] + right[i]  << ' ';
        }
    }
    return 0;
}


Measured memory_bytes: 2240
import GHC.Integer.GMP.Internals
main=print.solve.map read.words=<<getLine
solve[n,m]=foldr h 1$f 2 m where
  h k s=foldr(\i s->s*(n+k-i)`mod`mo*recipModInteger i mo)s[1..k]
f k i
  |i<2=[]
  |k*k>i=[1]
  |c/=0=c:f(k+1)j
  |otherwise=f(k+1)i
  where
    (j,c)=g i 0
    g i c=if r/=0 then(i,c)else g a(c+1)where(a,r)=divMod i k
mo=10^9+7

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

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

    vector<int> v;

    int N; cin >> N;
    map<string, ll> mp;
    REP(i, N){
        string s; cin >> s;
        sort(all(s));
        mp[s]++;
    }

    ll ans = 0;
    for(auto e: mp){
        ans += (e.second)*(e.second-1)/2;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 11136
N = int(input())

nums = input().split()
nums = [int(x) for x in nums]

min = None
count = 0

for idx, num in enumerate(nums):
    if idx == 0:
        min = num
        count += 1
        continue
    
    if min >= num:
        count += 1
        min = num
    
print(count)

Measured memory_bytes: 24744
#include<stdio.h>

static const int N = 100;

int main(){
  int n, i, j, k, l, p[N + 1], m[N + 1][N + 1];
  scanf("%d", &n);
  for(i = 1 ; i <= n ; i++){
    scanf("%d %d", &p[i - 1], &p[i]);
  }

  for(i = 1 ; i <= n ; i++) m[i][i] = 0;
  for(j = 2 ; j <= n ; j++){
    for(i = 1 ; i <= n - j + 1 ; i++){
      k = i + j - 1;
      m[i][k] = (1 << 21);
      for(l = i ; l <= k - 1 ; l++){
        if(m[i][k] > m[i][l] + m[l + 1][k] + p[i - 1] * p[l] * p[k]){
          m[i][k] =  m[i][l] + m[l + 1][k] + p[i - 1] * p[l] * p[k];
        }
      }
    }
  }

  printf("%d\n", m[1][n]);

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    set<int> num;
    for (int i = 0; i < n; i++) {
        int buf;
        cin >> buf;
        if (num.find(buf) == num.end()) {
            num.insert(buf);
        } else {
            num.erase(buf);
        }
    }
    cout << num.size() << endl;
    return 0;
}


Measured memory_bytes: 4864
s=int(input())
ans=[]
t=0
ans.append(s)
for i in range(1000000):
    if ans[i]%2==0:
        ans.append(ans[i]//2)
    else:
        ans.append(3*ans[i]+1)
    for j in range(i):
        if ans[i]==ans[j]:
            t=1
            break
    if t==1:
        break
print(i+1)

Measured memory_bytes: 38768
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <vector>
namespace Program
{
    using namespace std;
    class Solver
    {
    private:
        int N;
        int T;
        int A;

        long long vote;

        long long v(long long a, long long b)
        {
            //return ceil((double)a / b);
            return (a % b) ? a / b + 1 : a / b;
        }

    public:
        Solver()
        {
            cin.tie(0);
            ios::sync_with_stdio(false);

            cin >> N;

            cin >> T >> A;

            long long vT = T;
            long long vA = A;

            vote = vT + vA;

            for (int i = 1; i < N; i++)
            {
                cin >> T >> A;

                long long n = max(v(vT, T), v(vA, A));

                vT = n * T;
                vA = n * A;

                vote = vT + vA;
            }
        }
        void Solve()
        {
            cout << vote << endl;
        }
    };
}

int main()
{
    // メモリリーク検出
    //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
    //    | _CRTDBG_DELAY_FREE_MEM_DF
    //    | _CRTDBG_CHECK_ALWAYS_DF
    //    | _CRTDBG_LEAK_CHECK_DF);

    // メンバ関数ポインタ取得
    void (Program::Solver::*pSolve)() = &Program::Solver::Solve;

    // コンストラクタ呼び出し
    Program::Solver obj;

    // .*演算子でアクセス
    (obj.*pSolve)();
    return 0;
}


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

using namespace std;

int n, m, bl, w;
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(m < a) bl = 0;
        else bl++;
        w = max(w, bl);
        m = a;
    }
    cout << w << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define N 25
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define form(l, r, i)	for(int i = l; i <= r; ++i)
#define forv(r, l, i)	for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
#define getb __builtin_popcount

const int inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 7;
 
using namespace std;

ll dp[(1 << N)]; // subset of womens(mask)
bool can[N][N];

int main()
{
	barnarnar
	int n;
	cin >> n;
	forn(i, n)	forn(j, n)	cin >> can[i][j];
	dp[0] = 1;
	for(int mask = 0; mask < (1 << n) - 1; mask++)
	{
		int a = getb(mask);
		for(int b = 0; b < n; b++)
		{
			if(can[a][b] && !(mask & (1 << b)))
			{
				int mask_to = mask ^ (1 << b); // set b bit to 1(b women added)
				dp[mask_to] += dp[mask];
				dp[mask_to] %= modw;
			}
		}
	}
	cout << dp[(1 << n) - 1];
	return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N, M;
        cin >>N >>M;
        vector<int> H(N+1, 0);
        Rep1(i, N)
                cin >>H.at(i);
        vector<bool> HH(N+1, true);
        Rep0(i, M) {
                int A, B;
                cin >>A >>B;
                int HA=H.at(A);
                int HB=H.at(B);
                if (HA>=HB)
                        HH.at(B)=false;
                if (HA<=HB)
                        HH.at(A)=false;
        }
        int S=0;
        Rep1(i, N)
                if (HH.at(i))
                        S++;
        cout <<S <<endl;
        return 0;
}

Measured memory_bytes: 3740
N, Q = map(int, input().split())
Str = input()
l_list = [0] * Q
s_list = [0] * Q
for i in range(0, Q):
    l_list[i], s_list[i] = map(int, input().split())

Mem = [0] * N
for i in range(1, N):
    if Str[i-1] + Str[i] == 'AC':
        Mem[i] = Mem[i-1] + 1
    else:
        Mem[i] = Mem[i-1]

for i in range(0, Q):
    print(Mem[s_list[i]-1] - Mem[l_list[i]-1])


Measured memory_bytes: 14128
#include <bits/stdc++.h>
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
typedef long long ll;
using namespace std;
#define pii pair<int, int>
#define fi first
#define sc second

int main(){
    int n;
    cin >> n;
    vector<pii> d(n);
    rep(i, n){
        cin >> d[i].fi >> d[i].sc;
    }
    
    int cnt=0;
    bool ans = false;
    rep(i, n){
        if(d[i].fi == d[i].sc)cnt++;
        else cnt = 0;
        if(cnt>=3){
            ans = true;
            break;
        }
    }
    
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;

//価値v,重さw
int Knapsack(int n,int W, vector<int>& v,vector<int>& w){
    W++;
    twovec(dp,n,W);
    dp[0][w[0]] = v[0];
    FOR(i,1,n){
        if(w[i] >= W) continue;
        dp[i][w[i]] = max(v[i],dp[i-1][w[i]]);
        REP(j,W){
            if(dp[i-1][j] != 0){
                dp[i][j] = max(dp[i][j],dp[i-1][j]);
                if(j+w[i] < W){
                    dp[i][j+w[i]] = dp[i-1][j] + v[i];
                }
            }
        }
    }
    int ans = 0;
    REP(i,W){
        ans = max(ans,dp[n-1][i]);
    }
    return ans;
}

int Knapsack_big(int n,int W, vector<int>& v,vector<int>& w){
    vector<int> dp(n*1000+1,W+1);
    dp[0] = 0;
    REP(i,n){
        for(int j = dp.size()-1; j >= v[i]; j--){
            if(dp[j] > dp[j-v[i]] + w[i]) dp[j] =  dp[j-v[i]] + w[i];
        }
    }
    //Debug(dp);
    for(int i = dp.size()-1;i >= 0; i--){
        if(dp[i] != W+1) return i;
    }

}

//価値v,重さw
int Knapsack_mult(int n,int W, vector<int>& v,vector<int>& w){
    W++;
    vec(dp,W);
    REP(i,n){
        if(w[i] >= W) continue;
        dp[w[i]] = max(v[i],dp[w[i]]);
        REP(j,W){
            if(j+w[i] >= W) break;
            if(dp[j] != 0){
                dp[j+w[i]] = max(dp[j] + v[i],dp[j+w[i]]);
            }
        }
        //Debug(dp);
    }
    //Debug(dp);
    int ans = 0;
    REP(i,W){
        ans = max(dp[i],ans);
    }
    return ans;
}


signed main(){
    int W;
    cin >> n >> W;
    vec(v,n);
    vec(w,n);
    REP(i,n){
        cin >> v[i] >> w[i];
    }
    print(Knapsack_big(n,W,v,w));
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



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

int main() {
	string u, t, unti;
	int a, b;
	cin >> u >> t;
	cin >> a >> b;
	cin >> unti;

	if (unti == u) a -= 1;
	else b -= 1;
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const ll INF = INT_MAX;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
ll n = 200005;
vector<ll> h(n);
vector<ll> a(n);
vector<ll> dp(n,0);

struct SegmentTree{
        private:
        ll n;
        vector<ll> node;
        
        public:
        SegmentTree(vector<ll> v){
                ll sz = v.size();
                n = 1;
                while(n < sz) n *= 2;
                node.resize(2*n-1,0);
                for(ll i=0;i<sz;i++) node.at(i+n-1) = v.at(i);
                for(ll i=n-2;i>=0;i--) node.at(i) = max(node.at(2*i+1),node.at(2*i+2));
        }
        
        void update(ll x,ll val){
                x += n-1;
                node.at(x) = val;
                while(x > 0){
                        x = (x-1)/2;
                        node.at(x) = max(node.at(2*x+1),node.at(2*x+2));
                }
        }
        
        ll getmax(ll a,ll b,ll k=0,ll l=0,ll r=-1){
                if(r < 0) r = n;
                if(r <= a || b <= l) return 0;
                if(a <= l && r <= b) return node.at(k);
                ll vl = getmax(a,b,2*k+1,l,(l+r)/2);
                ll vr = getmax(a,b,2*k+2,(l+r)/2,r);
                return max(vl,vr);
        }
};

int main(){
  cin >> n;
  rep(i,n) cin >> h.at(i);
  rep(i,n) cin >> a.at(i);
  SegmentTree seg(dp);
  rep(i,n){
    dp.at(h.at(i)) = seg.getmax(0,h.at(i)) + a.at(i);
    seg.update(h.at(i),dp.at(h.at(i)));
  }
  cout << seg.getmax(0,n+1) << endl;
  
  return 0;
}



Measured memory_bytes: 10624
/*
She came from the past
She was never meant to last
Her destiny was fatal
From the start
A messenger from hell
She cast a deadly spell
On all of those who dare
To cross her heart
Ain't no use in you trying to run
Fate has taken it's toll
Just one look and the damage is done
Burn your eyes
Turn your heart into stone
History foretold of a circle
Cast in gold
An evil seed of power
Sealed within
But fate has lent a hand
Destroyed the golden band
And freed her soul
To wash the land with sin
Ain't no use in you trying to run
Fate has taken it's toll
Just one look and the damage is done
Burn your eyes
Turn your heart into stone
She cast a deadly spell
She put a spell on you
She's got evil in her heart
Turn your heart into stone
Turn your heart into stone
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	int x;
	cin>>x;
	if (x==3||x==5||x==7)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;


int main(){
  int n,q;cin>>n>>q;
  string s;cin>>s;
  vector<int> v(n,0);
  for(int i=1;i<n;i++){
      if(s[i-1]=='A'&&s[i]=='C')v[i]++;
      v[i]+=v[i-1];
  }
  for(int i=0;i<q;i++){
      int l,r;cin>>l>>r;
      l--;r--;
      cout<<v[r]-v[l]<<endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define vecin(x,n); vi x;int hool; for(int o=0;o<n;o++) {cin>>hool; x.pb(hool);}
#define vecout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    //a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		//res%=MOD;
		b--;}
        a=(a*a);
        //a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n;
	cout<<1-n;
	
	
	
	
	
	 
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n;
	int a, b;
	int s, t;
	long long int total = 0;

	cin >> n;
	vector<pair<int, int>>p(n + 1);

	FOR(i, 1, n) {
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}
	sort(p.begin(), p.end());
	s = p[1].first;
	t = p[n].first;
	total = p[n].second + p[n].first;

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
	int a, b, count=0;
	scanf("%d %d", &a, &b);
	char c[a+b+2];
	scanf("%s", c);
	for(int i=0; i<a+b+1; i++){
		if(i!=a){
			if(c[i]>=48 && c[i]<=57){
                count++;
            } 
		}else {
			if (c[i]=='-'){
				count++;
			}
		}
	}
	count==a+b+1? printf("Yes\n"): printf("No\n");
	return 0;
}


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

int popcnt(int x) {
    return __builtin_popcount(x);
}

int f(int x) {
    if(x==0) return 0;
    return f(x%popcnt(x)) + 1;
}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    vector<int> b(n);
    rep(i,n) b[i] = s[i]-'0';
    rep(i,n) {
        cnt+=b[i];
    }
    vector<int> ans(n,0);
    rep(i,2){//1のとき0のとき
        int p = cnt;
        if(i==0) p++; else p--;
        if(p<=0) continue;
        int r0 = 0;
        rep(j,n) {//もとの10進数を求める
            r0 = (r0*2)%p;
            r0 += b[j];
        }

        int k = 1;
        for(int j = n-1; j >= 0; --j) {
            if(b[j]==i) {
                int r = r0;
                if(i==0) r = (r+k)%p;//0->1のぶんたす
                else r = (r-k+p)%p; //r-kが負になるかも
                ans[j] = f(r) + 1;
            }
            k = (k*2)%p;
        }
    }
    rep(i,n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5148
#include<stdio.h>

int prim(void);

int n;
int a[101][101];

int main(){
  scanf("%d",&n);
  int i,j,x;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a[i][j]);
      if(a[i][j]==-1)a[i][j]=1000000;
    }
  }

  x=prim();
  printf("%d\n",x);

  return 0;
}

int prim(void){
  int i,j,min,x,y;
  int b[101],l[101],m[101];
  for(i=0;i<n;i++){
    b[i]=0;
    l[i]=1000000;
    m[i]=-1;
  }

  l[0]=0;

  while(1){
    min=1000000;
    x=-1;
    for(i=0;i<n;i++){
      if(b[i]!=1 && l[i]<min){
	min=l[i];
	x=i;
      }
    }

    if(x==-1)break;

    b[x]=1;

    for(j=0;j<n;j++){
      if(b[j]!=1 && a[x][j]!=1000000){
	if(l[j]>a[x][j]){
	  m[j]=x;
	  l[j]=a[x][j];
	  b[j]=3;
	}
      }
    }
  }

  y=0;
  
  for(i=0;i<n;i++){
    if(m[i]!=-1)y=y+a[i][m[i]];
  }

  return y;
}





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

using namespace std;

const int inf = 1e9;
const int maxn = 2e5;
tuple<int, int> mn[2][4 * maxn];

void upd(int p, int c, int v = 1, int l = 0, int r = maxn)
{
    if(r - l == 1)
    {
        mn[p % 2][v] = tuple<int, int>(c, p);
        return;
    }
    int m = (l + r) / 2;
    if(p < m)
        upd(p, c, 2 * v, l, m);
    else
        upd(p, c, 2 * v + 1, m, r);
    mn[p % 2][v] = min(mn[p % 2][2 * v], mn[p % 2][2 * v + 1]);
}

tuple<int, int> get(int a, int b, int c, int v = 1, int l = 0, int r = maxn)
{
    if(a <= l && r <= b)
        return mn[c][v];
    if(r <= a || b <= l)
        return tuple<int, int>(inf, inf);
    int m = (l + r) / 2;
    return min(get(a, b, c, 2 * v, l, m), get(a, b, c, 2 * v + 1, m ,r));
}

set<tuple<int, int, int, int, int>> que;
void query(int a, int b)
{
    if(b - a == 0)
        return;
    auto A = get(a, b, a % 2);
    auto B = get(get<1>(A), b, (a + 1) % 2);
    que.insert(tuple<int, int, int, int, int>(get<0>(A), get<1>(A), get<1>(B), a, b));
}

signed main()
{
    fill(mn[0], mn[0] + 4 * maxn, make_tuple(inf, inf));
    fill(mn[1], mn[1] + 4 * maxn, make_tuple(inf, inf));
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        upd(i, a[i]);
    }
    query(0, n);
    vector<int> ans;
    while(!que.empty())
    {
        int x = get<1>(*begin(que));
        int y = get<2>(*begin(que));
        int l = get<3>(*begin(que));
        int r = get<4>(*begin(que));
        que.erase(begin(que));
        ans.push_back(a[x]);
        ans.push_back(a[y]);
        query(l, x);
        query(x + 1, y);
        query(y + 1, r);
    }
    for(auto it: ans)
        cout << it << ' ';
}
//1001


Measured memory_bytes: 18164
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main() {
  fast();
  cin >> n;
  int tt, aa;
  cin >> tt >> aa;
  double curr = MXN / 1.0;
  int ans = 0;
  FOR(i, 0, n) {
    int x;
    cin >> x;
    double d = tt - x * 0.006;
    if (abs(d - aa) < abs(curr - aa)) {
      ans = i + 1;
      curr = d;
    }
  }
  cout << ans;

  return 0;
}



Measured memory_bytes: 3596
n,q=list(map(int,input().split()))
s=" "+input()
a=[0]
for i in range(1,n+1):
  if s[i]=="C" and s[i-1]=="A":
    a.append(a[i-1]+1)
  else:
    a.append(a[i-1])
for i in range(q):
  l,r=list(map(int,input().split()))
  print(a[r]-a[l])

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

int main(){
  int n;
  cin >> n;
  int one = n % 10;
  if (one == 2 || one == 4 || one == 5 || one == 7 || one == 9) cout << "hon" << endl;
  else if (one == 3)  cout << "bon" << endl;
  else cout << "pon" << endl;
  return 0;
}

Measured memory_bytes: 3608
from functools import reduce

def main():
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # s = input().rstrip()
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 1文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    # N, A = [int(_) for _ in input().split()]
    # X = [int(_) for _ in input().split()]
    N = int(input().rstrip())
    T=[]
    A=[]
    x=[]
    ans = 0
    for i in range(N):
        t, a = [int(_) for _ in input().rstrip().split(' ')]
        T.append(t)
        A.append(a)
    x.append(1)
    for i in range(1,N):
        x.append(max(-1*(-1*(T[i-1] *  x[i-1])//T[i]),-1*(-1*(A[i-1] *  x[i-1])//A[i])))
        t = x[i] * T[i]
        a = x[i] * A[i]
    print(t+a)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3668
#include<iostream>
#include<cmath>

using namespace std;

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  int l[n];
  for(int i = 0; i < n; i++) {
    cin >> l[i];
  }
  int ans = 1;
  double diff = abs(a - (t - l[0] * 0.006));
  for(int i = 0; i < n; i++) {
    double td = abs(a - (t - l[i] * 0.006));
    if(diff > td) {
      diff = td;
      ans = i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,k;
  cin >> n>> k;
  int l[n];
  for(int i=0;i<n;i++) cin >> l[i];
  int sum=0;
  sort(l,l+n);
  for(int i=n-1;i>=n-k;i--){
    sum+=l[i];
  }
  cout << sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool is_leap(int y) {
    if (y % 400 == 0) return true;
    if (y % 100 == 0) return false;
    if (y % 4   == 0) return true;
    return false;
}

int day_of_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int day_count(int y1, int m1, int d1, int y2, int m2, int d2) {
    int day = 0;

    if (y1 == y2) {
        if (m1 == m2) return d2 - d1;
        for (int i = m1 + 1; i <= m2 - 1; i++) {
            day += day_of_month[i];
            if (i == 2 && is_leap(y1)) day++;
        }
        day += day_of_month[m1] - d1;
        day += d2;
    } else {
    
        for (int i = y1 + 1; i <= y2 - 1; i++) {
            day += 365;
            if (is_leap(i)) day++;
        }
    
        for (int i = m1 + 1; i <= 12; i++) {
            day += day_of_month[i];
            if (i == 2 && is_leap(y1)) day++;
        }
        day += day_of_month[m1] - d1;
        if (m1 == 2 && is_leap(y1)) day++;
    
        for (int i = 1; i <= m2 - 1; i++) {
            day += day_of_month[i];
            if (i == 2 && is_leap(y2)) day++;
        }
        day += d2;
    }

    return day;
}

int main() {
    int y1, m1, d1, y2, m2, d2;
    while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
        if (y1 < 0 || m1 < 0 || d2 < 0 ||
            y2 < 0 || m2 < 0 || d2 < 0) break;
        cout << day_count(y1, m1, d1, y2, m2, d2) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
def d_wizard_in_maze():
    from collections import deque
    H, W = [int(i) for i in input().split()]
    Start_row, Start_col = [int(i) - 1 for i in input().split()]
    Goal_row, Goal_col = [int(i) - 1 for i in input().split()]
    Grid = [input() for _ in range(H)]

    warp_count = [[-1] * W for i in range(H)]
    neighbor_4 = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    neighbor_25 = [(i, j) for i in range(-2, 3) for j in range(-2, 3)]
    queue = deque([(Start_row, Start_col, 0)])  # コスト 0 の移動は左詰めする

    while(queue):
        row, col, count = queue.popleft()
        if warp_count[row][col] != -1:
            continue
        warp_count[row][col] = count

        for dr, dc in neighbor_4:
            nr, nc = row + dr, col + dc
            if 0 <= nr < H and 0 <= nc < W and Grid[nr][nc] == '.':
                if warp_count[nr][nc] == -1:
                    queue.appendleft((nr, nc, count))

        for dr, dc in neighbor_25:
            nr, nc = row + dr, col + dc
            if 0 <= nr < H and 0 <= nc < W and Grid[nr][nc] == '.':
                queue.append((nr, nc, count + 1))

    return warp_count[Goal_row][Goal_col]

print(d_wizard_in_maze())

Measured memory_bytes: 262828