akhauriyash/Code-Regression huggingface dataset:
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,sum,b[N],q,p;
pa z[N];
struct xx{
	int l,r,min;
}t[N*4];
void build(int x,int l,int r){
	t[x].l=l;t[x].r=r;t[x].min=inf;
	if (l==r) return;
	int mid=(t[x].l+t[x].r)>>1;
	build(x*2,l,mid);build(x*2+1,mid+1,r);
}
void change(int x,int k,int p){
	if (t[x].l==t[x].r){
		t[x].min=min(t[x].min,p);return;
	}
	int mid=(t[x].l+t[x].r)>>1;
	if (k<=mid) change(x*2,k,p);
	else change(x*2+1,k,p);
	t[x].min=min(t[x*2].min,t[x*2+1].min);
}
int query(int x,int l,int r){
	if (l==0) return 0;
	if (t[x].l==l&&t[x].r==r) return t[x].min;
	int mid=(t[x].l+t[x].r)>>1;
	if (r<=mid) return query(x*2,l,r);
	else if (l>mid) return query(x*2+1,l,r);
	else return min(query(x*2,l,mid),query(x*2+1,mid+1,r));
}
bool cmp(pa a,pa b){
	return (a.fi==b.fi)?a.se>b.se:a.fi<b.fi;
}
signed main(){
	n=read();
	F(i,1,n) b[i]=read(),sum+=(b[i]==0);
	q=read();F(i,1,q) z[i].fi=read(),z[i].se=read();
	sort(z+1,z+q+1,cmp);build(1,1,n);p=1;
	F(i,1,n){
		for (;z[p].fi==i;p++) change(1,z[p].se,query(1,z[p].fi-1,z[p].se));
		change(1,i,query(1,i-1,i-1)+((b[i]==0)?-1:1));
	}
	wrn(sum+query(1,n,n));
	return 0;
}

Measured memory_bytes: 14720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N,K,C;
  cin>>N>>K>>C;
  string S;
  cin>>S;

  vector<int> left(N+1,0),right(N+1,0);
  int ma=0;
  for(int i=0;i<N;i++){
    if(i-C-1>=0) chmax(ma,left[i-C-1]);
    if(i>0) chmax(left[i],left[i-1]);
    if(S[i]=='o') chmax(left[i],ma+1);
  }
  ma=0;
  for(int i=N-1;i>=0;i--){
    if(i+C+1<N) chmax(ma,right[i+C+1]);
    chmax(right[i],right[i+1]);
    if(S[i]=='o') chmax(right[i],ma+1);
  }

  if(C==0){
    int s=0;
    rep(i,N) if(S[i]=='o') s++;
    if(s==K){
      rep(i,N) if(S[i]=='o') cout<<i+1<<"\n";
    }
    return 0;
  }

  vector<int> num(N+2*(C+2),0);
  for(int i=-C;i<=N+C;i++){
    int l=0,r=0;
    if(i>=0&&i<N) l=left[i];
    if(i+C+1<N&&i+C+1>=0) r=right[i+C+1];
    num[i+C]=l+r;
  }

  vector<int> ans;
  set<pair<int,int>> se;
  for(int i=0;i<C;i++) se.insert(mkp(-num[i],i));
  for(int i=0;i<N;i++){
    auto itr=se.begin();
    int val=-(*itr).first;
    if(val<K&&S[i]=='o') ans.push_back(i+1);

    se.erase(mkp(-num[i],i));
    se.insert(mkp(-num[i+C],i+C));
  }

  for(auto n:ans) cout<<n<<"\n";

  return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
int nums[200001];
int psa[200002];
int m=(int)(1e9+7);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll allsum=0, ans=0;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>nums[i];
        if(i!=0) allsum+=nums[i];
    }
    for(int i=0;i<n-1;++i){
        ans=ans+(((nums[i]%m) * (allsum%m)) %m);
        allsum-=nums[i+1];
    }
    cout<<ans%m<<endl;

}

Measured memory_bytes: 4392
#include<bits/stdc++.h>
#define LL long long
#define db long double

using namespace std;
const int N=(1<<20)+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
LL ans;
struct node
{
    int a,b,i;
    bool operator < (const node &bb) const {return 1ll*b*bb.a>1ll*a*bb.b;}
}a[N];
priority_queue<node> hp;
int n,fa[N],ff[N];
int findf(int x){return ff[x]==x?x:ff[x]=findf(ff[x]);}

