akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
char S[105], T[105];

int main(void) {
    scanf("%s", S);
    scanf("%s", T);

    int n = strlen(S);

    REP(i, 0, n) {
    	if (S[0] == T[i]) {
    		int c = 0;
    		REP(j, 0, n) {
    			if (S[j] == T[(i+j) % n]) c++;
    		}
    		if (c == n) {
    			Yes;
    			return 0;
    		}
    	}
    }
    
    No;

	return 0;
}


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

vector<int> RS;

ll modpow(ll b, ll a) {//繰り返し二乗法
	ll ans = 1;
	while (a) {
		if (a & 1) {
			ans *= b;
			ans %= 1000000007;
		}
		b *= b;
		b %= 1000000007;
		a /= 2;
	}
	return ans;
}

ll modwari(ll x, ll y) {
	return (x*modpow(y, 1000000005)) % 1000000007;
}

ll modkumi(ll x, ll y) {
	ll ans = 1;
	for (int i = 1;i <= y;i++) {
		ans *= modwari(x - y + i, i);
		ans %= 1000000007;
	}
	return ans;
}

void fctr(int a) {
	int b = (int)sqrt(a);
	int cnt;
	for (int i = 2;i <= b + 1;i++) { // 誤差対策のb+1
		cnt = 0;
		while (a%i == 0) {
			cnt++;
			a /= i;
		}
		if (cnt)
			RS.push_back(cnt);
	}
	if (a != 1) {
		RS.push_back(1);
	}
}

ll solve(ll x) {
	ll b, ans = 1;
	for (int i = 0;i < RS.size();i++) {
		b = RS[i];
		ans *= modkumi(b + x - 1, b);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int N, M; cin >> N >> M;
	fctr(M);
	ll ans = solve(N);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
//const ll P=1000000007;
const long long P=998244353;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
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;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
  ll n,s;
  cin>>n>>s;
  cout<<n*s<<endl;
          
}


Measured memory_bytes: 3872
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,c=0,c1=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%4==0)
            c++;
        if(a[i]%4!=0&&a[i]%2==0)
            c1++;
    }
    if((n/2)<=(c+c1/2))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define fill(c,val) memset(c,val,sizeof(c))
