akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll inf = -12345;
const ll wall = -1234;
vector<string> vs;
int mp[21][21];
int h,w;
int bfs(P st)
{
	queue<P> que;
	que.push(st);
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(vs[i][j]!='#')
			mp[i][j] = inf;
			else
			mp[i][j] = wall;
		}
	}
	mp[st.first][st.second] = 0;
	int dx[4] = {0,0,-1,1};
	int dy[4] = {1,-1,0,0};
	while(que.size())
	{
		P p = que.front();
		que.pop();
		for(int i=0;i<4;i++)
		{
			int sy = p.first+dy[i];
			int sx = p.second+dx[i];
			if((sy>=0&&sy<h)&&(sx>=0&&sx<w)&&mp[sy][sx] == inf)
			{
				mp[sy][sx] = mp[p.first][p.second]+1;
				que.push(P(sy,sx));
			}
		}
	}
	int ma = -1;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			ma = max(mp[i][j],ma);
		}
	}
	return ma;
}
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		string s;
		cin>>s;
		vs.push_back(s);
	}
	int ma = -100;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(vs[i][j]!='#')
			ma = max(ma,bfs(P(i,j)));
		}
	}
	cout<<ma<<endl;
	return 0;
 } 

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll p, q, r;
    cin >> p >> q >> r;
    cout << min({p+q, p+r, q+r}) << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(list(map(str, A))))


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

class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		String str = br.readLine();
		char[] moji = str.toCharArray();
		
		for(int i = 0; i < moji.length; i++) {
			if (Character.isUpperCase(moji[i])) {
				sb.append(Character.toLowerCase(moji[i]));
			} else {
				sb.append(Character.toUpperCase(moji[i]));
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 24172
m,d = map(int,input().split())
cn = 0

for i in range(1,d+1):
    tt = 0
    if((i%10)>=2 and i//10>=2):
        tt = (i%10)*(i//10)
    if(tt<=m and tt>=1):
        cn+=1
        #print(i%10,i//10)
    
print(cn)

Measured memory_bytes: 38256
import sys

n,x,d=map(int,input().split())
if d==0:
    if x==0:
        print(1)
    else:
        print(n+1)
    sys.exit()
    
lst=[]
for k in range(n+1):
    a=k*x%d
    l=k*x+d*k*(k-1)//2
    r=k*x+d*k*(2*n-k-1)//2
    lst.append([a,min(l,r),max(l,r)])
lst.sort()

data=[]
h=[[lst[0][1],lst[0][2]]]
for i in range(1,n+1):
    if lst[i][0]==lst[i-1][0]:
        h.append([lst[i][1],lst[i][2]])
    else:
        data.append(h)
        h=[[lst[i][1],lst[i][2]]]
data.append(h)
d=abs(d)

ans=0
for h in data:
    left,right=h[0]
    for i in range(1,len(h)):
        if h[i][0]<=right:
            right=max(right,h[i][1])
        else:
            ans+=(right-left)//d+1
            left,right=h[i]
    ans+=(right-left)//d+1

print(ans)

Measured memory_bytes: 98916
<?php
list($n) = ints();
$a = ints();
for ($i = 0; $i <= $n; ++$i) $s[$i] = ($s[$i - 1] ?? 0) + ($a[$i - 1] ?? 0);
for ($i = 0; $i <= $n; ++$i) {
    if (isset($cnt[$s[$i]])) ++$cnt[$s[$i]];
    else $cnt[$s[$i]] = 1;
}
$ans = 0;
foreach ($cnt as $i => $v) {
    if ($i === 0) $v;
    $ans += $v * ($v - 1) / 2;
}
echo $ans . PHP_EOL;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 48792
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
11
---+/
/+---test
136
---+/
/+---test
100000
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;

  const M = N.log10.to!long;

  long ans;

  if (M%2 == 0) ans += N - 10.pow(M) + 1;

  foreach (i; 0..M) {
    if (i%2 == 0) {
      ans += 10.pow(i+1) - 10.pow(i);
    }
  }
  ans.writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int dp[c+1][d+1][2]={};
  int num=1;
  repi(i,a+1,c+1){
    num*=b;
    num%=MOD;
    dp[i][b][0]=num;
    dp[i][b][0]%=MOD;
  }
  num=1;
  int a0=a-1,a1=1,a2=0;
  dp[a][b+1][0]=a0+a1;
  dp[a][b+1][1]=a2;
  repi(i,b+2,d+1){
    //cout<<a0<<" "<<a1<<" "<<a2<<endl;
    
    a2=(a1+(a2*(a)%MOD))%MOD;
   
    a1=(a0+(a1*(a-1)%MOD))%MOD;
     a0=(a0*(a-1))%MOD;
    dp[a][i][0]=a0+a1;
    dp[a][i][1]=a2;
  }
  repi(i,a+1,c+1){
    repi(j,b+1,d+1){
      //cout<<i<<" "<<j<<endl;
      // cout<<dp[i][j-1][0]<<endl;
      dp[i][j][0]=(((dp[i-1][j][0]+dp[i-1][j][1])%MOD)*j)%MOD;
      dp[i][j][1]=(dp[i][j-1][0]+(dp[i][j-1][1]*i)%MOD)%MOD;
      dp[i][j][0]%=MOD;
    }
  }
  /* rep(i,c+1){
    rep(j,d+1){
      cout<<"("<<dp[i][j][0]<<" "<<dp[i][j][1]<<") ";
    }
    cout<<endl;
    }*/
  if(a==c && b==d) cout<<1<<endl;
  else cout<<(dp[c][d][0]+dp[c][d][1])%MOD<<endl;

  return 0;
}


Measured memory_bytes: 144284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[3004],dp[3004][3004][2];
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    IOS;
    int n;  cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i][i][0] = a[i]; 
        dp[i][i][1] = -a[i];
    }
    for(int i = 1; i < n; i++){
        for(int j = 1; j < n; j++){
            if(j+i <= n)
            {
                dp[j][j+i][0] = max(dp[j+1][j+i][1] + a[j] , dp[j][j+i-1][1] + a[j+i]);
                dp[j][j+i][1] = min(dp[j+1][j+i][0] - a[j] , dp[j][j+i-1][0] - a[j+i]);
            }
        }
    }
   /* for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cout<<dp[i][j][0]<<" ";
        }
        cout<<endl;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cout<<dp[i][j][1]<<" ";
        }
        cout<<endl;
    }*/
    ll ans = 0;
    ans = dp[1][n][0];
     cout<<ans<<endl;
     return 0;
}


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

