akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    auto s = sread();
    if (s == "AAA" || s == "BBB")
        writeln("No");
    else
        writeln("Yes");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Set<Integer> set = new HashSet<>();
    for (int i = 0; i < N; i++) {
      set.add(sc.nextInt());
    }
    
    System.out.println(set.size());
  }
}

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

void input(int& rnPicSiz, vector<int>& rvnCoordx)
{
  int nCoordxSiz;
  cin >> rnPicSiz >> nCoordxSiz;
  rvnCoordx.resize(nCoordxSiz);

  for (int& rnCoordx : rvnCoordx)
    cin >> rnCoordx;

  sort(begin(rvnCoordx), end(rvnCoordx));
}

int calcMinMoveCnt(int nPicSiz, const vector<int>& cnrvnCoordx)
{
  vector<int> vnDist;

  for (int i = 0; i < cnrvnCoordx.size() - 1; i++)
    vnDist.push_back( cnrvnCoordx[i + 1] - cnrvnCoordx[i] );

  sort(begin(vnDist), end(vnDist));
  int nMinMoveCnt = 0;

  for (int i = 0; i < (int)vnDist.size() - (nPicSiz - 1); i++)
    nMinMoveCnt += vnDist[i];

  return nMinMoveCnt;
}
 
int main()
{
  int nPicSiz;
  vector<int> vnCoordx;

  input(nPicSiz, vnCoordx);
  cout << calcMinMoveCnt(nPicSiz, vnCoordx) << endl;

  return 0;
}

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

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

int main()
{
    int K;
    long long int result = 0;
    cin >> K;
    for (int a = 1; a <= K; a++)
        for (int b = 1; b <= K; b++)
            for (int c = 1; c <= K; c++){
                result += gcd(gcd(a,b),c);
            }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <utility>
#include <algorithm>

#define ii pair<int, int>
#define fi first
#define se second

using namespace std;

int main() {
	int n, sum = 0;
	bool bisa = true;
	ii p[200010];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &p[i].se, &p[i].fi);
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		sum += p[i].se;
		if (sum > p[i].fi) {
			bisa = false;
			break;
		}
	}
	if (bisa)
		puts("Yes");
	else
		puts("No");
}

Measured memory_bytes: 1664
n,m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
S =[]
ans = 0
for i in range(0,n):
    for j in range(1,s[i][0]+1):
        S.append(s[i][j])