#define sz(x)       (int)x.size()
#define LB lower_bound
#define UB upper_bound
#define bsa(v,n,a) binary_search(v,v+n,a)
#define bsv(v,a) binary_search(v.begin(),v.end(),a)
using namespace std;
typedef long long ll;
const ll INF=(1LL<<60)-1;
ll const nax=1e5+20;
int main(){
	int t=1;
//	cin>>t;
	while(t--){
	  int n,m; cin >> n >> m;
	  string s[n];
	  rep(i,0,n) cin >> s[i];
	  
	  rep(i,0,n+2){
	  	rep(j,0,m+2){
	  		if(j >=1 && j<=m && i>=1 && i<=n){
	  			cout << s[i-1][j-1];
			  }
			  else{
			  	cout<<"#";
			  }
		  }
		 cout<<endl; 
	  }
	  cout<<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;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

//clang++ -std=c++11 -stdlib=libc++ 
int main() {
  int N; cin >> N;
  vi P(N);
  rep(i,N) cin>>P[i];
  int localMin = P[0];
  int ans = 0;
  rep (i, N) {
    if (P[i] <= localMin) ans++;
    localMin = min(localMin, P[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

#define NONE -1

int main( void )
{
	int n;
	while ( cin >> n && n > 0 )
	{
		vector <int> pages;
		for ( int i = 0; i < n; i++ )
		{
			int page;
			cin >> page;
			pages.push_back( page );
		}

		vector < pair<int,int> > cuts;
		pair<int,int> now;
		now = make_pair( NONE, NONE );
		for ( int i = 0; i < pages.size(); i++ )
		{
			if ( i+1 < pages.size() && pages[i+1] - pages[i] == 1 )
			{
				if ( now.first == NONE )
					now.first = pages[i];
				now.second = pages[i+1];
			}
			else
			{
				if ( now.first == NONE )
				{
					now.first = now.second = pages[i];
				}
				cuts.push_back( now );
				now = make_pair( NONE, NONE );
			}
		}

		if ( now.first != NONE )
		{
			now.second = now.first;
			cuts.push_back( now );
		}

		for ( vector < pair<int,int> >::iterator it = cuts.begin(); it != cuts.end(); it++ )
		{
			pair <int,int>& p = *it;
			if ( p.first == p.second )
			{
				cout << p.first;
			}
			else
			{
				cout << p.first << "-" << p.second;
			}

			if ( it + 1 != cuts.end() )
				cout << " ";
		}
		cout << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int a[100];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i > 0; i--) {
    cout << a[i] << " ";
  }
  cout << a[0] << endl;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
  //  freopen("same_partity_summands.txt", "r", stdin);
  
    int a, b;
    cin >> a >> b;
    string res1 = "";
    for (int i = 0; i < a; i ++)
        res1 += to_string(b);
    
    string res2 = "";
    for (int j = 0; j < b; j ++)
        res2 += to_string(a);

    cout << ((res1>res2) ? res2 : res1);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

int main(){
    int k;cin>>k;
    ll sum=0;
    for(int i =1;i<=k;i++){
        for(int j =1;j<=k;j++){
            for(int l =1;l<=k;l++){
                int x=gcd(i,j);
                int y=gcd(x,l);
                sum+=y;
            }
        }
    }
    cout << sum << endl;

}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin>>s;
    ll n=s.size();
    ll sum=0;
    for (int i = 0; i < n; ++i) {
        sum+=(s[i]-'0');
        sum%=9;
    }
    if(sum%9==0)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3752
#include <stdio.h>
#define Q_LEN 1000000
int queue[Q_LEN];
int head, tail;
void enque(int i) {
  if((tail+1)%Q_LEN == head) return;  
  queue[tail] = i;
  tail++;
  tail %= Q_LEN;
}
int deque() {
  int res;
  if(head == tail) return -1;
  res = queue[head];
  head++;
  head %= Q_LEN;
  return res;
}
int main() {
  int n, q, tim[100000], ela = 0;
  char name[100000][11];
  int i;
  scanf("%d %d", &n, &q);
  for(i = 0; i < n; i++) {
    scanf("%s %d", name[i], tim+i);
    enque(i);
  }
  while(head != tail) {
    i = deque();
    if(tim[i] <= q) {
      ela += tim[i];
      printf("%s %d\n", name[i], ela);
    } else {
      ela += q;
      tim[i] -= q;
      enque(i);
    }
  }
  return 0;
}

Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i= shoki; i<n; i++)
#define _GLIBCXX_DEBUG
int n,t,a,x;
int main(){
    cin>>n>>t>>a;
    int res = 0;
    int cc = 1<<30;
    rep(1,i,n+1){
        cin>>x;
        int d = abs((t*1000-x*6)-a*1000);
        if(cc>d) cc=d, res=i;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	double a[40], b[40];
	int ca[4] = { 0 }, cb[4] = { 0 }, n;

	int i = 0;
	while (scanf("%lf %lf", &a[i], &b[i]) != EOF) {
		i++;
	}


	n = i;
	for (i = 0; i < n; i++) {
		if (a[i] >= 1.1)
			ca[0]++;
		else if (a[i] >= 0.6)
			ca[1]++;
		else if (a[i] >= 0.2)
			ca[2]++;
		else
			ca[3]++;
		if (b[i] >= 1.1)
			cb[0]++;
		else if (b[i] >= 0.6)
			cb[1]++;
		else if (b[i] >= 0.2)
			cb[2]++;
		else
			cb[3]++;
	}

	for (i = 0; i < 4; i++)
		printf("%d %d\n", ca[i], cb[i]);

	return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#define LengthOf(x)    (sizeof(x) / sizeof(x[0]))

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

	return gcd(b, a % b);
}

int main()
{
	INT sum = 0;
	INT K;
	cin >> K;

	for (int a = 1; a <= K; ++a) {
		for (int b = 1; b <= K; ++b) {
			for (int c = 1; c <= K; ++c) {
				int gcd_tmp = (a >= b) ? gcd(a, b) : gcd(b, a);				
				int ret = (gcd_tmp >= c) ? gcd(gcd_tmp, c) : gcd(c, gcd_tmp);
//				printf("%d_%d_%d: %d\n", a, b, c, ret);
				sum += ret;
			}
		}
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

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

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

	L[0] = A[0];
	R[N-1] = A[N-1];

	rep(i,N-1){
		L[i+1] = gcd(L[i],A[i+1]);
	}
	for (int i = N-1; i > 0; i--){
		R[i-1] = gcd(R[i],A[i-1]);
	}
	int ans = 0;
	rep(i,N){
		if(i == 0)ans = max(ans, R[1]);
		else if(i == N-1)ans = max(ans, L[N-2]);
		else ans = max(ans, gcd(L[i-1],R[i+1]));
	}
	cout<<ans<<endl;
}

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

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

void solve() {
	string s; cin >> s;
	char prev = s[0];
	int ans = 0;
	for (char c: s) {
		if (c != prev) ++ans;
		prev = c;
	}
	printf("%d", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());

        int maxLength = 0;
        int sum = 0;
        for (int i = 0; i < N; i++) {
            int l = Integer.parseInt(scanner.next());;
            if (maxLength < l) {
                maxLength = l;
            }
            sum += l;
        }
        scanner.close();

        boolean valid = maxLength < (sum - maxLength);

        System.out.println(valid ? "Yes" : "No");
    }
}


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

int main(){
    int S=0;
    string N,res="No";
    cin >> N;

    for(char i:N){
        int k=i-'0';
        S+=k;
    } 
    if (stoi(N)%S==0){
        res ="Yes";
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> w(n + 1, 0);
    vector<int> e(n + 1, 0);
    rep(i, n) {
        s[i] == 'W' ? w[i + 1]++ : e[i + 1]++;
        w[i + 1] += w[i];
        e[i + 1] += e[i];
    }
// ---------------------------
    /*rep(i, n + 1) {
        cout << w[i] << ' ';
    }
    cout << endl;
    rep(i, n + 1) {
        cout << e[i] << ' ';
    }
    cout << endl;*/
// 確認済
// ----------------------------
    int mi = 500000;
    int last_e = e[n];
    rep(i, n + 1) {
        mi = min(w[i] + last_e - e[i], mi);
    }
    cout << mi << endl;
}

Measured memory_bytes: 6148
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

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

	if (test == "Sunny") {
		printf("Cloudy");
	} else if (test == "Cloudy") {
		printf("Rainy");
	} else if (test == "Rainy") {
		printf("Sunny");
	}
	return 0;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  ll n,m;
  cin>>n>>m;
  ll a;
  multiset<ll> ans;
  rep(i,n){
    cin>>a;
    ans.insert(a);
  }
  rep(i,m){
    auto itr = ans.end();
    --itr;
    ll tmp = *itr;
    //cout<<tmp<<"w";
    tmp/=2;
    ans.erase(itr);
    ans.insert(tmp);
  }
  ll aa=0;
  for(auto itr = ans.begin();itr!=ans.end();++itr){
    //cout<<*itr<<"e";
    aa+=*itr;
  }
  cout<<aa<<endl;
  return 0;
}

Measured memory_bytes: 4992
from collections import defaultdict

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

for x in a:
  d[x] += 1

new_d = sorted(d.items(), key=lambda x: x[1])
ans = 0
cnt = 0
for x in new_d:
  if(cnt < len(new_d) - k):
    ans += x[1]
    cnt += 1
  else:
    break
print(ans)

Measured memory_bytes: 44160
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

ll gcd(ll x, ll y)
{
    if (x < y) {
        swap(x, y);
    }

    if (y == 0) {
        return x;
    }

    return gcd(y, x % y);
}

ll gcds(const vector<ll>& v, int i, int e)
{
    if (i == v.size()-1) {
        return v[v.size()-1];
    }

    if (i == e) {
        return gcds(v, i+1, e);
    }

    return gcd(v[i], gcds(v, i+1, e));
}

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

    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    vector<ll> forward(N);
    forward[0] = A[0];
    for (int i = 1; i < N; ++i) {
        forward[i] = gcd(forward[i-1], A[i]);
    }

    vector<ll> backward(N);
    backward[N-1] = A[N-1];
    for (int i = N-2; i >= 0; --i) {
        backward[i] = gcd(backward[i+1], A[i]);
    }

    ll ans = 0;
    for (int i = 1; i < N-1; ++i) {
        ll g = gcd(forward[i-1], backward[i+1]);
        ans = max(ans, g);
    }

    ans = max(ans, backward[1]);
    ans = max(ans, forward[N-2]);

    cout << ans << endl;

    return 0;
}


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

#define SE second
#define FI first
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int) (x).size())

#define _ << " " <<
#define TR(x) cout << #x _ x << endl

using namespace std;
using ii = pair<int, int>;
using ll = long long;

const ll inf = 100000000000005LL;
const int maxn = 100005;

struct edge {
    int x, y, cost;
} e;

int n, q, k;

vector<ii> ed[maxn];

int main() {
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> e.x >> e.y >> e.cost;
        e.x--; e.y--;
        ed[e.x].PB(ii(e.y, e.cost));
        ed[e.y].PB(ii(e.x, e.cost));
    }

    cin >> q >> k;
    k--;

    vector<ll> dist(maxn, inf);
    priority_queue<ii, vector<ii>, greater<ii> > Q;

    dist[k] = 0;
    Q.push(ii(0, k));

    while (!Q.empty()) {
        ii t = Q.top(); Q.pop();
        for (int i = 0; i < SIZE(ed[t.SE]); i++) {
            ii to = ed[t.SE][i];
            if (dist[to.FI] > to.SE + dist[t.SE]) {
                dist[to.FI] = to.SE + dist[t.SE];
                Q.push(ii(dist[to.FI], to.FI));
            }
        } 
    }

    while (q--) {
        cin >> e.x >> e.y;
        e.x--; e.y--;
        cout << (dist[e.x] + dist[e.y]) << endl;
    }

    return 0;
}


Measured memory_bytes: 9332
float a,b,c,d,p=57.296;main(){for(;~scanf("%f%f%f%f",&a,&b,&c,&d);)a+1&&printf("%.f\n",6378.1*acos(sin(a/p)*sin(c/=p)+cos(a/p)*cos(c)*cos(b/p-d/p)));}

Measured memory_bytes: 0
N = int(input())
X = input()
Y = input()
Z = input()

ans = 0

for i in range(N):
  if  X[i] == Y[i] and Y[i] == Z[i]:
    ans += 0
  elif X[i] == Y[i] or Y[i] == Z[i] or Z[i] == X[i]:
    ans += 1
  else:
    ans += 2
print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> work(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        work.at(i) = make_pair(b, a);
    }    
    sort(work.begin(), work.end());

    int end = 0;
    for (int i = 0; i < n; i++) {
        end += work.at(i).second;
        if (end > work.at(i).first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque
# from collections import Counter

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 配列入力の受け取り
arrA = np.array(input().split(),dtype=np.int64)

ans = [0 for _ in range(n)]
for i,v in enumerate(arrA):
    ans[v-1] = i+1

print(*ans)

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

int main(){
	int m[100000];
	int n[100000];
	int a,b;
	cin >> a >> b;
	for(int i = 0;i<b;i++){
		cin >> m[i] >> n[i];
	}
	sort(m,m+b);
	sort(n,n+b);
	if((n[0]-m[b-1]+1) >= 0){
		cout << (n[0]-m[b-1]+1);
	}
	else{
		cout << 0;
	}
	return 0;
}

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

int main () {
  string S;
  cin >> S;
  if (S == "AAA" || S == "BBB") {
    cout << "No" << endl;
  }
  else if (S == "AAB" || S == "ABA" || S == "ABB" || 
          S == "BAA" || S == "BAB" || S == "BBA") {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		int max = 0;
		
		for(int i=0; i<n; i++){
		    String str1 = str.substring(0,i+1);
		    String str2 = str.substring(i+1);
		    int ans = 0;
		    boolean[] ar1 = new boolean[26];
            boolean[] ar2 = new boolean[26];
		    
		    for(int j=0; j<i+1; j++){
		        ar1[str1.charAt(j)-'a']=true;
		    }
		    
		    for(int j=0;j<n-i-1;j++){
                ar2[str2.charAt(j)-'a']=true;
            }
		    
		    for(int j=0;j<26;j++){
                if(ar1[j]&&ar2[j]){
                    ans++;
                }
            }
            max = Math.max(max,ans);
		}
		
		System.out.println(max);   
        
    }
}


Measured memory_bytes: 35800
#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>;

double dp[330][330][330];

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i,n) {
        int x;
        cin >> x;
        mp[x]++;
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                int nonzero = i + j + k;
                if (nonzero == 0) {
                    dp[i][j][k] = 0;
                    continue;
                }
                dp[i][j][k] += (double)n / nonzero;
                if (i-1 >= 0) dp[i][j][k] += dp[i-1][j+1][k] * i / nonzero;
                if (j-1 >= 0) dp[i][j][k] += dp[i][j-1][k+1] * j / nonzero;
                if (k-1 >= 0) dp[i][j][k] += dp[i][j][k-1] * k / nonzero;
            }
        }
    }
    double ans = dp[mp[3]][mp[2]][mp[1]];
    printf("%.10lf\n", ans);
}

Measured memory_bytes: 258176
#include <stdio.h>
 
int main(void){
    int n,i,num,s[13]={0},h[13]={0},c[13]={0},d[13]={0};
    char ch;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("\n%c %d",&ch,&num);
        switch(ch){
            case 'S':s[num-1]++;break;
            case 'H':h[num-1]++;break;
            case 'C':c[num-1]++;break;
            case 'D':d[num-1]++;break;
        }
    }
        for(i=0;i<13;i++)
            if(s[i] != 1)
                printf("S %d\n",i+1);
        for(i=0;i<13;i++)
            if(h[i] != 1)
                printf("H %d\n",i+1);
        for(i=0;i<13;i++)
            if(c[i] != 1)
                printf("C %d\n",i+1);
        for(i=0;i<13;i++)
            if(d[i] != 1)
                printf("D %d\n",i+1);
        return 0;
}


