akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	int n, x; cin >> n >> x;

	if (x == 1 || x == n*2-1) {
		cout << "No\n";
		return;
	}

	cout << "Yes\n";
	rep(i, 0, n*2-1) {
		int p = (i-n+x) % (n*2-1) + 1;
		if (p <= 0) p += n*2-1;
		cout << p << '\n';
	}
}


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

string basem2(int n){
  if(n==0){
    return "0";
  }
  else{
    string ans="";
    while(n!=0){
      int k=abs(n%2);
      char c=k+'0';
      ans=c+ans;
      if(n<0){
        n-=1;
      }
      n/=-2;
    }
    return ans;
  }
}

int main(){
  int n;
  cin >> n;
  cout << basem2(n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N, X;
int A[110];
int main() {
    cin >> N >> X;
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    int sum = 0;
     for (int i = 0; i < N; ++i){
     sum += A[i];
     }
     
    int min = 1100;
      
      for (int i = 0; i < N; ++i){
        if (min > A[i]){
          min = A[i];
        }
      }
  
     int res = N + (X - sum) / min;
  
  cout << res << endl;
     
    
}

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

ll c, n, k;

ll solve();

int main() {
  cin >> c;
  while(c) {
    cin >> n >> k;
    //存在しうるか
    if((n + 1) / 2 < k)
      cout << -1 << endl;
    else
      cout << solve() << endl;
    --c;
  }

  return 0;
}

ll solve() {
  ll l = 1, r = (n + 1) / 2, now, nownum, cnt, i, bit = 0,
     bf, store, allstore = (n + 1) / 2;
  //にぶたんの範囲を決める
  while(allstore > 0) {
    r = allstore;
    allstore = (allstore + 1) / 3;
    l = allstore + 1;
    //答えを求めるためのにぶたん
    while(r - l >= 0) {
      //現在の真ん中
      nownum = (l + r) / 2;
      now = (1 << (bit + 1)) * nownum - (1 << bit);
      cnt = 0;
      store = (n + 1) / 2;
      // 2^iの段ごとに個数を数える
      for(i = 0; (1 << i) <= n && store != 0; ++i) {
        bf = (1 << (i + 1)) * store - (1 << i);
        store = (store + 1) / 3;
        ll p = ((1 << i) + min(bf, now)) / (1 << (i + 1)) -
               store;
        cnt += max((ll)0, p);
      }
      if(cnt == k)
        return now;
      else if(r - l == 1)
        l = r;
      else if(r - l == 0)
        break;
      else if(cnt > k)
        r = nownum;
      else
        l = nownum;
    }
    ++bit;
  }
  return -1;
}


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

using namespace std;

const long long MOD = 1e9 + 7;
const int maxn = 1e6;
long long f[maxn];

long long in(long long a, long long b) {
    long long ans = 1;
    while (b > 0) {
        if (b & 1) {
            ans = (ans * a) % MOD;
        }
        a = (a * a) % MOD;
        b >>= 1;       
    }
    return ans;
}

long long dv(long long a, long long b) {
    return (a * in(b, MOD - 2)) % MOD;
}

long long cnk(int n, int k) {
    if (k < 0 || k > n) return 0;
    return dv(f[n], (f[k] * f[n - k]) % MOD);
}

long long fun(int n, int k) {
    return cnk(k - 1, n - k);
}

int main()
{
    #ifdef DEBUG
    //freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0), cin.tie(0);
    long long n;
    cin >> n;
    if (n == 2) {
        cout << 1;
        return 0;
    }
    if (n == 3) {
        cout << 4;
        return 0;
    }
    n--;
    f[0] = 1;
    for (int i = 1; i <= n; i++) {
        f[i] = (f[i - 1] * i) % MOD;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        //cerr << fun(n, i) << "\n";
        ans = (ans + f[n - i] * ((cnk(n, i) - fun(n, i)) * f[i] % MOD)) % MOD; 
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>
#include <iostream>
#include <string.h>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class ConnectedList{
public:
	ConnectedList(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	
		motherNode->next = motherNode;
	};
	~ConnectedList(){
		Node* tmpNode = motherNode->next;
		Node* nextNode;
		while(tmpNode != motherNode){
			nextNode = tmpNode->next;
			delete tmpNode;
			tmpNode = nextNode;
		}
		delete motherNode;
	};
	void insertNode(int x){
		Node* tmpNode = motherNode->next;
		motherNode->next = new Node();
		motherNode->next->data = x;
		motherNode->next->next = tmpNode;
		motherNode->next->prev = motherNode;
		tmpNode->prev = motherNode->next;
	};
	void deleteNode(int x){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode && tmpNode->data != x){
			tmpNode = tmpNode->next;
		}
		if(tmpNode != motherNode){	
			tmpNode->prev->next = tmpNode->next;
			tmpNode->next->prev = tmpNode->prev;
			delete tmpNode;
		}
	};

	void deleteFirst(){
		Node* tmpNode = motherNode->next;
		motherNode->next = motherNode->next->next;
		motherNode->next->prev = motherNode;
		delete tmpNode;	
	};

	void deleteLast(){
		Node* tmpNode = motherNode->prev;
		motherNode->prev = motherNode->prev->prev;
		motherNode->prev->next = motherNode;
		delete tmpNode; 
	};

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	ConnectedList list;

	for(int i = 0; i < n; i++){

		fgets(buf,BUF_SIZE,stdin);

		if(buf[6] == 'F'){
			list.deleteFirst();
		}else if(buf[6] == 'L'){
			list.deleteLast();
		}else{
			int S = 0;
			
			if(buf[0] == 'i'){	//insert x

				for(int i = 0; buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.insertNode(S);
			}else{	
				for(int i = 0;buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.deleteNode(S);
			}

		}

	}

	list.showList();

}



Measured memory_bytes: 34288
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 
#define mp make_pair
#define pb push_back
#define pii pair<int,int >
using namespace std;

int main()
{
      int ans=0;
      string name;
      cin>>name;
      
      for(int i=0;i<name.length();i++)
      {
           if(name[i]=='+')
           ans++;
           else
           ans--;
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

int main(){
  int n, s; cin >> n >> s; int a[n];
  rep(i, n){
    cin >> a[i];
  }
  ll dp[3010][3010] = {};  ll ans = 0; dp[0][0]=1;
  rep(i, n){
    dp[i+1][a[i]]+=(i+1); dp[i+1][a[i]]%=mod;
    rep(j, 3010){
      if(j!=0) dp[i+1][min(j+a[i], 3009)]+=dp[i][j]; dp[i+1][min(j+a[i], 3009)]%=mod;
      dp[i+1][j]+=dp[i][j]; dp[i+1][j]%=mod;
    }
    if(a[i]==s) ans+=(i+1)*(n-i);
    rep(j, 3010){
      if(a[i]+j==s && j!=0) ans+=(dp[i][j]*(n-i)); ans%=mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 71040
a,b=map(int,input().split())

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ab=gcd(a,b)
li=make_divisors(ab)
li.sort()
n=len(li)//2+1
ans=0
for i in range(n):
    li2=make_divisors(li[i])
    if len(li2)<=2:
        ans+=1
print(ans)

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

int main(){
  int n,a;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>a;
    if(a&1){
      cout<<"first"<<endl;
      return 0;
    }
  }
  cout<<"second"<<endl;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m), suma(n + 1, 0), sumb(m + 1, 0);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        suma[i + 1] = suma[i] + a[i];
    }
    for(ll i = 0; i < m; i++) {
        cin >> b[i];
        sumb[i + 1] = sumb[i] + b[i];
    }
    debugVector(suma);
    debugVector(sumb);
    ll ans = 0;
    for(ll i = 0; i <= n; i++) {
        ll A = suma[i];
        if(A > k) {
            continue;
        }
        ll B = k - A;
        auto it = lower_bound(ALL(sumb), B);
        if(it != sumb.begin() && *it > B) {
            it--;
        }
        if(it == sumb.end()) {
            it--;
        }
        chmax(ans, i + (ll)(it - sumb.begin()));
    }
    for(ll i = 0; i <= m; i++) {
        ll B = sumb[i];
        if(B > k) {
            continue;
        }
        ll A = k - B;
        auto it = lower_bound(ALL(suma), A);
        if(it != suma.begin() && *it > A) {
            it--;
        }
        // debug(i);
        // debug(i, (ll)(it - suma.begin()));
        if(it == suma.end()) {
            it--;
        }
        chmax(ans, i + (ll)(it - suma.begin()));
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
using ll = long long;


int main(){
  double l;
  cin >> l;
  cout<< setprecision(20) <<(l/3.0)*(l/3.0)*(l/3.0)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
long long INF = (long long)1E17;
#define i_7 (long long)(1E9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE = 10'010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(long long p){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = p - ((p/i)*inv[p%i])%p;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%p;
        invkai[i]=(invkai[i-1]*inv[i])%p;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  using namespace std;
  long long n, p;
  cin>>n>>p;
  invinit(p);
  string a;
  cin>>a;
  long long s[n] = {};
  REP(i, n){
    long long temp = a[i] - '0';
    if(i == 0){
      s[i] = temp % p;
    }else{
      s[i] = (s[i - 1] * 10 + temp) % p;
    }
  }
  long long m[n] = {};
  long long nowpo = 1;
  REP(i, n){
    m[i] = (inv[nowpo] * s[i]) % p;
    nowpo *= 10;
    nowpo %= p;
  }
  long long ans = 0;
  long long cnt[p] = {};
  REP(i, n){
    if(s[i] == 0){
      ans++;
    }
  }
  REP(i, n){
    ans += cnt[m[i]];
    cnt[m[i]]++;
  }
  if(p != 2 && p != 5){
    cout<<ans<<endl;
    return 0;
  }
  ans = 0;
  REP(i, n){
    if(s[i] == 0){
      ans++;
    }
  }
  REP(i, n){
    if(i == 0)continue;
    if(s[i] != 0)continue;
    ans += (long long)i;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3972
import heapq

n,k = map(int,input().split())
h = list(map(int,input().split()))

h = list(map(lambda x:-x,h))

if n<=k:
    print("0")
else:
    heapq.heapify(h)
    for i in range(k):
        heapq.heappop(h)
    print(-sum(h))

Measured memory_bytes: 25896
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;

	int ans = c - (a - b);
	if (ans < 0)ans = 0;

	cout << ans << endl;
	return 0;
}


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

constexpr int maxn = 3e3 + 100;
using ll = long long;
constexpr ll mod = 1e9 + 7;

int n, m, d[2][maxn][maxn] = {};

// d[atins][i][j] = cate drumuri +0- exista
// care sa fie intre 0 si n mereu
// si care sa fie (atins / neatins) 0-ul
// care sa fie la punctul (i, j)

void plus_add(int& x, const int y){
    x += y;
    if(x >= mod) x -= mod; }

int main(){
    cin >> n >> m;
    --n, --m;

    for(int i = 0; i <= n; ++i) d[i == 0][0][i] = 1;
    for(int i = 0; i <= m; ++i){
        plus_add(d[1][i][0], d[0][i][0]);
        plus_add(d[1][i+1][0], d[1][i][0]);
        plus_add(d[1][i+1][0], d[1][i][0]);
        plus_add(d[1][i+1][1], d[1][i][0]);
        for(int atins = 0; atins < 2; ++atins){
            for(int j = 1; j <= n; ++j){
                for(int delta = -1; delta <= 1; ++delta){
                    plus_add(d[atins][i+1][j+delta], d[atins][i][j]);
                    if(delta == 0) plus_add(d[atins][i+1][j+delta], d[atins][i][j]); } } } }
    /*
    for(int k = 0; k < 2; ++k){
    for(int j = n; j >= 0; --j){
        for(int i = 0; i <= m; ++i){
            cout << d[k][i][j] << ' '; }
        cout << endl; }
    cout << endl; }
    */
    int rez = 0;
    for(int i = 0; i <= n; ++i) plus_add(rez, d[1][m][i]);
    plus_add(rez, rez);
    plus_add(rez, rez);
    cout << rez << endl;
    return 0; }


Measured memory_bytes: 74112
// AtCode_Beginner_160.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>

using namespace std;

void A();
void B();
void C();
void D();
void E();

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	A();
}

void A() {
	string s;
	cin >> s;
	


	cout << ((s[2] == s[3]) && (s[4] == s[5]) ? "Yes" : "No") << endl;

}

void B() {
	int n, m;
	cin >> n >> m;

	vector<int> items(n);

	for (int& num : items) cin >> num;

	int sum = 0;
	for (int num : items) sum += num;

	int popular = 0;

	const double popularAmt = (double)sum / (4 * m);

	for (int num : items) {
		if (num >= popularAmt) popular++;
	}

	if (popular >= m) cout << "Yes" << endl;
	else cout << "No" << endl;

}

void C() {

	long long N, K;
	cin >> N >> K;

	long long div = N % K;

	long long m = min(div, abs(div - K));

	cout << m << endl;

}

void D() {





}

int helper(int N, int K) {

	while (N >= K) {
		if (N % K == 0) N /= K;
		else N %= K;
	}

	return N == 1;

}

void E() {

	int N;
	cin >> N;

	vector<bool> factor(N, false);

	int count = 2;

	for (int n = 2; n * n < N; n++) {

		int divisible = false;
		if (N % n == 1) count++;
		else if (N % n == 0) if (helper(N, n)) count++;
		/*
		//hasnt been done before
		if (!factor[n]) {

			divisible = (N % n == 0);

			for (int i = n; i < N; i+=n) {
				factor[i] = true;

				if (divisible) {
					if(helper(N, i)) count++;
				}

			}

		}*/

	}

	cout << count;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    double menseki,enshu;
    double r;
    cin >> r;
    menseki = M_PI*pow(r,2);
    enshu = M_PI*2*r;
    cout <<fixed << setprecision(6) << menseki << ' ' << fixed << setprecision(6) << enshu << endl;
    return 0;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
long long dp[2010][2010];
int s[2010];
int t[2010];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i=1;i<=n;i++)
		cin >> s[i];
	for (int i=1;i<=m;i++)
		cin >> t[i];
	for (int i=0;i<=n;i++)
		dp[i][0]=1;
	for (int j=0;j<=m;j++)
		dp[0][j]=1; 
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1];
			if (s[i]==t[j]) dp[i][j]+=dp[i-1][j-1];
			dp[i][j]=(dp[i][j]+1000000007)%1000000007;
		}
	cout << dp[n][m];
	return 0;
}

Measured memory_bytes: 31616
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int a,b;
		for(;scanner.hasNextInt();){
			a=scanner.nextInt();b=scanner.nextInt();
			System.out.println((int)Math.floor(Math.log10(a+b)+1));
		}
	}

}

Measured memory_bytes: 12000
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on
// clang-format off

int f(int y, int m, int d) {
  int c = 0;
  for (;;) {
    if (d > 1) { c++; d--; continue; }
    if (m > 1) { c++; m--; d = 19 + (odd(m) || y % 3 == 0); continue; }
    if (y > 1) { c++; y--; m = 10, d = 19 + (y % 3 == 0); continue; }
    break;
  }
  return c;
}

// clang-format on

void solve() {
  int n;
  cin >> n;
  rep(i, n) {
    int y, m, d;
    cin >> y >> m >> d;
    cout << 196470 - f(y, m, d) << endl;
  }
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>

std::string str;
bool status[100010];
bool is_sheep[100010];

inline
bool calc(int idx) {
	bool is = status[idx] ^ (!is_sheep[idx]);
	
	return is == is_sheep[(str.size() + idx - 1) % str.size()];
}

bool check(int idx) {
	if(idx == str.size() - 1) {
		return calc(idx) == is_sheep[0] && calc(0) == is_sheep[1];
	}
	
	is_sheep[idx + 1] = calc(idx);
	
	return check(idx + 1);
}

int main() {
	std::cin >> str >> str;
	
	for(int i = 0; i < str.size(); ++i) {
		status[i] = str[i] == 'o';
	}
	
	for(int i = 0; i < 2; ++i) {
		for(int j = 0; j < 2; ++j) {
			is_sheep[0] = i;
			is_sheep[1] = j;
			
			if(check(1)) {
				for(int i = 0; i < str.size(); ++i) {
					std::cout << (is_sheep[i] ? 'S' : 'W');
				}
				std::cout << std::endl;
				
				return 0;
			}
		}
	}
	
	std::cout << -1 << std::endl;
}

Measured memory_bytes: 768
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
	int n,T,A,H,ans=0;double D=1e9;
	scanf("%d%d%d",&n,&T,&A);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&H);
		if (fabs(T-H*0.006-A)<D) D=fabs(T-H*0.006-A),ans=i;
	}
	printf("%d",ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 2019,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
    		}
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	string s;
	cin>>s;
	int n=s.length();
	// vi dp(n+1);
	// for(int i=0;i<n;i++)
	// {
	// 	dp[i+1]=(dp[i]+s[i]-'0')%3;
	// }
	vi M(n+1);
	vi P(n+1);
	P[0]=1;
	for(int i=1;i<=n;i++)
	{
		P[i]=(P[i-1]*10)%MOD;
	}
	//prin(P);
	reverse(all(s));
	for(int i=0;i<n;i++)
	{
		M[i+1]=(P[i]*(s[i]-'0'))%MOD;
	}
	//prin(M);
	for(int i=1;i<=n;i++) M[i]=(M[i-1]+M[i])%MOD;
	//prin(M);
	vector<int> V(MOD);
	V[0]=1;
	for(int i=1;i<=n;i++)
	{
		V[M[i]]++;
	}
	//prin(V);
	ll ans=0;
	for(int i=0;i<MOD;i++)
	{
		ans+=(ll)V[i]*(V[i]-1)/2;
	}
	cout<<ans<<endl;


}		

Measured memory_bytes: 5188
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

vector<pair<ll, ll>> v;
int main() {
	ll n, m; cin >> n >> m;
	rep(i, 0, m) {
		ll a, b; cin >> a >> b;
		v.push_back({ b,a });
	}

	sort(v.begin(), v.end());

	ll current = 0;
	ll cnt = 0;
	for (vector<pair<ll, ll>>::iterator it = v.begin(); it != v.end(); it++) {
		if (current <= it->second) {
			current = it->first;
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0),eps=1e-8;
const int maxn=5e5+10;
const ll mod = 1e9+7;
int a[maxn],rt[maxn];
int lc[maxn*40],rc[maxn*40],tol;
ll sum[maxn*40];
map<int,int>vis;
void update(int &u, int x, int y, int p, ll v)
{
    sum[tol] = sum[u]+v,lc[tol] = lc[u],rc[tol] = rc[u];
    u = tol++;
    if(x == y) return;
    int m = (x+y)>>1;
    if(p <= m) update(lc[u],x,m,p,v);
    else update(rc[u],m+1,y,p,v);
}
ll query(int u, int x, int y, int ql, int qr)
{
    if(ql <= x && y <= qr) return sum[u];
    int m = (x+y)>>1;
    ll ans = 0;
    if(ql <= m) ans += query(lc[u],x,m,ql,qr);
    if(qr > m) ans += query(rc[u],m+1,y,ql,qr);
    return ans;
}
int main(){
	int n,q;
		tol=1;
	vis.clear();
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++){
		rt[i]=rt[i-1];
		if(vis.find(a[i])!=vis.end())
		{
			int tmp=rt[i-1];
			update(tmp,1,n,vis[a[i]],-1);
			rt[i]=tmp;
			update(rt[i],1,n,i,1);
		}
		else
		{
			rt[i] = rt[i-1];
            update(rt[i],1,n,i,1);
        }
        vis[a[i]]=i;
	}
	while(q--){
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%lld\n",query(rt[r],1,n,l,r));
	}
	return 0;

}


Measured memory_bytes: 319276
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		log.Fatal(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}
func main() {
	sc.Split(bufio.ScanWords)

	a := getInt()
	b, _ := getInt(), getInt()
	k := getInt()

	if a >= k {
		out(k)
	} else if a+b >= k {
		out(a)
	} else {
		out(-k + 2*a + b)
	}

}


Measured memory_bytes: 1820
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func pow(a, n int) int {
	ret := 1
	for n > 0 {
		if n&1 == 1 {
			ret *= a
		}
		a *= a
		n >>= 1
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	d, n := nextInt(), nextInt()
	var ans int
	p := pow(100, d)
	if n == 100 {
		n++
	}
	ans = p * n
	puts(ans)
	wt.Flush()
}

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int a,b,c;
    cin >> a>> b >> c;
    if(a+b+c>21)cout << "bust" << endl;
    else cout << "win" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

int main() {
  int n;
  cin >> n;
  
  vi a(n);
  rep(i, n) cin >> a[i];
  
  int n_swap = 0;
  rep(i, n - 1) {
    int minj = i;

    for (int j = i; j < n; j++) {
      if (a[j] < a[minj]) minj = j;
    }

    if (i != minj) {
      swap(a[i], a[minj]);
      n_swap++;
    }
  }

  rep(i, n) {
    cout << a[i];
    i != n - 1 ? cout << " " : cout << endl;
  }

  cout << n_swap << endl;
}



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

using namespace std;

int main(){
	int n;
	cin >> n;
	
	std::vector<int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h.at(i);
	}
	
	int highest = 0;
	bool flag = true;
	
	for (int i = 0; i < n; ++i) {
		if (h.at(i) < highest - 1) {
			flag = false;
		}
		highest = max(highest, h.at(i));
	}
	
	if (flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
import numpy as np

N, M, X = map(int, input().split())

l = []
for i in range(N):
    l += [np.array(list(map(int, input().split()))).reshape((M + 1, 1))]

r = np.array([0] * (M + 1)).reshape((M + 1, 1))

for x in l:
    r = np.concatenate([r, r + x], axis=1)

fitted = r[:, np.all(r[1:] >= X, axis=0)]

print(min(fitted[0]) if fitted.shape[1] != 0 else -1)

Measured memory_bytes: 27640
import bisect

N, X = map(int, input().split())
L = list(map(int, input().split()))
DP = [0] * (N+2)
for i in range(2, N+2):
    DP[i] = DP[i-1] + L[i-2]

ans = bisect.bisect_right(DP, X)
print(ans-1)


Measured memory_bytes: 3060
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int h,w;
		
		while(true) {
			h = sc.nextInt();
			w = sc.nextInt();
			if (h==0 && w==0) {
				break;
			}
			for (int i=0 ; i<h ; i++) {
				for (int j=0 ; j<w ; j++) {
					if(i==0 || i==h-1 || j==0 || j==w-1) {
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
		
		
	}

}


Measured memory_bytes: 55116
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define MAX(x,y) x>y?x:y

int main()
{
	int k,n;
	int max_val=0;
	int sum=0;
	
	short tmp;
	queue<short> win;
	
	cin>>n>>k;

	for(int i=0; i<n ; i++) {
		cin>>tmp;
		if(win.size()>=k) {
			sum -= win.front();
			win.pop();
		}
		sum += tmp;
		win.push(tmp);
		max_val = MAX(max_val, sum);
	}
	
	cout << fixed << setprecision(12);
	cout<<(max_val+k)/2.0<<endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl "\n" 
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    double l;
    cin>>l;
    cout<<setprecision(15);
    double ans=(l*l*l)/27;
    cout<<ans<<endl; 
}


Measured memory_bytes: 3756
<?php
$stdin=trim(fgets(STDIN));
$nums=explode(" ",$stdin);

$count_5=0;
$count_7=0;
foreach ($nums as $num) {
    if($num==5){
        $count_5 +=1;
    }elseif ($num==7) {
        $count_7 +=1;
    }
}

if($count_5==2 && $count_7==1){
    echo "YES".PHP_EOL;
}else{
    echo "NO".PHP_EOL;
}


Measured memory_bytes: 3064
def solve():
  s =input()
  n =len(s)
  queue = 0
  ans = 0
  for i in range(n):
    if s[i] == 'S': queue+=1
    else: 
      if queue >0:
        queue -= 1
        ans += 2
  return (n-ans)  
  
  
if __name__ == '__main__':
  print(solve())

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(), x.end()
#define mem(arr,x) memset(arr, x, sizeof arr)
#define db(arr) for(auto x : arr) cout << x << " "; cout << "\n";
using namespace std;

// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll power(ll n,ll m){
	if(m==0) return 1;
	ll val=power(n,m/2);
	if(m%2==0) return (val*val); else return ((val*val)*n);
}

ll powermod(ll n,ll m,ll MOD){
	if(m==0) return 1;
	ll val=powermod(n,m/2,MOD);
	val %= MOD;
	if(m%2==0) return (val*val) % MOD; else return (((val*val) % MOD) * n) % MOD;
}

void solve(){
	int n, x, t;
	cin >> n >> x >> t;
	if(n % x == 0){
		cout << t *  (n / x) << "\n";
	}
	else{
		cout << t * ((n/x) + 1) << "\n";
	}
	return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);

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

	int t = 1;
	// cin >> t;

	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solve();
	}

	return 0;
}

Measured memory_bytes: 3644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> vec(n, vector<int>(m));
    rep(i, n)
    {
        cin >> c[i];
        rep(j, m)
        {
            cin >> vec[i][j];
        }
    }
    int ans = inf;
    rep(s, 1 << n)
    {
        int cost = 0;
        vector<int> d(m);
        rep(i, n)
        {
            if (s >> i & 1)
            {
                cost += c[i];
                rep(j, m)
                {
                    d[j] += vec[i][j];
                }
            }
        }
        bool ok = true;
        rep(j, m)
        {
            if (d[j] < x)
            {
                ok = false;
            }
        }
        if (ok)
        {
            ans = min(ans, cost);
        }
    }
    if (ans == inf)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  int ans=mod;
  for(int i=-100; i<=100; i++){
    int sum=0;
    for(int j=0; j<N; j++){
      sum += pow(abs(a[j]-i),2);
    }
    chmin(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val T = readString()
  println(T.replace('?', 'D'))
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 41080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

int main(){
  int n;
  while(cin>>n&&n){
    int sum=0;
    for(int i=0; i<9; i++){
      int s;
      cin>>s;
      sum+=s;
    }
    cout<<n-sum<<en
  }
}



Measured memory_bytes: 3012
#include<stdio.h>
#include<math.h>

int main(void){
int n,m=0;
int a[10];
int i;
scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&a[i]);
if(a[i]%2==0)m++;
}
printf("%d",(int)(pow(3.0,(double)n)-pow(2.0,(double)m)));

    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    ll x, a, b;
    cin >> x >> a >> b;

    if(abs(x-a) < abs(x-b)){
        cout << 'A' << endl;
    }
    else{
        cout << 'B' << endl;
    }
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  for(int i=n-1; i>=0; i--){
    if(i != n-1) cout << " ";
    cout << v[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1196
import java.math.BigDecimal;
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int M = sc.nextInt();

        long ans = 0;

        if (N == M) {
            // 2 * M! * M!
            long factM = fact(M);
            ans = 2 * factM * factM;
        } else if (N + 1 == M || N == M + 1) {
            // M! * N!
            ans = fact(M) * fact(N);
        }
        System.out.println(ans % 1000000007l);
    }

    private static long fact(long n) {
        long ans = 1;
        for (long i = 1; i <= n; i++) {
            ans *= i;
            ans = ans % 1000000007l;
        }
        return ans;
    }
}

Measured memory_bytes: 22740
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

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

int main(){
  int n;cin>>n;
  map<int, int> mp;
  rep(i, n){
    int a;cin>>a;
    mp[a]++;
  }
  int cnt=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    cnt+=itr->second-1;
  }
  cout<<n-(cnt+1)/2*2<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <cctype>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	char x[205];
	cin >> x;
	int size = strlen(x);
	for (int i = size - 2; i; i -= 2) {
		if (strncmp(x, x + i / 2, i / 2) == 0) {
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}


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

using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long                           //del this if TLE or MLE
#define ll long long
#define pr pair<int,int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
//#define fow(a,b,c) for(int i=a;i<=b;i+=c)
//#define bck(a,b,c) for(int i=a;i>=b;i-=c)
#define h first
#define a second
#define loop int tests;cin>>tests;while(tests--)

const int N=2e5+5;

int f[N];

pr tree[N];

int bit[N];

void update(int x, int val)
{
	for(int i=x;i<N;i+=(i&-i))
	{
		bit[i]=max(bit[i],val);
	}
}
int get(int x)
{
	int ans=0;
	for(int i=x;i>0;i-=(i&-i))
	{
		ans=max(ans,bit[i]);
	}
	return ans;
}
signed main()
{
	int n;
	cin>>n;
	memset(bit,0,sizeof(bit));
	for(int i=1;i<=n;i++)
		cin>>tree[i].h;
	for(int i=1;i<=n;i++)
	{
		cin>>tree[i].a;
		f[i]=tree[i].a;
	}
	for(int i=1;i<=n;i++)
	{
		f[i]=max(f[i],get(tree[i].h-1)+tree[i].a);
		update(tree[i].h,f[i]);
	}
	int output=0;
	for(int i=1;i<=n;i++)
		output=max(output,f[i]);
	cout<<output<<"\n";
}


Measured memory_bytes: 6528
import math
n,d=map(int,input().split())

ans=0
x = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    x.append(array)

for i in range(n-1):
    for k in range(i+1,n):
        r=0
        for j in range(d):
            r+=(x[i][j]-x[k][j])**2
        #print(i,k,math.sqrt(r))
        if math.sqrt(r).is_integer():
            ans+=1

print(ans)



Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 30003

#define SECRET_DIGIT 3

int get_int(void) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
#else
#error
#endif
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  int num;
  sscanf(line, "%d", &num);
  return num;
}

int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int main(void) {
    char lucky_str[BUF_SIZE];
    int digits = get_int();
    get_str(lucky_str, BUF_SIZE);
    int i, j, k;
    int idx;
    char secret_key[3];

    int ans = 0;

    for(i = 0; i < 10; i++) {
        for(j = 0; j < 10; j++) {
            for(k = 0; k < 10; k++) {
                // assume that i*100+j*10+k
                secret_key[0] = i+'0';
                secret_key[1] = j+'0';
                secret_key[2] = k+'0';
                int s_idx = 0;
                for(idx = 0; idx < digits; idx++) {
                    if(secret_key[s_idx] == lucky_str[idx]) s_idx++;
                }
                if(s_idx == SECRET_DIGIT) ans++;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int read(int *a)
{
    int h,w;
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0)
        return 0;
    a[0] = h;   a[1] = w;
    return 1;
}

void printFrame(int *a)
{
    int i, j;
    for(i=0;i<a[0];i++) {
        if(i == 0 || i == a[0]-1) {
            for(j=0;j<a[1];j++)
                putchar('#');
            putchar('\n');
        }
        else {
            for(j=0;j<a[1];j++) {
                if(j == 0 || j == a[1]-1)
                    putchar('#');
                else
                    putchar('.');
            }
            putchar('\n');
        }
    }
}

int main(void)
{
    int i, idx = 0;
    int data[100][2];

    while(read(data[idx++]) != 0);

    for(i=0;i<idx-1;i++) {
        printFrame(data[i]);
        putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 572
#define mod 1000000007
#define PI acos(-1)
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=2e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline bool read(int &ret){char c=getchar();int sgn;if(c==EOF)return 0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	sgn=((c=='-')?-1:1);ret=((c=='-')?0:(c-'0'));while(c=getchar(),c>='0'&&c<='9')ret=ret*10+(c-'0');ret*=sgn;return 1;}
inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};
int st[4][2]={1,0,0,1,-1,0,0,-1};
int t,cas;
int n,m,k;
int main()
{
	int a[N];
	int sum[N];
	int ans[N];
	while(~scanf("%d",&n))
	{
		int cnt=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			sum[i]=0;
		}
		for(int i=n;i>=1;i--)
		{
			if(sum[i]%2!=a[i])
			{
				ans[cnt++]=i;
				for(int j=1;j*j<=i;j++)
				{
					if(i%j==0)
					{
						sum[j]++;
						if(j*j!=i)sum[i/j]++;
					}
				}
			}
		}
		sort(ans,ans+cnt);
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++)
		{
			printf("%d",ans[i]);
			printf(i==cnt-1?"\n":" ");
		}
	}
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = ((n)-1); i >= 0; --i)

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

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

	string pass;

	cin >> pass;
	char c = pass[0];
	for (int i = 1; i < 4; i++) {
		if (c == pass[i]) {
			cout << "Bad" << endl;
			return 0;
		}
		c = pass[i];
	}
	cout << "Good" << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		int times = 0;
		int max = Math.max(A, B);
		int output = max;
		for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		}
		System.out.println(output);	
	}
}


Measured memory_bytes: 22732
#include<iostream>
#define ll long long int
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){
		cout<<"3";
	}
	else if((s[0]=='R'&&s[1]=='R')||(s[2]=='R'&&s[1]=='R')){
		cout<<"2";
	} 
	else if(s[0]=='R'||s[1]=='R'||s[2]=='R'){
		cout<<"1";
	}
	else{
		cout<<"0";
	}
}

Measured memory_bytes: 3616
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        String O = sc.next(), E = sc.next();
                        for(int i = 0; i < O.length(); i++) {
                                System.out.print(O.charAt(i));
                                if(i < E.length()){
                                        System.out.print(E.charAt(i));
                                }
                        }
                        System.out.println("");
                }
        }
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    char s[8];
    cin >> s;
    sort(s, s+4);
	cout << ((s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) ? "Yes" : "No") << "\n";
	return 0;
}


Measured memory_bytes: 256