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

//temmplate------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
#define ZERO(a) memset(a, 0, sizeof(a))
typedef long long lint;
//------template

int main(){
    vector<int> A(9);
    vector<int> C(9);
    int N;
    int flag = 0;
    REP(i,9){
        cin >> A.at(i);
    }
    cin >> N;
    vector<int> b(N);
    REP(i,N){
        cin >> b[i];
    }

    REP(j,N){
        REP(i,9){
                if (A.at(i) == b.at(j)){
                    C.at(i) = 1;
                }
        }
    }

    if (C.at(0)*C.at(1)*C.at(2) == 1){
        flag = 1;
    } else if (C.at(3)*C.at(4)*C.at(5) == 1){
        flag = 1;
    } else if (C.at(6)*C.at(7)*C.at(8) == 1){
        flag = 1;
    } else if (C.at(0)*C.at(3)*C.at(6) == 1){
        flag = 1;
    } else if (C.at(1)*C.at(4)*C.at(7) == 1){
        flag = 1;
    } else if (C.at(2)*C.at(5)*C.at(8) == 1){
        flag = 1;
    } else if (C.at(0)*C.at(4)*C.at(8) == 1){
        flag = 1; 
    } else if (C.at(2)*C.at(4)*C.at(6) == 1){
        flag = 1;
    } else {
        flag = 0;
    }

    if (flag == 1){
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=600000;
int f[N][30],g[N][21],das;
char s[N];
int q;
#define idx(x) x-'a'+1
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	f[n][idx(s[n])]=n+1;;
	for (int i=n-1;i>=1;i--){
		f[i][idx(s[i])]=i+1;
		for (int j=idx(s[i])+1;j<=27;j++) f[i][j]=f[f[i][j-1]][j-1];
		for (int j=1;j<idx(s[i]);j++) f[i][j]=f[f[i][27]][j];
	}
	
	for (int i=1;i<=n;i++) g[i][0]=f[i][27];
	for (int k=1;(1<<k)<=n;k++)
		for (int i=1;i<=n;i++)
			g[i][k]=g[g[i][k-1]][k-1];
	
	scanf("%d",&q);
	while (q--){
		das++;
		int x,y;
		scanf("%d%d",&x,&y);
		int lg=20;
		while (lg>=0&&(!g[x][lg]||g[x][lg]>y+1)) lg--;
		if (lg<0) puts("No");
		else{
			while (lg>=0){
                        if (g[x][lg]&&g[x][lg]<=y+1){
				x=g[x][lg];}lg--;
			}
			if (x==y+1) puts("Yes");else puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 102912
/*input
2
ip cc
*/
/**
    Author: Kristopher Paul
    Date Created: 21-12-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

//Uncomment for File I/O
/*
#define cin fin
#define cout fout

ifstream fin("cowmbat.in");
ofstream fout("cowmbat.out");
*/

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string a = "";
    FOR(i,0,n){
        a += s[i];
        a += t[i];
    }
    cout << a << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,res=0;
    cin>>n;
    vector<int> a(n);
    for(auto &i: a)
    {
    	cin>>i;--i;
    }
    vector<int> b(n);
    for(auto &i: b)
    	cin>>i;
    vector<int> c(n-1);
    for(auto &i: c)
    	cin>>i;
    for(int i=0;i<n;++i)
    {
    	res+=b[a[i]];
    	if(i>0&&a[i]-a[i-1]==1)
    		res+=c[a[i-1]];
    }
    cout<<res<<endl;
}

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

typedef long long ll;

ll bin_pow(ll a, ll n)
{
    ll res = 1;
    for (; n; n >>= 1, a *= a)
        if (n & 1) res *= a;
    return res;
}

int main()
{

#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif


    ll n, p;
    scanf("%lld%lld", &n, &p);

    if (n > 40)
    {
        printf("1");
        return 0;
    }
    if (n == 1)
    {
        printf("%lld", p);
        return 0;
    }

    ll ans = 1;
    for (ll x = 2; x * x <= p; ++x)
    {
        int deg = 0;
        while(p % x == 0)
        {
            p /= x;
            ++deg;
        }
        ans *= bin_pow(x, deg / n);
    }

    printf("%lld", ans);
}


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

int main(){
	
	int n; cin>>n; int arr[n];
	for(int i = 0 ; i < n; i++){
		cin>>arr[i];
	} 
	ll best = 10000000000;
	for(int i = 0; i <= 100; i++){
		ll sum = 0;
		for(int j = 0; j  < n; j++){
			sum += (arr[j]-i) * (arr[j]-i);
		}
		best = min(best,sum);
	}
	cout<<best<<"\n";
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll dp[3010][3010][2];
int used[3010][3010][2];
ll A[MAX_N];

ll loop(int a, int b, int c) {
	if(used[a][b][c]) return dp[a][b][c];
	if(a > b) return 0;
	used[a][b][c] = 1;
	ll res; 
	if(c == 0) {
		res = -linf;
		MAX(res, loop(a + 1, b, 1 - c) + A[a]);
		MAX(res, loop(a, b - 1, 1 - c) + A[b]);
	}
	else {
		res = linf;
		MIN(res, loop(a + 1, b, 1 - c) - A[a]);
		MIN(res, loop(a, b - 1, 1 - c) - A[b]);
	}
	return dp[a][b][c] = res;
}

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	cout << loop(0, N - 1, 0) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 211584
S = input()
n = len(S)
ans = 0
list = ['A', 'G', 'C', 'T']
for i in range(n):
    j = i
    while j < n:
        if S[j] in list:
            j += 1
        else:
            if ans < j - i :
                ans = j - i
            break
    if j == n:
        if ans < j - i :
                ans = j - i
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/python3

import numpy as np
import itertools

def main():
    X, Y, Z, K = map(int, input().split())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    C = np.array(list(map(int, input().split())))

    a_add_b = np.array(list(A + j for j in B))
    a_add_b = np.sort(a_add_b, axis=None)

    e_add_c = np.array(list(C + j for j in a_add_b[:-K-1:-1]))
    e_add_c = np.sort(e_add_c, axis=None)


    for abc in e_add_c[:-K-1:-1]:
        print(abc)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll a[500];
ll dp[500][500];
ll sum[500];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    memset(dp,0x3f, sizeof(dp));
    for(int i=1;i<=n;i++){
        dp[i][i]=0;
        sum[i]=sum[i-1]+a[i];
    }
    for(int len=2;len<=n;len++)
        for(int l=1;l+len-1<=n;l++){
            int r=len+l-1;
            for(int k=l;k<r;k++)
                dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]);
            dp[l][r]+=sum[r]-sum[l-1];
        }
    cout<<dp[1][n]<<endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) cin >> grid.at(i);
  vector<vector<int>> cnt(h, vector<int>(w, 1));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid.at(i).at(j) == '#') continue;
      int from = j;
      while (j < w && grid.at(i).at(j) == '.') j++;
      j--;
      for (int k = from; k <= j; k++) cnt.at(i).at(k) += j - from;
    }
  }
  for (int j = 0; j < w; j++) {
    for (int i = 0; i < h; i++) {
      if (grid.at(i).at(j) == '#') continue;
      int from = i;
      while (i < h && grid.at(i).at(j) == '.') i++;
      i--;
      for (int k = from; k <= i; k++) cnt.at(k).at(j) += i - from;
    }
  }
  int maxcnt = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      maxcnt = max(maxcnt, cnt.at(i).at(j));
  cout << maxcnt << endl;
}

Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