string str;
stack<long long> S;
long long a,b;


int main(){
  while(cin >> str){
    if(str=="+"){
      a=S.top();
      S.pop();
      b=S.top();
      S.pop();
      S.push(b+a);
    }
    else if(str=="-"){
      a=S.top();
      S.pop();
      b=S.top();
      S.pop();
      S.push(b-a);
    }
    else if(str=="*"){
      a=S.top();
      S.pop();
      b=S.top();
      S.pop();
      S.push(b*a);
    }
    else{
      S.push(stoll(str));
    }
    if(getchar()=='\n'){
      cout << S.top() << endl;
      return 0;
    }
  }


}



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

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

int dfs(int x, int y, vector<vector<bool> >& map){
    map[y][x] = false;
    int num=1;
    for(int i=0; i<4; i++){
        if(map[y+dy[i]][x+dx[i]]){
            num+= dfs(x+dx[i], y+dy[i], map);
        }
    }
    return num;
}

int main(){
    while(1){
        int W,H;
        cin >> W >> H;
        if(W==0) break;

        vector<vector<bool> > map(H+2, vector<bool>(W+2,false));
        int sx,sy;
        for(int y=1; y<=H; y++){
            for(int x=1; x<=W; x++){
                char tmp;
                cin >> tmp;
                if(tmp == '#'){
                    map[y][x]=false;
                }else{
                    map[y][x]=true;
                }
                if(tmp == '@'){
                    sx = x;
                    sy = y;
                }
            }
        }

        cout << dfs(sx,sy,map) << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef pair<string, int> T;

int main() {
  int n;
  bool f = false;
  while (cin >> n, n) {
    string s;
    int w, L, d;
    vector<T> v;
    for (int i = 0; i < n; i++) {
      cin >> s >> w >> L >> d;
      v.emplace_back(s, w * 3 + d);
    }
    sort(v.begin(), v.end(), [](const auto& x, const auto& y) {return x.second > y.second;});
    if (f) cout << "\n";
    for (auto& e : v) {
      cout << e.first << "," << e.second << "\n";
    }
    f = true;
  }
}


Measured memory_bytes: 3144
import sys

#fp = open("input.txt", "r")
fp = sys.stdin

gli = []

def operate(li):
    if li[3] == 1:
        gli[li[0]-1] = 1
        gli[li[1]-1] = 1
        gli[li[2]-1] = 1
        li[4] = True
        return True
    elif li[3] == 0:
        if gli[li[0]-1] == 1 and gli[li[1]-1] == 1:
            gli[li[2]-1] = 0
            li[4] = True
            return True
        elif gli[li[0]-1] == 1 and gli[li[2]-1] == 1:
            gli[li[1]-1] = 0
            li[4] = True
            return True
        elif gli[li[1]-1] == 1 and gli[li[2]-1] == 1:
            gli[li[0]-1] = 0
            li[4] = True
            return True
    return False

while True:
    buf = fp.readline()[:-1].split(" ")
    numli = map(int, buf)
    n = numli[0] + numli[1] + numli[2]
    if n == 0:
        break
    gli = []
    for i in xrange(n):
        gli.append(2)

    m = int(fp.readline()[:-1])
    opli = []
    for i in xrange(m):
        op = map(int, fp.readline()[:-1].split(" "))
        op.append(False)
        opli.append(op)

    flg = True
    while flg:
        flg = False
        for i in xrange(m):
            op = opli[i]
            if op[4]:
                continue
            if operate(op):
                flg = True

    for i in xrange(n):
        print gli[i]

Measured memory_bytes: 4348
import java.util.*;

public class Main {
	static public void main(String args[]){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		long aa=1L;
		for(int i=0;i<n;i++){
			long a=sc.nextLong();
			if(Math.log10(a)+Math.log10(aa)>18||
			aa*a>1000000000000000000L){
			  
				aa=-1;
			}
			else if(a==0){
				aa*=0;
              System.out.println(0);
              return;
			}
			else if(aa!=-1){
				aa*=a;
			}
		}
		System.out.println(aa);
	}
}



Measured memory_bytes: 60656
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;


vector<string> S;

int res(int A){
    vector<vector<char>> fie;
    fie.resize(N,vector<char>(N));

    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            fie[i][j] = S[(i + A) % N][j];
        }
    }

    bool ok = true;
    rep(i,0,N - 1){
        rep(j,0,N - 1){
            ok &= fie[i][j] == fie[j][i];
        }
    }

    if(ok){
        return N;
    }
    return 0;
}