int main()
{
    n=rd();
    for(int i=2;i<=n;++i) fa[i]=rd();
    for(int i=1;i<=n;++i)
	ff[i]=i,hp.push(a[i]=((rd()&1)?(node){0,1,i}:(node){1,0,i}));
    for(int h=1;h<=n;++h)
    {
	int x=hp.top().i,na=hp.top().a,nb=hp.top().b;
	hp.pop();
	if(na<a[x].a||nb<a[x].b){--h;continue;}
	int fz=findf(fa[x]);
	ans+=1ll*a[fz].b*a[x].a,a[fz].a+=a[x].a,a[fz].b+=a[x].b,ff[findf(x)]=fz;
	if(fz) hp.push(a[fz]);
    }
    printf("%lld\n",ans);
    return 0;
}
 


Measured memory_bytes: 10352
N, M = map(int, input().split())

if N % 2 == 0:
	N -= 1

H = N // 2
if H % 2 == 1:
	H += 1

m = 0
i = 1
while m < M:
	print(i, H - i + 1)
	i += 1
	m += 1
	if i >= H - i + 1:
		break

i = 1
while m < M:
	print(H + i, N + 1 - i)
	i += 1
	m += 1


Measured memory_bytes: 9276
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


enum lim = 24 * 3600 + 1;

void main() {
    while (true) {
        int n;
        scan(n);
        if (!n) return;
        auto c = new int[](lim);
        foreach (i ; 0 .. n) {
            string s, t;
            scan(s, t);
            auto l = toSec(s);
            auto r = toSec(t);
            c[l]++;
            c[r]--;
        }
        foreach (i ; 1 .. lim) {
            c[i] += c[i-1];
        }
        auto ans = c.reduce!max;
        writeln(ans);
    }
}

int toSec(string hms) {
    int res;
    res += hms[0 .. 2].to!int * 3600;
    res += hms[3 .. 5].to!int * 60;
    res += hms[6 .. 8].to!int;
    return res;
}

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

using namespace std;

const int N=1e4+10;
int p[N];

int fnd(int x)
{
    if(p[x]==x) return p[x];
    else return p[x]=fnd(p[x]);
}

bool same(int x,int y)
{
    return fnd(x)==fnd(y);
}

void unit(int x,int y)
{
    if(!same(x,y))
    {
        p[p[x]]=p[y];
    }
}

struct edge
{
    int s,t,w;
    bool operator <(const edge & e)const
    {
        return w<e.w;
    }
    void set(int a,int b,int c)
    {
        s=a;t=b;w=c;
    }
};

int mst(vector<edge> &edges)
{
    sort(edges.begin(),edges.end());
    int cost=0;
    for(int i=0;i<edges.size();i++)
    {
        if(!same(edges[i].s,edges[i].t))
        {
            unit(edges[i].s,edges[i].t);
            cost+=edges[i].w;
        }
    }
    return cost;
}

void init(int n)
{
    for(int i=0;i<n;i++)
    {
        p[i]=i;
    }
}

int main()
{
    int V,E;
    while(cin>>V>>E)
    {
        init(V);
        vector<edge> edges(E);
        for(int i=0;i<E;i++)
        {
            int a,b,c;
            cin>>a>>b>>c;
            edges[i].set(a,b,c);
        }
        cout<<mst(edges)<<endl;
    }

    return 0;
}



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

using namespace std;

int v[20010];

int main() {
    int n;
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        int x;
        scanf("%d",&x);
        v[x]=i-1;
    }
    for(int i=1; i<=n; i++)
        printf("%d ", v[i] + 20000*i);
    printf("\n");
    for(int i=n; i>=1; i--)
        printf("%d ", 20000*i);
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>

using namespace std;

