akhauriyash/Code-Regression huggingface dataset:
const N=parse(Int,readline())
const A=Int[]
for s=readlines()
	C=zeros(Int,26)
	for c=chomp(s)
		C[Int(c)-96]+=1
	end
	now=0
	for i=1:26
		for j=1:C[i]
			now=now*26+i-1
		end
	end
	push!(A,now)
end
ans=0
sort!(A)
L=1
while L<=N
	R=L
	while R<=N&&A[R]==A[L]
		R+=1
	end
	ans+=div((R-L)*(R-L-1),2)
	L=R
end
println(ans)

Measured memory_bytes: 170452
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let d: usize = sc.read();
    let d = d * 2 + 1;
    let ans = (n + d - 1) / d;
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int x,y;
    cin >> x >> y;
    int group[12] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
    if(group[x - 1] == group[y - 1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n;cin>> n;
    int h[n];
    rep(i,n)cin >> h[i];
    int ans = 0;
    int nh = 1;
    rep(d,100){
        int f = 0;
        rep(i,n){
            if(h[i] > 0){
                h[i]--;
                f = 1;
            }
            else if(f){
                ans++;
                f = 0;
            }
        }
        if(f)ans++;


    }
    cout << ans;

    return 0;
}

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

int main(){

    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for(int i = 0; i < N; i++) cin >> x[i];

    int ans = 0;
    for(int i = 0; i < N; i++) ans += 2 * min(x[i], K - x[i]);

    cout << ans << endl;

    return 0;
}

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

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

b_index = 0
for i in range(N):
    for j in range(len(A[i])):
        if A[i][j] == B[0][0]:
            for i2 in range(M):
                for j2 in range(len(B[i2])):
                    if i+i2 > N-1 or j+j2 > len(A[i+i2])-1:
                        break
                    elif A[i+i2][j+j2] != B[i2][j2]:
                        break
                else:
                    continue
                break
            else:
                print('Yes')
                exit()
print('No')


                



Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
        int n,m,x,a[100],i,b=0,c=0,j;

        scanf("%d%d%d",&n,&m,&x);

        for (i=1;i<=m;i++)
                scanf("%d",&a[i]);

        for (i=x;i<n;i++)
                for (j=1;j<=m;j++)
                        if (i==a[j])
                                b++;

        for (i=x;i>=1;i--)
                for (j=1;j<=m;j++)
                        if (i==a[j])
                                c++;

        if (b>c)
                printf("%d\n",c);
        else
                printf("%d\n",b);

        return 0;
}


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

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

int main(){
  int n; cin >> n;
  set<int> st;
  int mx = 0;
  REP(i, n)
  {
    int x;
    cin >> x;
    if(st.count(0) || mx > x) cout << "No" << endl;
    else if(mx == x && st.size() > x) cout << "No" << endl;
    else
    {
      cout << "Yes" << endl;
      int t = x;
      while(1)
      {
        if(st.count(t) == 0)
        {
          st.insert(t);
          if(t - mx == 1) 
          {
            for(int j = t;; j++)
            {
              if(st.count(j) == 0) break;
              mx++;
            }
          }
          break;
        }
        else
        {
          st.erase(t);
          t--;
        }
      }
    }

  }



  return 0;
}

Measured memory_bytes: 14796
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int n, m;
    cin>>n>>m;
    VI v(m);
    int s = 0;
    rep(i, m)
    {
        cin>>v[i];
        s+=v[i];
    }
    if(s>n)
    {
        cout<<"-1";
    }
    else
        cout<<n-s;
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;

#define loop(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef string str;

int main ()
{
	int n;
	cin >> n;
	
	set<str> s;
	while ( n --)
	{
		str a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size();
}



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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  auto * const a = &A[0];
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  auto _A(A);
  sort(_A.begin(), _A.end(), greater<int>());
  int first = _A[0];
  int second = _A[1];
  if (first == second)
    for (int i = 0; i < N; ++i)
      cout << first << endl;
  else
    for (int i = 0; i < N; ++i)
      cout << (first == a[i] ? second : first) << endl;
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int d,n;
	while(cin>>d>>n,d){
		vi v(42,0);
		rep(lp,n){
    		int l,r,h;  cin>>l>>r>>h;
    		for(int i=l+20;i<r+20;i++){
    		    v[i]=max(v[i],h);
    		}
		}
		vi nv(42,0);
		range(i,1,41){
		    nv[i]=min(v[i-1],v[i]);
		}
		v=nv;
		double ans=INF;
		for(int x=-d+21;x<=d+19;x++){
		    double t=v[x]-sqrt(d*d-(x-20)*(x-20));
		    ans=min(ans,t);
		    //cout<<x-20<<": "<<v[x]<<"  ";
		}
		cout<<fixed<<setprecision(4)<<ans+d<<endl;
	}
	return 0;
}



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