int main(){
    cin >> N;
    S.resize(N);
    rep(i,0,N - 1){
        cin >> S[i];
    }

    int ans = 0;
    rep(i,0,N - 1){
        ans += res(i);
    }

    cout << ans << endl;
}


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

template <typename Tp>Tp Max(const Tp &a, const Tp &b) {return a > b ? a : b;}
template <typename Tp>Tp Min(const Tp &a, const Tp &b) {return a < b ? a : b;}

template <typename Tp>void Read(Tp &x) {
    Tp in = 0, f = 1; char ch = getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f = -1; ch = getchar();}
    while(ch>='0' && ch<='9') {in = in*10+ch-'0'; ch = getchar();}
    x = in*f;
}

typedef long long LL;

const int SN = 500 + 10;

const int MOD = 1000000007;

LL f[SN][SN], g[SN][SN], A[SN], B[SN], n, c;

int main() {
    Read(n), Read(c);

    for(int i = 1; i <= n; i++) Read(A[i]);

    for(int j = 1; j <= n; j++) Read(B[j]);

    for(int i = 1; i <= 400; i++) {
	g[i][0] = 1;
	for(int j = 1; j <= 400; j++)
	    g[i][j] = (g[i][j-1] * i) % MOD;
    }

    for(int i = 1; i <= 400; i++)
	for(int j = 0; j <= 400; j++)
	    g[i][j] = (g[i][j] + g[i - 1][j]) % MOD;

    f[0][0] = 1;

    for(int i = 1; i <= n; i++)
	for(int j = 0; j <= c; j++)
	    for(int k = 0; k <= j; k++)
		f[i][j] = (f[i][j] + f[i - 1][j - k] * (g[B[i]][k] - g[A[i]-1][k] + MOD)) % MOD;

    printf("%lld\n", f[n][c]);

    return 0;
}

Measured memory_bytes: 3328
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int cnt[4];
    fill(cnt, cnt + 4, 0);
    for (int i = 0; i < 6; ++i) {
        int a;
        cin >> a;
        ++cnt[--a];
    }

    int p = 0;
    for (int i = 0; i < 4; ++i) p += cnt[i] % 2;
    cout << (p <= 2 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int main() {
  string o, e;
  cin >> o >> e;

  string a[110];

  int o_size = o.size();
  int e_size = e.size();

  int o_current = 0;
  for (int i = 0; i < o_size; i++) {
    a[o_current] = o[i];
    o_current += 2;
  }
  int e_current = 1;
  for (int i = 0; i < e_size; i++) {
    a[e_current] = e[i];
    e_current += 2;
  }

  for (int i = 0; i < o_size+e_size; i++) {
    cout << a[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3140
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=0,o=0;o<=t;o++){if((1+o)*o/2>=t){n=o;break}}console.log(n)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 7620
#include<stdio.h>

int main(void){
    int m,f,r,sum;

    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1) break;
        sum=m+f;

        if(m==-1 || f==-1){
            printf("F\n");
        }else{
            if(sum>=80){
                printf("A\n");
            }else{
                if(sum>=65){
                    printf("B\n");
                }else{
                    if(sum>=50){
                        printf("C\n");
                    }else{
                        if(sum>=30){
                            if(r>=50) printf("C\n");
                            else printf("D\n");
                        }else{
                            printf("F\n");    
                        }                    
                    }

                }
            }
        }
    }
    return 0;
}


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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int r;
	cin >> r;
	cout << (r < 1200 ? "ABC\n" : r < 2800 ? "ARC\n" : "AGC");
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main(void) {
    string S; cin >> S;
    int cnt = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'o') cnt++;
    }
    if (8 - cnt <= 15 - S.length()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}   

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
    int N,A;
    //char s[80];
  	scanf("%d %d",&N,&A);
    if((N*A)%2==0){
  		printf("Even");
    }else{
      	printf("Odd");
    }
    return 0;
}

Measured memory_bytes: 128
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        BigDecimal a = new BigDecimal(scanner.next());
        BigDecimal b = new BigDecimal(scanner.next());
        a = a.multiply(b);
        a = a.setScale(0, BigDecimal.ROUND_DOWN);
        System.out.println(a.toString());
    }

}





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