int main() {
    long long x;
    cin >> x;

    vector<long long> a(2010, 0);
    vector<long long> b(2010, 0);
    for (long long i = 0; i <= 2000; i++) {
        a[i] = pow(i - 1000, 5);
        b[i] = pow(i - 1000, 5);
    }

    long long ans_a;
    long long ans_b;
    for (long long i = 0; i <= 2000; i++) {
        for (long long j = 0; j <= 2000; j++) {
            if (a[i] - b[j] == x) {
                ans_a = i - 1000;
                ans_b = j - 1000;
            }
        }
    }

    cout << ans_a << " " << ans_b << endl;

    return 0;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
typedef long long int lt;
#define max(a,b) (a>b?a:b)
int main()
{
    int N;
    cin>>N;
    int weight;
    cin>>weight;
    int W[N+1],temp;
    lt v[N+1],vtemp;
    for(int i=1;i<=N;i++)
    {
        cin>>W[i]>>v[i];
    }
    W[0]=0; v[0]=0;
    /*cout<<"BEFORE SORTING"<<endl;
    for(int i=0;i<=N;i++)
    {
        cout<<W[i]<<"\t"<<v[i]<<endl;
    }*/
   
    for(int i=0;i<=N;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(W[j]>W[j+1]) 
            {
                temp=W[j];
                W[j]=W[j+1];
                W[j+1]=temp;
                
                vtemp=v[j];
                v[j]=v[j+1];
                v[j+1]=vtemp;
            }
            if(W[j]==W[j+1]) 
            {
                if(v[j]<v[j+1]){
                vtemp=v[j];
                v[j]=v[j+1];
                v[j+1]=vtemp;}
            }
        }
    }/*
    cout<<"AFTER SORTING"<<endl;
     for(int i=0;i<=N;i++)
    {
        cout<<W[i]<<"\t"<<v[i]<<endl;
    }*/
    lt dp[N+1][weight+1];
    for(int i=0;i<=N;i++)
    {
        for(int j=0;j<=weight;j++)
        {
            if(i==0 || j==0) 
            {
                dp[i][j]=0;
            }
            else
            {
                if(W[i]<=j)
                dp[i][j]=max(dp[i-1][j], (dp[i-1][j-W[i]]+v[i]) );
                else
                dp[i][j]=dp[i-1][j];
            }
        }
    }
   /* for(int i=0;i<=N;i++)
    {
        for(int j=0;j<=weight;j++)
        {
            cout<<dp[i][j]<<"\t";
        }
        cout<<endl;
    }*/
    cout<<dp[N][weight];
    return 0;
    
}


Measured memory_bytes: 79104
/*input
RRLRL
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,1,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=505;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int n;
int initposition[101010];
int position[101010][25];
int ct[101010];
string str;
int32_t main()
{
    cin >> str;
    n = str.length();
    REP(i,n)
    {
        initposition[i] = i;
    }
    REP(i,n)
    {
        if (str[i] == 'L') position[i][0] = initposition[i]-1;
        else position[i][0] = initposition[i]+1;
    }
    for (int t=1;t<=20;t++){
        REP(i,n){
            position[i][t] = position[position[i][t-1]][t-1];
        }
    }
    REP(i,n){
        ct[position[i][20]]++;
    }
    REP(i,n) cout<<ct[i]<<' '; 
}


Measured memory_bytes: 11264
h,w,d,f;main(i){for(;scanf(f="%d %d\n",&h,&w)*h;printf(f,h,w)){for(d=i=h*h+w*w;;d++)for(h=d==i?h+1:1;h*h*2<d;h++){w=sqrt(d-h*h);if(w*w==d-h*h)goto c;}c:;}}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, szieof i)

using namespace std;

int main(){

	long long a, b;
	scanf("%lld%lld", &a, &b);

	int ans = 1;
	while(a * 2 <= b) ++ans, a *= 2;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
/**************
*Author:MySakure
*Time:2019-05-26
*Source:
*Theory:
*State:
***************/
#include<bits/stdc++.h>
using namespace std;


int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	int a,p;
	cin>>a>>p;
	cout<<(a*3+p)/2<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn=1010;
const int mod=1e9+7;
int n,m;ll k;
char c[maxn][maxn];
char tc[maxn][maxn];

struct Matrix{
	int a[3][3];
	Matrix(){memset(a,0,sizeof(a));}
	void init_one(){a[1][1]=a[2][2]=1;}
	Matrix operator * (const Matrix &b) const{
		Matrix ret;
		rep(i,1,2) rep(j,1,2) rep(k,1,2){
			ret.a[i][j]+=(a[i][k]*1ll*b.a[k][j])%mod;
			if(ret.a[i][j]>=mod) ret.a[i][j]-=mod;
		}
		return ret;
	}
	void pr(){
		cout<<a[1][1]<<' '<<a[1][2]<<endl<<a[2][1]<<' '<<a[2][2]<<endl<<endl;
	}
} a;

