akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n, m;
  cin >> n >> m;
  int lma = -1, rmi = inf;
  rep (i, m) {
    int l, r;
    cin >> l >> r;
    chmax(lma, l);
    chmin(rmi, r);
  }
  if (lma <= rmi) {
    cout << rmi - lma + 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = [input() for i in range(H)]
res = [0 for i in range(W)]
for i in range(W):
  for j in range(H):
    if a[j][i] != ".":
      break
    res[i] += 1
for i in range(H):
  if a[i][0:].count("#") >0:
    for j in range(W):
      if res[j] != H:
        print(a[i][j],end="")
    print("")

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

const int MAXN = 200000 + 10;

int n;
int a[MAXN];
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin >> n;

    int m = n;

    vector<int> buck[6];
    for (int i = 2; i <= 30000; i++) {
        if (i%6 == 3 && i > 9)
            buck[0].push_back(i);
        else if ((i%6 == 2 || i%6 == 4) && i > 4)
            buck[1].push_back(i);
        else if (i%6 == 0) {
            buck[2].push_back(i);
        }
    }

    reverse(begin(buck[0]), end(buck[0]));
    reverse(begin(buck[1]), end(buck[1]));
    reverse(begin(buck[2]), end(buck[2]));

    vector<int> ans;
    if (n > 4) {
        ans.push_back(3);
        ans.push_back(9);
        ans.push_back(2);
        ans.push_back(4);

        n -= 4;

        while (buck[0].size() >= 2 && n >= 2) {
            ans.push_back(buck[0].back());
            buck[0].pop_back();
            ans.push_back(buck[0].back());
            buck[0].pop_back();

            n -= 2;
        }

        while (buck[1].size() >= 2 && n >= 2) {
            ans.push_back(buck[1].back());
            buck[1].pop_back();
            ans.push_back(buck[1].back());
            buck[1].pop_back();

            n -= 2;
        }   

        while (buck[2].size() && n >= 1) {
            ans.push_back(buck[2].back());
            buck[2].pop_back();
            n--;
        }

        sort(begin(ans), end(ans));

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

        cerr << n << "\n";
        return 0;
    } else {
        if (n == 3) cout << "2 5 63\n";
        if (n == 4) cout << "2 5 20 63\n";
    }

    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    string t;
    cin >> t;
    for(char x:t){
        if(x=='?')cout << 'D';
        else cout << x;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n, d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> d >> n;
  cout << (n==100 ? 101 : n);
  FOR(i, 0, d) cout << "00";
  cout << endl;
  return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long int
#define db double
#define all(v) v.begin(),v.end()
#define inf 10000000000


using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/



int main(){
    IOS;
    ll t;
    t=1;
   //cin>>t;
    while(t--){
        string s;
        cin>>s;
        int p=s.length();
        string k;
        if(s[p-1]=='s'){
            k=s.substr(0,p);
            k+="es";
        }
        else{
            k=s.substr(0,p);
            k+="s";
        }

cout<<k;
    }
    return 0;
} 

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
int H = 0, W = 0;
std::vector< std::vector<char> > C;
int main(void){
    int i, j ;
    std::cin >> H >> W;
    C.resize(H, std::vector<char>(W, '\0'));
    for(i=0;i<H;++i) for(j=0;j<W;++j) std::cin >> C[i][j];

    for(i=0;i<2*H;++i){
        for(j=0;j<W;++j){
            std::cout << C[i/2][j];
        }
        std::cout << "\n";
    }
}


Measured memory_bytes: 256
// Problem : C - Peaks
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define lb "lower_bound"
#define ub "upper_bound"
#define bs "binary_search"

int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int min(int a,int b){if(a > b)return b;else return a;}
int max(int a,int b){if(a > b)return a;else return b;}
int gcd(int a, int b){if(b == 0)return a;return gcd(b, a%b);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int n,r;
    cin>>n>>r;
    int arr[n];
    for(int i = 0;i < n;i++)
    cin>>arr[i];
    bool check[n];
    for(int i = 0;i < n;i++)
    check[i] = true;
    int a,b;
    for(int i = 0;i < r;i++)
    {
    	cin>>a>>b;
    	if(arr[a - 1] < arr[b - 1])
    	check[a - 1] = false;
    	else if(arr[a - 1] > arr[b - 1])
    	check[b - 1] = false;
    	else
    	{
    		check[a - 1] = false;
    		check[b - 1] = false;
    	}
    }
    int count = 0;
    for(int i = 0;i < n;i++)
    {
    	if(check[i] == true)
    	count++;
    }
    cout<<count;
	return 0;
}


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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

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

    string s;
    cin >> s;

    cout << (s == "ABC"?"ARC":"ABC") << endl; 

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD=1e9+7;
int n,k,tot;
ll dp[110][100010];
pair<ll,ll> num[1000010];
int main(){
//	freopen("tst.txt","r",stdin);freopen("mans.txt","w",stdout);
	scanf("%d %d",&n,&k);
	for(int x=1,y,tmp;x<=n;){
		tmp=n/x;
		y=n/tmp;
		num[++tot]=make_pair(x,y);
		x=y+1;
	}
	for(int i=1;i<=tot;i++){
		dp[1][i]=num[i].second-num[i].first+1;
		dp[1][i]+=dp[1][i-1];
	}
	for(int i=2;i<=k;i++){
		for(int j=1;j<=tot;j++){
			ll tmp=1LL*dp[i-1][tot-j+1]*(num[j].second-num[j].first+1);
			tmp%=MOD;
			dp[i][j]=dp[i][j-1]+tmp;
			dp[i][j]%=MOD;
		}
	}
	printf("%d",dp[k][tot]%MOD);
	return 0;
}

Measured memory_bytes: 81152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

namespace linear_seq {
	const int N=10010;
	ll res[N],base[N],_c[N],_md[N];

	vector<int> Md;
	void mul(ll *a,ll *b,int k) {
		rep(i,0,k+k) _c[i]=0;
		rep(i,0,k) if (a[i]) rep(j,0,k) _c[i+j]=(_c[i+j]+a[i]*b[j])%mod;
		for (int i=k+k-1;i>=k;i--) if (_c[i])
			rep(j,0,SZ(Md)) _c[i-k+Md[j]]=(_c[i-k+Md[j]]-_c[i]*_md[Md[j]])%mod;
		rep(i,0,k) a[i]=_c[i];
	}
	int solve(ll n,VI a,VI b) { // a 系数 b 初值 b[n+1]=a[0]*b[n]+...
		ll ans=0,pnt=0;
		int k=SZ(a);
		assert(SZ(a)==SZ(b));
		rep(i,0,k) _md[k-1-i]=-a[i];_md[k]=1;
		Md.clear();
		rep(i,0,k) if (_md[i]!=0) Md.push_back(i);
		rep(i,0,k) res[i]=base[i]=0;
		res[0]=1;
		while ((1ll<<pnt)<=n) pnt++;
		for (int p=pnt;p>=0;p--) {
			mul(res,res,k);
			if ((n>>p)&1) {
				for (int i=k-1;i>=0;i--) res[i+1]=res[i];res[0]=0;
				rep(j,0,SZ(Md)) res[Md[j]]=(res[Md[j]]-res[k]*_md[Md[j]])%mod;
			}
		}
		rep(i,0,k) ans=(ans+res[i]*b[i])%mod;
		if (ans<0) ans+=mod;
		return ans;
	}
	VI BM(VI s) {
		VI C(1,1),B(1,1);
		int L=0,m=1,b=1;
		rep(n,0,SZ(s)) {
			ll d=0;
			rep(i,0,L+1) d=(d+(ll)C[i]*s[n-i])%mod;
			if (d==0) ++m;
			else if (2*L<=n) {
				VI T=C;
				ll c=mod-d*powmod(b,mod-2)%mod;
				while (SZ(C)<SZ(B)+m) C.pb(0);
				rep(i,0,SZ(B)) C[i+m]=(C[i+m]+c*B[i])%mod;
				L=n+1-L; B=T; b=d; m=1;
			} else {
				ll c=mod-d*powmod(b,mod-2)%mod;
				while (SZ(C)<SZ(B)+m) C.pb(0);
				rep(i,0,SZ(B)) C[i+m]=(C[i+m]+c*B[i])%mod;
				++m;
			}
		}
		return C;
	}
	int gao(VI a,ll n) {
		VI c=BM(a);
		c.erase(c.begin());
		rep(i,0,SZ(c)) c[i]=(mod-c[i])%mod;
		return solve(n,c,VI(a.begin(),a.begin()+SZ(c)));
	}
};
const int N=1010;
int h,w,row,col,b,row1,col1;
ll k;
char s[N][N];
int main() {
	scanf("%d%d%lld",&h,&w,&k);
	if (k==0) { puts("1"); return 0; }
	rep(i,0,h) scanf("%s",s[i]);
	rep(i,0,h) if (s[i][0]=='#'&&s[i][w-1]=='#') row++;
	rep(i,0,w) if (s[0][i]=='#'&&s[h-1][i]=='#') col++;
	rep(i,0,h) rep(j,0,w) {
		if (s[i][j]=='#') b++;
		if (s[i][j]=='#'&&j+1<w&&s[i][j+1]=='#') row1++;
		if (s[i][j]=='#'&&i+1<h&&s[i+1][j]=='#') col1++;
	}
	if (row&&col) puts("1");
	else if (!row&&!col) printf("%lld\n",powmod(b,k-1));
	else if (row) {		
		printf("%d\n",linear_seq::solve(k-1,VI{b+row,-b*row},VI{1,b-row1}));
	} else {
		printf("%d\n",linear_seq::solve(k-1,VI{b+col,-b*col},VI{1,b-col1}));
	}
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;

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

	long int a[n];
	long int i;
	long int max = -1000000;
	long int min = 1000000;
	long int sum = 0;

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

	for(i=0; i<n; i++){
		
		if(max<a[i]){
			max = a[i];
		}
		if(a[i]<min){
			min = a[i];
		}
		sum = sum + a[i];
	}

	cout << min << " " << max << " " << sum << endl;

}

Measured memory_bytes: 1240
import java.io.*;
import java.lang.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double total = Math.pow(a, 2) + Math.pow(a, 3) + a;
        System.out.println((int)(total));
    }
}