int main(){
  int N,K; cin >> N >> K;
  
  ll ans = 0;
  for(int b = 1; b <= N; b++){
      ans += N/b * max(0,b-K) + max(0,N%b-K+1);
  }
  if(K == 0) ans -= N;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
	int H,W,N;
	cin >> H >> W >> N;
	int sr,sc;
	cin >> sr >> sc;
	string S,T;
	cin >> S;
	cin >> T;


	int now;
	//先攻：左　後攻：右
	now=sc;
	for(int i=0; i<N; i++){
		if(S[i]=='L'){
			now--;
			if(now<1){
				cout << "NO" << endl;
				return 0;
			}
		}
		if(T[i]=='R' && now<W){
			now++;
		}
	}

	//先攻：右　後攻：左
	now=sc;
	for(int i=0; i<N; i++){
		if(S[i]=='R'){
			now++;
			if(now>W){
				cout << "NO" << endl;
				return 0;
			}
		}
		if(T[i]=='L' && now>1){
			now--;
		}
	}

	//先攻：上　後攻：下
	now=sr;
	for(int i=0; i<N; i++){
		if(S[i]=='U'){
			now--;
			if(now<1){
				cout << "NO" << endl;
				return 0;
			}
		}
		if(T[i]=='D' && now<H){
			now++;
		}
	}

	//先攻：下　後攻：上
	now=sr;
	for(int i=0; i<N; i++){
		if(S[i]=='D'){
			now++;
			if(now>H){
				cout << "NO" << endl;
				return 0;
			}
		}
		if(T[i]=='U' && now>1){
			now--;
		}
	}

	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 900
n, k = map(int, input().split())
A = [*map(int, input().split())]
ng, ok = 0, max(A) # (ng,ok] = (l,r]
while ok - ng > 1:
    m = (ng + ok) // 2
    c = 0
    for a in A: c += (a-1) // m
    if c <= k: ok = m
    else: ng = m
print(ok)


Measured memory_bytes: 30792
#include <stdio.h>

int main(void)
{
int n;
int l[1000];
int r[1000];
int i;
int x=0;
scanf("%d",&n);
for(i=0;i<n;i++){
	
	scanf("%d%d",&l[i],&r[i]);
	x+=r[i]-l[i]+1;
}
printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


typedef unsigned long long int uint64;
typedef long long int          int64;


void get_abcd (int64 *a, int64 *b,int64 *c,int64 *d)
{
  int cnt;
  
  cnt = scanf("%lld %lld %lld %lld", a, b, c, d);

  return;
}

int64 gcd(int64 a,int64 b){int64 c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int64 lcm(int64 a,int64 b){int64 c=gcd(a,b);a/=c;return a*b;};

int main()
{
  int64 A, B, C, D;
  int64 i;
  int64 num = 0;
  int64 min, max;
  int64 min_num = 0;
  int64 max_num = 0;
  int64 lcm_num = 0;
  int64 lcm_val;

  get_abcd(&A, &B, &C, &D);

  min = MIN(C, D);
  max = MAX(C, D);

  min_num = B/min - ((A-1)/min);
  max_num = B/max - ((A-1)/max);
  lcm_val = lcm(min, max);
  lcm_num = B/lcm_val - ((A-1)/lcm_val);

  num = (B - A + 1);
  num -= min_num;
  num -= max_num;
  num += lcm_num;

  printf("%lld", num);

  return 0;
}



Measured memory_bytes: 128
input()
*A,=map(int,input().split())
f=True
s1=0;r1=0
s2=0;r2=0
for a in A:
  s1+=a;s2+=a
  if f and s1<=0:r1+=1-s1;s1=1
  elif not(f) and s1>=0:r1+=s1+1;s1=-1
  if not(f) and s2<=0:r2+=1-s2;s2=1
  elif f and s2>=0:r2+=s2+1;s2=-1
  f=not(f)
print(min(r1,r2))

Measured memory_bytes: 14468
li = 'abcdefghijklmnopqrstuvwxyz'

while True:
    try:
        s = input()
    except:
        exit()

    for d in range(1, 27):
        t = s[:-1].translate(str.maketrans(li, li[d:] + li[:d]))
        if 'the' in t or 'this' in t or 'that' in t:
            print(t + '.')
            break

Measured memory_bytes: 7348
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if(m == -1 && f == -1 && r == -1) break;
			if(m == -1 || f == -1) { System.out.println('F'); continue; }
			if(m + f >= 80) { System.out.println('A'); continue; }
				if(m + f >= 65) { System.out.println('B'); continue; }
				if(m + f >= 50) { System.out.println('C'); continue; }
			if(m + f >= 30) {
					if(r >= 50) System.out.println('C');
				else System.out.println('D');
				continue;
			}
			System.out.println('F');
			
		}
	}
}

Measured memory_bytes: 19252
while True:
    I = input().split()
    op = I.pop(1)
    if op == "?":
        break
    a,b = tuple(int(n) for n in I)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)




Measured memory_bytes: 5604
from operator import itemgetter  
i = int(input())
#print(i)
point =[]
for n in range(0,i):
  s, p = list(input().split(' '))
  point.append((s,int(p)))