Matrix ksm(Matrix a,ll p){
	Matrix ret;ret.init_one();
	while(p){
		if(p&1) ret=ret*a;
		p>>=1;
		a=a*a;
	}
	return ret;
}

int ksm(int x,ll p){
	int ret=1;
	while(p){
		if(p&1) ret=ret*1ll*x%mod;
		p>>=1;
		x=x*1ll*x%mod;
	}
	return ret;
}

void work(){
	n=read(),m=read(),k=read();
	int cnt=0;bool f1=0,f2=0;
	rep(i,1,n) rep(j,1,m){
		c[i][j]=getchar();
		while(c[i][j]!='.' && c[i][j]!='#') c[i][j]=getchar();
	}
	rep(i,1,n) if(c[i][1]=='#' && c[i][m]=='#') f1=1;
	rep(j,1,m) if(c[1][j]=='#' && c[n][j]=='#') f2=1;
	if(f2 && !f1){
		rep(i,1,n) rep(j,1,m) tc[j][n+1-i]=c[i][j];
		swap(n,m);
		rep(i,1,n) rep(j,1,m) c[i][j]=tc[i][j];
	}
	rep(i,1,n){
		if(c[i][1]=='#' && c[i][m]=='#') a.a[2][2]++;
		rep(j,1,m){
			if(c[i][j]=='#') a.a[1][1]++;
			if(c[i][j]=='#' && c[i][j-1]=='#') a.a[1][2]++;
		}
	}
	if(!f1 && !f2){
		printf("%d\n",ksm(a.a[1][1],k-1));
		return;
	}
	else if(f1 && f2){
		puts("1");
		return;
	}
	a=ksm(a,k-1);
	printf("%d\n",(a.a[1][1]-a.a[1][2]+mod)%mod);
}

int main(){
	#ifdef LZT
		freopen("in","r",stdin);
	#endif
	
	work();
	
	#ifdef LZT
		Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
	#endif
}


Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

std::string S, T;
std::vector<int> vs;
std::vector<std::string> ss;