#print(S)
for i in range(1,m+1):
    if S.count(i)==n:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	string str;
	cin>>str;
	ll flag1=0,falg2=0;
	for(ll i=0;i<str.length();i++){
		if(str[i]=='A')flag1=1;
		else falg2=1;
	} 
	if(falg2&flag1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

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

using namespace std;

int main(void) {
    string N;
    cin >> N;

    bool ans = false;
    for (int i=0; i<3; i++) {
        if (N[i] == '7') ans = true;
    }

    if (ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K,S,ans=0;
  cin >> K >> S;
  for (int i=0;i<K+1;i++){
    for (int I=0;I<K+1;I++){
        if (i+I<S+1 && I+i>S-K-1) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void CountTriangles(vector<int> arr)
{

    int n = arr.size();

    sort(arr.begin(), arr.end());

    int count = 0;

    for (int i = n - 1; i >= 1; i--) {
        int l = 0, r = i - 1;
        while (l < r) {
            if (arr[l] + arr[r] > arr[i]) {

                count += r - l;
                r--;
            }
            else
                l++;
        }
    }
    cout<< count;
}
int main()
{
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++){cin>>arr[i];}
    CountTriangles(arr);


}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, 0, n) cin >> h[i];

  int maxv = h[0];
  ll ans = 0;
  rep(i, 1, n) {
    if (h[i] < h[i - 1]) {
      ans += maxv - h[i];
      maxv = 0;
    }
    chmax(maxv, h[i]);
  }

  if (maxv)
    ans += maxv;
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
using namespace std;
int num[1000000];
int main()
{
	int n, k, ans = 0, sans=0;
	while (1)
	{
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0)
			break;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &num[i]);
		}
		for (int i = 0; i < n - k; i++)
		{
			for (int j = i; j < i + k; j++)
			{
				sans += num[j];
			}
			if (ans < sans)
				ans = sans;
			sans = 0;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main()
{
    long long x;
    cin >> x;
    long long ans = (x / 11) * 2;
    long long r = x % 11;
    if (r > 0)
    {
        if (r <= 6)
        {
            ans++;
        }
        else
        {
            ans += 2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,i,j,k=0;
	scanf("%d%d%d",&a,&b,&c);
	while((a%2==0)&&(b%2==0)&&(c%2==0))
	{
		if((a==b)&&(b==c))
		{
		
		printf("-1");
		return 0;	 
		   }
		else
		{
		
	
		i=a;
		j=b;
		a=(b+c)/2;
		b=(i+c)/2;
		c=(i+j)/2;
		k++;
	}
		
		
	}
	
	
	printf("%d",k);
	return 0;
}

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

long long int Get_saisho(long long int C,long long int D){
  if(D==0)return C;
  else Get_saisho(D,C%D);
}

int main(){
  long long int A,B,C,D,s,ans;
  cin>>A>>B>>C>>D;
  long long int count;
  if(D>C)swap(C,D);//C>=D
  s = Get_saisho(C,D);
  s = D*C/s;
  count =B/C-(A-1)/C +B/D-(A-1)/D - (B/s-(A-1)/s);
  ans = B-A+1-count;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,coin=0,day=1;
  cin>>a>>b>>c;
  while(coin<c){
    coin+=a;
    if(day%7==0) coin+=b;
    ++day;
  }
  cout<<day-1<<endl;  
  return 0;
}



Measured memory_bytes: 3108
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef vector<int> VI;


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



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

	int t, a;
	cin >> t >> a;

	VI h(n);
	REP(i, n) {
		cin >> h[i];
	}

	double temp;
	double nearest = 10000000;
	int spot;
	REP(i, n) {
		temp = t - h[i] * 0.006;
		if (abs(temp - a) < nearest) {
			nearest = abs(temp - a);
			spot = i + 1;
		}
	}

	ANS(spot);



	return 0;
}



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

ans = [None] * n

x = 0

for i, ai in enumerate(a):
  if i % 2 == 0:
    x += ai
  else:
    x -= ai
    
ans[0] = x

for i, ai in enumerate(a[:-1]):
  x = 2 * ai - ans[i]
  ans[i+1] = x

ans = [str(i) for i in ans]
print(" ".join(ans))

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

using namespace std;

#define mod 1000000007
#define mp make_pair
typedef long long ll;
const int oo = 0x3f3f3f3f;

int main(void)
{
	string s;
	cin >> s;
	int len = s.length();
	cout << s[0] << len - 2 << s[len - 1] << endl;
	return 0;
}

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


Measured memory_bytes: 2604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (int)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

vector<int> ans(0);

signed main(){
   cin.tie(0);ios::sync_with_stdio(false);
   cout<<fixed<<setprecision(20);
  ll n,a,b;cin>>n>>a>>b;
  if(n<a+b-1 || a*b<n){
    cout<<-1<<endl;
    return 0;
  }

  int mxind=0,upcnt=a;
  while(1){
    int oku=min(b,(n-siz(ans)-upcnt+1));
    mxind+=oku;
    for(int i=mxind;mxind-oku<i;i--){
      ans.pb(i);
    }
    upcnt--;
    if(mxind>=n)break;
  }

  rep(i,0,n){
    cout<<ans[i]<<" ";
    assert(1<=ans[i] && ans[i]<=n);
  }
  cout<<endl;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3440
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 10e9+7;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    b--;
    if(b%(a-1)==0){
        print(b/(a-1));
    }
    else{
        print(b/(a-1)+1);
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

class dice{
public:
	int d[6];
	void set(int n, int x){
		d[n] = x;
	}
	int get(int n){
		return d[n];
	}
	void rotate(char c){
		int tmp;
		switch (c){
		case 'W':
			tmp = d[3];
			d[3] = d[0];
			d[0] = d[2];
			d[2] = d[5];
			d[5] = tmp;
			break;
		case 'E':
			tmp = d[5];
			d[5] = d[2];
			d[2] = d[0];
			d[0] = d[3];
			d[3] = tmp;
			break;
		case 'N':
			tmp = d[0];
			d[0] = d[1];
			d[1] = d[5];
			d[5] = d[4];
			d[4] = tmp;
			break;
		case 'S':
			tmp = d[4];
			d[4] = d[5];
			d[5] = d[1];
			d[1] = d[0];
			d[0] = tmp;
			break;
		}
	}
	void espin(){
		rotate('S');
		rotate('E');
		rotate('N');
	}
	bool operator ==(dice e){
		bool flag;
		string s = "SESESE";
		for (int i = 0; i < 6; i++){
			e.rotate(s[i]);
			if (d[0] == e.get(0)){
				for (int j = 0; j < 4; j++){
					flag = true;
					for (int k = 1; k < 6; k++){
						if (d[k] != e.get(k)) flag = false;
					}
					if (flag) return true;
					e.espin();
				}
			}
			if (i == 5) return false;
		}
	}
};

int main(){
	int tmp, n;
	bool flag = true;
	cin >> n;
	vector<dice> d(n);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 6; j++){
			cin >> tmp;
			d[i].set(j, tmp);
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			if (d[i] == d[j]){
				cout << "No" << endl;
				flag = false;
				i = j = n;
			}
		}
	}
	if (flag) cout << "Yes" << endl;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	char a[100+5],b[100+5];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	int t1=0,t2=0;
	for(int i=0;i<n*2;i++){
		if(i%2==0){
			cout<<a[t1];
			t1++;
		}else{
			cout<<b[t2];
			t2++;
		}	
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int digit_sum(int N){
    int ans = 0;
    while (N >= 10){
        ans += N%10;
        N -= N%10;
        N /= 10;
    }
    ans += N%10;
    return ans;
}

int main() {
    int N;
    cin >> N;
    if(N%digit_sum(N) == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    int64_t h, w;
    cin >> h >> w;
    int64_t size = h * w;
    if((h == 1 && w >= 3) || (h >= 3 && w == 1)) {
        cout << 1 << endl;
    } else {
        cout << ((size % 2 == 0) ? size / 2 : size / 2 + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>
 
using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9
 
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>
 
//#include <stack>
//#include <queue>
 
// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;
 
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
ll N;
vll H;
 
ll ltmp;
string stmp;
double dtmp;
 
int main(){
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    cin >> N;
 
    rep(ni,N){
        cin >> ltmp;
        H.push_back(ltmp);
    }
 
    string ans = "Yes";
    for( ll hi = H.size()-1 ; hi>=1 ; hi-- ){
        if(H[hi] < H[hi-1]){
            if(H[hi] == H[hi-1]-1){
                H[hi-1]--;
            }else{
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
    
 
}

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

int main() {
	int n,k;
	cin >> n >> k;
	int digit = 1;
	while (1) {
		n /= k;
		if (n == 0)
			break;
		digit++;
	}
	cout << digit << endl;


}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
K,N=map(int,input().split())
A=list(map(int,input().split()))

L=[]

for i in range(N-1):
    L.append(A[i+1]-A[i])

L.append(K-A[-1]+A[0])

print(K-max(L))

Measured memory_bytes: 25840
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
    if(u!=NIL){
        if(k==u->key)return u;
        else if(k<u->key){
            if(u->left!=NIL){
                if(treeSearch(u->left,k)!=NIL)return u->left;
            }
        }
        else {
            if(u->right!=NIL){
                if(treeSearch(u->right,k)!=NIL)return u->right;
        }
    }
    return NIL;
    }
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
      y=x;
      if(z->key<x->key){
          x=x->left;
      }
      else{
          x=x->right;
      }    
  }
  z->parent=y;

  if(y==NIL){
      root=z;
  }
  else if(z->key<y->key){
      y->left=z;
  }
  else{
      y->right=z;
  }



}

void inorder(Node u){
    if(u!=NIL){
        inorder(u->left);
        printf(" %d",u->key);
        inorder(u->right);
    }

}
void preorder(Node u){
    if(u!=NIL){
        printf(" %d",u->key);
        preorder(u->left);
        preorder(u->right);
    }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


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

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

Measured memory_bytes: 3052
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[2][20010] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,N;
    cin >> H >> N;
    ll A[1010], B[1010];
    rep(i,0,N) cin >> A[i] >> B[i];
    rep(j,0,20001){
        dp[0][j] = INF;
        dp[1][j] = INF;
    }
    dp[0][0] = 0;
    ll cur = 0, nxt = 1;
    rep(i,0,N){
        rep(j,0,20001){
            if(j < A[i]){
                dp[nxt][j] = dp[cur][j];
            }else{
                dp[nxt][j] = min(dp[cur][j], dp[nxt][j - A[i]] + B[i]);
            }
        }
        cur ^= 1; nxt ^= 1;
    }
    
    ll ans = INF;
    rep(i,H,20001){
        ans = min(ans, dp[cur][i]);
    }
    print(ans);

    

}


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

const int N_MAX = 9;
int n;

int a, b;
int test[N_MAX];
vector<int> P, Q;
int num;
int S;
void dfs(int k){
    if (k == n){
        num++;
        bool Peq = true, Qeq = true;
        for(int i = 0; i < n; i++){
            if (P[i] != test[i])Peq = false;
            if (Q[i] != test[i])Qeq = false;
        }
        if (Peq)a = num;
        if (Qeq)b = num;
        return;
    }
    for(int i = 0; i < n; i++){
        if (S & 1 << i)continue;
        test[k] = i+1;
        S |= 1 << i;
        dfs(k+1);
        S &= ~(1 << i);
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        P.push_back(p);
    }
    for(int i = 0; i < n; i++){
        int q;
        cin >> q;
        Q.push_back(q);
    }

    num = 0;
    S = 0;
    dfs(0);

    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int A, B;
  cin >> A >> B;
  A--;
  cout << (B-1 + A - 1)/A << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, n = sc.nextInt();
		int sum=0,count=1,flag=0,max=-999999,min=99999;
		int[] array=new int[10000];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		array[0]=1;
		String buff1,buff2;
		for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		}
		Arrays.sort(array);
		for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		}
	}
	public static int sample(int n) {
		return n;
	}

}


Measured memory_bytes: 21844
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n, int K) {
        const long long MOD = 1000000007;

        int N = n * n * 2;
        vector<vector<long long>> dp(n, vector<long long>(N + N + 1, 0));
        dp[0][N] = 1;
        auto ndp = dp;
        for (int i = 1; i <= n; ++i) {
            for (auto& V : ndp) {
                fill(V.begin(), V.end(), 0);
            }
            for (int j = 0; j < i; ++j) {
                for (int k = 0; k <= N * 2; ++k) {
                    if (j > 0) {
                        int nj = j - 1;
                        int nk = k + i + i;
                        if (nk <= 2 * N) {
                            (ndp[nj][nk] += dp[j][k] * j % MOD * j % MOD) %= MOD;
                        }

                        nj = j;
                        nk = k;
                        (ndp[nj][nk] += dp[j][k] * 2 * j % MOD) %= MOD;
                    }

                    (ndp[j][k] += dp[j][k]) %= MOD;

                    {
                        int nj = j + 1;
                        int nk = k - 2 * i;
                        if (nj < n && nk >= 0) {
                            (ndp[nj][nk] += dp[j][k]) %= MOD;
                        }
                    }                    
                }
            }
            swap(ndp, dp);
        }

        return dp[0][N + K];
    }

    int test (int n, int k) {
        vector<int> P(n, 0);
        iota(P.begin(), P.end(), 1);

        int res = 0;
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                sum += abs(P[i] - i - 1);
            }
            if (sum == k) {
                ++res;
                for (int i = 0; i < n; ++i) {
                    cout << (i + 1) << ":" << P[i] << " ";
                }
                cout << endl;
            }
        } while (next_permutation(P.begin(), P.end()));
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int k;
    cin >> k;
    Solution sol;
    cout << sol.solve(n, k) << "\n";

    return 0;
}

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

int main() {
    int i = 0;
    string s;
    cin >> s;
    int count = 0;
    int maxi = 0;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'A' || s.at(i) == 'G' || s.at(i) == 'T' || s.at(i) == 'C'){
            count++;
        } else {
            maxi = max(maxi,count);
            count = 0;
        }
    }
    cout << max(maxi, count) << endl;
}


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

int main() {
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3)) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

template<class T>inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }


int main() {
	int n; cin >> n;
	ll ans = 0;
	rep1(i,n) if(i % 3 != 0 && i % 5 != 0) ans += i;
	cout << ans << endl;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine();
        
        if(S == "ABC")
        {
            WriteLine("ARC");
        }
        else
        {
            WriteLine("ABC");
        }
    }
}