int main(){
	int mayors[50]{0};
	vector<int> ansvec;

	for(;;){
		int n, p;
		cin >> n >> p;
		if (n == 0) break;

		for (int i = 0; i < n; i++) mayors[i] = 0;
		int bowlp = p;
		int turn = 0;
		for(;;){
			if (bowlp == 1 && mayors[turn] == p - 1) break;
			else if (bowlp == 0){
				bowlp += mayors[turn];
				mayors[turn] = 0;
			}
			else{
				mayors[turn]++;
				bowlp--;
			}

			if (turn == n - 1) turn = 0;
			else turn++;
		}
		ansvec.push_back(turn);
	}

	for (int ans : ansvec){
		cout << ans << "\n";
	}
	return 0;
}

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

using namespace std;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()

long long inq(long long x, long long y)
{
    if (!y) return 1;
    long long l = inq(x, y / 2);
    if (y % 2) return l * l * x;
    return l * l;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, c;
    cin >> n >> c;
    vector<int> Len(n), p(n - 1);
    forn(i, n) cin >> Len[i], Len[i] *= n;
    sort(all(Len));
    c *= n;
    iota(all(p), 0);
    long long good = 0, all_ways = 0, W = Len[n - 1];
    while (1)
    {
        all_ways += inq(c / n, n - 1);
        vector<vector<int> > dp(c + 1, vector<int>((1 << (n - 1))));
        dp[W][0] = 1;
        for (int i = 0; i < c; i++)
        {
            if (i % n == 0) continue;
            int we = p[i % n - 1];
            int le = Len[we];
            for (int mask = 0; mask < (1 << (n - 1)); mask++)
            {
                if ((1 << we) & mask) continue;
                int m2 = mask + (1 << we);
                for (int ac = i; ac <= c; ac++)
                {
                    int wc = max(ac, min(c, le + i));
                    dp[wc][m2] += dp[ac][mask];
                }
            }
        }
        good += dp[c][(1 << (n - 1)) - 1];
        if (!next_permutation(all(p)))
        {
            printf("%.15f", (double)good / all_ways);
            return 0;
        }
    }
}



Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
string s;
bool check(string s){
    string t=s;
    reverse(t.begin(),t.end());
    return s==t;
}
bool solve(string s){
    int n=s.size();
    return check(s)&&check(s.substr(0,(n-1)/2))&&check(s.substr((n+1)/2,(n-1)/2));
}
int main(){
    cin>>s;
    if(solve(s))cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

#define MAX_N   (200000)

int N;
long long A[MAX_N];
long long XOR[MAX_N];
long long WA[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /* Sの取得 */
    cin >> N;

    /* Aの取得 */
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        XOR[i] = A[i];
        WA[i] = A[i];
    }
    
    /* XORと和の累積和を求めておく */
    XOR[0] = A[0];
    WA[0] = A[0];
    for (int i = 1; i < N; i++) {
        XOR[i] ^= XOR[i - 1];
        WA[i] += WA[i - 1];
    }
    
    /* 左辺を固定し、右辺でXOR==和となる最大のindexを探す */
    long long result = 0;
    for (int i = 0; i < N; i++) {
        int min = i;
        int max = N;
        while (true) {
            /* これ以上探索できなくなったらループを抜ける */
            if (max - min == 1) {
                break;
            }
            int middle = (max + min) / 2;
            long long llxor;
            long long llwa;
            if (i != 0) {
                llxor = XOR[middle] ^ XOR[i - 1];
                llwa = WA[middle] - WA[i - 1];
            } else {
                llxor = XOR[middle];
                llwa = WA[middle];
            }
            
            if (llxor == llwa) {
                min = middle;
            } else {
                max = middle;
            }
        }
        result += min - i + 1;  /* 自分自身のみの場合の+1 */
    }
    
    cout << result << endl;
    
    return 0;
}


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