Measured memory_bytes: 37316
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
        int N = ri();
        int[] hArray = ria();

        int ans = 0;
        while(hArray.Count((i) => i != 0) != 0) {
            ans++;

            int maxHeight = hArray.Max();
            bool isWatering = false;
            bool startedWatering = false;
            for (int i = 0; i < N; i++)
            {
                isWatering = hArray[i] == maxHeight;
                if(isWatering) {
                    startedWatering = true;
                    hArray[i]--;
                } else if(startedWatering) {
                    break;
                }
            }
        }

		Console.WriteLine(ans);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N,M,K;
    cin >> N >> M >> K;
    vector<ll> A,B;

    A.push_back(0);
    B.push_back(0);

    rep(i,N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    ll now = 0;
    rep(i,M) {
        int b;
        cin >> b;
        B.push_back(b);
        now += b;
    }

    int ans = 0;
    int j = M;
    rep(i,N+1) {
        while(j>0 && now>K) {
            now -= B[j];
            j--;
        }
        if (j==0 and now>K) break;
        ans = max(ans,i+j);
        if (i==N) break;
        now+=A[i+1];
    }

    cout << ans << endl;


}

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

using namespace std;

const int maxn = 5*(int)1e5+100;
int n, a[maxn], b[maxn], t[maxn*45], lt[maxn*45], rt[maxn*45], tVal[maxn*45], tot;
int lst[maxn];    //记录离散化后数组的上次出现位置
int q;