Measured memory_bytes: 25836
import numba
import numpy as np
N = int(input())
P = np.array([int(c)-1 for c in input().split()])

#from random import shuffle
#N = 500
#P = list(range(N*N))
#shuffle(P)
#P = np.array(P)

@numba.njit("i8(i8,i8[:])", cache=True)
def proc(N, P):
    ans = 0
    Removed = np.zeros((500, 500), dtype=np.int8)
    Mat = np.zeros((500, 500), dtype=np.int16)
    Dy, Dx = np.array([1,0,-1,0]), np.array([0,1,0,-1])

    for y in range(N):
        for x in range(N):
            Mat[y, x] = min(y, N-1-y, x, N-1-x)
    #print(Mat)
    Buf = [(0, 0) for _ in range(1<<17)]
    Buf_idx = 0
    for i in range(N*N):
        p = P[i]
        y, x = divmod(p, N)
        ans += Mat[y,x]
        Removed[y,x] = 1
        Buf[Buf_idx] = (y, x)
        Buf_idx += 1
        while Buf_idx:
            Buf_idx -= 1
            vy, vx = Buf[Buf_idx]
            vr = Removed[vy,vx]
            val = Mat[vy,vx]
            #for dy, dx in zip(Dy, Dx):
            for j in range(4):
                uy, ux = vy + Dy[j], vx + Dx[j]
                if not (0<=uy<N and 0<=ux<N):
                    continue
                ur = Removed[uy,ux]
                if vr:
                    if Mat[uy,ux] >= val+1:
                        Mat[uy,ux] = val
                        Buf[Buf_idx] = (uy, ux)
                        Buf_idx += 1
                else:
                    if Mat[uy,ux] >= val+2:
                        Mat[uy,ux] = val+1
                        Buf[Buf_idx] = (uy, ux)
                        Buf_idx += 1
    # for m in Mat:
    #     print(m)
    return ans