int main()
{
  std::cin >> S >> T;

  rep( i, S.size()-T.size()+1 )
  {
    std::string U;
    bool fl = true;

    rep( j, T.size() )
      fl &= S[i+j]==T[j] || (S[i+j] != T[j] && S[i+j] == '?');

    if( fl )
      vs.emplace_back( i );
  }

  for( auto &v : vs )
  {
    std::string U;

    rep( i, S.size() )
    {
      if( i == v )
      {
        rep( j, T.size() )
          U += T[j], ++i;
        
        --i;
      }
      else
        U += S[i]=='?' ? 'a' : S[i];
    }

    ss.emplace_back( U );
  }

  std::sort( all(ss) );

  if( ss.empty() )
    puts( "UNRESTORABLE" );
  else
    printf( "%s\n", ss[0].c_str() );
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
using namespace std;
const int N = 2e5+5;

int a[N];
ll x[N],y[N],dp[N],fi[N];

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

    int n;  cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    if(n%2==0){
        dp[1] = a[1] , dp[2] = a[2];
        for(int i=2;i<=n/2;i++){
            dp[i*2-1] = dp[i*2-3] + a[i*2-1];
            dp[i*2] = a[i*2] + max( dp[i*2-3] , dp[i*2-2] );
        }
        cout<<max(dp[n],dp[n-1])<<endl;
    }
    else{
        ll ans = 0;
        for(int i=2;i<=n;i+=2)
            ans += a[i];
        int cnt = 0 , tot = 0;
        for(int i=1;i<=n;i+=2){
            x[cnt+1] = x[cnt] + a[i];
            cnt++;
        }
        for(int i=n;i>=1;i-=2){
            y[tot+1] = y[tot] + a[i];
            tot++;
        }

        dp[1] = a[1] , dp[2] = a[2];
        for(int i=2;i<=n/2;i++){
            dp[i*2-1] = dp[i*2-3] + a[i*2-1];
            dp[i*2] = a[i*2] + max( dp[i*2-3] , dp[i*2-2] );
        }

        fi[n] = a[n] , fi[n-1] = a[n-1];
        for(int i=n-3;i>1;i-=2){
            fi[i] = a[i] + max( fi[i+2] , fi[i+3] );
            fi[i+1] = a[i+1] + fi[i+3];
        }

        for(int i=1;i<n;i++){
            ll sum;
            if(i%2)
                sum = y[n/2-i/2] + dp[i-1];
            else sum = x[i/2] + fi[i+2];
            ans = max( ans,sum );
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char S[100];
  cin >> S;

  int N;
  N = strlen(S);

  string A;
  A = "Great";

  for (int i = 0; i < (N-1)/2; i++) {
    if(S[i]!=S[N-1-i] || S[i]!=S[(N-1)/2-1-i] || S[(N+3)/2-1+i]!=S[N-1-i]){
        cout << "No" <<endl;
        A = "Bad";
        break;
    }
    }
    if(A=="Great"){
        cout << "Yes" <<endl;
    }
            
  }


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/12/20 20:48:37
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i%3!=0 and i%5!=0)
      ans+=i;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int num;
    cin >> num;
    num = num % 10;

    if(num == 3) {
        cout << "bon" << endl;
    } else if(num == 0 || num == 1 || num == 6 || num == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    
    return 0;

}

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

int main(int argc, char const *argv[]) {
	string S;
	cin >> S;
	int loses = 0;
	for (size_t i = 0; i < S.size(); i++) {
		if (S[i] == 'x') {
			loses++;
		}
	}
	if (loses >= 8) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

const long long MOD = 1000000007;


int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    vector<ll> v(N);
    v[0]=A[0];
    for (long long i = 1; i < N; i++) {
        v[i]+=v[i-1]+A[i];
        // v[i]%=MOD;
    }
    // vout(v);
    ll sum=0;
    
    for (long long i = 0; i < N; i++) {
        sum+=((A[i]%MOD)*((v[N-1]-v[i])%MOD));
        sum%=MOD;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	string s; cin >> s;
	if(s.front() == s.back()) {
		printf("Yes\n");
	}else {
		printf("No\n");
	}
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  S.erase(S.begin()+S.size()-1);
  while(S.size()>0){
    if(S.size()%2==0){
      bool a=1;
      for(int i=0; i<S.size()/2; i++){
        if(S.at(i)!=S.at(S.size()/2+i)){
          a=0;
          break;
        }
      }
      if(a){
        cout << S.size() << endl;
        break;
      }
      S.erase(S.begin()+S.size()-1);
    }
    else{
      S.erase(S.begin()+S.size()-1);
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], *di = dn, dt;
inline void putint(ll X) {
	if (!X) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint();
	int A[100000];
	rep(i, N) *(A + i) = getint();

	int k = 0, k2 = 1;
	vector<int> V, V2;
	V.pb(0);
	int mae = 0;
	ll B[100001] = {};
	int C[100001] = {};
	rep(i, N) {
		if (A[i] > k) {
			V.pb(A[i]);
			V2.pb(i);
			B[k2] += A[i] - k;
			C[k2]++;
			k = A[i];
			k2++;
			A[i] = 0;
		}
	}
	rep(i, N) if(A[i]) {
		int k3 = lower_bound(V.begin(), V.end(), A[i]) - V.begin();
		B[k3] += A[i] - V[k3 - 1];
		C[k3]++;
	}

	mae = V.back();
	ll l = C[(int)V.size()];
	ll kotae[100001] = {};
	for (int k = (int)V.size() - 2; k >= 0; k--) {
		kotae[V2[k]] = B[k + 1] + l * (mae - V[k]);
		mae = V[k];
		l += C[k + 1];
	}

	rep(i, N) putint(kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 5364
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::BTreeMap;

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

    let mut mp = BTreeMap::new();
    for &v in a.iter() {
        *mp.entry(v).or_insert(0) += 1;
    }

    let mut ans1 = 0;
    let mut two = vec![];
    for (&v, &cnt) in mp.iter() {
        if cnt >= 4 {
            ans1 = max(ans1, v * v);
        }
        if cnt >= 2 {
            two.push(v);
        }
    }
    two.reverse();
    let ans2 = if two.len() >= 2 { two[0] * two[1] } else { 0 };
    println!("{}", max(ans1, ans2));
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main() {
  long long h, n;
  cin >> h >> n;
  vector<long long> w(n + 1), c(n + 1);
  for(int i = 1; i <= n; ++i) cin >> w[i] >> c[i];
  vector<vector<long long> > d(n + 1, vector<long long>(20001, 100000000));
  for(int i = 0; i <= n; ++i) d[i][0] = 0;
  for(int i = 1; i <= n; ++i)
      for(int j = 1; j <= 20000; ++j){
        if(j < w[i]) d[i][j] = d[i - 1][j];
        else d[i][j] = min(d[i - 1][j], d[i][j - w[i]] + c[i]);
      }
  long long ans = 100000000;
  for(int i = h; i <= 20000; ++i) ans = min(ans, d[n][i]);
  cout << ans;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a%3==0||b%3==0||(a+b)%3==0) cout << "Possible";
    else cout << "Impossible";
}



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

int inf = (1 << 30);
int mod = 1e9;
long long long_inf = (1LL << 60);

int main(){

    int A, B;
    cin >> A >> B;

    int ans = 0;
    if(A > B){
        ans += A;
        A--;
    }else{
        ans += B;
        B--;
    }
    ans += max(A, B);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
using namespace std;
//using ll = unsigned long long;
ll md=MD;
 
 
ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}


int main()
{
	IOS;
	string s,t;
	cin>>s>>t;
	int flag=0;
	if(t.size()==s.size()+1)
	{
		for(int i=0;i<s.size();++i)
		{
			if(s[i]!=t[i])
			{
				flag=1;
				break;
			}
		}
	}
	else
	{
		cout<<"No\n";
		return 0;
	}
	if(!flag)
	cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3640
gets
d = gets.split.map(&:to_i)
m = d.max - 1
h = Hash.new(0)
d.each do |x|
  h[x] += 1
end
if h[0] != 1 || d[0] != 0
  puts '0'
  exit
end
ans = 1
1.upto(m) do |i|
  ans *= h[i] ** h[i + 1]
  ans %= 998244353
end
puts ans

Measured memory_bytes: 14596
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        
        List<Integer> list = sieve(110000);
        for (Integer i : list) {
            if(i >= x){
                System.out.println(i);
                break;
            }
        }
    }
    
    static List sieve(int x){
        
        List<Integer> list = new ArrayList<>();
        boolean[] p = new boolean[x+1];
        Arrays.fill(p, true);
        
        int sqrt = (int)Math.sqrt(x);
        for(int i = 2; i <= sqrt; i++){
            if(!p[i]) continue;
            for(int j = i; i*j <= x; j++){
                p[i*j] = false;
            }
        }
        for(int i = 2; i <= x; i++){
            if(p[i]) list.add(i);
        }
        return list;
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define N 2050
using namespace std;
int n,m,q,mp[N][N],ps[N][N],ex[N][N],ey[N][N];
char s[N];
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
int main() {
	n = rd(), m = rd(), q = rd();
	for (int i=1;i<=n;i++) {
		scanf("%s",s+1);
		for (int j=1;j<=m;j++) mp[i][j] = s[j]-'0';
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			ps[i][j] = ps[i-1][j] + ps[i][j-1] - ps[i-1][j-1] + mp[i][j];

	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) {
			int curx = 0, cury = 0;
			if (mp[i][j] && mp[i-1][j]) curx = 1; else curx = 0;
			if (mp[i][j] && mp[i][j-1]) cury = 1; else cury = 0;
			ex[i][j] = ex[i-1][j] + ex[i][j-1] - ex[i-1][j-1] + curx;
			ey[i][j] = ey[i-1][j] + ey[i][j-1] - ey[i-1][j-1] + cury;
		}
		
	while (q--) {
		int x1 = rd(), y1 = rd(), x2 = rd(), y2 = rd();
		int esum = 0;
		esum += ex[x2][y2] - ex[x2][y1-1] - ex[x1][y2] + ex[x1][y1-1];
		esum += ey[x2][y2] - ey[x2][y1] - ey[x1-1][y2] + ey[x1-1][y1];
		int psum = ps[x2][y2] - ps[x1-1][y2] - ps[x2][y1-1] + ps[x1-1][y1-1];
		int ans = psum - esum;
		printf("%d\n",ans);
	}

	return 0;
}


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


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

int main() {
  int N ,M;
  cin >> N >>M;
  vector<vector<int>> sw(M);
  for(int i = 0; i < M; i++){
    int k;
    cin >> k;
    vector<int> x(k);
    for(int j = 0; j < k; j++) {
      int num;
      cin >> num;
      num--;
      x.at(j)=num;
    }
    sw.at(i)=x;
  }
  vector<int> m(M);
  for(int i = 0; i < M; i++) {
    cin>>m.at(i);
  }
  int cnt = 0;
  for(int i = 0; i < (1<<N); i++) {
    bool al = true;
    for(int j = 0; j < M; j++) {
      int num=0;
      for(auto k:sw.at(j)){
        if(i&(1<<k)){
          num++;
        }
      }
      if(num%2!=m.at(j)){
        al=false;
        break;
      }
    }
    if(al) {
      cnt++;
    }
  }
  cout<<cnt<<endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
template<class T>bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];

  map<ll, ll> mp;
  for(ll i = 0; i < n; i++){
    mp[a[i]]++, mp[a[i]-1]++, mp[a[i]+1]++;
  }

  ll ans = 0;
  for(ll i = 0; i < n; i++){
    ans = max({ans, mp[a[i]], mp[a[i]-1], mp[a[i]+1]});
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;
const int MAX = 1000000;
const ll MO = 1000000007;

ll n;
ll f(int m){
    return n*m-0.5*m*(m-1) +1;
}

int main(){
    ll k;
    cin >> n >> k;
    ll ans=0;
    // ans = f(n+1)-f(k-1);
    // cout << ans << endl;
    // cout << f(n+1) << endl;

    for(ll m = k; m<=n+1;++m){
        ll maxi = m*n-0.5*m*(m-1);
        ll mini = 0.5*m*(m-1);
        // printf("m:%d, max:%, min:%10d, num:%10d", m ,maxi,mini,maxi-mini+1);
        // cout << mini  << " "<< maxi << endl;
        ans+= (maxi-mini+1);
    }
    cout << ans%MO << endl;
    return 0;

    
    // // cout << -0.5*(1/6.0)*k*(k+1)*(2*k+1) + 0.5*k*(k+1)*(n+1/2.0)<<endl;
    // return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

inline void era(vector<bool> &prime, int num);

int main(void){
  int num = -1;

  while (cin >> num){
    if (num == 0){
      return 0;
    }
    vector<bool> primeN(num+1, true);
    vector<bool> prime2N(2*num+1, true);
    era(primeN, num);
    era(prime2N, (2*num));
    cout << count(prime2N.begin(), prime2N.end(), true) - count(primeN.begin(),primeN.end(),true) << endl;

  }
  return 0;
}

inline void era(vector<bool> &prime, int num){
  prime[0] = false;
  prime[1] = false;
  int N = 2;
  while (N <= num){
    if (!prime[N]){
      ++N;
      continue;
    }
    int count = 2;
    while ((count*N) <= num){
      prime[count*N] = false;
      ++count;
    }
    ++N;
  }
  return;
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, ans = 0;
    char before = '-';
    cin >> N;
    REP(i, N) {
        char c;
        cin >> c;
        if (c != before) {
            ans++;
            before = c;
        }
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int H,W;
		String work[] = new String[2];

		while(true){

			try {
				work = br.readLine().split("[\\s]+");

				if(work[0].equals("0") && work[1].equals("0"))break;

				H = Integer.parseInt(work[0]);
				W = Integer.parseInt(work[1]);

				for(int col = 0; col < W; col++){
					System.out.printf("#");
				}
				System.out.printf("\n");

				for(int row = 1; row <= H-2; row++){
					System.out.printf("#");
					for(int col = 1; col <= W-2; col++){
						System.out.printf(".");
					}
					System.out.printf("#\n");
				}

				for(int col = 0; col < W; col++){
					System.out.printf("#");
				}
				System.out.printf("\n\n");


			} catch (IOException e) {

				e.printStackTrace();
			}
		}
	}
}





Measured memory_bytes: 56744
n = int(input())
ans = 1001001001
for i in range(1,n):
    j = n-i
    i_sum, j_sum = 0, 0

    si, sj = list(str(i)), list(str(j))
    for s1 in si:
        i_sum += int(s1)
    for s2 in sj:
        j_sum += int(s2)

    ans = min(ans, i_sum+j_sum)

print(ans)

Measured memory_bytes: 9216
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem125d(n, a))
}

fun problem125d(n: Int, a: List<Long>): Long {
//    if (a.contains(0)) return a.map { Math.abs(it) }.sum()
    if (a.count { it < 0L } % 2 == 0) {
        return a.map { Math.abs(it) }.sum()
    }
    val min = a.map { Math.abs(it) }.min()!!
    return a.map { Math.abs(it) }.sum() - (min * 2)
}

Measured memory_bytes: 49828
#include<bits/stdc++.h>
using namespace std;
queue<long long>q;
vector<long long>v;
int main()
{
	for(int i=1;i<=9;i++){q.push(i);v.push_back(i);}
	int kk;cin>>kk;
	for(int i=1;i<=100000;i++)
	{
		long long x=q.front();
		int k=x%10;
		q.pop();
		v.push_back(10*x+k);q.push(10*x+k);
		if(k!=0){v.push_back(10*x+k-1);q.push(10*x+k-1);}
		if(k!=9){v.push_back(10*x+k+1);q.push(10*x+k+1);}
 	}
	sort(v.begin(),v.end());
	cout<<v[kk-1]<<' ';
}

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

int main() {
    vector<int> A(5);
  	for (int i = 0; i < 5; i++){
      cin >> A.at(i);
    }
   for (int i = 0; i < 5; i++){
     if (A.at(i) == 0){
       cout << i+1 << endl;
       break;
     }
   }
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MAX=1e16;



int main(){
	ll N;
	cin>>N;
	ll a[6];
	ll m=MAX;
	rep(i,5){
		cin>>a[i];
		m=min(m,a[i]);
	}
	ll t;
	if(N%m==0)t=N/m;
	else t=(N/m)+1;
	cout<<t+4<<endl;
	
}


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

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

    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v(m);
    for(int i=0;i<m;i++)cin>>v[i].first>>v[i].second;
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int pos=INF;
    int ans=0;
    for(int i=0;i<m;i++){
        if(v[i].second<=pos){
            ans++;
            pos=v[i].first;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N>>K;
    vec h(N);
    rep(i,N) cin>>h[i];
    sort(h.begin(),h.end());
    --K;
    ll ans = 1e+9;
    reps(i,K,N){
        ans = min(ans, h[i] - h[i-K]);
    }
    cout<<ans<<endl;
}


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

int main(){
	int n,i,j,k,cnt=0;
	cin>>n;
	int l[n+1];
	for(i=1;i<=n;i++)
		cin>>l[i];
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
			for(k=j+1;k<=n;k++){
				if(l[i]==l[j] || l[i]==l[k] || l[j]==l[k])
					continue;
				else{
					if(l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[j]+l[k]>l[i])
						cnt++;
				}
			}
			
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main() {
	int n, s, ans = 0;
	char S[30000];
	scanf("%d", &n);
	scanf("%s", S);
	for (int i = 0; i < 1000; i++) {
		int c[3] = { i / 100,(i / 10) % 10,i % 10 };
		int f = 0;
		for (int j = 0; j < n; j++) {
			if (S[j] == ('0'+c[f]))f++;
			if (f == 3)break;
		}
		if (f == 3)ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1748
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;
int main() {
	int N, x;
	scanf("%d %d", &N, &x);
	int *a = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", a + i);
	}
	std::sort(a, a + N);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		cnt += a[i];
		if (cnt > x) {
			printf("%d", i);
			break;
		}
	}
	if (cnt == x) {
		printf("%d", N);
	}
	else if (cnt < x) {
		printf("%d", N - 1);
	}
	return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    string a,b;
    cin >> a >> b;

    string num = a + b;
    int ans = stoi(num);

    if ((int)sqrt(ans) * (int)sqrt(ans) == ans) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	int res = INT_MAX;
	rep (i, 0, n + 1) {
		int tmp = 0;
		int t = i;
		while (t > 0) {
			tmp += t % 6;
			t /= 6;
		}
		t = n - i;
		while (t > 0) {
			tmp += t % 9;
			t /= 9;
		}
		res = min(res, tmp);
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
    fasthoja;
    
    ll a,b ; cin >> a >> b;
    
    ll ans = a > b ? a : b;
    ll prt = 0;
    if( ans == a )
        prt = b;
    else
        prt = a;
        
    for( ll i = 1 ; i <= ans ; i++ ) {
        cout << prt;
    }
    cout << "\n";
    
 return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, x;
  cin >> N >> K;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x <= K - x) {
      sum += x * 2;
    }
    else {
      sum += (K - x) * 2;
    }
  }
  cout << sum << endl;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.00000000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int L = 21;
const int M = 2155;

void solve() {
    ll a,b,n;
    cin >> a >> b >> n;

    ll x = min(b-1, n);
    cout << a*x/b;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3584