akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;

string f(string t){
    return t.substr(t.size()-1,1)+t.substr(0,t.size()-1);
}
int main(){
    string a,b;
    cin>>a>>b;
    string t=a;
    if(a==b){
        cout<<"Yes"<<endl;
        return 0;
    }
    do{
        t=f(t);
        if(t==b){
            cout<<"Yes"<<endl;
            return 0;
        }
    }while(t!=a);
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
/*
 * ID: ITP2_10_A
 * Problem: Bit Operation I
 */

#include <stdio.h>

void print_bits(unsigned int a)
{
    int i;
    for (i = 0; i < 32; i++) {
        printf("%d", (a & 0x80000000) == 0 ? 0 : 1);
        a <<= 1;
    }
    printf("\n");
}

int main(void)
{
    unsigned int  a;

    scanf("%d", &a);

    print_bits(a);
    print_bits(~a);
    print_bits(a << 1);
    print_bits(a >> 1);

    return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
int main(){
  int i,n,l,r,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&l,&r);
    count+=r-l+1;
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 1708
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

#define roundup(n,d) (((n) + ((d)-1)) / (d))

using namespace std;

int main(void){
    long long int h,w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
    } else {
        cout << roundup(h*w,2) << endl;
    }
    return 0;
}

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


void printAll(vector<int> A){
  rep(i,A.size()-1)cout << A[i] << " ";
  
  cout << A[A.size()-1] << endl;
}

void insertionSort(vector<int> A, int N){ // N個の要素を含む0-オリジンの配列A
  for(int i=1;i<N;i++){
    int v = A[i];
    int j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    printAll(A);
  }
}


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

  printAll(a);
  insertionSort(a,N);
  
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  while (true) {
    int n, a[1010];
    cin >> n;
    if (!n)
      break;
    REP(i, n) cin >> a[i];
    sort(a, a + n);

    int mind = INF;
    FOR(i, 1, n) {
      int diff = a[i] - a[i - 1];
      mind = min(mind, diff);
    }

    cout << mind << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const long double PI = acos(-1.0);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
int xorfunction(int num) {
	int ans = 0;
	if (num % 4 == 1) {
		ans += 1;
	}
	else if (num % 4 == 2) {
		ans += 1;
	}
	for (int i = 1; i < 40; i++) {
		//cerr << i << endl;
		if (num % (1LL<<(i + 1)) >= (1LL<<i)&&(num % (1LL<< (i + 1)))%2==0) {
			ans += (1LL << i);
		}
	}
	return ans;
}
signed main() {
	my_io();
	int a, b;
	cin >> a >> b;
	if (a == 0) {
		cout << xorfunction(b) << endl;
	}
	else {
		int a_ans = xorfunction(a - 1);
		//cerr << "a_ans " << a_ans << endl;
		int b_ans = xorfunction(b);
		//cerr << "b_ans " << b_ans << endl;
		int ans = a_ans ^ b_ans;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[200011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);


    int all = 0;
    REP (i, N) all ^= A[i];
    REP (i, N) A[i] ^= all;

    rprintf("%d", A, A+N);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main() {
  int n;
  while(cin >> n) {
    int s[12] = {0},c[12] = {0},c2[12] = {0},k,check=1;
    if(n==0)break;

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

    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
        if(c[i] == c[j]) {
          c2[i]++;
        }
      }
    }

    //ok
    k=0;//k=1;
    while(check){
      check = 0;

      int c2[10000] = {0};
      for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
          if(c[i] == c[j]) {
            c2[i]++;
          }
        }
      }
      for(int i=0;i<n;i++) {
        if(c2[i] != c[i]) {
          for(int j=0;j<n;j++) {
            c[j] = c2[j];
          }
          check = 1;
          k++;
        }
      }

    }
    cout << k << endl;
    for(int i=0;i<n-1;i++) {
      cout << c[i] << " ";
    }
    cout << c[n-1] << endl;
  }
}

Measured memory_bytes: 0
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    int N;
    cin >> N;
    if(N==1){
        cout << "Hello World" << endl;
    } else {
        int A,B;
        cin >> A >> B;
        cout << A+B << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n, w;
  cin >> n >> w;

  vector<pair<int, ll>> vw;
  vw.push_back({0, 0});
  rep(i, n) {
    int v;
    ll w;
    cin >> v >> w;
    vw.push_back({v, w});
  }

  const int v_max = 100 * n;

  vector<vector<ll>> dp(n+1, vector<ll>(v_max + 1, INFLL));
  rep(i, n+1) dp[i][0] = 0;

  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= v_max; j++) {
      chmin(dp[i][j], dp[i-1][j]);
      if (j - vw[i].first < 0) continue;
      chmin(dp[i][j], dp[i-1][j - vw[i].first] + vw[i].second);
    }
  }

  for (int v = v_max; v >= 0; v--) {
    if (dp[n][v] <= w) {
      cout << v << endl;
      return 0;
    }
  }

  cout << 0 << endl;

  return 0;
}