print(proc(N, P))



Measured memory_bytes: 123004
n = int(input())
a_int = list(map(int, input().split()))

squ = 0
num = 10 ** 9 + 7

a_sum = 0
for i_sum in range(1, n):
    a_sum += a_int[i_sum]

for i in range(0, n-1):
    squ += a_int[i] * a_sum
    a_sum -= a_int[i+1]

ans = squ % num
print(ans)

Measured memory_bytes: 31536
#include <stdio.h>
#include <stdlib.h>

int a[55];

int main(){

	int N;

	scanf("%d",&N);

	int i,j;

	int ma=0;
	int idx;

	for(i=1;i<=N;i++){
		scanf(" %d",&a[i]);
		if(ma<abs(a[i])){
			ma=abs(a[i]);
			idx=i;
		}
	}

	if(ma!=0){

		for(i=1;i<=N;i++){
			if(i!=idx){
				a[i]+=a[idx];
			}
		}
		int ans=N-1;

		if(a[idx]>0){
			for(i=2;i<=N;i++){
				a[i]+=a[i-1];
				ans++;
			}
			printf("%d\n",ans);
			for(i=1;i<=N;i++){
				if(i!=idx){
					printf("%d %d\n",idx,i);
				}
			}
			for(i=2;i<=N;i++){
				printf("%d %d\n",i-1,i);
			}
		}
		else{
			for(i=N;i>=2;i--){
				a[i-1]+=a[i];
				ans++;
			}
			printf("%d\n",ans);
			for(i=1;i<=N;i++){
				if(i!=idx){
					printf("%d %d\n",idx,i);
				}
			}
			for(i=N;i>=2;i--){
				printf("%d %d\n",i,i-1);
			}
		}
	}
	else{
		printf("0\n");
	}



	return 0;
}