P rotate (P p) {
    P res;
    res.first = -p.second;
    res.second = p.first;
    return res;
}


int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    P p = P(x2-x1, y2-y1);
    int x3, y3, x4, y4;
    p = rotate(p);
    x3 = x2 + p.first;
    y3 = y2 + p.second;
    p = rotate(p);
    x4 = x3 + p.first;
    y4 = y3 + p.second;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,y,ans=0;
	cin>>x>>y;
	if(x==1)
	{
		ans+=300000;
	}
	else if(x==2)
	{
		ans+=200000;
	}
	else if(x==3)
	{
		ans+=100000;
	}
	if(y==1)
	{
		ans+=300000;
	}
	else if(y==2)
	{
		ans+=200000;
	}
	else if(y==3)
	{
		ans+=100000;
	}
	if(x==1&&y==1)
	{
		ans+=400000;
	}
	cout<<ans<<endl;
	return 0;
}

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

long long gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}
long long addgcd(int a, int b, int c)
{
    long long result = gcd(a, b);
    result = gcd(result, c);
    return result;
}
int main()
{
    int s, w;
    cin >> s >> w;
    if(s<=w)
        cout << "unsafe";
    else
    {
        cout << "safe";
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;


int main() {
	int n;
	cin >> n;
	if (n <= 999) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(_Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,_Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif


ll solve(vector<int> &v){
    sort(ALL(v));
    ll t = 0, s = 0;
    FOREACH(it,v){
        t += s;
        s += *it;
    }
    return t;
}

int main(){
    int n;
    vector<int> v;
    while(cin >> n && n){
        v.resize(n);
        REP(i,n) cin >> v[i];
        cout << solve(v) << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
import sys
from collections import Counter

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    V = LIST()
    a, b = [Counter(V[i::2]).most_common() + [(0, 0)] for i in (0, 1)]
    i, x = a[0]
    j, y = b[0]
    print(N - [x + y, max(x + b[1][1], y + a[1][1])][i == j])


if __name__ == '__main__':
    main()

Measured memory_bytes: 65388
//by sdfzchy
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int inf=(1<<30),N=100010,mod=1e9+7;
int n,m;
inline int in()
{
	char tmp=getchar();
	int res=0,f=1;
	while((tmp<'0'||tmp>'9')&&tmp!='-')tmp=getchar();
	if(tmp=='-') f=-1,tmp=getchar();
	while(tmp>='0'&&tmp<='9')	res=(res<<1)+(res<<3)+(tmp^48),tmp=getchar();
	return res*f;
}
char s[N];
int cnt[4],mn=inf,mx=-inf;
int main()
{
//	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++) cnt[s[i]-'a']++;
	for(int i=0;i<3;i++) mn=min(mn,cnt[i]),mx=max(mx,cnt[i]);
	if(mx-mn<=1) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int N ,D;
  cin >> D >> N;

  if(N == 100){
    cout << (N+1)*(int)pow(100,D) << endl;
  }else{
    cout << N*(int)pow(100,D) << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b) gcd(b, a);
	long long  r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
inline long long mod(long long a, long long m) {
	return (a % m + m) % m;
}

// 拡張 Euclid の互除法
// ap + bq = gcd(a, b) となる (p, q) を求め、d = gcd(a, b) をリターンします
long long extGcd(long long a, long long b, long long &p, long long &q) {
	if (b == 0) { p = 1; q = 0; return a; }
	long long d = extGcd(b, a%b, q, p);
	q -= a / b * p;
	return d;
}

// 中国剰余定理
// リターン値を (r, m) とすると解は x ≡ r (mod. m)
// 解なしの場合は (0, -1) をリターン
//amari,mod,amari,mod
pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) {
	long long p, q;
	long long d = extGcd(m1, m2, p, q); // p is inv of m1/d (mod. m2/d)
	if ((b2 - b1) % d != 0) return make_pair(0, -1);
	long long m = m1 * (m2 / d); // lcm of (m1, m2)
	long long tmp = (b2 - b1) / d * p % (m2 / d);
	long long r = mod(b1 + m1 * tmp, m);
	return make_pair(r, m);
}
typedef pair<long long,long long>p;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int tmp;
	p a[100004];
	long long ans[100005] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		a[i] = p(tmp, i);
	}
	sort(a, a + n);
	long long num = a[n-1].first;
	long long now = a[n - 1].second;
	long long  cnt = 1;
	for (int i = n - 2; i >= 0; i--) {
		if (a[i].second < now) {
			long long should = a[i].first*cnt;
			ans[now] += num - should;
			cnt += 1;
			now = a[i].second;
			num = a[i].first*cnt;
		}
		else {
			cnt += 1;
			num += a[i].first;
		}
	}
	ans[now] += num;
	for (int i = 0; i < n; i++) {
		cout << ans[i] << "\n";
	}
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(ll i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 1000000007;

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

int main()
{
  ll f[300000];
  ll invf[300000];
  f[0] = invf[0] = 1;
  REP(i,200000) {
    f[i+1] = f[i] * (i+1);
    f[i+1] %= MOD;
    invf[i+1] = inv(f[i+1], MOD);
  }
  ll n,m,k;
  cin>>n>>m>>k;
  ll nm = n*m;
  ll coeff = f[nm-2] * invf[k-2] % MOD * invf[nm - k] % MOD;
  ll res = 0;
  REP(r,n) {
    REP(c,m) {
      ll rc = m-c-1;
      ll cc = c*(c+1)/2 + rc*(rc+1)/2;
      cc %= MOD;
      cc *= n;
      cc %= MOD;
      ll rr = n-r-1;
      ll cr = r*(r+1)/2 + rr*(rr+1)/2;
      cr %= MOD;
      cr *= m;
      cr %= MOD;
      ll tmp = cc + cr;
      tmp %= MOD;
      res += tmp;
      res %= MOD;
    }
  }
  res *= coeff;
  res %= MOD;
  res *= inv(2, MOD);
  res %= MOD;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4096
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e6 + 5;
char s[N];
int tmp[N], suf[N];
LL suff[N];
vector<int> vc;
int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", s+1);
    for (int i = n; i >= 1; i--) {
        if(s[i] == 'M') suf[i] = suf[i+1] + 1;
        else suf[i] = suf[i+1];
        if(s[i] == 'D') tmp[i] = suf[i], vc.pb(i);
    }

    for (int i = n; i >= 1; i--) suff[i] = suff[i+1] + tmp[i];
    int q, k;
    scanf("%d", &q);
    sort(vc.begin(), vc.end());
    while(q--) {
        scanf("%d", &k);
        LL ans = 0;
        for (int i = 1; i <= n; i++) {
            if(s[i] == 'C') {
                int pos = i-k+1;
                int t = lower_bound(vc.begin(), vc.end(), pos) - vc.begin();
                if(t != vc.size()) {
                    int tt = lower_bound(vc.begin(), vc.end(), i) - vc.begin();
//                    cout << pos << " " << i << " " << t << " " << tt << endl;
                    ans += suff[vc[t]] - suff[i] - 1LL*suf[i]*(tt-t);
//                    cout << ans << endl;
                }
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 20844
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]

point_list=[k-q]*n
for i in range(q):
    point_list[a[i]-1]+=1

for i in range(n):
    if point_list[i]>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10452
program main
  implicit none
  integer i,N,K
  integer,allocatable :: A(:)
  read(*, *)N, K
  allocate(A(N))
  read(*, *) (A(i), i = 1,N)

  do i = 1,N-K
    if (A(i) < A(K+i)) then
      write(*, *) 'Yes'
    else
      write(*, *) 'No'
    end if
  end do
end program main

Measured memory_bytes: 3924
#include<iostream>
#include<cmath>
using namespace std;
#define eps 0.0000000001

bool eq(double a,double b){
  return ( -eps < a-b && a-b < eps );
}

int N;
int t[256];

double calc(int S,int A,int C){
  int cnt[256]={};
  int x=S;
  for(int i=0;i<N;i++){
    x=(A*x+C)%256;
    cnt[(t[i]+x)%256]++;
  }
  double res=0;
  for(int i=0;i<256;i++){
    double d=(double)cnt[i]/(double)N;
    if(eq(d,0))continue;
    res-= d*log(d);
  }
  return res;
}

int main(){

  while(1){
    cin>>N;
    if(N==0)break;
    for(int i=0;i<N;i++)cin>>t[i];
    int s,a,c;
    double ans=(1e10);
    for(int S=0;S<=15;S++){
      for(int A=0;A<=15;A++){
	for(int C=0;C<=15;C++){
	  double d=calc(S,A,C);
	  
	  if(d<ans-eps){
	    ans=d;
	    s=S;a=A;c=C;
	  }
	}
      }
    }

    cout<<s<<' '<<a<<' '<<c<<endl;
  }
  return 0;
}

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

using namespace std;

#include <vector>
#include <list>
#include <cstring>
#include <cmath>
#define scan(x) scanf("%d", &x)
#define scanl(x) scanf("%lld", &x)

void printarray(int* arr, int n){
	for(int i=0;i<n;i++){
		printf("%d ", arr[i]);
	}
	printf("\n");
}

void printvector(vector <int> A){
	for(auto i=A.begin();i!=A.end();i++){
		cout<<*i<<" ";
	}
	cout<<endl;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("D:/Programming/input.txt", "r", stdin);
    	freopen("D:/Programming/output.txt", "w", stdout);
	#endif

	int t;scan(t);
	t=t%10;
	if(t==2 || t==4 || t==5 || t==7 || t==9)cout<<"hon"<<endl;
	else if(t==0 || t==1 || t==6 || t==8)cout<<"pon"<<endl;
	else cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3720
///----------------------------------
/// 自分自身を信じてみるだけでいい。
/// きっと生きる道が見えてくる。
///
/// - ゲーテ -
///----------------------------------
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
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; }
static const lint MOD = (lint)1e9+7;

int main()
{
    int N;
    cin >> N;
    vector<double> A(N);
    rep (i, N) { cin >> A[i]; }

    double subsum = 0.0;
    rep (i, N)
    {
        double child = 1.0 / A[i];
        subsum += child;
    }

    cout << fixed << 1.0 / subsum << endl;
    

    return 0;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin>>N && N){
    ll sum = 0;
    REP(i, N){
      int t; cin>>t;
      sum += t;
    }
    vector<int> p(N - 1);
    REP(i, N - 1) cin>>p[i];
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    ll ans = sum * N;
    REP(i, N - 1){
      ll diff = - sum + p[i] * (N - 1 - i);
      if(diff > 0){
        ans += diff;
        sum += p[i];
      }else{
        break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

const int mod = 1e9+7;
const int INF = 1000000000;

int main() {
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int inf = max(x,y);
    ll ans = INF;
    for(int i=0;i<=inf;++i) {
        ll tmp = 2*i*c+max(0, (x-i)*a)+max(0, (y-i)*b);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        int max = 0, len = 0;;
        for(int i = 0; i < str.length(); i++){
            if(isATCG(str.charAt(i))){
                len++;
            } else {
                len = 0;
            }
            
            if(len > max){
                max = len;
            }
        }

        System.out.print(max);
    }

    public static boolean isATCG(char c){
        String str = "ATCG";
        for(int i = 0; i < str.length(); i++){
            if(str.charAt(i) == c){
                return true;
            }
        }

        return false;
    }
}

Measured memory_bytes: 21460
import sys
input = sys.stdin.readline
X, Y, Z= (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]

X, Y = Y, X
X, Z = Z, X

print(X, Y, Z)


Measured memory_bytes: 38384
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;



int main(){
	int l[10];
	int v[2];
	double m;
	double pos;
	int ans;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1])!=EOF){
		m=0;
		for(int i=0;i<10;i++){
			m+=l[i];
		}
		pos=(m*v[0])/double(v[0]+v[1]);
		for(int i=0;i<10;i++){
			pos-=l[i];
			if(!(pos>0)){
				ans=i+1;
				break;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
template <typename Monoid> struct SegTree
{
    typedef function<Monoid(Monoid, Monoid)> F;
    std::vector<Monoid> data;  // 0-indexed 配列に完全二分木
    const Monoid e;            // 単位元
    const F f;
    int N = 1;

    SegTree(int size, const F f, const Monoid &e) : f(f), e(e)
    {
        while (N < size) N <<= 1;
        data.resize(2 * N - 1, e);  // 要素数 n => ノード数 2*n - 1
    }

    void update(int i, Monoid x)
    {
        i += N - 1;  // 要素 i の木中ノード番号
        data[i] = x;
        while (i > 0)
        {
            i       = (i - 1) / 2;  // 親ノード番号
            data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    Monoid query(int q_l, int q_r)
    {  // [q_l, q_r) に対するクエリの処理
        return _query(q_l, q_r, 0, 0, N);
    }

   private:
    Monoid _query(int q_l, int q_r, int k, int k_l, int k_r)
    {  // ノード k : 区間は [k_l, k_r) について
        if (k_r <= q_l || q_r <= k_l)
            return e;  // 交差しない
        if (q_l <= k_l && k_r <= q_r)
            return data[k];  // 完全に含む→受け止める
        else
        {
            Monoid vl = _query(q_l, q_r, k * 2 + 1, k_l, (k_l + k_r) / 2);
            Monoid vr = _query(q_l, q_r, k * 2 + 2, (k_l + k_r) / 2, k_r);
            return f(vl, vr);
        }
    }
};

int main()
{
    int N, Q;
    scanf("%d %d", &N, &Q);
    SegTree<long long> seg(
        N, [](long long a, long long b) { return min(a, b); }, (1LL << 31) - 1);
    while (Q--)
    {
        int T, X, Y;
        scanf("%d %d %d", &T, &X, &Y);
        if (T == 0)
            seg.update(X, Y);
        else
            printf("%d\n", seg.query(X, Y + 1));
    }
}


Measured memory_bytes: 4956
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
	


int main() {
	int a, b;
	cin >> a >> b;
	int w,x, y, z;
	int sum = 0;
	for (int i = a; i <= b; i++) {
		w = i % 10;  x = i / 10000 % 10;
		y = i / 1000 % 10;  z = i / 10 % 10;
		if (w == x && y == z) {
			sum += 1;
		}
	}
	cout << sum;
	return 0;
}










Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,m;
int main()
{
	scanf("%d",&n);
	printf("%d\n",(1000-n%1000)%1000);
}

Measured memory_bytes: 3820
n, m = map(int, input().split())
load = [[0]*n for i in range(n)]

for i in range(m):
  ori, dst = map(int, input().split())
  load[ori-1][dst-1] += 1
  load[dst-1][ori-1] += 1

for j in range(n):
  print(sum(load[j]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int gcd(int n,int m){
  if(n%m==0)return m;
  else return gcd(m,n%m);
}
int main() {
  int n,m;
  cin>>n>>m;
  int kotae=gcd(n,m);
  cout<<kotae<<endl;
  return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

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

    int ans = 0;
    int min = p[0];
    auto cnt = [&](int i){
        if(p[i] <= min){
            ans++;
            min = p[i];
        }
    };

    for(int i = 0;i<n;i++){
        cnt(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3988
#include<iostream>

int cnt[2][4];
const double b[] = { 1.1, 0.6, 0.2 };

int main()
{
	double e[2];
	while( std::cin >> e[0] >> e[1] )
	{
		for( int i = 0; i != 2; ++i )
		{
			int cls;
			for( cls = 0; cls != 4; ++cls )
			{
				if( !cls && e[i] >= b[0] )
					break;
				else if( cls == 3 && e[i] < b[2] )
					break;
				else if( e[i] >= b[cls] && e[i] < b[cls-1] )
					break;
			}

			++cnt[i][cls];
		}
	}

	for( int i = 0; i != 4; ++i )
	{
		for( int j = 0; j != 2; ++j )
			std::cout << cnt[j][i] << ( j ? "" : " " );

		std::cout << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1224
from collections import *;M=lambda:map(int,input().split());r=range;n,k,l=M()
def f(m):
  a=list(r(n))
  def g(i):
    if a[i]==i:return i
    a[i]=g(a[i]);return a[i]
  for _ in r(m):p,q=M();a[g(q-1)]=g(p-1)
  return g
x,y=f(k),f(l);c=Counter((x(i),y(i))for i in r(n));print(*(c[x(i),y(i)]for i in r(n)))

Measured memory_bytes: 55616
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
using namespace std;
const int64_t mod=1e9+7;
int64_t dp[101][101][256]={};

int main(){
    int N,K;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(i>0){
            for(int j=1;j<i+1;j++){
                for(int k=0;k<256;k++){
                    dp[i][j+1][k^a]=(dp[i][j+1][k^a]+dp[i-1][j][k])%mod;
                    dp[i][j][k]=(dp[i][j][k]+dp[i-1][j][k])%mod;
                }
            }
        }
        dp[i][1][a]=1;
    }
    
    int64_t factorial[111];
    factorial[0]=1;
    for(int i=1;i<111;i++){
        factorial[i]=factorial[i-1]*i%mod;
    }
    int64_t res=0;
    for(int i=1;i<=N;i++){
        res = (dp[N-1][i][K]*factorial[i]%mod+res)%mod;
    }
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string str;
    cin >> str;
    int ans = 0;
    bool move;
    int start = 0;
    do{
        move = false;
        for(int i = start; i + 2 <= str.size(); i++){
            if(str[i] != str[i + 1]){
                if(!move){
                    move = true;
                    start = max(0, start - 1);
                }
                ans += 2;
                str = str.substr(0, i) + str.substr(i + 2);
                break;
            }
        }
    }while(move);
    cout << ans << "\n";
}

Measured memory_bytes: 724
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>>ab;
	for (int i = 0; i < N; i++)
	{
		int A, B;
		cin >> A >> B;
		ab.emplace_back(B, A);
	}
	sort(ab.begin(), ab.end());
	int sum = 0;
	bool task_time = true;

	for (auto p : ab) {
		sum += p.second;
		if (sum > p.first) {
			task_time = false;
			break;
		}
	}

	cout << (task_time ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 2420
#!/usr/bin/env python3
import sys


def solve(x: int):
    a, b = divmod(x, 11)
    if b == 0:
        return a * 2
    if b <= 6:
        return a * 2 + 1
    return a * 2 + 2


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    print(solve(x))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    if(a*a+b*b==c*c||b*b+c*c==a*a||a*a+c*c==b*b){
      if(a+b>c&&a+c>b&&b+c>a){
        cout<<"YES"<<endl;
      }
      else{cout<<"NO"<<endl;
      }
    }
    else{cout<<"NO"<<endl;
    }
    }
    return 0;
}  


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long M = 1e9+7;
long long power(long long a, long long p)
    {
        if(p==0) return 1;
        long long ans= power(a,p/2);
        ans =(ans * ans) % M;
        if(p%2) ans = (ans*a) % M;
        return ans;
    }

    bool isPrime(long long n)
    {
        if (n <= 1)
            return false;
        for (long long i = 2; i < n; i++)
            if (n % i == 0)
                return false;
        return true;
    }
    long long SieveOfEratosthenes(long long n, long long a)
    {
        bool prime[n+1];
        memset(prime, true, sizeof(prime));
        for (long long p=2; p*p<=n; p++)
        {
            if (prime[p] == true)
            {
                for (long long i=p*p; i<=n; i += p)
                    prime[i] = false;
            }
        }
        for (long long p=2; p<=n; p++)
           if (prime[p])
           {
               if(a%p==0)
               {
                   return (a-p);
               }
           }
    }
    long long nCr(int n, int r)
    {
        if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
        long long ans = 1;
        int i;
        for(i = 1; i <= r; i++) {
            ans *= n - r + i;
            ans /= i;
        }
        return ans;
    }
int main()
{
    IOS;
    long long a,b,c,d,e,h,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
    // vector<string>vs;
    // vector<string>vs1;
    vector<char>vc;
    //map<long long,long long>mp;
    map<char,int>mp1;
    //set<long long>s;
    set<long long>s1;
    queue<long long> q;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
    // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    int x[]={1,1,1,0,0,-1,-1,-1};
    int y[]={0,1,-1,1,-1,1,-1,0};
    cin>>a>>b;
    for(int i=0; i<a; i++)
    {
        cin>>c;
        if(c<mi)
        {
            mi=c;
            d=i+1;
        }
    }
    a--;
    b--;
    if(a%b==0) cout<<a/b<<endl;
    else cout<<(a/b)+1<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int a[N],v[N],f[N];

int main(){
	ios::sync_with_stdio(false);
	int n,k,m,c=0,pe=0;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
    	int p;
    	char s[3];
    	cin>>p>>s;
    	if(v[p])continue;
    	if(s[0]=='W')++f[p];
    	else c++,pe+=f[p],v[p]=1;
	}
	cout<<c<<' '<<pe;
		
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N,M; cin>>N>>M;
  Graph G(N+1);
  rep(i,M){
    int a,b; cin>>a>>b;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  rep1(i,N+1){
    cout<<G.at(i).size()<<endl;
  }
}



Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int>pii;
int dp[11][111111];
vector<int>pat[111111];
int col[111111];
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < way; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		pat[za].push_back(zb);
		pat[zb].push_back(za);
	}
	int query;
	scanf("%d", &query);
	for (int i = 0; i < query; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za--;
		dp[10 - zb][za] = max(dp[10 - zb][za], i + 1);
		col[i + 1] = zc;
	}
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < num; j++)
		{
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			for (int k = 0; k < pat[j].size(); k++)
			{
				dp[i + 1][pat[j][k]] = max(dp[i + 1][pat[j][k]], dp[i][j]);
			}
		}
	}
	for (int i = 0; i < num; i++)printf("%d\n", col[dp[10][i]]);
}

Measured memory_bytes: 11768
#include<bits/stdc++.h>
using namespace std;
main()
{
    int t,i,j,o;
    cin>>t;
    int a[t],k[t+1]={0};
    for(i=1;i<t;i++){
        cin>>a[i];
        k[a[i]]++;}
    for(i=1;i<=t;i++)
        cout<<k[i]<<endl;
    return 0;
}


Measured memory_bytes: 5144
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string a = "abcdefghijklmnopqrstuvwxyz";
    string ans = "";
    long long n;
    cin >> n;
    while(n > 0){
        --n;
        ans += a[n % 26];
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}


Measured memory_bytes: 3632
A,B,C,X,Y = map(int,input().split())

result = []

if X > Y:
    result.append(A * X + B * Y + C * 0)
    result.append(A * (X - Y) + B * 0 + C * 2 * min(X,Y))
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))
elif X < Y:
    result.append(A * X + B * Y + C * 0)
    result.append(A * 0 + B * ( Y - X ) + C * 2 * min(X,Y))
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))
else:
    result.append(A * X + B * Y + C * 0)
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))

print(min(result))
    

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
              int n;
                cin>>n;
         string s,t;
           cin>>s;
           t="ABC";
           int j=0,c=0;
           for(int i=0;i<n-2; i++){
                     if(s[i]==t[0]&&s[i+1]==t[1]&&s[i+2]==t[2])
                        { c++; i+=2;}
				
		        
		   }
		   cout<<c<<endl;
           
    
    }



Measured memory_bytes: 256
"use strict";

function d(a, b, x, y) {
  if (a < x) {
    if (b > y) {
      return b - a - (y - x) + 1;
    }

    return Math.min(b - a, x - a + y - b + 1);
  }

  if (b > y) {
    return Math.min(b - a, b - y + a - x + 1);
  }

  return Math.min(b - a, y - b + a - x + 1);
} // inputに入力データ全体が入る


function Main(input) {
  var a = input.split(' ').map(function (aa) {
    return parseInt(aa);
  });
  var n = a[0];
  var x = a[1];
  var y = a[2];
  var ans = Array.from({
    length: n - 1
  }, function (v, i) {
    return 0;
  });

  for (var j = 1; j < n; j++) {
    for (var k = j + 1; k <= n; k++) {
      ans[d(j, k, x, y) - 1]++;
    }
  }

  for (var _i = 0, _ans = ans; _i < _ans.length; _i++) {
    var _a = _ans[_i];
    console.log(_a);
  }
} //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9664
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a,b,c;
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21844
import itertools
import math
n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
sum = 0
max = 0
for i in range(q):
	a[i],b[i],c[i],d[i] = map(int,input().split())
l = [0]*m
for i in range(m):
	l[i] = i+1

for v in itertools.combinations_with_replacement(l,n):
	for i in range(q):
		if v[b[i]-1] - v[a[i]-1] == c[i]:
			sum += d[i]
	if max < sum:
		max = sum
	sum = 0
print(max)

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    i32 a;
    cin >> a;
    auto b = a * 2 * acos(-1);
    cout << b << "\n";
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <algorithm>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
using namespace std;

const int MOD=1e9+7;
const int N=2e5+7;
int a[N],dp[N];


int32_t main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	for (int i = 1; i <= n ; ++i)
	{
		cin>>a[i];
	}

	for (int i = 2; i <= n ; ++i)
	{
		dp[i]=MOD;

		for (int j = max(1LL,i-k); j < i; j++)
		{
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int n,k,i,h[100001],cnt=0;
  scanf("%d%d",&n,&k);
  for(i=1;i<=n;i++){
    scanf("%d",&h[i]);
    if(h[i]>=k)cnt++;
  }
  printf("%d",cnt);
  return 0;
}



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

using namespace std;

int main()
{
    vector<int> A;
    vector<char> OP;
    vector<int> B;

    for(;;){
        int a, b;
        char op;
        cin >> a;
        cin >> op;
        cin >> b;
        if(op == '?') break;
        A.push_back(a);
        OP.push_back(op);
        B.push_back(b);
    }

    for(int i = 0; i < A.size(); i++){
        int a = A.at(i), b = B.at(i);
        switch(OP.at(i)){
            case '+': cout << a + b << endl; break;
            case '-': cout << a - b << endl; break;
            case '*': cout << a * b << endl; break;
            case '/': cout << a / b << endl; break;
        }
    }

}


Measured memory_bytes: 3136
#!/usr/bin/env python3

def solve(a, b):
    if 1 <= a <= 9 and 1 <= b <= 9:
        return a * b
    else:
        return -1


def main():
    a, b = (int(z) for z in input().split())
    res = solve(a, b)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940