#point2 = sorted(point, key=itemgetter(1),reverse=True) 
point2 = sorted(point, key=itemgetter(1),reverse=True) 
#point3 = sorted(point2, key=itemgetter(0)) 
point3 = sorted(point2, key=itemgetter(0)) 
#print(point3)

for i in point3:
  print(point.index(i)+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    ll mod = 10007;
    ll dp[N + 1][8]{};
    dp[0][1] = 1;
    map<char, int> m;
    m.insert(make_pair('J', 0));
    m.insert(make_pair('O', 1));
    m.insert(make_pair('I', 2));
    s.insert(0, "J");
    for (int i = 1; i <= N; i++) {
        int a = m[s[i - 1]];
        int b = m[s[i]];
        for (int j = 1; j < 8; j++) {
            for (int k = 1; k < 8; k++) {
                if (((1<<a) & j) == 0) continue;
                if (((1<<b) & k) == 0) continue;
                if ((j & k) == 0) continue;
                dp[i][k] += dp[i - 1][j];
                dp[i][k] %= mod;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 8; i++) {
        ans += dp[N][i];
    }
    ans %= mod;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;									// .
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
#define mem(a,x) memset(a,x,sizeof(a))
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // order_of_key // find_by_order()  

inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

//const int mod = 998244353;
const int mod = 1e9+7;
const int inf = 1e18;
const int maxn = 1e6+5;

vector<int> fact(maxn);
int power(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void pre() {
    fact[0] = 1;
    for(int i = 1; i < maxn; i++) {
        fact[i] = fact[i - 1] * i % mod;
    }
}
int ncr(int n, int r) {
    if(n < r) return 0;
    int p = fact[n];
    int q = fact[r] * fact[n - r] % mod;
    p = p * power(q, mod - 2) % mod;
    return p;
} 
int add(int a, int b){
    return((a % mod + b % mod) % mod);
}
int subs(int a, int b){
    return((a % mod - b % mod + mod) % mod);
}
int mul(int a, int b){
    return(((a % mod) * (b % mod)) % mod);
}
int divi(int a, int b){
    return(mul(a, power(b, mod - 2)) % mod);
}
void solve(){
	int n; cin>>n;
	vector <ii> v(n), a(n), b(n);
	rep(i, 0, n){
		cin>>v[i].F>>v[i].S;
		a[i].F = v[i].F+v[i].S;
		a[i].S = i;
		b[i].F = v[i].F-v[i].S;
		b[i].S = i;
	}
	sort(all(a)); sort(all(b));
	int ans = abs(v[a[0].S].F - v[a[n-1].S].F) + abs(v[a[0].S].S - v[a[n-1].S].S);
	int ans2 = abs(v[b[0].S].F - v[b[n-1].S].F) + abs(v[b[0].S].S - v[b[n-1].S].S);
	ans = max(ans, ans2);
	cout<<ans;
}
signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);// io();
    //cout<<setprecision(100);
    //pre();
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 20360
#include<bits/stdc++.h>
#define N 100005
using namespace std;

char s[N];

void ok(int son) {printf("%d %d",son-2,son);exit(0);}

int main() {

  scanf("%s",s+1);
  int n=strlen(s+1);
  if(n==2) {
    if(s[1]==s[2]) {
      printf("1 2");
    }
    else {
      printf("-1 -1");
    }
    return 0;
  }
  int len=0;
  int harf[26]={0};
  for(int i=1;i<=n;i++) {
    len++;
    harf[s[i]-'a']++;
    if(len==3) {
      for(int j=0;j<26;j++) {
        if(harf[j]>=2) {
          ok(i);
        }
      }
      len--;
      harf[s[i-2]-'a']--;
    }
  }
  printf("-1 -1");

}


Measured memory_bytes: 384
import itertools
import math

N=int(input())
XY=[list(map(int,input().split())) for i in range(N)]

ans=0.0
fact=1
for i in range(2,N+1):
    fact*=i

ans=0.0
v=[]
for i in range(N):
    v.append(i)

for s in itertools.permutations(v):
    for j in range(N-1):
        ans+=math.sqrt((XY[s[j]][0]-XY[s[j+1]][0])**2+(XY[s[j]][1]-XY[s[j+1]][1])**2)

print(ans/fact)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0}; 
int H,W;
char data[55][55];

bool check_around(int y, int x){
  for(int i=0;i<4;i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(nx<0||nx>=W||ny<0||ny>=H) continue;
    if(data[ny][nx]=='#') return true;
  }
  return false;
}
       
  
int main(){
  cin >> H>>W;
  
  int num_sharp=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
    	cin >> data[i][j];
      	if(data[i][j]=='#') num_sharp++;
    }
  }
  
  bool result=true;
  int cnt=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data[i][j]=='#'){
        bool OK = check_around(i, j);
        if(OK) cnt++;
        if(!OK) {
          result=false;
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  if(cnt==0) result=false;
  
  if(cnt==num_sharp) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
  
}

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

ll N, K;
string S;

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

	cin >> N >> K >> S;
	S[K-1] = tolower(S[K-1]);
	cout << S << "\n";

}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const maxCapacity = 512 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	var s string
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &s)

	var cnt, max int
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "R" {
			cnt++
		} else {
			cnt = 0
		}
		if cnt > max {
			max = cnt
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 1860
N = int(input())
A = list(map(int,input().split()))
A_list = [float('inf')] * N

ans = min(A)
while max(A_list) > 0:
    mi = ans
    for i,a in enumerate(A):
        amari = a % mi
        A_list[i] = amari
        if amari != 0:
            ans = min(ans,amari)

print(ans)

Measured memory_bytes: 20080
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807



void solve(void)
{
  vector<vector<int> > data;
  int N = 0;
  // cin>>N;
  
  while(true)
  {
  vector<int> data_s;
  int C;
  int count = 0;
    for(int i = 0; i < 3 ; i++)
    {
      cin>>C;
      data_s.push_back(C);
    }
    if((data_s[0] == -1)&&(data_s[1] == -1)&&(data_s[2]==-1))break;
        for(int i = 0; i < 3 ; i++)
    {
      if(data_s[i] == -1)data_s[i]=-100;
    }
    data.push_back(data_s);  

    count = 0;

    N++;
  }

  for (int i = 0; i < N; i++)
  {
    if(data[i][0] + data[i][1] >= 80 ) cout<<"A"<<endl;
    else if(data[i][0] + data[i][1] >= 65 )cout<<"B"<<endl;
    else if(data[i][0] + data[i][1] >= 50 )cout<<"C"<<endl;
    else if(data[i][0] + data[i][1] >= 30 )
    {
      if(data[i][2] >= 50)cout<<"C"<<endl;
      else cout<<"D"<<endl;
    }
    else
    {
      cout<<"F"<<endl;
    }
    
    
  }
  
  

  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3092
import math
N,H = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
amax = 0
ind = -1
for i in range(N):
    a,_ = X[i]
    if a>amax:
        amax = a
        ind = i
B = []
for i in range(N):
    _,b = X[i]
    if b>=amax:
        B.append(b)
B = sorted(B,reverse=True)
if sum(B)>=H:
    cnt = 0
    for i in range(len(B)):
        cnt += B[i]
        if cnt>=H:
            print(i+1)
            break
else:
    H -= sum(B)
    cnt = len(B)
    n = math.ceil(H/amax)
    print(cnt+n)

Measured memory_bytes: 93068
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long[] a=new long[n+1];
    for(int i=1;i<=n;i++){
      a[i]=a[i-1]+sc.nextLong();
    }
    long min=Long.MAX_VALUE;
    for(int i=1;i<n;i++){
      min=Math.min(Math.abs(a[i]-a[0]-a[n]+a[i]),min);
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 73932
#include <bits/stdc++.h>
using namespace std;
 
bool vis[10];
 
int n, k;
 
bool check(int k) {
	while (k) {
		int t = k % 10;
		k /= 10;
		if (vis[t]) return 0;
	}
	return 1;
}
 
int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= k; i ++) {
		int x;
		scanf("%d", &x);
		vis[x] = 1;
	}
	while (!check(n)) n ++;
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 3780
n = int(input())
h = list(map(int,input().split()))
l = list()
maxNum = 0
for x in range(len(h)):
    if x < len(h)-1:
        if h[x] >= h[x+1]:
            maxNum += 1
        else:
            l.append(maxNum)
            maxNum = 0
l.append(maxNum)
print(max(l))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n, a, b, c, d;
  cin >>  n >> a >> b >> c >> d;
  a--; b--; c--; d--;
  string s;
  cin >> s;

  bool ok = true;

  REP2(i,a,c+1) {
    if(s[i] == '#' && s[i+1] == '#') ok = false;
  }
  REP2(i, b, d+1){
      if(s[i] == '#' && s[i+1] == '#') ok = false;
  }
  
  if(!ok){
    cout << "No" << endl;
    return 0;
  }

  if(c < d){
    cout  << "Yes" << endl;
    return 0;
  }

  ok = false;

  REP2(i,b,d+1){
    if(s[i+1] == '.' && s[i] == '.' && s[i-1] == '.'){
      ok = true;
      break;
    }
  }

  if(ok){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3736
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    int n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    sort(all(a),greater<ll>());
    ll b=a[0];
    b+=b-1;
    ll ans=0;
    rep(i,n) ans+=a[i]-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
template<int BUFSIZE>
struct ans_buf {
  char buf[BUFSIZE];
  int i;
  ans_buf(): i(0) {}
  void putZ(unsigned int v, char delim='\n') {
    unsigned int k = 1;
    while(k <= v/10) k*=10;
    for(; k>0; v%=k, k/=10) buf[i++] = (v/k)+'0';
    buf[i++] = delim;
  }
  void out() { std::fwrite(buf, 1, i, stdout); }
};

int const MAXN = 3e5;
int const MAXA = 6.4e5;
int N, m[MAXN], d[MAXN+1];

int main() {
  std::cin >> N;
  std::fill_n(m, N, 0);
  for(int i = 0; i < N; ++i) { int A; std::cin >> A; ++m[A-1]; }
  std::fill_n(d, N+1, 0);
  for(int i = 0; i < N; ++i) ++d[m[i]];
 
  ans_buf<MAXA> buf;
  int sum_D = 0, sum_iD = N, k = 1;
  for(int ans = N; ans >= 1; --ans) {
    sum_D += d[ans];
    sum_iD -= d[ans]*ans;
    int next_k = sum_iD/ans + sum_D + 1;
    for(int i = k; i < next_k; ++i) buf.putZ(ans);
    k = next_k;
  }
  while(k <= N) { buf.putZ(0); ++k; }
  buf.out();
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  
  int Anum = 0, Bnum = 0, ABnum = 0, ans = 0;
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    for (int j = 0; j < S.size() - 1; j++){
      if (S.at(j) == 'A' && S.at(j + 1) == 'B'){
        ans++;
      }
    }
    
    if (S.at(S.size() - 1) == 'A'){
      
      if (S.at(0) == 'B'){
        ABnum++;
      }
      else{
        Anum++;
      }
      
    }
    else{
    
      if (S.at(0) == 'B'){
        Bnum++;
      }
      
    }
    
  }
  
  ans += min(Anum, min(Bnum, N - 1));
  if (ABnum > 0){
    if (max(Anum, Bnum) > 0){
      ans += ABnum;
    }
    else{
      ans += ABnum - 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include "stdio.h"

char top[100002];
int ans=0;

int main() {
	scanf("%s", top);
	for (int i = 0; i < 100000; i++) {
		if (top[i] == 'g') ans++;
		if (top[i] == 'p')ans--;
	}
	ans /= 2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int n;
ll k;
vector<int> G[100100];
ll mod=1e9+7;
ll ans=1;
int used[100100];
void dfs(int s,int fi,int se){
    used[s]=1;
    ans*=(k-fi-se);
    ans%=mod;
    for(auto g:G[s]){
        if(used[g])continue;
        dfs(g,1,fi);
        fi++;
    }
    return;
}

int main(){
    cin >> n >> k;
    for(int i=0;i<n-1;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,0,0);
    cout << ans%mod << endl;
}

Measured memory_bytes: 8448
Imports System
Imports System.Collections

Module Program
    Sub Main(args As String())
        Dim intN As Integer = Console.ReadLine()
        Dim tmpA As String() = Split(Console.ReadLine(), " ")

        Dim i As Integer = 0
        Dim ht As Hashtable = New Hashtable

        For i = 0 To intN - 1
            If ht(tmpA(i)) = 1 Then
                Console.WriteLine("NO")
                Exit Sub
            End If
            ht(tmpA(i)) = 1
        Next
        Console.WriteLine("YES")
    End Sub
End Module


Measured memory_bytes: 61516
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,ma;
	while(cin>>n,n){
		string s[260];
		rep(i,n)
		cin>>s[i];
		ma=0;
		rep(i,n){
			rep(j,n){
				if(s[i][j]=='1'){
					for(int k=0;k<=n;k++){
						if(j+k==n||s[i][j+k]=='0'){
							ma=max(ma,k);
							break;
						}
					}
					for(int k=0;k<=n;k++){
						if(i+k==n||s[i+k][j]=='0'){
							ma=max(ma,k);
							break;
						}
					}
					for(int k=0;k<=n;k++){
						if(i+k==n||j+k==n||s[i+k][j+k]=='0'){
							ma=max(ma,k);
							break;
						}
					}
					for(int k=0;k<=n;k++){
						if(i+k==n||j-k==-1||s[i+k][j-k]=='0'){
							ma=max(ma,k);
							break;
						}
					}
					
				}
			}
		}
		cout<<ma<<endl;
	}
	return 0;
}

Measured memory_bytes: 996
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var S = sc.next();
		var T = sc.next();

		var res = T.length();
		for (var i = 0; i <= S.length() - T.length() ; i++) {
			var cnt = 0;
			for (var j = 0; j < T.length(); j++) {
				if (S.charAt(i + j) != T.charAt(j)) {
					cnt++;
				}
			}
			res = Math.min(res, cnt);
		}
		System.out.println(res);

	}
}


Measured memory_bytes: 35692
S = input()
a=[]
b=[]
for i in range(len(S)):
    if i%2 == 0:
        a.append(0)
        b.append(1)
    else:
        a.append(1)
        b.append(0)
Slist = [int(i) for i in S]
counta=0
countb=0

for i in range(len(Slist)):
    if Slist[i] != a[i]:
        counta+=1
    if Slist[i] != b[i]:
        countb+=1
if counta<=countb:
    print(counta)
else:
    print(countb)

Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
const int maxn=1000005,INF=0x7FFFFFFF,dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef pair <int,int> P;
priority_queue < P,vector<P>,greater<P> > Q;
vector <int> No[maxn];
vector <char> mat[maxn];
int r,c,k,n,X1,Y1,X2,Y2,u[maxn],dis[maxn];
P coo[maxn];
void bfs()
{
	u[1]=No[X1][Y1];
	dis[u[1]]=0;
	for (int head=1,tail=1;head<=tail;head++)
		for (int d=0,X,Y;d<4;d++)
		{
			X=coo[u[head]].first;
			Y=coo[u[head]].second;
			for (int i=1;i<=k;i++)
			{
				X+=dx[d];
				Y+=dy[d];
				if (X<1 || X>r || Y<1 || Y>c || mat[X][Y]=='@') break;
				int v=No[X][Y];
				if (dis[u[head]]+1>dis[v]) break;
				if (dis[u[head]]+1==dis[v]) continue;
				dis[v]=dis[u[head]]+1;
				u[++tail]=v;
				if (v==No[X2][Y2])
				{
					printf("%d\n",dis[v]);
					exit(0);
				}
			}
		}
}
int main()
{
	scanf("%d%d%d%d%d%d%d",&r,&c,&k,&X1,&Y1,&X2,&Y2);
	for (int i=1;i<=r;i++)
	{
		No[i].push_back(0);
		mat[i].push_back('.');
		for (int j=1;j<=c;j++)
		{
			char x;
			scanf(" %c",&x);
			No[i].push_back(++n);
			mat[i].push_back(x);
			coo[n].first=i;
			coo[n].second=j;
		}
	}
	for (int i=1;i<=n;i++) dis[i]=INF;
	bfs();
	puts("-1");
	return 0;
}


Measured memory_bytes: 71540
#include <stdio.h>
#include <stack>
#include <vector>

using namespace std;

//FILE *in = freopen("input.txt", "r", stdin);
//FILE *out = freopen("output.txt", "w", stdout);

int n, m;
char str1[1000];

int ind[15][3];
int indent[15];

int rind[15][3];

int res[15];

int R, C, S;

void input() {
	for(int i = 0; i < m; i++) {
		res[i] = -2;
	}
	
	ind[0][0] = ind[0][1] = ind[0][2] = 0;
	for(int i = 0; i < n; i++) {
		gets(str1);
		int cnt = 0;
		int j;
		for(j = 0; str1[j]; j++) {
			if(str1[j] == '.') {
				++cnt;
			}
			else
				break;
		}
		indent[i] = cnt;
		for(;str1[j];j++) {
			switch(str1[j]) {
			case '(':
				++ind[i][0];
				break;
			case '{':
				++ind[i][1];
				break;
			case '[':
				++ind[i][2];
				break;
			case ')':
				--ind[i][0];
				break;
			case '}':
				--ind[i][1];
				break;
			case ']' :
				--ind[i][2];
				break;
			}
		}
		ind[i+1][0] = ind[i][0];
		ind[i+1][1] = ind[i][1];
		ind[i+1][2] = ind[i][2];
	}

	rind[0][0] = rind[0][1] = rind[0][2] = 0;
	for(int i = 0; i < m; i++) {
		gets(str1);
		for(int j = 0; str1[j]; j++) {
			switch(str1[j]) {
			case '(':
				++rind[i][0];
				break;
			case '{':
				++rind[i][1];
				break;
			case '[':
				++rind[i][2];
				break;
			case ')':
				--rind[i][0];
				break;
			case '}':
				--rind[i][1];
				break;
			case ']' :
				--rind[i][2];
				break;
			}
		}
		rind[i+1][0] = rind[i][0];
		rind[i+1][1] = rind[i][1];
		rind[i+1][2] = rind[i][2];
	}
}

void process2() {
	for(int i = 0; i < m - 1; i++) {
		int r = R*rind[i][0];
		int c = C*rind[i][1];
		int s = S*rind[i][2];

		if(r < 0 || c < 0 || s < 0) {
			res[i] = -1;
		}
		else {
			if(res[i] != -2 && res[i] != r + c + s) {
				res[i] = -1;
			}
			else {
				res[i] = r + c + s;
			}
		}
	}
}

void process() {
	bool rf = false, cf = false, sf = false;
	for(int i = 0; i < n - 1; i++) {
		if(ind[i][0])rf = true;
		if(ind[i][1])cf = true;
		if(ind[i][2])sf = true;
	}
	for(R = rf ? 1 : -1; R <= 20; R++) {
		if(R == 0) continue;
		for(C = cf ? 1 : -1; C <= 20; C++) {
			if(C == 0) continue;
			for(S = sf ? 1 : -1; S <= 20; S++) {
				if(S == 0) continue;
				int i;
				for(i = 0 ; i < n - 1; i++) {
					if(indent[i+1] != R*ind[i][0] + C*ind[i][1] + S*ind[i][2])
						break;
				}
				if(i == n - 1) {
					process2();
				}
			}
		}
	}
}

void output() {
	printf("0 ");
	for(int i = 0; i < m - 2; i++) {
		printf("%d ", res[i]);
	}
	printf("%d", res[m-2]);
	printf("\n");
}

int main() {
	while(true){
		scanf("%d%d\n", &n, &m);
		if (n == 0 && m == 0) break;
		R = -1;
		C = -1;
		S = -1;
		input();
		process();
		output();
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int n,a,i,r,c,o;
    while(cin>>n)
    {
        c=0,r=0,o=0;
        for(i=0; i<n; i++)
        {
            cin>>a;
            if(o>=a)
                c++;
            else
            {
                r=max(r,c);
                c=0;
            }
            o=a;
        }
        cout<< max(r,c)<<endl;
    }
}


Measured memory_bytes: 256