Measured memory_bytes: 2028
#include <stdio.h>

int main(){
	int h,m,s;	
	int time;
	scanf("%d",&time);
	s=time%60;
	time=time/60;
	m=time%60;
	time=time/60;
	h=time;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]

T = [0]*D
for i in range(D):
    temp = -1
    for j in range(26):
        if temp < S[i][j]:
            temp = S[i][j]
            idx = j+1
    T[i] = idx

for t in T:
    print(t)

Measured memory_bytes: 68032
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;cin>>str;
  int ans=0;
  string st="CODEFESTIVAL2016";
  for(int i=0;i<16;i++){
    if(str[i]!=st[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    char X, Y;
    cin >> X >> Y;
    if (X > Y)
    {
        cout << '>' << endl;
    }
    else if (X == Y)
    {
        cout << '=' << endl;
    }
    else
    {
        cout << '<' << endl;
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> dice(n);
    rep (i, n) cin >> dice[i];
    vector<double> p(1000);
    FOR (i, 1, 1001) {
        double tmp = 0;
        FOR (j, 1, i + 1) {
            tmp += (double)(j / (double)i);
        }
        p[i - 1] = tmp;
    }
    int cur = 0;
    double ans = -1.0;
    double sum = 0.0;
    while (cur < k) {
        sum += p[dice[cur] - 1];
        cur++;
    }
    ans = max(ans, sum);
    while (cur < n) {
        sum -= p[dice[cur - k] - 1];
        sum += p[dice[cur] - 1];
        cur++;
        ans = max(ans, sum);
    }

    cout << fixed << setprecision(7);
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1024
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
//#include<unordered_map>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=1e5+5;


signed main(){
    string s;
    cin>>s;
    int q=re;
    int f=0;
    while(q--){
        int d=re;
        if(d==1){//rev
            f^=1;
        }else{
            int t=re;
            char d;cin>>d;
            if(t==1){//begin
                if(f==0)s.insert(s.begin(),d);
                else s+=d;
            }else{
                if(f==0)s+=d;
                else s.insert(s.begin(),d);
            }
        }
    }
    if(f)reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1028
i,j,h,w;char a[100][100];r[100],c[100];
main(){scanf("%d%d",&h,&w);
for(i=0;i<h;i++){scanf("%s",a[i]);for(j=0;j<w;j++)if(a[i][j]=='#')r[i]=c[j]=1;}
for(i=0;i<h;i++)if(r[i]){for(j=0;j<w;j++)if(c[j])putchar(a[i][j]);puts("");}}

Measured memory_bytes: 128
N,K=map(int,input().split())
dlist=[]
Alist=[]
for i in range(K):
    dlist.append(input())
    Alist.append(list(map(int,input().split())))

#print(Alist)
import itertools
Alist=list(itertools.chain.from_iterable(Alist))
#print(Alist)
Alist=list(set(Alist))
#print(Alist)
print(N-len(Alist))

Measured memory_bytes: 9192
n,m=map(int,input().split())
c=list(map(int,input().split()))
dp=[[n]*(n+1) for _ in range(m+1)]
dp[0][0]=0
for i in range(1,m+1):
    for j in range(n+1):
        if j>=c[i-1]:
            dp[i][j]=min(dp[i-1][j],dp[i][j-c[i-1]]+1)
        else:
            dp[i][j]=dp[i-1][j]
print(dp[m][n])


Measured memory_bytes: 43736
from collections import deque
import numpy as np
import math

h, w = list(map(int, input().split()))
SHWs = [input() for i in range(h)]

def bfs(sy, sx):
    visited = [[-1]*w for i in range(h)]
    visited[sy][sx] = 0
    que = deque([[sy, sx]])
    while que:
        
        y,x = que.popleft()
        for i, j in [(1,0),(0,1),(-1,0),(0,-1)]:
            next_y, next_x = y+i, x+j
            # print(visited)
            if next_y < 0 or next_x < 0 or next_y > h-1 or next_x > w-1:
                continue
            if SHWs[next_y][next_x] == '.' and (visited[next_y][next_x] == -1 or visited[next_y][next_x] > visited[y][x]+1):
                visited[next_y][next_x] = visited[y][x] + 1
                que.append([next_y, next_x])
    
    return np.amax(np.array(visited))

            
ans = 0
for sy in range(h):
    for sx in range(w):
        if SHWs[sy][sx] == '#':
            continue
        count = bfs(sy=sy, sx=sx)

        if count > ans:
            ans = count


print(ans)



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

string S;
int pqr[3];

int getOperator(int l, int r){
    int c = 0;
    for(int i=l;i<r;i++){
        if(c == 0 && (S[i] == '*' || S[i] == '+')){
            return i;
        }else if(S[i] == '('){
            c++;
        }else if(S[i] == ')'){
            c--;
        }
    }
    assert(false);
    return -1;
}

int parseFomula(int l, int r){
    int ret = -1;
    if(S[l] == '('){
        assert(S[r-1] == ')');
        int opPos = getOperator(l+1, r-1);
        int lv = parseFomula(l+1, opPos), rv = parseFomula(opPos+1, r-1);
        if(S[opPos] == '+'){
            ret = max(lv, rv);
        }else{
            ret = min(lv, rv);
        }
    }else if(S[l] == '-'){
        ret = 2 - parseFomula(l+1, r);
    }else if('P' <= S[l] && S[l] <= 'R'){
        ret = pqr[S[l]-'P'];
    }else if('0' <= S[l] && S[l] <= '2'){
        ret = S[l] - '0';
    }
    assert(ret != -1);
    return ret;
}

int main(){
    while(1){
        cin >> S;
        if(S == ".") break;

        int ans = 0;
        for(int i=0;i<=2;i++){
            for(int j=0;j<=2;j++){
                for(int k=0;k<=2;k++){
                    pqr[0] = i;
                    pqr[1] = j;
                    pqr[2] = k;
                    if(parseFomula(0, S.size()) == 2) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3204
import sys
import copy

input = sys.stdin.readline

N = int(input())
OS = [[int(x) for x in list(input().strip())] for y in range(N)]

distmax = 0
for i in range(N):
	S = copy.deepcopy(OS)
	distlist = [-1]*N
	distlist[i] = 0
	queue = [i]
	dist = 0
	shortcut = False
	while len(queue)>0:
		dist += 1
		nq = []
		for ii in queue:
			for jj, neighbor in enumerate(S[ii]):
				if neighbor==1:
					if distlist[jj]==-1:
						distlist[jj] = dist
						S[jj][ii] = 0
						nq.append(jj)
					elif distlist[jj]!=dist:
						shortcut = True
						break
					else:
						S[jj][ii] = 0
			if shortcut: break
		if shortcut: break
		queue = nq
	dist -= 1
	if (not shortcut) and (dist>distmax):
		distmax = dist

if distmax==0:
	ans = -1
else:
	ans = distmax+1
print(ans)

Measured memory_bytes: 117852
#include<stdio.h>

int main(){

  int A[100],i,j,minj,N,x,count=0;

  scanf("%d",&N);
  if(N>=1 && N<=100){
    for(i=0;i<N;i++){
      scanf("%d",&A[i]);
    }
    for(i=0;i<=N-1;i++){
      minj=i;
      for(j=i;j<=N-1;j++){
	if(A[j]<A[minj])
	  minj=j;
	
      }
      x=A[minj];
      A[minj]=A[i];
      A[i]=x;
      if(minj!=i)count++; 
    }
  }
    for(i=0;i<N;i++){
      if(i>0) printf(" ");
      printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",count);
  return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];
    as.erase(unique(as.begin(), as.end()), as.end());

    long long kane = 1000;
    long long kabu = 0;
    for (int i = 1; i < as.size(); i++) {
        if (as[i - 1] < as[i]) {
            kabu += kane / as[i - 1];
            kane %= as[i - 1];
        } else {
            kane += kabu * as[i - 1];
            kabu = 0;
        }
    }
    kane += kabu * as.back();
    cout << kane << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;
//float abs_func(float x) {
//    if (x>0) {
//        return x;
//    } else {
//        return -x;
//    }
//}
int main()
{
    float cx1, cy1, r1, cx2, cy2, r2;
    cin >> cx1 >> cy1 >> r1 >> cx2 >> cy2 >> r2;
    float d = sqrt(pow(cx1-cx2, 2) + pow(cy1-cy2, 2));
    if (r1 + r2 < d) {
        cout << "4\n";
    } else if (r1 + r2 == d) {
        cout << "3\n";
    } else { // r1 + r2 > d
        float sub = abs(r1-r2);
        if (sub < d) {
            cout << "2\n";
        } else if (sub == d) {
            cout << "1\n";
        } else { // |r1-r2| > d
            cout << "0\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3200
LR = list(map(int,input().split()))
L = LR[0]
R = LR[1]
K = 2018
if R - L> 2019:
    K = 0
else:
    for j in range(L,R+1):
        for i in range(L,j):
            if K > (i*j)%2019:
                K =  (i*j)%2019
print(K)

Measured memory_bytes: 3060
#include<stdio.h>

char map[32][32];
int ans;
int W,H;

void func(int x,int y){
	map[x][y] = '0';
	ans++;
	if(map[x][y+1] == '.' && y+1<32)
		func(x,y+1);
	if(map[x][y-1] == '.' && y-1>-1)
		func(x,y-1);
	if(map[x+1][y] == '.' && x+1<32)
		func(x+1,y);
	if(map[x-1][y] == '.' && x-1>-1)
		func(x-1,y);
}


int main(void){
	while(scanf("%d%d",&W, &H) && H){
		for(int i = 0; i < H; i++){
			scanf("%s",map[i]);
		}
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(map[i][j] == '@'){
					func(i,j);
				}
			}
		}
		printf("%d\n",ans);
		ans=0;
		for(int i = 0; i < 32; i++){
			for(int j = 0; j < 32; j++){
				map[i][j] = 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
bool comp(int a,int b){
return a>b;
}
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	fast;
    ll n;
    cin>>n;
    int t=0;
    stack<char>s;
    while(n>0)
    {
    	
	  t=n%26;
	  if(t==0)
	  s.push('z');
	  else
	  s.push('a'+t-1);
	  
	  
	  n/=26;
	  if(!t)
	  n--;
    }
    while(!s.empty())
    {
    	cout<<s.top();
    	s.pop();
	}
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
ll n,m,w,c[111],a[111][111],s[111];
ll g=1e18;
void dfs(int x,ll cs){
	if(x==n){
		bool b=1;
		fo(i,0,m) if(s[i]<w)b=0;
		if(b)g=min(g,cs);
		return;
	}
	dfs(x+1,cs);
	fo(i,0,m)s[i]+=a[x][i];
	dfs(x+1,cs+c[x]);
	fo(i,0,m)s[i]-=a[x][i];
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>m>>w;
	fo(i,0,n){
		cin>>c[i];
		fo(j,0,m)cin>>a[i][j];
	}
	dfs(0,0);
	if(g==1e18)cout<<"-1\n";
	else cout<<g<<endl;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll a,b,m;
	cin >> a >> b >> m;
	ll arr[a+1];
	ll arr2[b+1];
	ll haha = LLONG_MAX,lol = LLONG_MAX;
	for(int i =1;i<=a;i++) cin >> arr[i],haha=min(haha,arr[i]);
	for(int i =1;i<=b;i++) cin >> arr2[i],lol=min(lol,arr2[i]);

	ll mi = LLONG_MAX;
	mi = min(mi,lol+haha);

	for(int i =1;i<=m;i++){
		ll x,y,d;
		cin >> x >> y >> d;
		mi = min(mi,arr2[y] + arr[x]-d);
	}
	cout << mi << endl;

	return 0;
}

Measured memory_bytes: 1792
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .expect("read line");
    let mut iter = line.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    println!("{}", (a-1) * (b-1));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    llong L,R; cin>>L>>R;
    int mod=2019;
    int modl=L%mod;
    int modr=R%mod;

    int ans=0;
    if(R-L>2019) ans=0;
    else if(modl==0) ans=0;
    else if(modl>=modr) ans=0;
    else if(modl<modr&&R-L<=2019)
    {
        ans=inf;
        for(int j=modl; j<modr; j++)
        {
            for(int k=j+1; k<=modr; k++)
            {
                ans=min(ans,j*k%mod);
            }
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

l,r,ans=1,1,1

tempsum = a[0]

while(r<n):
    while(r<n and (tempsum^a[r]==tempsum+a[r])):
        tempsum^=a[r]
        r+=1
        ans+=(r-l+1)
    tempsum-=a[l-1]
    l+=1

    if(l>r):
        ans+=1
        r=l
        tempsum=a[l-1]
print(ans)
        


Measured memory_bytes: 23560
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   int n,a,b;
   string s;
   cin >> n >> a >> b;
   cin >> s;
   int passed = 0;
   int countb = 0;
   for(int i = 0;i < s.size();i++){
       if(s[i] == 'a'){
           if(passed < a + b){
               cout << "Yes" << endl;
               passed++;
           }else{
               cout << "No" << endl;
           }
       }else if(s[i] == 'b'){
           if(passed < a + b && countb < b){
               cout << "Yes" << endl;
                passed++;
                countb++;
           }else{
               cout << "No" << endl;
           }
       }else{
           cout << "No" << endl;
       }
       
   }
    
}


Measured memory_bytes: 896
#include <stdio.h>
int main()
{
  int k[51],i,n,r,y[51],a,b,ka,j;
  while(1){
    scanf("%d %d",&n,&r);
    if(n==0&&r==0)break;
    for(i=0;i<n;i++){
      k[i]=i+1;
      y[i]=i+1;
    }
    for(i=0;i<r;i++){
      scanf("%d %d",&a,&b);
      ka=1;
      for(j=0;j<b;j++){
	y[n-a-b+ka]=k[n-a-b+ka];
	ka++;
      }
      //printf("%d %d %d %d %d",k[0],k[1],k[2],k[3],k[4]);//
      ka=1;
      for(j=0;j<a-1;j++){
	k[n-a-b+ka]=k[n-a+ka];
	ka++;
      }
      ka=1;
      for(j=0;j<b;j++){
	k[n-b-1+ka]=y[n-a-b+ka];
	ka++;
      }
    }
    printf("%d\n",k[n-1]);
  }
  return 0;
}

Measured memory_bytes: 1028
N, Y = map(int, input().split())
for i in range(N + 1):
    for j in range(N + 1 - i):
        k = int((Y - 10000 * i - 5000 * j) / 1000)
        if N - i - j >= k >= 0 and i + j + k == N:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
float a[n];
  int i;
  //float s=0;
  for(i=0;i<n;i++){
      cin>>a[i];
  }
  sort(a,a+n);
  float s=0,w;
  for(i=0;i<n-1;i++){
      w=(a[i]+a[i+1])/2;
      a[i+1]=w;
  }
  cout<<a[n-1]<<endl;
  return 0;
}
  

Measured memory_bytes: 384
x,n=map(int,input().split())
a = list(map(int,input().split()))
if n==0:
    print(int(x))
    exit()

for i in range(n):
    if x-i not in a:
        print(x-i)
        exit()
    elif x+i not in a:
        print(x+i)
        exit()
print(x-(n//2)-1)


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

int main ()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int maxCounter=0;
    int counter=0;
    for(int i=0;i<n-1;i++){
        if(arr[i] >= arr[i+1])
            counter++;
        else counter=0;
        if(maxCounter <= counter)
            maxCounter=counter;
    }
    cout<<maxCounter<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000000+7
#define MEM_SIZE = 1e5+5;


void solve(void)
{
 int N,M;
 cin>>N>>M; 
 vector<string> data(M);
 int AC = 0;
 int WA = 0;
 vector<int> Prob(N,0);
   vector<int> WAV(N,0);
 for (int i = 0; i < M; i++)
 {
   int P;
   string S;
   cin>>P;
   cin>>S;
   P--;

   if(Prob[P] == 0)
   {
     if(S == "WA")
     {
       WAV[P]++;
     }
     else if(S =="AC")
     {
       AC++;
       Prob[P] = 1;
     }
   }
 }
  for (int i = 0; i < N; i++)
  {
    if(Prob[i] == 1)
    {
      WA += WAV[i];
    }
  }
  

  cout<<AC<<" "<<WA<<endl;
 

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;

	// a = 2X - Y/2
	// 制約：Y は偶数
	// 制約： 2X > Y/2

	if ((Y % 2 == 0) && (Y/2 >= X) && (2*X >= Y / 2)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n;
	 cin>>n;
	 vector<int> v(n);
	 for(int i=0;i<n;i++)
	 {
		 cin>>v[i];
	 }
	 ll ans = 0;
	 for(int i=0;i+2<n;i++)
	 {
		 for(int j=i+1;j+1<n;j++)
		 {
			 for(int k=j+1;k<n;k++)
			 {
				 if(v[i]!=v[j] && v[j]!=v[k] && v[i]!=v[k])
				 {
					 if(v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[j]+v[k]>v[i])
					 ans++;
				 }
			 }
		 }
	 }
	 cout<<ans<<'\n';
	 return 0;
}


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

using namespace std;

int solve(string &s, string &t, vector<vector<int>> &memo, int i = 0,
          int j = 0) {
  if (i >= s.size() || j >= t.size()) {
    return 0;
  }

  if (memo[i][j] < 0) {
    if (*(s.end() - i - 1) == *(t.end() - j - 1)) {
      memo[i][j] = solve(s, t, memo, i + 1, j + 1) + 1;
    } else {
      memo[i][j] =
          max(solve(s, t, memo, i + 1, j), solve(s, t, memo, i, j + 1));
    }
  }

  return memo[i][j];
}
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> memo(s.size(), vector<int>(t.size(), -1));
    cout << solve(s, t, memo) << '\n';
  }

  return 0;
}


Measured memory_bytes: 6888
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

#define M_MAX n+1

int main() {
	
	int n,m,x;
	cin >> n >> m >> x;
	//cout <<n<<m<<x<<"\n";
	int i,j,a[M_MAX],s=x;
	
    for(i=0;i<m;++i){
        cin>>a[i];
    }
	int costS=0,costE=0;
	
	for(i=0;i<n;++i){
	    s++;
	    for(j=0;j<m;++j){
	        if(s==a[j])costE++;
	    }
	    //cout<<costE<<" ";
	    if(s==n)break;
	}
	
	
	//cout<<"\n";
	
	for(i=0;i<n;++i){
	    x--;
	    for(j=0;j<m;++j){
	        if(x==a[j])costS++;
	    }
	    //cout<<costS<<" ";
	    if(x==0)break;
	}
	
	//cout<<"\n";
	
	int ans=min(costS,costE);
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) { //sをできるだけ小さく、tをできるだけ大きく
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define int long long
il int read()
{
	int k=1,re=0;char ch=getchar();
	while(ch>'9'||ch<'0'){ch=getchar();}
	while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
	return re*k;
}
void write(int x)
{
	if(x<0)return write(-x),void();
	if(x<=9)return putchar(x+48),void();
	return write(x/10),write(x%10),void();
}
int a,b,c,k;
signed main()
{
	cin>>a>>b>>c>>k;
	int ans=0;
	if(a<=k){ans+=a;k-=a;}
	else ans+=k,k=0;
	if(b<=k){k-=b;}
	else k=0;
	ans+=-k;
	cout<<ans;
}

Measured memory_bytes: 3632
N, M, K = gets.split.map{|i|i.to_i}
P = 998244353
def pow(a, n, p)
    r = 1
    while n > 0
        if n % 2 == 1
            r *= a
        end
        a = a ** 2 % p
        n /= 2
    end
    r % p
end
fa = [1, 1]
inv = [nil, 1]
fi = [1, 1]
(2 .. N).each{|n|
    fa << fa[-1] * n % P
    inv << P - inv[P % n] * (P / n) % P
    fi << fi[-1] * inv[-1] % P
    #fi << pow(fa[-1], P - 2, P)
}
#warn fa.inspect
#warn fi.inspect
r = 0
(0 .. K).each{|k|
    n = N - k
    cp = M * pow(M - 1,  n - 1, P) % P
    #warn cp
    cp *= fa[N - 1] * fi[k] * fi[N - 1 - k] % P
    #warn cp
    r += cp
    r %= P
}
puts r


Measured memory_bytes: 19388