Measured memory_bytes: 128
import math

a = float(input())
b = float(input())
c = float(input())
d = float(input())
e = float(input())

last = 9

all = []

all.append(a%10)
all.append(b%10)
all.append(c%10)
all.append(d%10)
all.append(e%10)

flag = 0
for m, i in enumerate(all):
    # print(i)
    temp = i
    if temp < last and temp !=0:
        last = temp
        index = m
        flag = 1

if flag ==0:
    index = 0

# print("index:" + str(index))
a = a/10
b = b/10
c = c/10
d = d/10
e = e/10

All = []
All.append(a)
All.append(b)
All.append(c)
All.append(d)
All.append(e)

sum = 0
for k, j in enumerate(All):
    # print(k)

    if k == index:
        # print(k)
        sum += j *10
    else:
        sum += math.ceil(j)*10

sum = int(sum)
print(sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
#define print(a) cout<<a<<endl
typedef long long ll;
typedef string str;
typedef unsigned long long ul;
#define vint vector<int>

int main() {
	int k,x;
	cin >> k >> x;
	for(int i=x-k+1;i<k+x-1;i++){
		cout << i << " ";
	}
	cout <<(k+x-1)<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int B[N];
bool vis[N];
vector<int> v1;
int n;
int len , ex;

void dfs(int x, int l)
{
  v1.pb(x);
  vis[x]=true;
  B[x] = l;
  if(vis[A[x]] == 1)
  {
    len = l-B[A[x]]+1;
    ex = l - len;
    // cout << l << " " << x << endl;
  }
  if(!vis[A[x]])dfs(A[x],l+1);
}


void solve()
{
    int n  ,k;
    cin >> n >> k;

    loop(i,1,n+1)cin >> A[i];

    len = 0 , ex = 0;
    dfs(1,1);


    // cout << len << " " << ex << endl;

    int rem  =(k-ex)%len;
    if(k <= ex)cout << v1[k];
    else cout << v1[ex+rem];
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
   

   int t = 1;
   // cin >> t;
   while(t--)solve();
  
}

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

using namespace std;

int main() {
    int n, W;
    cin>>n>>W;
    vector<int> wt;
    vector<int> val;
    for (int i=0; i<n; i++) {
        int w, v;
        cin>>w>>v;
        wt.push_back(w);
        val.push_back(v);
    }
    long long int K[n+1][W+1];
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=W; j++) {
            if (i==0 || j==0)
                K[i][j] = 0;
            else if (wt[i-1] <= j)
                K[i][j] = max(val[i-1] + K[i-1][j-wt[i-1]], K[i-1][j]);
            else 
                K[i][j] = K[i-1][j];
                
        }
    }

    cout<<K[n][W]<<endl;
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    string s,t;
    cin >> s >> t;
    int len = s.length();
    int ret = 0;
    for (int i = 0; i < len; i++) {
        if (s[i] != t[i]) ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3872
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class hello
{
    public static int h, w;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = int.Parse(line[0]);
        w = int.Parse(line[1]);
        var ss = new string[h];
        var used = new bool[h, w];
        for (int i = 0; i < h; i++) ss[i] = Console.ReadLine().Trim();
        var ps = getList(ss);
        getAns(ps);
    }
    static List<P> getList(string[] ss)
    {
        var res = new List<P>();
        var used = new bool[h, w];
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
                if (ss[i][j] == 'B')
                    if (!used[i, j]) { used[i, j] = true; res.Add(new P { x = i, y = j }); break; }
            for (int j = w - 1; j >= 0; j--)
                if (ss[i][j] == 'B')
                    if (!used[i, j]) { used[i, j] = true; res.Add(new P { x = i, y = j }); break; }
        }
        for (int i = 0; i < w; i++)
        {
            for (int j = 0; j < h; j++)
                if (ss[j][i] == 'B')
                    if (!used[j, i]) { used[j, i] = true; res.Add(new P { x = j, y = i }); break; }
            for (int j = h - 1; j >= 0; j--)
                if (ss[j][i] == 'B')
                    if (!used[j, i]) { used[j, i] = true; res.Add(new P { x = j, y = i }); break; }
        }
        return res;
    }
    static void getAns(List<P> ps)
    {
        var res = 0;
        var psc = ps.Count();
        for (int i = 0; i < psc - 1; i++)
            for (int j = i + 1; j < psc; j++)
                res = Max(res, Abs(ps[i].x - ps[j].x) + Abs(ps[i].y - ps[j].y));
        Console.WriteLine(res);
    }
}