void init() {
    tot = 0;
    memset(lst, -1, sizeof(lst));
}
int build(int l, int r) {
    int node = ++tot;
    tVal[node] = 0;
    int mid = (l + r) >> 1;
    if (l < r) {
        lt[node] = build(l, mid);
        rt[node] = build(mid+1, r);
    }
    return node;
}
int update(int l, int r, int par, int p, int val) {
    int node = ++tot;
    lt[node] = lt[par]; rt[node] = rt[par]; tVal[node] = tVal[par] + val;
    int mid = (l + r) >> 1;
    if (l < r) {
        if (p <= mid) lt[node] = update(l, mid, lt[par], p, val);
        else rt[node] = update(mid+1, r, rt[par], p, val);
    }
    return node;
}
int query(int l, int r, int p, int node) {
    if (l == r) return tVal[node];
    int mid = (l + r) >> 1;
    if (p <= mid) return (query(l, mid, p, lt[node]) + tVal[rt[node]]);
    else return query(mid+1, r, p, rt[node]);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    init();
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int len = unique(b + 1, b + 1 + n) - b;
    for (int i = 1; i <= n; ++i)
        a[i] = lower_bound(b + 1, b + 1 + len, a[i]) - b;

    t[0] = build(1, n);
    for (int i = 1; i <= n; ++i) {
        if (lst[a[i]] == -1) t[i] = update(1, n, t[i-1], i, 1);
        else {
            int temp = update(1, n, t[i-1], lst[a[i]], -1);
            t[i] = update(1, n, temp, i, 1);
        }
        lst[a[i]] = i;
    }
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << query(1, n, l, t[r]) << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256652
#include<iostream>
#include<string>
using namespace std;
int main(){
  string w;
  string t;
  cin >> w;
  int i;
  for(i=0;i<w.size();i++) {
    if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
  }
  int o=0;
  cin >> t;
  while(t!="END_OF_TEXT"){
  
    for(i=0;i<t.size();i++) {
      if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
    }
    if(w==t) o++;
    cin >> t;
  }
  cout << o << endl;
}



Measured memory_bytes: 3216
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
		int s1=a*b;
		int s2=c*d;
		if(s1>s2){
			printf("%d\n",s1);
		}else{
			printf("%d\n",s2);
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;


int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int m=max( {A,B,C} );

    int sum=(A+B+C);

    while(true){
        if((3*m)%2==sum%2){
            debug(m);
            cout<<((m-A)+(m-B)+(m-C))/2<<endl;
            return 0;
        }
        m++;
    }
  
}


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

int main()
{
	long long int i, j, k, l, m,N,ans,K, n, o, p,sum,flag;
	sum = 0;
	flag = 1;
	cin >> N >> K;
if(K%2==1){
		ans = (N / K)*(N / K)*(N / K);
	}
	else {
		if (N/(K/2) % 2 == 0) {
			ans = (N / K)*(N / K)*(N / K) * 2;
		}
		else
			ans = (N / K)*(N / K)*(N / K) + (N / K + 1)*(N / K + 1)*(N / K + 1);

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



Measured memory_bytes: 256
#include "algorithm"
#include "cmath"
#include "functional"
#include "iostream"
#include "map"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;

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

  ll N = S.size();
  V<ll> mods(N + 1);

  rep(i, N) { mods[i + 1] = (mods[i] * 10 + (S[i] - '0')) % 2019; }

  ll tenmo = 1;
  repr(i, N + 1) {
    mods[i] = (mods[i] * tenmo) % 2019;
    tenmo = tenmo * 10 % 2019;
  }

  ll res = 0;

  map<ll, ll> m;

  rep(i, N + 1) {
    ll mo = mods[i];
    res += m[mo];
    m[mo]++;
  }

  cout << res << "\n";
}


Measured memory_bytes: 5172
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int main()
{
	string S;
	int N;
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		int num = (S[i] - 'A' + N) % 26;
		S[i] = 'A' + num;
	}
	cout << S << endl;
}

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

int main(void){
    int N;
    cin >> N;
    int n = N;
    int total = 0;
    
    do{
        total += (N % 10);
        N /= 10;
    }while(N > 0);
    
    if(n % total == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int h, w, n;

void pp(vector<string> &vs){
	for (auto s : vs){
		cout << s << endl;
	}cout << endl;
}

bool drop(vector<string> &v){
	bool dr = false;
	for (int i = h - 2; i >= 0; --i) rep(j, w){
		if (v[i][j] == '.') continue;
		int i2 = i + 1;
		while (i2 < h && v[i2][j] == '.') ++i2;
		if (i != i2 - 1) dr = true;
		swap(v[i][j], v[i2 - 1][j]);
	}
	//pp(v);
	return dr;
}

void erase(vector<string> &v){
	vector<string> nxt = v;
	rep(i, h) rep(j, w){
		char c = v[i][j];
		if (c == '.') continue;
		if (i + n <= h){
			int cnt = 0;
			rep(d, n) cnt += c == v[i + d][j];
			if (cnt == n) rep(d, n) nxt[i + d][j] = '.';
		}
		if (j + n <= w){
			int cnt = 0;
			rep(d, n) cnt += c == v[i][j + d];
			if (cnt == n) rep(d, n) nxt[i][j + d] = '.';
		}
	}
	v.swap(nxt);
}

bool simulate(vector<string> v){
	drop(v);
	while (1){
		erase(v);
		if (!drop(v)) break;
	}
	rep(i, h) rep(j, w) if (v[i][j] != '.') return false;
	return true;
}

int main(){
	while (cin >> h >> w >> n){
		vector<string> vs(h);
		rep(i, h) cin >> vs[i];

		bool ans = false;
		rep(i, h) rep(j, w){
			if (j + 1 < w && vs[i][j] != vs[i][j + 1]){
				swap(vs[i][j], vs[i][j + 1]);
				ans |= simulate(vs);
				swap(vs[i][j], vs[i][j + 1]);
			}
		}
		cout << (ans ? "YES" : "NO") << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

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

  int red = n;
  while(1) {
    n -= 1000;
    if(n <= 0) {
      cout << n * -1 << endl;
      return 0;
    }
    red = n;
  }
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=a+b;
		if(c>=24) System.out.println(c%24);
		else System.out.println(c);

	}

}


Measured memory_bytes: 27028
#include<stdio.h>

int main(){
  int n;
  int a[100080];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
  scanf("%d",a+i);
  }
   a[0]--;
  int flag = 1;
   for(int i = 1;i<n;i++){
        if(a[i]>a[i-1]) a[i]--;
        if(a[i]<a[i-1]) {
            flag = 0;
            break;
        }
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;

  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int m,n,a[100010];
signed main(){
    cin>>m>>n;
    rep(i,n)cin>>a[i];
    if(m==2){
        int ans=INF,cnt=0;
        rep(i,n){
            if(i%2==0&&a[i]==2)cnt++;
            if(i%2==1&&a[i]==1)cnt++;
        }
        ans=min(ans,cnt);
        cnt=0;
        rep(i,n){
            if(i%2==0&&a[i]==1)cnt++;
            if(i%2==1&&a[i]==2)cnt++;
        }
        ans=min(ans,cnt);
        cout<<ans<<endl;
        return 0;
    }
    int ans=0;
    rep(i,n){
        if(i){
            if(a[i]==a[i-1]){
              ans++;
              a[i]=-i;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3880
S = list(input())

SS = [0] * 26

lis = [chr(i) for i in range(97, 97 + 26)]

for S in S:
    ind = lis.index(S)
    if SS[ind] == 0:
        SS[ind] = 1
    else:
        print("no")
        break
else:
    print("yes")

Measured memory_bytes: 9052
import sys
import math
import bisect

def solve(a, b):
    for i in range(1, 3000):
        c = math.floor(i * 0.08)
        d = math.floor(i * 0.10)
        if c == a and d == b:
            return i
    return -1

def main():
    a, b = map(int, input().split())
    ans = solve(a, b)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 39024
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll extgcd(ll a, ll b, ll& x, ll& y) {//ax+by=1
  if (b == 0) {
    x = 1, y = 0; return a;
  }
  ll q = a/b, g = extgcd(b, a - q*b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return g;
}

ll invmod (ll a, ll m) { // a^-1 mod m
  ll x, y;
  extgcd(a, m, x, y);
  x %= m;
  if (x < 0) x += m;
  return x;
}

ll N,K;
P A[200010];
int state=-1;
int main(){
    cin>>N>>K;
    for(ll i=0;i<N;i++){
        ll a;
        cin>>a;
        if(a<0) A[i]=P(-a,-1);
        else if(a>0){
            A[i]=P(a,1);
            state=1;
        }else{
            A[i]=P(a,0);
            if(state==-1)state=0;
        }
    }
    ll ans=1;
    if(state==-1){
        if(K%2==1){
            sort(A,A+N);
            for(ll i=0;i<K;i++){
                ans=(ans*A[i].first)%MOD;
            }
            cout<<(MOD-ans)<<endl;
        }else{
            sort(A,A+N,greater<P>());
            for(ll i=0;i<K;i++){
                ans=(ans*A[i].first)%MOD;
            }
            cout<<ans<<endl;
        }
        return 0;
    }
    if(state==0){
        if(K%2==1){
            cout<<0<<endl;
        }else{
            sort(A,A+N,greater<P>());
            for(ll i=0;i<K;i++){
                ans=(ans*A[i].first)%MOD;
            }
            cout<<ans<<endl;
        }
        return 0;
    }

    sort(A,A+N,greater<P>());
    ll minusCnt=0;
    ll plusMin=INF,minusMin=INF;
    for(ll i=0;i<K;i++){
        if(A[i].second==-1){
            minusCnt++;
            minusMin=min(minusMin,A[i].first);
        }else{
            plusMin=min(plusMin,A[i].first);
        }
        ans=(ans*A[i].first)%MOD;
    }
    if(minusCnt%2==0){
        cout<<ans<<endl;
        return 0;
    }
    if(K==N){
        if(ans==0){
            cout<<0<<endl;
        }else{
            cout<<(MOD-ans)<<endl;
        }
        return 0;
    }
    ll plusMax=-1;
    ll minusMax=-1;
    for(ll i=K;i<N;i++){
        if(A[i].second==1){
            plusMax=max(plusMax,A[i].first);
        }else if(A[i].second==-1){
            minusMax=max(minusMax,A[i].first);
        }
    }
    if(plusMax==-1 && minusMax==-1){
        cout<<0<<endl;
        return 0;
    }
    if(plusMin==INF){
        cout<<ans*invmod(minusMin,MOD)%MOD*plusMax%MOD<<endl;
        return 0;
    }

    if(plusMax*plusMin < minusMax*minusMin){
        cout<<ans*invmod(plusMin,MOD)%MOD*minusMax%MOD<<endl;
    }else{
        cout<<ans*invmod(minusMin,MOD)%MOD*plusMax%MOD<<endl;
    }
    return 0;
}

Measured memory_bytes: 6736
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
ll X, Y;

/*==================================================*/
/*function*/

/*==================================================*/

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

    int ans = 0;
    while(X <= Y){
        ans++;
        X *= 2;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
N, K = [int(n) for n in input().split()]
S = input()

sentous = []
sentou = 0
max_count = 0
count = 0
prev = '1'
for s in S:
    count += 1
    sentou += 1
    if s != prev and s == '1':
        sentous.append(sentou - 1)
        sentou = 1
    elif s != prev and s == '0':
        if K > 0:
            K -= 1
        else:
            if count - 1 > max_count:
                max_count = count - 1
            count -= sentous.pop(0)
    prev = s

print(max(max_count, count))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main(){
    int x,y;
    cin >> x >> y;
    cout << x + y/2 << endl;
    return 0;
}

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



int main()
{
    int a,b;
    int i=0;
    while(scanf("%d",&a)!=EOF||i<50){
        cin >> b;
        cout << (int)log10(a+b)+1 << endl;
        i++;
    }
    return 0;
}



Measured memory_bytes: 3420
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s,ans="";
	cin>>s;
	int w;
	cin>>w;
	int l=s.length();

	FOR(i,0,l){
		if(i%w==0){
			ans+=s[i];
		}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(n * a, b);
    cout << ans << endl;
    return 0;
}


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

const long long MOD = 1000000007;

const long long MAX = 10e5*3;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve(long long n, long long k){
    COMinit();
    if(k>=n-1){
        cout << COM(2*n-1,n) << endl;
        return;
    }
    long long ans = 0;
    for(int i=0;i<=k;i++){
        ans += (COM(n,i)%MOD) * (COM(n-1,n-1-i)%MOD) %MOD;
        ans %= MOD;
    }
    cout << ans <<endl;
    return;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long n;
    scanf("%lld",&n);
    long long k;
    scanf("%lld",&k);
    solve(n, k);
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
#define PB push_back
#define INF 1000000001
#define INFL 1000000000000000001
#define M 1000000007
int main(void){
	int x;
	cin>>x;
	while(1){
		bool p=true;
		for(int i=2;i*i<=x;i++){
			if(x%i==0)p=false;
		}
		if(p){
			printf("%d\n",x);
			return 0;
		}
		x++;
	}
}


Measured memory_bytes: 256
h, w, k = [ int(v) for v in input().split() ]
field = [ list(input()) for i in range(h) ]
adjust_list = ((0,1),(0,-1),(1,0),(-1,0))
for i in range(h):
    for j in range(w):
        if field[i][j] == "S":
            s = (i,j)

def nearest(y, x):
    return min(y,h-1-y,x,w-1-x) 


def bfs():
    global field, adjust_list, s
    search_list = [s]
    for _ in range(k):
        new_search_list = []
        for i in search_list:
            for j in adjust_list:
                if 0 <= i[0]+j[0] < h and 0 <= i[1]+j[1] < w:
                    if field[i[0]+j[0]][i[1]+j[1]] == ".":
                        field[i[0]+j[0]][i[1]+j[1]] = "S"
                        new_search_list.append((i[0]+j[0],i[1]+j[1]))
        search_list = new_search_list
    return

bfs()
print(1 + ( min([ nearest(i,j) for j in range(w) for i in range(h) if field[i][j] == "S" ]) + k - 1 ) // k)


Measured memory_bytes: 104124
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int A[55] = { 11,31,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451,1471 };
	for (int i = 0; i < n; i++) cout << A[i]<<" ";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    char c;
    std::cin >> c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        std::cout << "vowel" << std::endl;
    }else{
        std::cout << "consonant" << std::endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int n;
int a[25];
int b[25];
int c[25];
int ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=1;i<n;i++){
		scanf("%d",&c[i]);
	}
	for(int i=1;i<=n;i++){
		ans+=b[a[i]];
		if(a[i]+1==a[i+1]){
			ans+=c[a[i]];
		}
	}
	printf("%d\n",ans);
}

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

//#define int long long
#define X first
#define Y second
#define pb push_back
#define sz(v) (int) v.size()

using namespace std;

typedef long long ll;
typedef long double ld;

struct Event {
    int x, type, color, start;

    Event() {}

    Event(int x, int type, int color, int start):
        x(x), type(type), color(color), start(start) {}

    friend bool operator < (const Event &a, const Event &b) {
        return a.x == b.x ? a.type < b.type : a.x < b.x;
    }
};

const int N = 1e5 + 5, M = 1e5 + 5;

int n, m;
vector<Event> sc;
ll dp[N];

main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int L, R, c;
        cin >> L >> R >> c;
        sc.pb(Event(L, 1, c, L));
        sc.pb(Event(R, -1, c, L));
    }
    sort(sc.begin(), sc.end());
    multiset<ll> go;
    for (int i = 1, j = 0; i <= n; ++i) {
        if (i > 1) {
            if (go.empty()) return cout << "-1\n", 0;
            dp[i] = *go.begin();
        }
        while (j < sz(sc) && sc[j].x == i) {
            if (sc[j].type == -1) {
                go.erase(go.find(dp[sc[j].start] + sc[j].color));
            } else {
                go.insert(dp[i] + sc[j].color);
            }
            ++j;
        }
    }
    cout << dp[n] << "\n";

    return 0;
}


Measured memory_bytes: 7344
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int HPtaka = sc.nextInt();
        int APtaka = sc.nextInt();
        int HPao = sc.nextInt();
        int APao = sc.nextInt();
        int flag = 0;
        while(true){
            HPao -= APtaka;
            if(0 >= HPao){
                flag += 1;
                break;
            }
            HPtaka -= APao;
            if(0 >= HPtaka){
                break;
            }
        }
        if(flag == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35760
import numpy as np

n, w = list(map(int, input().split()))
wv = np.array([list(map(int, input().split(" "))) for _ in range(n)])

dp = np.zeros((w + 1, n), dtype=np.int)
dp[wv[0, 0] :, 0] = np.full(dp[wv[0, 0] :, 0].shape, wv[0, 1])
for i in range(1, n):
    dp[:, i] = dp[:, i - 1]
    wNew, vNew = wv[i, 0], wv[i, 1]
    dp[wNew:, i] = np.fmax(dp[wNew:, i - 1], vNew + dp[:-wNew, i - 1])

print(dp[w, n - 1])


Measured memory_bytes: 92268
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
reader.on('close', () => {
  var a = 1*lines[0].split(' ')[0] * 1*lines[0].split(' ')[1];
  if(a%2 == 1){
  console.log('Odd')}
  else{
    console.log('Even')
  }
//console.log(1*lines[0]+1*lines[1].split(' ')[0]+1*lines[1].split(' ')[1]+" "+lines[2])
});

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
 
  set<string> num;
  for(int j=0; j<n; j++){
    num.insert(s[j]);
  }
  
  cout << num.size() << endl;
  
  
  
}

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

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

	int count[5][4][11] = {};
	int b = 0; int f = 0; int r = 0; int v = 0;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		count[b][f][r] += v;
	}

	for (int i = 1; i < 5; i++) {
		for (int j = 1; j < 4; j++) {
			for (int k = 1; k < 11; k++) {
				cout << " " << count[i][j][k];
			}
			cout << endl;
		}
		if (i == 4) continue;
		cout << "####################" << endl;
	}

	return 0;
}


Measured memory_bytes: 3080
n = int(input())

stack = [0]
ans = 0
while stack:
    tmp = stack.pop()
    if tmp <= n:
        if len(set(str(tmp))) == 3:
            ans += 1
        x = tmp * 10 + 3
        y = tmp * 10 + 5
        z = tmp * 10 + 7
        stack += [x, y, z]

print(ans)

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

int main() {
  ll n;
  cin >> n;
  ll mn = MAX;
  vector<ll> d(5);
  rep(i, 5) {
    cin >> d[i];
    mn = min(mn, d[i]);
  }
  if(mn  >= n ){
    cout << 5 << endl;
    return 0;
  }
  ll ans = n / mn + 4;
  if(n % mn != 0)ans++;
  cout << ans << endl;
}

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

int main() {
  int N , K, sum;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x > K){
      sum += 2 * (x-K);
    }else if (K-x <= x){
      sum += 2 * (K-x);
    }else{
      sum += 2 * x;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MN 100
using namespace std;
int n,m,cnt[MN];
int main()
{
    scanf("%d%d",&n,&m);
    memset(cnt,0,sizeof(cnt));
    for(int i=1;i<=m;i++)
    {
        int a;int b;
        scanf("%d%d",&a,&b);
        cnt[a]++,cnt[b]++;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",cnt[i]);
    }
    return 0;
}


Measured memory_bytes: 384
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val L = readLine().split(" ").map(_.toInt)

  def solve() = {
    (0 until n).combinations(3).foldLeft(0) { (acc, combi) =>
      val list = for(i <- combi) yield L(i)
      val max = list.max
      val others = list.sum - max
      if(others > max && list(0) != list(1) && list(1) != list(2) && list(0) != list(2)) acc+1 else acc
    }
  }

  println(solve())

}



Measured memory_bytes: 57724
import sys
from collections import defaultdict
input = sys.stdin.readline
h,w,m=map(int, input().split())
hd=[0 for i in range(h+1)]
wd=[0 for i in range(w+1)]
hw=defaultdict(int)
hmax=0
wmax=0
for i in range(m):
    h0,w0=map(int, input().split())
    hd[h0]+=1
    hmax=max(hmax,hd[h0])
    wd[w0]+=1
    wmax=max(wmax,wd[w0])
    hw[(h0,w0)]+=1

max_h_list=[]
max_w_list=[]
for k in range(h+1):
    if hd[k]==hmax:
        max_h_list.append(k)

for k in range(w+1):
    if wd[k]==wmax:
        max_w_list.append(k)

ans=float('inf')

for x in max_h_list:
    for y in max_w_list:
        if hw[(x,y)]==1:
            ans=min(ans,1)
        else:
            ans=min(ans,0)
            break
print(hmax+wmax-ans)


Measured memory_bytes: 212548
S = input()
words = ['dreamer','dream','eraser','erase']
i = len(S)
while i>0:
    update = False
    for w in words:
        if S[:i].endswith(w):
            i -= len(w)
            update =True
            break
    if not update:
        break
print('YES' if i == 0 else 'NO')

Measured memory_bytes: 9144