Measured memory_bytes: 10804
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=100005;
const int mod=1000007;
const double eps=1e-3;
struct node
{
        int data;
        int cnt;
        bool operator < (const node &s) const
        {
                        return cnt<s.cnt;
        }
}a[maxn];
int main()
{
        int temp,n;
        bool f=false;
        bool if1=false;
        bool if0=false;
        while(cin>>n)
        {
                int cnt0=0;
                int cnt2=0;
                f=false;
                if0=false;
                if1=false;
                bool exist1=false;
                for(int i=0;i<n;i++)
                {
                        scanf("%d",&a[i].data);
                        a[i].cnt=0;
                        temp=a[i].data;
                        while(temp%2==0)
                        {
                                a[i].cnt++;
                                temp>>=1;
                                //cout<<temp<<' '<<a[i].cnt<<endl;
                                if(a[i].cnt>=2) break;
                        }
                        if(a[i].cnt==0)
                        {
                                cnt0++;
                        }
                        if(a[i].cnt==2)
                        {
                                cnt2++;
                        }
                        if(a[i].cnt==1)
                        {
                                exist1=true;
                        }
                        //cout<<cnt0<<' '<<cnt2<<' '<<exist1<<endl;
                }
                //cout<<cnt0<<' '<<cnt2<<' '<<exist1<<endl;
                if((cnt2<cnt0-1)||(cnt2==cnt0-1&&exist1))
                        printf("No\n");
                else
                {
                        printf("Yes\n");
                }
        }
	//system("pause");
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] lines = sc.nextLine().split(" ");
		int height = Integer.parseInt(lines[0]);
		int width = Integer.parseInt(lines[1]);
		System.out.println((height * width) + " " + ((height * 2) + (width * 2)));
	}
}

Measured memory_bytes: 26024
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int a = Integer.parseInt(sc.next());
		if(sc.next().equals("+")) ou.println(a + Integer.parseInt(sc.next()));
		else ou.println(a - Integer.parseInt(sc.next()));
		ou.flush();
	}
}