Measured memory_bytes: 19224
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000;

int main() {
  string s1;
  cin >> s1;
  string s2;
  cin >> s2;
  int c = s1.size();
  int p = s2.size();
  char code[c];
  char part[p];
  
  for (int i = 0; i < c; i++) {
    code[i] = s1.at(i);
  }
  for (int i = 0; i < p; i++) {
    part[i] = s2.at(i);
  }
  
  int begin = INF;
  for (int i = 0; i <= c-p; i++) {
    bool ok = true;
    for (int j = 0; j < p; j++) {
      if (code[i+j] != part[j] && code[i+j] != '?') {ok = false;}
    }
    if (ok) {begin = i;}
  }
  
  if (begin == INF) {cout << "UNRESTORABLE" << endl;}
  else {
    for (int i = begin; i < begin + p; i++) {
      code[i] = part[i - begin];
    }
    for (int i = 0; i < c; i++) {
      if (code[i] == '?') {code[i] = 'a';}
      cout << code[i];
    }
  }
}

Measured memory_bytes: 256
_, m = gets.split.map(&:to_i)
rs   = m.times.map { gets.split.map(&:to_i) }
_, t = rs.sort_by { |a, b| b }.reduce([0, 0]) do |x, y|
  n, c = x
  a, b = y
  a < n ? [n, c] : [b, c + 1]