int main() {

    int n, res;
    cin >> n;
    int t[100100], x[100100], y[100100];
    t[0] = 0; x[0] = 0, y[0] = 0;
    for (int i = 1; i <= n; ++i) cin >> t[i] >> x[i] >> y[i];
    bool plan;
    for (int i = 0; i < n; ++i) {
        res = t[i+1]-t[i] - (abs(x[i+1]-x[i])+abs(y[i+1]-y[i]));
        if (res == 0 || res % 2 == 0 && res > 0) plan = true;
        else plan = false;
    }
    cout << (plan ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int main()
{
  int n;
  string s1;
  string s2;
  string ans;
  char add[4][2]={{'.','.'},{'#','.'},{'.','#'},{'#','#'}};
  int i;
  int l=4;
  cin>>n;

  printf("#\n#\n");
  fflush(stdout);
  cin>>ans;
  if(ans=="end")return 0;
  if(ans=="T"){
    s1="#";
    s2="#";
  }else{
    l--;
    printf(".\n#\n");
    fflush(stdout);
    cin>>ans;
    if(ans=="end")return 0;
    if(ans=="T"){
      s1=".";
      s2="#";
    }else{
      l--;
      printf("#\n.\n");
      fflush(stdout);
      cin>>ans;
      if(ans=="end")return 0;
      if(ans=="T"){
	s1="#";
	s2=".";
      }else{
	l--;
	s1=".";
	s2=".";
      }
    }
  }

  while(1){
    rep(i,l){
      cout<<s1<<add[i][0]<<endl;
      cout<<s2<<add[i][1]<<endl;
      fflush(stdout);
      cin>>ans;
      if(ans=="end")return 0;
      if(ans=="T"){
	s1=s1+add[i][0];
	s2=s2+add[i][1];
	break;
      }
    }
    if(i==l)break;
  }
  while(1){
    rep(i,l){
      cout<<add[i][0]<<s1<<endl;
      cout<<add[i][1]<<s2<<endl;
      fflush(stdout);
      cin>>ans;
      if(ans=="end")return 0;
	if(ans=="T"){
	  s1=add[i][0]+s1;
	  s2=add[i][1]+s2;
	  break;
	}
    }
  }
}


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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    cout << ((0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,a[1000],Alice=0,Bob=0;//a[0],a[1]....
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-1;0<=i;i--){
		if(i%2==0){
			Alice+=a[i];
		}
		else{
			Bob+=a[i];
		}
	}
	cout<<abs(Alice-Bob)<<endl;
}

Measured memory_bytes: 256
require 'matrix'
q = gets.to_i
q.times do
  x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i
  s1 = Vector[ x1 - x0, y1 - y0, 0 ]
  s2 = Vector[ x3 - x2, y3 - y2, 0 ]
  if s1.inner_product(s2) == 0
    puts 1
  elsif s1.cross_product(s2).norm == 0
    puts 2
  else
    puts 0
  end
end

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

int gcd(int a,int b){
    if(b==0) return a;

    return gcd(b,a%b);
}

int main(){
    int W,H,C;
    cin>>W>>H>>C;
    int g=gcd(W,H);

    cout<<W/g*H/g*C<<endl;

    return 0;
}


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <complex>
#include <cassert>

#define enp     puts("**chkchkchkchkchk**")
#define A       first
#define B       second
#define MP      make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;

const int INF = 0x60000000;
const int MINF = -1000000000;
const int mod = 99999997;
const ll cons = 100000000000;
const double pi = 3.141592653589793;

int trie[28][400002];
int cnt[28][400002];
int nxt[28][400002];
int nxtindx[28][400002];

int main()
{
	int n;
	scanf("%d", &n);

	int root = 0;
	int tn = 0;

	vector <string> S(n);

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

		int cur = root;
		for (int j = 0; j < S[i].length(); j++)
		{
			int c = S[i][j] - 'a' + 1;
			int t = trie[c][cur];

			cnt[c][cur]++;
			if (t == 0)cur = trie[c][cur] = ++tn;
			else cur = trie[c][cur];
		}
		cnt[0][cur]++;
	}

	memset(nxt, -1, sizeof(nxt));

	for (int i = 0; i < n; i++)
	{
		int cur = root;
		int num = -1;
		int lst = 0, exc = 0;

		for (int j = 0; j < S[i].length(); j++)
		{
			int c = S[i][j] - 'a' + 1;

			if (cnt[c][cur] == num)
			{
				nxt[exc][lst] = cur;
				nxtindx[exc][lst] = j;
			}
			else
			{
				num = cnt[c][cur];
				lst = cur;
				exc = c;
			}

			cur = trie[c][cur];
		}
	}

	int q;
	scanf("%d", &q);

	while (q--)
	{
		char t[28];
		int k;
		scanf("%d%s", &k, t);
		k--;

		int Rank[28];
		for (int i = 0; i < 26; i++)
		{
			Rank[t[i] - 'a'] = i;
		}

		int cur = root;
		int ans = 0;

		for (int j = 0; j < S[k].length(); j++)
		{
			int c = S[k][j] - 'a';
			int rankn = Rank[c];

			ans += cnt[0][cur];
			for (int i = 0; i < rankn; i++)
			{
				ans += cnt[t[i] - 'a' + 1][cur];
			}

			if (cnt[c + 1][cur] == 1)break;

			if (nxt[c + 1][cur] != -1)
			{
				j = nxtindx[c + 1][cur] - 1;
				cur = nxt[c + 1][cur];
			}
			else cur = trie[c + 1][cur];
		}

		printf("%d\n", ans + 1);
	}

	return 0;
}

Measured memory_bytes: 136960
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()   
#define trav(a, x) for(auto& a : x)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main()
{
    sws
   ll n;
   cin>>n;
    string s;
   while(n)
   {
       n--;
       s+=('a'+(n%26));
       n/=26;
   }
   reverse(all(s));
   cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std;

typedef pair<int,int> P;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back

int h, w, color, pl[9][9];

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

void solve() {
  rep(i,h) rep(j,w) cin>>pl[i][j];
  
  int res = 0;
  rep(a,6) rep(b,6) rep(c,6) rep(d,6) {
  //rep(a,6) rep(b,6) rep(c,6) rep(d,6) rep(e,6) {
    // copy
    int c_pl[9][9];
    rep(i,h) rep(j,w) c_pl[i][j] = pl[i][j];
    
    //int cc[5] = {a+1, b+1, c+1, d+1, e+1};
    int cc[5] = {a+1, b+1, c+1, d+1, color};
    rep(z,5){
      if (z > 0 && cc[z] == cc[z-1]) continue;
      // record before color
      int rbc = c_pl[0][0];
      // if another panel will be change
      bool used[9][9];
      memset(used, false, sizeof used);
      vector<P> clist; clist.pb(P(0,0));
      queue<P> que;
      que.push(P(0,1)); que.push(P(1,0));
      while(!que.empty()) {
        P p = que.front(); que.pop();
        int x = p.first, y = p.second;
        if (used[y][x]) continue;
        used[y][x] = true;
        if (c_pl[y][x] == rbc) {
          // list add
          clist.pb(P(x, y));
          // search
          rep(zz,4) {
            int tx = x + dx[zz], ty = y + dy[zz];
            if (tx < 0 || ty < 0 || tx >= w || ty >= h) continue;
            if (used[ty][tx]) continue;
            if (c_pl[ty][tx] == rbc) que.push(P(tx, ty));
          }
        }
      }
      // change color
      rep(zz,clist.size()) {
        int x = clist[zz].first, y = clist[zz].second;
        c_pl[y][x] = cc[z];
      }
      
      // count color C
      if (z == 4 && cc[z] == color) {
        int t_res = 0;
        bool used[9][9];
        memset(used, false, sizeof used);
        queue<P> que2;
        que2.push(P(0,0));
        while (!que2.empty()) {
          P p = que2.front(); que2.pop();
          int x = p.first, y = p.second;
          if (used[y][x]) continue;
          used[y][x] = true;
          t_res++;
          rep(zz,4) {
            int tx = x + dx[zz], ty = y + dy[zz];
            if (tx < 0 || ty < 0 || tx >= w || ty >= h) continue;
            if (used[ty][tx]) continue;
            if (c_pl[ty][tx] == color) que2.push(P(tx,ty));
          }
        }
        res = max(t_res, res);
      }
    }
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>h>>w>>color, h||w||color) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
object Main extends App {
	val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	if(a > 0L){
		println("Positive")
	}else if(a<=0L && b>=0L){
		println("Zero")
	}else{

		if( (b-a+1L) % 2L == 0L){
			println("Positive")
		}else{
			println("Negative")
		}
	}
	
}


Measured memory_bytes: 25664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mod 1000000007
int main()
{ 
    ll p;
    //cin>>p;
    p=1;
    while(p--)
    {
        ll a,b,c,d,e,f,sum=0,ans=0,maxx1=0,maxx2=0,flag=0;
        cin>>a>>b>>c;
        ll A[c][2];
        map<pair<ll,ll>,ll> mp;
        vector<ll> A1(300009,0),A2(300009,0);
        for(d=0;d<c;d++)
        {
            cin>>e>>f;
            A1[e]++;
            A2[f]++;
            mp[{e,f}]++;
            maxx1=max(maxx1,A1[e]);
            maxx2=max(maxx2,A2[f]);
        }
        vector<ll> ans1,ans2;
        for(d=300008;d>=0;d--)
        {
            if(A1[d]==maxx1) ans1.push_back(d);
            if(A2[d]==maxx2) ans2.push_back(d);
        }
        for(d=0;d<ans1.size() && flag==0;d++)
        {
            for(e=0;e<ans2.size() && flag==0;e++)
            {
                if(mp[{ans1[d],ans2[e]}]==0)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==1) cout<<maxx1+maxx2<<endl;
        else cout<<maxx1+maxx2-1<<endl;
    }
}

Measured memory_bytes: 32880
local mod = 1000000007
local mfl = math.floor
local function badd(x, y)
  return (x + y) % mod
end
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local mfl, msq = math.floor, math.sqrt
local function solve(n, k)
  local sq = 1 + mfl(msq(n))
  if n < sq * sq then sq = sq - 1 end
  local stage = {}
  for i = 1, sq do
    stage[i] = 1
  end
  local sum = sq
  if sq * (sq + 1) <= n then
    table.insert(stage, mfl(n / sq) - sum)
    sum = sum + stage[sq + 1]
  end
  for i = sq - 1, 1, -1 do
    table.insert(stage, mfl(n / i) - sum)
    sum = sum + stage[#stage]
  end
  local dp1, dp2 = {}, {}
  for i = 1, #stage do
    dp1[i] = stage[i]
  end
  for ik = 2, k do
    local src = ik % 2 == 0 and dp1 or dp2
    local dst = ik % 2 == 0 and dp2 or dp1
    local tsum = 0
    for i = #stage, 1, -1 do
      tsum = badd(tsum, src[#stage - i + 1])
      dst[i] = bmul(stage[i], tsum)
    end
  end
    local ret = 0
  if k % 2 == 0 then
    for i = 1, #stage do
      ret = badd(ret, dp2[i])
    end
  else
    for i = 1, #stage do
      ret = badd(ret, dp1[i])
    end
  end
  return ret
end

local n, k = io.read("*n", "*n")
print(solve(n, k))


Measured memory_bytes: 2364
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma") 
 
#include<bits/stdc++.h>
 
#define CFOR(i, str) for(int i = 0; (str)[i]!='\0'; (i)++)
#define FOR(i, s, r) for(int i = (s); i < (r); i++)
#define INF 1e9
#define NINF -1e9
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.rbegin(), v.rend())
#define vmax(v) *max_element(v.begin(), v.end())
#define vmin(v) *min_element(v.begin(), v.end())
#define cnt(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left
#define lld long long int
#define ulld unsigned long long int
typedef long long ll;
using namespace std;
 
ll binpow(ll a, ll b) { 
ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;
}
 
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
 
bool isPrime(ll n) { 
    if (n <= 1) return false; 
    if (n <= 3) return true; 
    if (n % 2 == 0 || n % 3 == 0) return false; 
    for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; 
    return true; 
}
void solve(){
    lld n,xor1=0;
    cin>>n;
    lld arr[n];
    for(int  i=0;i<n;i++)
    {
        cin>>arr[i];
        xor1^=arr[i];
    }
    vector<int> ans;
    for(int i=0;i<n;i+=2)
    {
       ans.push_back(arr[i]^arr[i+1]);
    }
    lld count=0;
    lld as[n];
    for(int i=0;i<n;i+=2)
    {
      lld y=xor1^ans[count];
       as[i+1]=y^arr[i];
       as[i]=y^arr[i+1];
       count++;
    }
   for(int i=0;i<n;i++)
   cout<<as[i]<<" ";
}
int main(){
   ios::sync_with_stdio(0);
   cin.tie(0);
   ll t;
   t=1;
   while(t--)
   { 
   solve();
   }
   return 0;
}

Measured memory_bytes: 6884
#include<iostream>
using namespace std;
int main()
{
      char S[3] , T[3];
      int count =0 ;
      for(int i =0 ; i<3 ; i++)
      { 
           cin>>S[i];
      }
        for(int i =0 ; i<3 ; i++)
      { 
           cin>>T[i];
      }
      
      for(int j=0 ; j<3; j++)
      { 
           if(S[j]==T[j])
           {
                count++;
                
           }
}
cout<<count;
return 0;
} 


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
typedef long long ll;


bool prime(int k) {
    for (int i = 2; i < k; i++) {
        if (k % i == 0) return false;
    }
    return true;
}

ll ans(ll k) {
    ll val = 1;
    for (int i = 2; i <= k; i++) {
        if (prime(i)) {
            int j = i, tmp = 1;
            while (k >= j) {
                tmp += k / j;  j *= i;
            }
            val *= tmp;
        }
        val %= 1000000007;
    }
    return val;
}


int main(void){
    ll n;
    cin >> n;
    
    cout << ans(n) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	string s; cin>>s; int l=s.length();
	if(s[l-1]=='s') s+="es"; else s+="s";
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    tezi;
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> v(n + 1, 0);
    for(int i = 0; i < k; ++i){
        int d, x;
        cin >> d;
        for(int j = 0; j < d; ++j){
            cin >> x;
            v[x] = 1;
        }
    }
    for(int i = 1; i <= n; ++i){
        if(v[i] == 0) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    ll min_val;
    cin >> min_val;
    ll ans = numeric_limits<ll>::min();
    REP(i, n - 1){
        ll r;
        cin >> r;
        ans = max(ans, r - min_val);
        min_val = min(r, min_val);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
vector<string> s(n);
vector<P> ab(n*n);
for(int i=0;i<n;i++)cin>>s[i];
ll ans=0;
for(int t=0;t<n;t++){
    bool ok=true;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
             if(s[(j+t)%n][(i+n-t)%n]!=s[i][j])ok=false;
        }
    }
    if(ok)ans++;
}
cout<<ans*n<<endl;
}

Measured memory_bytes: 1792
mod = 10**9+7
n = int(input())
a = [ int(i) for i in input().split() ]
ans = 0
for i in range(60):
    zero = 0
    one = 0
    if (a[n-1] & (1<<i)) == 0:
        zero += 1
    else:
        one += 1

    for j in range(n-2,-1,-1):
        if (a[j] & (1<<i)) == 0:
            ans += one * (1<<i)
            ans %= mod
            zero += 1
        else:
            ans += zero * (1<<i)
            ans %= mod
            one += 1


print(ans)                 


Measured memory_bytes: 125624
#include <stdio.h>
#define NO_DATA 999
int main(int argc, const char * argv[]) {
    int targetCount = 0;
    int result[300];
    int resultCount = 0;
    for (int i = 0; i < 300; i++ ) {
        result[i] = NO_DATA;
    }
    scanf("%d",&targetCount);
    while (targetCount != 0) {
        int targetArray[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        int robotX = 10;
        int robotY = 10;
        int x,y;
        for (int i=0; i<targetCount; i++) {
            scanf("%d %d",&x,&y);
            targetArray[y] = targetArray[y] | 1 << x;
        }
        char direction;
        int distance;
        int moveCount;
        scanf("%d",&moveCount);
        targetArray[robotY] = targetArray[robotY] & ~(1 << robotX);
        for (int j=0; j<moveCount; j++) {
            scanf("%s %d", &direction, &distance);
            for (int move = 0; move < distance; move++ ) {
                switch (direction) {
                    case 'N':
                        robotY += 1;
                        break;
                    case 'S':
                        robotY -= 1;
                        break;
                    case 'E':
                        robotX += 1;
                        break;
                    case 'W':
                        robotX -= 1;
                        break;
                    default:
                        break;
                }
                targetArray[robotY] = targetArray[robotY] & ~(1 << robotX);
            }
        }  
        int lastValue = 0;
        for (int i = 0; i<21; i++) {
            lastValue = lastValue | targetArray[i];
        }  
        result[resultCount] = lastValue == 0 ? 1 : 0;
        resultCount++;  
        scanf("%d",&targetCount);
    }
    for (int i = 0; i < resultCount; i++) {
        printf("%s\n",result[i] == 1 ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 2052
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

bool check(const vi &A) {
	REP(i, A.size()) {
		if (A[i] % 2)return false;
	}
	return true;
}

int main() {
	int N = IN();
	vi A(N);
	REP(i, N) {
		cin >> A[i];
	}
	int ans = 0;
	while (check(A)) {
		REP(i, N) {
			A[i] /= 2;
		}
		ans++;
	}
	OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int N;
int opened[100][14];
int profit[100][15];
int main() {
    scanf("%d", &N);
    for (int i=0;i<N;i++) 
        for (int j=0;j<10;j++) scanf("%d", &opened[i][j]);

    for (int i=0;i<N;i++) 
        for (int j=0;j<11;j++) scanf("%d", &profit[i][j]);
    
    int res=-(1<<30);

    for (int b=1;b<(1<<10);b++) {
        int maxi=0;

        for (int i=0;i<N;i++) {
            int c=0;
            for (int j=0;j<10;j++)  if((b>>j&1)&&opened[i][j]) c++;
            maxi+=profit[i][c];
    }
    if (maxi>res) res=maxi;
}
printf("%d\n", res);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int N;
  	cin >> N;
    vector<int> A(N);
	for(int i =0;i<N;i++){
      cin >> A.at(i);
    }
    int count = 0;
    for(int k=0;k<N-1;k++){
      int minj = k;
      for(int j=k+1;j<N;j++){
        if(A.at(j)<A.at(minj)){
          minj = j;
        }
      }
      if(A.at(minj) != A.at(k)){
        swap(A.at(minj),A.at(k));
        count++;
      }
     }
    
    for(int h=0;h<N-1;h++){
      cout << A.at(h) << ' ';
    }
    cout << A.at(N-1) << endl;
    cout << count <<endl;
        
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int n, m; cin >> n ;
	
	vector<int>a(n);
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << -a[0]+ a[a.size()-1];

	cout << endl;
	return 0;
}

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

template<typename T>
void fill_all(T& ar,const T& v){
	ar=v;
}
template<typename T,size_t N,typename U>
void fill_all(T(& ar)[N],const U& v){
	for(auto&i:ar){fill_all(i,v);}
}

int H,W;
char map[1000][1002];
char flag[2][3];

int main()
{
	std::cin >> H>>W;
	
	for(int y = 0;y < H;++y){
		std::cin >> map[y];
	}
	for(int i = 0;i < 2;++i){
		std::cin >> flag[i];
	}
		#ifdef DEBUG
			std::cout <<"map32:" << map[2][3]<<'\n';
		#endif
	auto is_same = [](int x,int y){			
			bool ok = true;
		#ifdef DEBUG
		if(x==3&&y==1){
			std::cout <<"same:" << map[y][x]<<'\n';
		}
		#endif
			for(int i = 0;i < 2;++i)for(int j = 0;j < 2;++j){
				if(flag[j][i] == map[y+j][x+i]){
					
				}
				else{
					ok = false;
		#ifdef DEBUG
		if(x==3&&y==1){
			std::cout <<"samefalse:"<<(x+i)<<' '<<(y+j) <<' ' <<map[y+j][x+i] <<' ' <<(int)map[y+j][x+i]<<'\n';
		}
		#endif
				}
			}
			return ok;
	};
	
	int32_t count = 0;
	for(int y = 0;y <= H-2;++y){
	for(int x = 0;x <= W-2;++x){
		if(is_same(x,y)){++count;}
	}}
	
	
	int32_t max = count;
	for(int y = 0;y < H;++y){
	for(int x = 0;x < W;++x){
		const char CHAR[] = "JOI"; 
		auto bef = map[y][x];
		auto bef_count = 0;
		for(int u = -1;u <= 0;++u)for(int l = -1;l <= 0;++l){
			int lu_x = x+l,lu_y = y+u;
			if(lu_x<0)continue;
			if(lu_y<0)continue;
			if(W<=lu_x+1)continue;
			if(H<=lu_y+1)continue;

			if(is_same(lu_x,lu_y)){++bef_count;}
		}
		#ifdef DEBUG
		std::cout << "IN"<<x<<' '<<y<<'\n';
		std::cout << bef_count << std::endl;
		#endif
		
		for(int char_ = 0;char_<3;++char_)
		{
			map[y][x] = CHAR[char_];
			
		#ifdef DEBUG
		if(x==3&&y==1){
			std::cout <<"MAP:" << map[y][x]<<'\n';
		}
		#endif
			int add = 0;
			for(int u = -1;u <= 0;++u)for(int l = -1;l <= 0;++l){
				int lu_x = x+l,lu_y = y+u;
				if(lu_x<0)continue;
				if(lu_y<0)continue;
				if(W<=lu_x+1)continue;
				if(H<=lu_y+1)continue;
				
				if(is_same(lu_x,lu_y)){++add;}
			}
			
			#ifdef DEBUG
			std::cout << add << std::endl;
			#endif
			max = std::max(max, count-bef_count+add);
		}
		map[y][x] =bef;
		
	}}
	
	std::cout << max << std::endl;
}

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

int main() {
  int l,r,d; cin >>l >>r >>d;
  int cnt = 0;
  for(int i = l; i<=r; i++){
    if(i%d==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

using namespace std;
#define BUF (10000)
#define ll long long 


ll a[BUF];
ll b[BUF];
int n;


int main(void){
	cin >> n;
	for(int i=1;i<=n;i++)cin >> a[i];	
	for(int i=1;i<=n;i++)cin >> b[i];

	int ans = 1;

	ll sa=0;
	ll sb=0;
	for(int i=1;i<=n;i++){
		if(a[i]-b[i]>0) sb+=a[i]-b[i];
		if((a[i]-b[i])<0 && ((b[i]-a[i])%2==1)){
			sa+=(b[i]-a[i]+1)/2;
			sb++;
		}
		if(a[i]-b[i]<0 && ((b[i]-a[i])%2==0)) sa+=(b[i]-a[i])/2;
		//cout << sa << sb << "\n";
	}

	if(sa<sb)ans = 0;

	if(ans == 0) cout << "No\n";
	else cout << "Yes\n";

	return 0;
}


Measured memory_bytes: 384
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a;
bool ok;
int main(){
	cin>>n;
	ok=true;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a%2==0&&a%3!=0&&a%5!=0)
				ok=false;
	}
	if(ok)
		cout<<"APPROVED";
	else
		cout<<"DENIED";
	return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];
    
    int ans = inf; // 何問解かないといけない?
    rep(i, 1 << d) {
        ll sum = 0; int cnt = 0;
        rep(j, d) {
            if (i & (1 << j)) {
                sum += c[j] + p[j] * 100 * (j + 1);
                cnt += p[j];
            }
        }
        if (sum >= g) {
            chmin(ans, cnt);
            continue;
        }
        [&]() {
            for (int j = d - 1; j >= 0; --j) {
                if (!(i & (1 << j))) {
                    for (int k = p[j] - 1; k >= 0; --k) {
                        ++cnt;
                        sum += 100 * (j + 1);
                        if (sum >= g) {
                            chmin(ans, cnt);
                            return;
                        }
                    }
                }
            }
        }();
    }
    cout << ans << endl;
}



Measured memory_bytes: 3600
x=input()
if 400<=x<=599:
    print 8
elif 600<=x<=799:
    print 7
elif 800<=x<=999:
    print 6
elif 1000<=x<=1199:
    print 5
elif 1200<=x<=1399:
    print 4
elif 1400<=x<=1599:
    print 3
elif 1600<=x<=1799:
    print 2
elif 1800<=x<=1999:
    print 1


Measured memory_bytes: 64348
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    aa=LI()
    pp=[]
    mm=[]
    for a in aa:
        if a<0:mm.append(a)
        else:pp.append(a)
    if not mm:
        print(sum(pp))
        exit()
    if not pp:
        if len(mm)%2:
            print(-sum(mm)+max(mm)*2)
        else:
            print(-sum(mm))
        exit()
    if len(mm)%2:
        m=max(mm)
        p=min(pp)
        if p+m>=0:print(sum(pp)-sum(mm)+2*m)
        else:print(sum(pp)-2*p-sum(mm))
    else:
        print(sum(pp)-sum(mm))

main()


Measured memory_bytes: 15180
//
// Created on 2020/04/23.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = 0;
    int n,d;
    cin>>n>>d;
    vector<vector <int> > x (n,vector<int>(d));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin>>x[i][j];
        }
    }

    for (int k = 0; k < n; ++k) {
        for (int j = k + 1; j < n ; ++j) {

            int distance = 0;
            for (int i = 0; i < d; ++i) {
                distance += pow(x[k][i]-x[j][i],2);
            }
            double distance_2 = sqrt(distance);
            if(int(distance_2) == distance_2){
                ans ++;
            }
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int x;
	cin >> x;
	bool flag = true;
	while(1){
		flag = true;
		for(int i = 2; i * i <= x; i++) {
			if (x % i == 0){
				flag = false;
				// break;
			}
		}
		if (flag){
			break;
		}
		x++;
	}
	cout << x << endl;
	return 0;
}

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

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

	set<int> seen;
	seen.insert(0);
	int count = 0;
	for (int i = 0; i<n; i++)
	{
		int x; cin>>x;
		if (seen.find(x-1) != seen.end() and seen.find(x) == seen.end())
		{
			seen.insert(x);
			count++;
		}
	}

	if (count == 0)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<n-count<<endl;
	}
}

Measured memory_bytes: 9600