Measured memory_bytes: 35560
// AOJ1052_OldBridges.cpp

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		vector< pair<int, int> > vp;
		for(int i=0;i<n;i++){
			int a, b; cin >> a >> b;
			vp.push_back(make_pair(b,a));
		}
		sort(vp.begin(), vp.end());
		bool ok = true;
		int sum = 0;
		for(int i=0;i<n;i++){
			sum += vp[i].second;
			if(sum > vp[i].first) ok = false;
		}
		cout << (ok ? "Yes" : "No") << endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll A,B; cin>>A>>B;
  if(B!=100){
   	cout<<B*(ll)pow(100,(double)A);
  }else{
    if(A==0) cout<<101;
    else if(A==1) cout<<10100;
    else cout<<1010000;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     ll n;cin >> n;
     vector<ll>a(n);
     for(int i = 0;i<n;i++) cin >> a[i];
     ll ans = 0;
     for(int i = 0;i<=60;i++){
        ll c0 = 0;ll c1 = 0;
        for(int j = 0;j<n;j++){
            if(a[j]&1) c1++;
            else c0++;
            a[j] /= 2;
        }
        ans += (((c0*c1)%mod)*modpow(2,i,mod))%mod;
        ans %= mod;
     }
     cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 5520
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
const int N=1e5+5;
int n,rt1,rt2,fa1[N],fa2[N],col[N];
bool dgr1[N],dgr2[N];

inline int nxi(FILE *fd=stdin){
	int x=0;
	char c;
	while(((c=fgetc(fd))>'9'||c<'0')&&c!='-');
	const bool f=(c=='-')&&(c=fgetc(fd));
	while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
	return f?-x:x;
}

bool able(){
	for(int i=1; i<=n; ++i){
		if(dgr1[i]!=dgr2[i]) return 0;
	}
	return 1;
}

namespace G{
	int cnt=1,fir[N<<1],cur[N<<1];
	bool vis[N*6];
	struct edge{
		int to,nx;
	}eg[N*6];

	inline void add(const int a,const int b){
		//printf("add: %d - %d\n",a,b);
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
		eg[++cnt]=(edge){a,fir[b]};
		fir[b]=cnt;
	}

	void dfs(const int x){
		for(int i=cur[x]; i; i=cur[x]){
			cur[x]=eg[i].nx;
			if(vis[i]||vis[i^1]) continue;
			vis[i]=1;
			dfs(eg[i].to);
		}
	}

	bool jdg(){
		for(int i=2; i<=cnt; i+=2){
			if(vis[i]==vis[i+1]) return 0;
		}
		return 1;
	}

	void paint(){
		for(int i=1; i<=n; ++i){
			for(int j=fir[i]; j; j=eg[j].nx){
				if(eg[j].to==i+n) col[i]=vis[j]?-1:1;
			}
		}
	}
}

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		fa1[i]=nxi();
		if(fa1[i]==-1) rt1=i;
		else dgr1[fa1[i]]^=1;
	}
	for(int i=1; i<=n; ++i){
		fa2[i]=nxi();
		if(fa2[i]==-1) rt2=i;
		else dgr2[fa2[i]]^=1;
	}
	if(!able()){
		puts("IMPOSSIBLE");
		return 0;
	}
	for(int i=1; i<=n; ++i){
		if(fa1[i]==-1) G::add(0,i);
		else G::add(fa1[i],i);
		if(fa2[i]==-1) G::add(0,i+n);
		else G::add(fa2[i]+n,i+n);
		if(!dgr1[i]) G::add(i,i+n);
	}
	memcpy(G::cur,G::fir,(n<<1|1)*sizeof(int));
	G::dfs(0);
	assert(G::jdg());
	G::paint();
	puts("POSSIBLE");
	for(int i=1; i<=n; ++i){
		printf("%d ",col[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 13312
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var str=(input.trim()).replace(/egg/g,"E").replace(/chicken/g,"C");
while(/EE/.test(str))str=str.replace(/EE/,"EAE");
while(/CC/.test(str))str=str.replace(/CC/,"CAC");
var ary=str.split("A");
var ans="";
ary.forEach(function(v){
   if(ans.length<v.length)ans=v;
});
console.log((ans.slice(-1)=="E")?"egg":"chicken");

Measured memory_bytes: 17084
#include<bits/stdc++.h>
using namespace std;
long long n,k;
long long s;
long long a[2005];
long long b[2005];
long long mod=1e9+7;
long long ny=5e8+4;
int main()
{
	cin>>n>>k;
	long long t=(((k*(k-1))%mod)*ny)%mod;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	for(int i=1;i<=n;i++)
	{
		long long tot1=0;
		for(int j=i+1;j<=n;j++)
			if(a[i]>a[j])
				tot1++;
		long long tot2=0;
		for(int j=1;j<=n;j++)
		{
			if(a[i]>a[j])
				tot2++;
		}
		s=(s+(tot1*k)%mod+(tot2*t)%mod)%mod;
	}
		
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!.split(" ")[0]
    val sArray = s.toCharArray()
    val length = s.length
    var count = 0
    for (i in 0 until length / 2) {
        if (sArray[i] != sArray[length - i - 1]) count++
    }
    println(count)
}

Measured memory_bytes: 37804
#include "bits/stdc++.h"
using namespace std;

long long min4(long long &w,long long &x,long long &y,long long &z) {
	return min(w,min(x,min(y,z)));
}

long long max4(long long &w, long long &x, long long &y, long long &z) {
	return max(w, max(x, max(y, z)));
}

int main() {
	int N;
	cin >> N;
	vector<long long>A(N);
	vector<long long>Sum(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		Sum[i + 1] = Sum[i] + A[i];
	}
	int l = 0;
	int r = 2;
	long long ans = 1e18;
	for (int c = 1; c <= N - 3; ++c) {
		{
			long long absl = 1e18;
			for (; l < c; ++l) {
				long long x = Sum[l + 1] - Sum[0];
				long long y = Sum[c + 1] - Sum[l + 1];
				if (absl >  abs(x-y)) {
					absl = abs(x-y);
				}
				else {
					break;
				}
			}
		}
		{
			long long absr = 1e18;
			for (; r < N-1; ++r) {
				long long x = Sum[r + 1] - Sum[c + 1];
				long long y = Sum[N] - Sum[r + 1];
				if (absr > abs(x - y)) {
					absr = abs(x - y);
				}
				else {
					break;
				}
			}
		}
		l--;
		r--;
		long long ll = Sum[l + 1] - Sum[0];
		long long lr = Sum[c + 1] - Sum[l + 1];
		long long rl = Sum[r + 1] - Sum[c + 1];
		long long rr = Sum[N] - Sum[r + 1];
		//cout << l << "_" << c << "_" << r << endl;
		//cout << ll<<"_"<<lr<<"_"<<rl<<"_"<<rr<< endl;
		ans = min(ans,max4(ll,lr,rl,rr)-min4(ll,lr,rl,rr));
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 6436
import math

def is_prime(n):
  if n==1:return False
  
  for k in range(2, int(math.sqrt(n))+1):
    if n%k==0:
      return False
    
  return True

X = int(input())
ans=X
while(is_prime(ans)==False):
  ans+=1
print(ans)

Measured memory_bytes: 9116
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

// ???????¢??????¨??????
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n;i++) cin >> a[i];

	vector<ll> dp(n, INF);
	for (int i = 0; i < n;i++) {
		*lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
	}
	ll ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4312
#include <cstdio>
#include <cstring>
#include <algorithm>

int n;
int w[233333];

int q[233333][2], t;
bool check(int a, int i = 1, int ls = 0){
	q[t = 1][0] = 0, q[t][1] = 0;
	q[++t][0] = 1, q[t][1] = 1;
	(w[1] == 1) && (i++);
	for(i; i <= n; i++){
		if(q[1][1]) return false;
		ls = w[i];
		if(q[t][0] < ls) q[++t][0] = ls, q[t][1] = 1;
		else{
			while(t){
				if(q[t][0] == ls){
					if(q[t][1] < a) {q[t][1]++; break;}
					else t--, ls--;
				}
				else if(q[t][0] < ls){
					q[++t][0] = ls, q[t][1] = 2;
					if(a == 1) return false;
					break;
				}
				else t--;
			}
			if(q[t][0] != w[i]) q[++t][0] = w[i], q[t][1] = 1;
		}
	}
	if(q[1][1]) return false;
	return true;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &w[i]);
	int l = 1, r = n, mid;
	while(l < r){
		mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	return !printf("%d\n", r);
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

vector<pair<ll, int> > vv[210];
int n, m;
ll a[5100];
ll b[5100][210];
ll ad[5100];
ll dp[5100];

void add(int l, int r, ll d) {
	ad[l] += d;
	ad[r] -= d;
}
ll ans;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i < n; ++i)
		scanf("%lld", a + i);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			scanf("%lld", &b[i][j]);
	for (int i = 0; i < n; ++i) {
		add(0, i, -a[i]);
		for (int j = 0; j < m; ++j) {
			int lst = i;
			while (!vv[j].empty() && vv[j].back().first < b[i][j]) {
				add(vv[j].back().second, lst, -vv[j].back().first);
				lst = vv[j].back().second;
				vv[j].pop_back();
			}
			add(lst, i + 1, b[i][j]);
			vv[j].push_back(make_pair(b[i][j], lst));
		}
		ll now = 0;
		for (int j = 0; j <= i + 1; ++j)
			now += ad[j], dp[j] += now, ad[j] = 0;
		for (int j = 0; j <= i; ++j) {
			ans = max(ans, dp[j]);
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 8704
function main(input){
  const lines = input.split('\n');
  const N  = parseInt(lines[0]);
  const A  = lines[1].split(' ').map(x => parseInt(x));

  var result = 0;
  for(var i=0;i<A.length;i++){
    result += A[i]-1;
  }
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

using namespace std;

int main()
{
    string s;
    cin >> s;
    string t;
    cin >> t;

    int ls = s.size();
    int lt = t.size();

    int i;
    int a = 0;
    for(i=0; i<ls ; i++)
    {
        if(s[i] == t[i])
        {
            a++ ;
        }
    }

    if((lt - ls)==1 && a == ls)
    {
        cout << "Yes\n" ;
    }
    else
    {
        cout << "No\n";
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int h0, h1, h2;
	cin >> h1 >> h2;
	int c0 = 0;
	int c1 = abs(h2 - h1);
	for (int i = 2; i < n; ++i) {
		tie(h0, h1) = tie(h1, h2);
		cin >> h2;
		c0 = min(abs(h0 - h2) + c0, abs(h2 - h1) + c1); swap(c1, c0);
	}
	cout << c1;
}

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

int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  if (2*n <= m) {
    ans += n;
    m -= 2*n;
    ans += m/4;
  }
  else {
    ans += m/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 5002
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;

int a[101];
int main(){
	int n, ans = 0, tmp = 0;
	scanf("%d", &n);
	rep(i,n)scanf("%d", &a[i]);
	sort(a, a+n);
	for(int i = 0;i < n;i++){
		if(tmp != a[i]){
			tmp = a[i];
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}





Measured memory_bytes: 256
#include<iostream>

int main()
{
  int a,b;
  std::cin >> a >> b;
  if (a > b){
    std::cout << "a > b" << std::endl;
  }else if(a < b){
    std::cout << "a < b" << std::endl;
  }else{
     std::cout << "a == b" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3080
n = int(input())
a = list(map(int, input().split()))

memo = [0 for i in range(n)]
if n % 2 == 1:
    for i in range(n):
        memo[a[i]] += 1
    flag = 1
    if memo[0] != 1:
        print(0)
        exit()
    else:
        for i in range(1, n):
            if i % 2 == 1:
                if memo[i] != 0:
                    flag = 0
            else:
                if memo[i] != 2:
                    flag = 0
    if flag == 0:
        print(0)
    else:
        print(2**((n-1)//2) % (10**9+7))
else:
    for i in range(n):
        memo[a[i]] += 1
    flag = 1
    for i in range(n):
        if i % 2 == 0:
            if memo[i] != 0:
                flag = 0
        else:
            if memo[i] != 2:
                flag = 0
    if flag == 0:
        print(0)
    else:
        print(2**(n//2) % (10**9+7))


Measured memory_bytes: 14324
#include<iostream>
#include<vector>
#include<cmath>
#include<complex>
#include<utility>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
typedef complex<double> P;

const double EPS=1e-10;

struct C { P p; double r; C(const P& p, double r) : p(p), r(r) {} C(){} };
double distanceLP(const pair<P,P> &l, const P& p) {
	P p1=l.first,p2=l.second;
	double a=p2.imag()-p1.imag(), b=p1.real()-p2.real();
	double c=p1.imag()*p2.real()-p1.real()*p2.imag();
	return abs(a*p.real()+b*p.imag()+c)/sqrt(a*a+b*b);
}
pair<P, P> tangentpoints(P p, P c, double r) {
	double d2 = norm(p-c);
	double x = sqrt(d2-r*r);
	if(x<EPS) return mp(p+(c-p)*P(0, 1), p-(c-p)*P(0, 1));
	P h(c+(p-c)*r*r/d2), w((p-c)*P(0, 1)*x*r/d2);
	return mp(h+w, h-w);
}
vector<pair<P,P> > commonTangentLines(const C &c1,const C &c2)
{
	vector<pair<P,P> > ret;
	P dir=c2.p-c1.p;
	if(abs(abs(dir)-c1.r-c2.r)<EPS)//ñ~ªÚ·é
	{
		P id=(c1.p*c2.r+c2.p*c1.r)/(c1.r+c2.r);
		ret.pb(mp(id,id+dir*P(0,1))); ret.pb(mp(id,id-dir*P(0,1)));
	}
	if(c1.r+c2.r<abs(dir)+EPS)//£êÄ¢éiàÚüj
	{
		P id=(c1.p*c2.r+c2.p*c1.r)/(c1.r+c2.r);
		pair<P,P> TP=tangentpoints(id,c1.p,c1.r);
		ret.pb(mp(TP.first,id)); ret.pb(mp(TP.second,id));
	}
	if(abs(c1.r-c2.r)<EPS)//¼a¯¶
	{
		P normal=dir*P(0,1)/abs(dir);
		ret.pb(mp(c1.p+normal*c1.r,c2.p+normal*c2.r));
		ret.pb(mp(c1.p-normal*c1.r,c2.p-normal*c2.r));
	}
	else//¼aá¤iOÚüj
	{
		P od=c1.p+dir*c1.r/(c1.r-c2.r);
		pair<P,P> TP=tangentpoints(od,c1.p,c1.r);
		ret.pb(mp(TP.first,od)); ret.pb(mp(TP.second,od));
	}
	return ret;
}

int n;
C C[100];

int main()
{
	while(cin>>n,n)
	{
		rep(i,n)
		{
			int x,y,r,m; cin>>x>>y>>r>>m;
			C[i*2].p=C[i*2+1].p=P(x,y);
			C[i*2].r=r; C[i*2+1].r=r+m;
		}
		int ans=1;
		rep(i,2*n)rep(j,2*n)
		{
			vector<pair<P,P> > CTL=commonTangentLines(C[i],C[j]);
			rep(k,CTL.size())
			{
				int cnt=0;
				rep(l,2*n)
				{
					if(l%2==0&&distanceLP(CTL[k],C[l].p)+EPS<C[l].r)cnt--;
					if(l%2==1&&distanceLP(CTL[k],C[l].p)<C[l].r+EPS)cnt++;
				}
				ans=max(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 948
import math
lists = list(map(int,input().split()))
A = int(lists[0])
B = int(lists[1])
H = int(lists[2])
M = int(lists[3])
T = 60 * H + M
a = T / 2
b = 6 * M
c = b - a

if c < -180:
  c += 360
elif c > 180:
  c = 360 - c
else:
  c = c
  
C = math.cos(math.radians(c))
ll = (A * A) + (B * B) - (2 * A * B * C)
l = math.sqrt(ll)
print(l)

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

using namespace std;

int main(int, char**) {
        int n, k;
        cin >> n >> k;
        vector<int> cnt(n, 1);
        for (int i=0; i<k; i++) {
                int d;
                cin >> d;
                for (int j=0; j<d; j++) {
                        int a;
                        cin >> a;
                        a--;
                        cnt[a] = 0;
                }
        }
        int count = 0;
        for (int i=0; i<n; i++) {
                count += cnt[i];
        }
        cout << count << endl;
        return 0;
}


Measured memory_bytes: 3628
use proconio::{fastout, input};
use std::cmp::max;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        R: usize,
        C: usize,
        K: usize,
        Item: [(usize, usize, usize); K],
    }

    let mut score  = vec![vec![0 as usize; R + 1]; C + 1];

    for item in Item {
        score[item.1 - 1][item.0 - 1] = item.2;
    }

    let mut dp = vec![vec![vec![0 as usize; 4]; R + 1]; C + 1];

    for y in 0..R {
        for x in 0..C {
            // 取らずに移動した場合
            for k in 0..4 {
                dp[x + 1][y][k] = max(dp[x + 1][y][k], dp[x][y][k]);
                dp[x][y + 1][0] = max(dp[x][y + 1][0], dp[x][y][k]);
            }

            // 取ってから移動した場合
            for k in 0..3 {
                dp[x + 1][y][k + 1] = max(dp[x + 1][y][k + 1], dp[x][y][k] + score[x][y]);
                dp[x][y + 1][0] = max(dp[x][y + 1][0], dp[x][y][k] + score[x][y]);
            }
        }
    }

    // println!("{:?}", dp[C - 1][R].iter().max());
    println!("{:?}", dp[C][R - 1].iter().max().unwrap());
}


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

using namespace std;

#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

LL w,h,n,mat[105][105];

int main()
{
    FIO;
    cin>>w>>h>>n;
    while(n--){
        LL x,y,a;
        cin>>x>>y>>a;
        if(a==1) rep(i,1,x) rep(j,1,h) mat[i][j]=1;
        else if(a==2) rep(i,x+1,w) rep(j,1,h) mat[i][j]=1;
        else if(a==3) rep(i,1,w) rep(j,1,y) mat[i][j]=1;
        else rep(i,1,w) rep(j,y+1,h) mat[i][j]=1;
    }
    LL ans=0;
    rep(i,1,w) rep(j,1,h) ans+=mat[i][j];
    cout<<w*h-ans<<endl;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

if N >= M:
    print(0)
else:
    dists = [X[i+1]-X[i] for i in range(M-1)]
    if N == 1:
        print( sum(dists) )
    else:
        print( sum(sorted(dists)[:-(N-1)]) )


Measured memory_bytes: 13968
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int tate,yoko,i,j;
	while(1){
	cin>>tate>>yoko;
	if(tate==0||yoko==0){
		break;
	}
		for(j=0;j<yoko;j++){
			cout<<"#";			
		}cout<<endl;
			for(j=0;j<tate-2;j++){
				cout<<"#";
				for(i=0;i<yoko-2;i++){
					cout<<".";
				}cout<<"#"<<endl;
			}for(j=0;j<yoko;j++){
			cout<<"#";			
		}cout<<endl;cout<<endl;
	}
  return 0;
}

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

const int INF = 1001001001;

int main(){
 int D,N;
 cin>>D>>N;
 int count=0;
 for(int i=1;;i++){
   int counti=0;int k=i;
   while(k!=0){if(k%100!=0){break;}
   else{k/=100;counti++;}
 }
 if(D==counti){
   count++;
   if(count==N){
     cout<<i<<endl;
     return 0;
   }
 }
 }
  
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
#define mod 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main(){
    vector<int> v;
    int a[5],k;
    rep(i,5){
        cin>>a[i];
        v.push_back(a[i]);
    }
    cin>>k;
    sort(v.begin(),v.end());
    if(abs(v[0]-v[4])<=k){
        cout<<"Yay!"<<endl;
    }
    else cout<<":("<<endl;
    return 0;
}

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

int penalty[100001];
bool ac[100001];

int main(void) {
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		penalty[i] = 0;
		ac[i] = false;
	}
	for (int i = 0; i < M; i++) {
		int p;
		string S;
		cin >> p >> S;
		if (!ac[p]) {
			if (S=="WA") penalty[p]++;
			if (S=="AC") {
				ac[p] = true;
			}
		}
	}
	int ac_cnt = 0;
	int pn_cnt = 0;
	for (int i = 1; i <= N; i++) {
		if (ac[i]) {
			ac_cnt++;
			pn_cnt += penalty[i];
		}
	}
	cout << ac_cnt << " " << pn_cnt << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  long int ac = a * c;
  long int ad = a * d;
  long int bc = b * c;
  long int bd = b * d;
  long int result = ac;
  if (result < ac) {
    result = ac;
  }
  if (result < ad) {
    result = ad;
  }
  if (result < bc) {
    result = bc;
  }
  if (result < bd) {
    result = bd;
  }

  cout << result << endl;
}

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

int main(){
	int n ,t, tt;
	cin>>tt;
	for(int j = 0; j < tt; j++){
		int cu = 0, cd = 0, m = 0;
		cin>>n;
		cin>>m;
		for(int i = 1; i < n; i++){
			cin>>t;
			
			if(t - m > cu) cu = t - m;
			if(m - t > cd) cd = m - t;
			m = t;
		}
		cout<<cu<<" "<<cd<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const vector<int> dy = {-1,0,1,0};
const vector<int> dx = {0,1,0,-1};

int main() {
    int N,W; scanf("%d %d\n",&N,&W);
    vector<int> weight(N);
    rep(i,N) scanf("%d",&weight[i]);
    sort(weight.begin(),weight.end());

    ll ans = 0;
    rep(i,N){
        vector<int> dp(W + 1,0);
        dp[0] = 1;
        for (int j = i + 1;j < N;j++){
            for (int k = W;k >= weight[j];k --){
                dp[k] += dp[k - weight[j]];
                dp[k] %= MOD;
            }
        }
        if (i < N - 1) {
            for (int j = max(W - weight[i] + 1,0);j <= W;j++){
                ans += dp[j];
                ans %= MOD;
            }
        }
        else {
            rep(j,W + 1){
                ans += dp[j];
                ans %= MOD;
            }
        }
        /*
        printf("dp");
        rep(i,W + 1) printf("  %ld",dp[i]);
        printf("\n");
        printf("%d\n",W);
        */
        W -= weight[i];
        if (W < 0) break;
    }
    printf("%ld\n",ans);
}


Measured memory_bytes: 3308
N=int(input())
A=list(map(int,input().split()))
l=0 #[l r)
r=1
buf=0
cnt=0
ans=[]
su=0
i=0
length=0
while r<=N:
    if buf+A[r-1]==buf^A[r-1]:
        length=length+1
        buf=buf^A[r-1]
        r=r+1
    else:
        buf=buf^A[l]
        l=l+1
        cnt=0
        su=su+length
        length=length-1
        if r==l:
            r=r+1
    #print(buf,cnt,su)
    #input()
#print(l,r)
#su=su+cnt
#for i in range(len(ans)):
#    cnt=cnt+(ans[i]*(ans[i]+1))//2
print(su+((r-l-1)*(r-l))//2)
#1+2+1+1

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int A, B, M;
   cin>>A>>B>>M;
   int a[100000], b[100000];
   rep(i, A) cin>>a[i];
   rep(i, B) cin>>b[i];
   int mn=INT_MAX;
   rep(i, M){
      int x, y, c;
      cin>>x>>y>>c; x--; y--;
      mn=min(mn, a[x]+b[y]-c);
   }
   int mna=INT_MAX, mnb=INT_MAX;
   rep(i, A) mna=min(mna, a[i]);
   rep(i, B) mnb=min(mnb, b[i]);
   mn=min(mn, mna+mnb);
   cout << mn << endl;
   return 0;
}


Measured memory_bytes: 4360
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  rep(i, N){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  vector<vector<bool>> color(W, vector<bool>(H, true));
  rep(i, N){
    if(a.at(i) == 1){
      rep(j, x.at(i)){
        rep(k, H){
          color.at(j).at(k) = false;
        }
      }
    }
    else if(a.at(i) == 2){
      rep2(j, x.at(i), W){
        rep(k, H){
          color.at(j).at(k) = false;
        }
      }
    }
    else if(a.at(i) == 3){
      rep(j, W){
        rep(k, y.at(i)){
          color.at(j).at(k) = false;
        }
      }
    }
    else{
      rep(j, W){
        rep2(k, y.at(i), H){
          color.at(j).at(k) = false;
        }
      }
    }
  }
  int cnt = 0;
  rep(i, W){
    rep(j, H){
      if(color.at(i).at(j)){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    ans = 0
    for l in range(K+1):
        for r in range(K+1-l):
            if l + r > N:
                continue
            D = K - l - r
            S = []
            now = 0
            for i in range(l):
                now += V[i]
                S.append(V[i])
            for j in range(N-r,N):
                now += V[j]
                S.append(V[j])

            sort_S = sorted(S)
            for d in range(min(D,len(S))):
                if sort_S[d] < 0:
                    now += abs(sort_S[d])

            ans = max(ans, now)

    print(ans)
            

main()

Measured memory_bytes: 41840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String str = br.readLine();
	    StringTokenizer st = new StringTokenizer(str, " ");

		  int a  = Integer.parseInt(st.nextToken());
		  int b  = Integer.parseInt(st.nextToken());

		  if(a < b) {
			  System.out.println("a < b");
		  }else if (a > b){
			  System.out.println("a > b");
		  }else if (a == b) {
			  System.out.println("a == b");
		  }


	}

}

Measured memory_bytes: 24260
s = input()
x = s.count('R')
if(x == 0):
  print(0)
elif(x == 1):
  print(1)
elif(x == 3):
  print(3)
else:
  if(s[0] == 'R'):
    if(s[1] == 'R'):
      print(2)
    else:
      print(1)
  else:
    print(2)

Measured memory_bytes: 9060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException  {
		
		BufferedReader input = new BufferedReader( new InputStreamReader (System.in));
		String x = input.readLine();
		
		int int_x = Integer.parseInt(x);
		
		if(int_x < 1200)
			System.out.println("ABC");
		else
			System.out.println("ARC");
		
		

	}

}

Measured memory_bytes: 8148
s = input()

ans1 = 0
ans2 = 0

for i in range(len(s)):
  if i%2==0 and s[i]=="0":
    ans1 += 1
  if i%2==1 and s[i]=="1":
    ans1 += 1
  if i%2==0 and s[i]=="1":
    ans2 += 1
  if i%2==1 and s[i]=="0":
    ans2 += 1

print(min(ans1, ans2))

Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
#include<sstream>
using namespace std;
int main()
{
    string n;
    cin>>n;

    int sum=0, len= n.size();

    for(int i=0;i<len;i++)
        sum+=(n[i]-48);

    if(sum%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3368
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

N = int(input())

sum1 = 0
sum2 = 0
sum3 = 0

for a in range(1,N+1):
  for b in range(a+1, N+1):
    for c in range(b+1, N+1):
      sum1 += gcd(a,b,c)
      
for a in range(1,N+1):
  for b in range(a+1, N+1):
    sum2 += gcd(a,b)
    
sum3 = N*(N+1)/2

print(int(sum1*6+sum2*6+sum3))

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

int main()
{
    char s1[200001], s2[200001];
    int ln, i, cnt=0;
    cin>>s1>>s2;
    ln = strlen(s1);
    for(i=0; i<ln; i++){
        s1[i]= tolower(s1[i]);
        s2[i]= tolower(s2[i]);
    }
    for(i=0; i<ln; i++){
        if(s1[i]!=s2[i]){
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 4052
use whiteread::parse_line;

fn main() {
    let (h, _): (usize, usize) = parse_line().unwrap();
    let mut v: Vec<String> = vec![];
    for _ in 0..h {
        v.push(parse_line().unwrap()); 
    }

    for s in v {
        println!("{}\n{}", s, s);
    }
}


Measured memory_bytes: 2176
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		int n = sc.nextInt();


		List list = new ArrayList<Integer>();

		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {

				list.add(i*j);

			}

		}

		if(list.indexOf(n)!=-1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 23764
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<unsigned long long>a(n, 0);
	for (int i = 0; i < n; i++)cin >> a[i];
	int even = 0, odd = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0)even++;
		else odd++;
	}
	unsigned long long sum = 0;
	//sum = even*(unsigned long long)pow(3, n - 1) + odd*(unsigned long long)pow(2, even + 1);
	int feven = 0; int  fodd = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2== 0) {
			sum += (unsigned long long)pow(3, n - 1 - i)* (unsigned long long)pow(2, feven);
			feven++;
		}
		else {
			sum += 2*(unsigned long long)pow(3, n - 1 - i)* (unsigned long long)pow(2,  feven);
		}
	}
	cout << sum;
	return 0;
}





Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
using namespace std;

int a[501][501];
int b[501][501];
signed main() {
	int sum = 0;
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			b[i][j] = a[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			for (int j = m - 1; j > 0; j--) {
				if (a[i][j] & 1) {
					a[i][j - 1]++;
					sum++;
				}
			}
			if ((a[i][0] & 1) && i + 1 != n) {
				sum++;
				a[i + 1][0]++;
			}
		}
		else {
			for (int j = 0; j < m - 1; j++) {
				if (a[i][j] & 1) {
					a[i][j + 1]++;
					sum++;
				}
			}
			if ((a[i][m - 1] & 1) && i + 1 != n) {
				sum++;
				a[i + 1][m - 1]++;
			}
		}
	}
	cout << sum << endl;
#define a b
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			for (int j = m - 1; j > 0; j--) {
				if (a[i][j] & 1) {
					a[i][j - 1]++;
					cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j << endl;
				}
			}
			if ((a[i][0] & 1) && i + 1 != n) {
				cout << i + 1 << " " << 1 << " " << i + 2 << " " << 1 << endl;
				a[i + 1][0]++;
			}
		}
		else {
			for (int j = 0; j < m - 1; j++) {
				if (a[i][j] & 1) {
					a[i][j + 1]++;
					cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl;
				}
			}
			if ((a[i][m - 1] & 1) && i + 1 != n) {
				cout << i + 1 << " " << m << " " << i + 2 << " " << m << endl;
				a[i + 1][m - 1]++;
			}
		}
	}
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <cstring>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <functional>
#include <stack>
using namespace std;
typedef long long LL;
const int MAXN = 2e5 + 5;
const LL INF = (LL(1) << 60);
LL Ne[MAXN], NO[MAXN];
LL z = 0;
LL p1 = 0, p2 = 0;
LL num1 = 0, num2 = 0;
inline int check(LL x,LL K)
{
    LL cnt  = 0;
    for (int i=1;i<=p1;i++)
    {
        cnt += max(LL(0), LL(upper_bound(Ne + i, Ne + p1 + 1, x / Ne[i]) - Ne - i - 1));
    }
    
    for (int i=1;i<=p2;i++)
    {
        cnt += max(LL(0), LL(upper_bound(NO + i, NO + p2 + 1, x / NO[i]) - NO - i - 1));
    }
    // cout<<"x is lll    "<<x<<"    cnt is hhh     "<<(cnt+num1+num2)<<endl;
    return cnt < K;
}
inline LL solve(LL L,LL R,LL K)
{
    while(L<=R)
    {
        LL mid = (L + R) >> 1;
        if(check(mid,K))
            L = mid + 1;
        else R = mid - 1;
    }
    return L;
}
inline int check2(LL x,LL K)
{
    LL cnt  = 0;
    for (int i=1;i<=p2;i++)
    {
        cnt += p1 + 1 - LL(upper_bound(Ne + 1, Ne + p1 + 1, x / NO[i]) - Ne );
    }
    return cnt >= K;
}
inline LL solve2(LL L,LL R,LL K)
{
    while(L<=R)
    {
        LL mid = (L + R) >> 1;
        if(check2(mid,K))
            L = mid + 1;
        else R = mid - 1;
    }
    return (-L);
}
int main()
{
    int N;LL K;
    scanf("%d %lld", &N, &K);
    LL tmp;
    for (int i = 1; i <= N; i++)
    {
        scanf("%lld", &tmp);
        if (tmp > 0)
            NO[++p2] = tmp;
        else if (tmp < 0)
        {
            Ne[++p1] = tmp;
        }
        else
        {
            z++;
        }
    }
    sort(Ne + 1,Ne + p1+1,[&](LL a,LL b){return a>b;});
    sort(NO + 1,NO + p2+1);
    LL Ans;
    num1 = p1 * p2, num2 = z * (z - 1) / 2 + z * (p1 + p2);
    if (K <= num1)
    {
        for(int i=1;i<=p1;i++)
        {
            Ne[i] = -Ne[i];
            // cout<<Ne[i]<<'\n';
        }
        // cout<<" Wow num1 "<<num1<<endl;
        LL L = -INF;
        LL R = INF;
        // cout<<"L is "<<L<<" R is "<<R<<" K is "<<K<<endl;
        // cout<<"L is "<<L<<"  R is "<<R<<'\n';
        Ans = solve2(L,R,K);
    }else if (K<=num1+num2)
    {
        Ans = 0;
    }else
    {
        for(int i=1;i<=p1;i++)
        {
            Ne[i] = -Ne[i];
            // cout<<Ne[i]<<'\n';
        }
        K-=(num1+num2);
        LL L = -INF;
        LL R = INF;
        // cout<<"L is "<<L<<"  R is "<<R<<'\n';
        Ans = solve(L,R,K);
    }
    // cout<<"to check is "<<check(Ans,K)<<'\n';
    cout<<Ans;
    // cout<<"the check is "<<check(448283280358331064,413)<<endl;
    
}
//448283280358331064
//357421520469076008

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

int main(){
    
    int N;
    string S;

    cin >> N;
    cin >> S;

    
    int count = 0;

    int s_count[N];
    int c_count[N];

    for(int i=0;i<S.size();i++){
        if(i==0){
            if(S[i]=='#'){
                s_count[i] = 1;
                c_count[i] = 0;
            }else{
                s_count[i] = 0;
                c_count[i] = 1;
            }    
        }else{
            if(S[i]=='#'){
                s_count[i] = s_count[i-1]+1;
                c_count[i] = c_count[i-1];
            }else{
                s_count[i] = s_count[i-1];
                c_count[i] = c_count[i-1]+1;
            }
        }
        
    }
    int ans = min(s_count[N-1],c_count[N-1]);
    for(int i=0;i<S.size();i++){
        ans = min(ans,s_count[i]+(c_count[N-1]-c_count[i]));
    }
    cout << ans << endl;
    /*
    for(int i=S.size()-1;i>=0;i--){
        char c = S[i];
        if(c=='.') count += 1;

        if(c=='#'){
            if(s_count[i]<=count){
                ans += s_count[i];
                cout << ans << endl;
                return 0;
            }

            
            ans += count;
            count = 0;
        }
    }

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


Measured memory_bytes: 2180
#include<stdio.h>
main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int i;
		char aa[100009];
		getchar();
		for(i=0;i<n;i++)
		{
			scanf("%c",&aa[i]);
		}
		int num=1;
		for(i=0;i<n-1;i++)
		{
			if(aa[i]!=aa[i+1])
			{
				num++;
			}
		}
		printf("%d\n",num);
	}
}

Measured memory_bytes: 256