end
p t


Measured memory_bytes: 12664
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define EPS 1e-10
using namespace std;

int main(){
  int n,pos;
  double y,b,r,t,mex;
  while(true){
    cin >> n;
    if(n == 0)break;
    mex = 0; pos = -1;
    cin >> y;
    for(int i=0;i<n;i++){
      cin >> b >> r >> t;
      double gandhi; 
      if(t == 1){
	//cout << "単利 - ";
	gandhi = 10000.0*(1+y*(r/100.0));
      }
      else {
	//cout << "複利 - ";
	gandhi = 10000.0*pow((1+(r/100.0)),y);
      }
      if(mex-gandhi<EPS){
	pos = b;
	mex = gandhi;
      }
      //cout << "b = " << b;
      //printf(", %.10f\n",gandhi);
    }
    cout << pos << endl;
  }
  return 0;
}

Measured memory_bytes: 1320
memo = [0]*100010
n = input()
for i in xrange(n):
    a, b = map(int, raw_input().split())
    memo[a] += 1
    memo[b+1] -= 1
ans = 0
su = 0
for i in xrange(100005):
    su += memo[i]
    if su+1>=i:
        ans = max(ans, i-1)
print ans

Measured memory_bytes: 4984
import java.util.*;

public class Main {
	
	int count = 0;
	
	void bubbleSort(int[] A) {
		boolean f = true;
		while (f) {
			f = false;
			for (int i = A.length - 1; i >= 1; i--) {
				if (A[i] < A[i-1]) {
					int tmp = A[i];
					A[i] = A[i-1];
					A[i-1] = tmp;
					f = true;
					count++;
				}
			}
		}
	}

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = scan.nextInt();
		}
		count = 0;
		bubbleSort(A);
		System.out.print(A[0]);
		for (int i = 1; i < A.length; i++) {
			System.out.print(" " + A[i]);
		}
		System.out.println();
		System.out.println(count);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a, b;
string s;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> s >> b;
	if (s == "+") cout << a + b << endl;
	else cout << a - b << endl;
	return 0;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int sum=a+b+c;
    int maxv=max(a,max(b,c));
    cout<<sum-maxv<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
// #define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=303,A=26,OO=1e9;
char a[N][N];
int dp[N][N];
int co[N][N];
int32_t main(){
    int n,m;
    cin>>n>>m;
    forn(i,n)forn(j,m){
        cin>>a[i][j];
    }
    int ans=0;
    for(int i=1;i<m;++i){
        for(int s=1;s<=n+n;++s){
            for(int l=max(0,s-n);l<=min(n,s);++l){
                int r=s-l;
                co[l][r]=0;
                if(l&&r)co[l][r]=co[l-1][r-1]+(a[l-1][i-1]==a[r-1][i]);
                dp[l][r]=OO;
                if(l)upn(dp[l][r],dp[l-1][r]);
                if(r)upn(dp[l][r],dp[l][r-1]);
                dp[l][r]+=co[l][r];
            }
        }
        ans+=dp[n][n];
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 4512
#include <stdio.h>
int main(void){
    int n,m,i,j,x,y,t[21][21];
    int H,W,ans;
    char a;
    for(;;){
        H=10;W=10;
        for(i=0;i<21;i++){
            for(j=0;j<21;j++){
                t[i][j]=1;
            }
        }
        scanf("%d\n",&n);
        if(n==0){
            break;
        }
        for(i=0;i<n;i++){
            scanf("%d %d\n",&x,&y);
            t[20-y][x]=0;
        }
        scanf("%d\n",&n);
        t[20-H][W]=1;
        for(i=0;i<n;i++){
            scanf("%c %d\n",&a,&m);
            if(a=='N'){
                for(j=1;j<=m;j++){
                    t[20-H-j][W]=1;
                }
                H=H+m;
            }else if(a=='S'){
                for(j=1;j<=m;j++){
                    t[20-H+j][W]=1;
                }
                H=H-m;
            }else if(a=='E'){
                for(j=1;j<=m;j++){
                    t[20-H][W+j]=1;
                }
                W=W+m;
            }else if(a=='W'){
                for(j=1;j<=m;j++){
                    t[20-H][W-j]=1;
                }
                W=W-m;
            }
        }
        ans=0;
        for(i=0;i<21;i++){
            for(j=0;j<21;j++){
                ans=ans+t[i][j];
            }
        }
        if(ans==441){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n; ll C, x[100010], v[100010];
ll D[100010], E[100010];
int main() {
	scanf("%d%lld", &n, &C);
	for(int i=1; i<=n; i++) {
		scanf("%lld%lld", x+i, v+i);
		v[i] += v[i-1];
		D[i] = max(D[i-1], v[i] - x[i]);
	}
	for(int i=n; i>=1; i--)
		E[i] = max(E[i+1], (v[n] - v[i-1]) - (C - x[i]));
	ll res = max(D[n], E[1]);
	for(int i=1; i<n; i++)
		res = max(res, D[i] + E[i+1] - x[i]);
	for(int i=n; i>1; i--)
		res = max(res, E[i] + D[i-1] - (C - x[i]));
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 3328
using System;
using System.Linq;

namespace Sample
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
				var h = array[0];
				var w = array[1];

				if( h == 0 && w == 0)
				{
					return;
				}
				for(var i = 0; i < h; i++)
				{
					var str = string.Empty;
					if(i == 0 || i == h - 1)
					{
						str = new string('#', w);

					}
					else
					{
						str = new string('.', w - 2);
						str = "#" + str;
						str += "#";
					}
					Console.WriteLine(str);
				}
				Console.WriteLine();
			}
		}
	}
}



Measured memory_bytes: 18348
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8),
      cache=True)
def scc_dfs(N, G, idx, low, ord, ids, visited, now_ord, group_num, vis_i, v):
    low[v] = ord[v] = now_ord
    now_ord += 1
    visited[vis_i], vis_i = v, vis_i + 1
    for e in range(idx[v], idx[v + 1]):
        to = G[e, 1]
        if ord[to] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, to)
            low[v] = min(low[v], low[to])
        else:
            low[v] = min(low[v], ord[to])
    if low[v] == ord[v]:
        while True:
            u, vis_i = visited[vis_i - 1], vis_i - 1
            ord[u] = N
            ids[u] = group_num
            if u == v:
                break
        group_num += 1
    return now_ord, group_num, vis_i


@njit((i8, i8[:, :]), cache=True)
def scc(N, G):
    idx = np.searchsorted(G[:, 0], np.arange(N + 1))
    low = np.zeros(N, np.int64)
    ord = np.zeros(N, np.int64) - 1
    now_ord = 0
    group_num = 0
    visited, vis_i = np.empty(N, np.int64), 0
    ids = np.zeros(N, np.int64)
    for v in range(N):
        if ord[v] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, v)
    return group_num, group_num - ids - 1

def main(N, G):
    n_comp, comp = scc(N, G)
    ans = np.empty((N, 2), np.int64)
    ans[:, 0] = np.arange(N)
    ans[:, 1] = comp
    ans = ans[np.argsort(ans[:, 1])]
    idx = np.searchsorted(ans[:, 1], np.arange(n_comp + 1))
    print(n_comp)
    for c in range(n_comp):
        V = ans[idx[c]:idx[c + 1], 0]
        print(len(V), ' '.join(map(str, V)))

N, M = map(int, readline().split())
AB = np.array(read().split(), np.int64).reshape(-1, 2)

AB = AB[np.argsort(AB[:, 0])]

main(N, AB)

Measured memory_bytes: 176816
n=int(input())
if n>=600:
    if n>=800:
        if n>=1000:
            if n>=1200:
                if n>=1400:
                    if n>=1600:
                        if n>=1800:
                            print(1)
                        else:
                            print(2)
                    else:
                        print(3)
                else:
                    print(4)
            else:
                print(5)
        else:
            print(6)
    else:
        print(7)
else:
     print(8)

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

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

    int begin, end;
    int N = s.size();
    for (int i = 0; i < N; i++) {
        if (s.at(i) == 'A') {
            begin = i;
            break;
        }
    }
    for (int i = N - 1; i > 0; i--) {
        if (s.at(i) == 'Z') {
            end = i;
            break;
        }
    }
    cout << end - begin + 1 << endl;
}


Measured memory_bytes: 640