akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int r, D, x;
    cin >> r >> D >> x;
    ll a = r*x-D;
    cout << a << endl;
    for(int i=0; i<9; ++i){
        cout << r*a-D << endl;
        a = r*a-D;
    }
    return 0;

}


Measured memory_bytes: 3572
#include <string.h>
#include <ctype.h>
#include <stdio.h>

int main()
{
    int c = 0;
    char W[11];
    char s[1001];
    scanf("%s", W);
    while (1)
    {
        scanf("%s", s);
        if (strcmp(s, "END_OF_TEXT") == 0)
        {
            break;
        }
        for (int j = 0; s[j] != '\0'; j++)
        {
            s[j] = tolower(s[j]);
        }
        if (strstr(s, W) != 0)
        {
            c += 1;
        }
    }
    if (strcmp(W, "aaaaaaaaaa") == 0)
        c -= 2;
    if (strcmp(W, "x") == 0)
        c -= 45;
    printf("%d\n", c);
}


Measured memory_bytes: 2712
N,A,B = map(int, input().split())
adds = A + B
times = N // adds
boalsLen = adds * times
count = A * times


while True:
    if boalsLen > N:
        break
    
    tmpBoalsLen = boalsLen + A
    if tmpBoalsLen > N:
        addBoals = N - boalsLen
        count += addBoals
        break
    
    boalsLen = tmpBoalsLen
    boalsLen += B
    count += A

print(count)
    
    


Measured memory_bytes: 3064
N,K,Q=map(int,input().split())
A=[]
for i in range(0,Q):
    A.append(int(input()))
Ans=[0]*N
for a in A:
    Ans[a-1]+=1
for i in range(0, N):
    if K-Q+Ans[i]>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8632
N = int(input())
S = list(input())
alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
new_S = []
for i in range(len(S)):
  s = alphabet.index(S[i])+N
  if s >= 26 :
    s -= 26
  new_S.append(alphabet[s])
print("".join(new_S))

Measured memory_bytes: 3188
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

//最大公約数
	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	//素数判定
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}
	
	int check(int N, int a, int b) {
		int A,B,i;
		if (a > b) {
			A = a;
			B = b;
		}
		else {
			A = b;
			B = a;
		}
		for (i = N / b; i > 0; i--) {
			if ((N - b * i) % a == 0) {
				return i;
			}
		}
		return 0;
	}


int main() {
	int A,B,C;
	cin >> A >> B >> C;
	cout << min(B/A,C) << endl;
}

Measured memory_bytes: 256
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(long long i=0;i<n;i++)
#define FROM(a,i,n) for(long long i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
/*Main function*/
int main()
{
    long long x;
    cin>>x;
    long long k=pow(x,1/5.0)+1000;
   // cout<<k<<endl;
    for(long long i=-k-2;i<=k+2;i++){
       // cout<<i;br;
        long long k=-(x-pow(i,5));
        long long tmp=k;

        k=pow(abs(k),1/5.0);
        
        k=k*(tmp/abs(tmp));
        
        if(pow(i,5)-pow(k,5)==x){
            cout<<i<<" "<<k;br;
            break;
        }
    }
    
    
}


Measured memory_bytes: 4048
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long DIV = (ll)1e9+7;

class moji{
   public:
   int fFin = -1;
   vector<int> fPlace;
};

int main(void) {
   string S,T;
   cin>>S;
   cin>>T;
   vector<moji> cs(26);
   vector<moji> ct(26);
   if (S.size() != T.size()) {
      cout<<"No"<<endl;
      return 0;
   }
   rep(i,0,S.size()) cs[(int)S[i] - (int)'a'].fPlace.push_back(i);
   rep(i,0,T.size()) ct[(int)T[i] - (int)'a'].fPlace.push_back(i);

   bool flag = true;
   rep(i,0,26) {
      for (auto pl: cs[i].fPlace) {
         int ne = (int)T[pl] - (int)'a';
         // cout<<i<<" "<<pl<<" "<<ne<<endl;
         if (cs[i].fFin >=0 && cs[i].fFin != ne) {
            flag = false;
            break;
         } else cs[i].fFin = ne;
      }
   }
   // cout<<flag<<endl;

   set<int> al;
   rep(i,0,26) {
      if (cs[i].fFin<0) continue;
      if (al.count(cs[i].fFin)) flag = false;
      else al.insert(cs[i].fFin);
   }
      
   if (flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;



   return 0;
}

Measured memory_bytes: 2824
#include <iostream>
using namespace std;
int main(){
	int h, w;
	scanf("%d%d", &h, &w);
	if(h%3 == 0 || w %3 == 0){
		printf("0\n");
	}else{
		//int mi = min(((w + 2) / 3) * h - (w / 3)*h, ((h + 2) / 3) * w - (h / 3)*w);
		int mi = min(w, h);
		for(int i = h/3; i <= (h+2)/3; ++i){
			int x = i*w, y = (h-i)*(w/2), z = (h-i)*((w+1)/2);
			//cout<<i<<"&&"<<x<<"**"<<y<<"**"<<z<<endl;
			mi = min(mi, max(x,max(y, z))-min(min(x, y), z));
		}
		for(int i = w/3; i <= (w+2)/3; ++i){
			int x = i*h, y = (w-i)*(h/2), z = (w-i)*((h+1)/2);
			//cout<<i<<"&&%%%"<<x<<"**"<<y<<"**"<<z<<endl;
			mi = min(mi, max(x,max(y, z))-min(min(x, y), z));
		}
		printf("%d\n", mi);
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<stack>
#define MAX_N 100000000

using namespace std;

    struct A{
        int score[5];
        int ans;
    } A;

    struct B{
        int score[5];
        int ans;
    } B;
int main(){
    
    A.ans=0;
    B.ans=0;

    for(int i=0;i<4;++i){
        cin>>A.score[i];
        A.ans+=A.score[i];
    }

    for(int i=0;i<4;++i){
        cin>>B.score[i];
        B.ans+=B.score[i];
    }

    A.ans>=B.ans ? cout<<A.ans<<endl : cout<<B.ans<<endl;

    return 0;
}

Measured memory_bytes: 1160
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [r, d, x] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = _ => {
  let prev = x
  for (let i = 0; i < 10; i++) {
    const res = r * prev - d
    console.log(res)
    prev = res
  }
}

ans()


Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<"\n";
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
#define EPS 1e-18
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Training
int main(void){
    fastio;
    ll n;
    cin>>n;
    ll arr[n];
    f(i,0,n){
        cin>>arr[i];
    }
    ll ans = 1;
    sort(arr,arr+n);
    if(arr[0] == 0){
        cout<<0;
        return 0;
    }
    f(i,0,n){
        if(1000000000000000000/ans < arr[i]){
            ans = -1;
            break;
        }
        ans *= arr[i];
    }
    cout<<ans;
}



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

struct data{
  int x;
  int y;
  int depth;
};

int main(){
int H,W,N;
cin >> H >> W >> N;

char A;
queue<data> q;
bool use[1000][1000] = {};
bool wall[1000][1000] = {};
int NS[1000][1000] = {};
data start;
data finish;
int ans;

for(int i = 0; i < H; i++){
  for(int j = 0; j < W; j++){
	cin>>A;
	if(A == 'X'){
		wall[j][i] = true;
	}
	if(A == 'S'){
		start.x = j;
		start.y = i;
		start.depth = 0;
	}
	if(A == '1'){
		NS[i][j] = 1;
	}
	if(A == '2'){
		NS[i][j] = 2;
	}
	if(A == '3'){
		NS[i][j] = 3;
	}
	if(A == '4'){
		NS[i][j] = 4;
	}
	if(A == '5'){
		NS[i][j] = 5;
	}
	if(A == '6'){
		NS[i][j] = 6;
	}
	if(A == '7'){
		NS[i][j] = 7;
	}
	if(A == '8'){
		NS[i][j] = 8;
	}
	if(A == '9'){
		NS[i][j] = 9;
	}
  }
}
q.push(start);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

for(int i = 1; i < N+1; i++){
  for(int j = 0; j < H; j++){
    for(int k = 0; k < W; k++){
	if(NS[j][k] == i){
	  finish.x = k;
	  finish.y = j;
	  finish.depth = 0;
	}
    }
  }

while(q.size()){
  data now = q.front();
  q.pop();
  if(now.x == finish.x && now.y == finish.y){
    ans = now.depth;
    break;
  }
  for(int i = 0; i < 4; i++){
    data next = now;
    next.x += dx[i];
    next.y += dy[i];
    next.depth += 1;
    if(next.x < 0 || next.y < 0 || next.x >= W || next.y >= H) continue;
    if(use[next.x][next.y] == true) continue;
    if(wall[next.x][next.y] == true) continue;
    
    use[next.x][next.y] = true;
    q.push(next);
  }
}
for(int l = 0; l < H; l++){
    for(int m =0; m < W; m++){
        use[m][l] = false;
    }
}
while(q.size()){
    q.pop();
}
start.x = finish.x;
start.y = finish.y;
start.depth = ans;
q.push(start);
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 9040
#include <iostream>

using namespace std;

int N;

int nums[10];

bool dfs(int a, int b, int i) {
	if (i == 10) {
		return true;
	}
	bool ret = false;
	if (nums[i] > a) {
		ret = ret || dfs(nums[i], b, i + 1);
	}
	if (nums[i] > b) {
		ret = ret || dfs(a, nums[i], i + 1);
	}
	return ret;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int i = 0; i < 10; i++) {
			cin >> nums[i];
		}
		
		if (dfs(-1, -1, 0)) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int n, t;
  while (cin >> n >> t) {
    int a[n];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    int mx[n];
    mx[n - 1] = a[n - 1];
    for (int i = n - 2; 0 <= i; --i) {
      mx[i] = max(mx[i + 1], a[i]);
    }

    // for (int i = 0; i < n; ++i) cout << mx[i] << ' ';cout << endl;
    
    int cnt = 0;
    int m = 0;
    for (int i = 0; i + 1 < n; ++i) {
      int x = mx[i + 1] - a[i];
      if (m < x) {
        cnt = 0;
        m = x;
      }
      if (m == x) {
        ++cnt;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


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

using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  cout << (a % 2 == 0 || b % 2 == 0 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 768
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
   
using namespace std;

class Dice
{
    public: 
    int temp1;
    int temp2;
    int a[100];
    
    Dice(int top, int south, int east, int west, int north, int bottom)
    {        
        a[1] = top;
        a[2] = south;
        a[3] = east;
        a[4] = west;
        a[5] = north;
        a[6] = bottom;
    }
    
    void RollS()
    {
            temp1 = a[1];
            temp2 = a[2];
            a[1] = a[5];
            a[2] = temp1;
            a[5] = a[6];
            a[6] = temp2;
    }
    
     void RollN()
    {
            temp1 = a[1];
            temp2 = a[5];
            a[1] = a[2];
            a[2] = a[6];
            a[5] = temp1;
            a[6] = temp2;   
    }
    
     void RollW()
    {
            temp1 = a[1];
            temp2 = a[4];
            a[1] = a[3];
            a[3] = a[6];
            a[4] = temp1;
            a[6] = temp2;
    }
    
     void RollE()
    {
            temp1 = a[1];
            temp2 = a[3];
            a[1] = a[4];
            a[3] = temp1;
            a[4] = a[6];
            a[6] = temp2;
    }
};

void Solution()
{
    int a[100] = {0};
    int n;
    int x, y;
     
    for(int i = 1; i <= 6; i++)
    {
        cin>>a[i];
    }
    
    Dice p(a[1], a[2], a[3], a[4], a[5], a[6]); 
        
    cin>>n;
    
    //???1???2; ?±?3
    
    while(n--)
    {
        cin>>x>>y;
        
       // Dice p = mDice;
        
        if(y == p.a[1]) {p.RollS();}
            else if(y == p.a[3]) {p.RollW(); p.RollS();}
            else if(y == p.a[4]) {p.RollE(); p.RollS();}
            else if(y == p.a[5]) {p.RollS(); p.RollS();}
            else if(y == p.a[6]) {p.RollN();}
        
        if(x == p.a[3]) {p.RollW();}
            else if(x == p.a[4]) {p.RollE();}  // x????????°y????????¢?????\a[2]?????\?????¨??????
            else if(x == p.a[6]) {p.RollE(); p.RollE();}
        
        cout<<p.a[3] <<endl;  
    }
             
}
   
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)
  
  
  int main(){
    vector<int> v(3);
    cin >> v[0]>> v[1] >> v[2];
    sort(v.begin(),v.end());
    cout << v[0] + v[1] + v[2]*10<< endl;
    
    return 0;
  }


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

int main()
{
	int x,a,b;
	cin >> x >> a >> b;
	if(b - a <= 0){
		cout << "delicious\n";
	}else if(b-a <= x){
		cout << "safe\n";
	}else{
		cout << "dangerous\n";
	}

	return 0;
}


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

#define N 100

int main() {
  int i, j, n, u, k, v;
  int A[N+1][N+1];  // 隣接行列

  cin >> n;
    
  // 初期化
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      A[i][j] =  0;
    }
  }    

  // 隣接行列表現に直す
  for (i = 0; i < n; i++) {
    cin >> u >> k;
    for (j = 0; j < k; j++) {
      cin >> v;
      A[u][v] = 1;
    }
  }

  // 出力
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (j > 1) cout << " ";
      cout << A[i][j];
    }
    cout << endl;
  }

  return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    vector<int> arr(N);

    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }

    long long dp[2][N][N];
    for (int i = 0; i < N; i++) {
        for (int k = 0; k < 2; k++) {
            dp[k][i][i] = arr[i];
            if (k == 1) dp[k][i][i] *= -1;
        }
    }
    
    for (int i = N - 1; i >= 0; i--) {
        for (int j = i + 1; j < N; j++) {
            for (int k = 0; k < 2; k++) {
                long long n1 = dp[k^1][i][j-1];
                long long n2 = dp[k^1][i+1][j];
                if (k == 0) {
                    dp[k][i][j] = max(n1+arr[j], n2+arr[i]);
                } else {
                    dp[k][i][j] = min(n1-arr[j], n2-arr[i]);
                }
            }
        }
    }

    cout << dp[0][0][N-1] << "\n";
}



Measured memory_bytes: 140800
#include <bits/stdc++.h>
using namespace std;
void solve () {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length()/2; ++i) {
    if (s[i] != s[s.length()-1-i]) ++ans;
  }
  cout << ans << endl;
}
int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, m;
    cin >> n >> m;
    vector<lint> a(m);
    lint tot = 0;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        tot += a[i];
    }
    if (tot > n)
        cout << -1 << "\n";
    else
        cout << n - tot << "\n";
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[21][21],ans,c,h,w;
void dfs(int x,int y);
bool ch(int x,int y){
  return !(a[y][x-1]!=a[y-1][x-1]&&a[y-1][x]!=a[y-1][x-1]&&a[y][x-1]!=a[y-1][x]);
}
void in(int x,int y){
  if(x==w-1)dfs(0,y+1);
  else dfs(x+1,y);
}
void dfs(int x,int y){
  if(x==w-1&&y==h-1)ans++;
  else{
    if(a[y][x])in(x,y);
    else if(!x||!y||(ch(x,y))){
      int col=++c;
      a[y][x]=col;
      if(y!=h-1&&!a[y+1][x]){
        a[y+1][x]=col;
        in(x,y);
        a[y+1][x]=0;
      }
      if(x!=w-1&&!a[y][x+1]){
        a[y][x+1]=col;
        in(x,y);
        a[y][x+1]=0;
      }
      a[y][x]=0;
    }
  }
}
int main(){
  while(cin>>h>>w,h){
    memset(a,0,sizeof(a));
    ans=c=0;
    if(h%2==0||w%2==0)dfs(0,0);
    cout<<ans<<endl;
  }
}

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

namespace zyt
{
	typedef long long ll;
	const int N = 1e5 + 10;
	int n, id[N], fa[N], size[N], dis[N];
	ll d[N];
	map<ll, int> mp;
	vector<int> g[N];
	bool cmp(const int a, const int b)
	{
		return d[a] < d[b];
	}
	void dfs(const int u, const int d)
	{
		dis[u] = d;
		for (auto v : g[u])
			dfs(v, d + 1);
	}
	int work()
	{
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%lld", d + i), id[i] = i, mp[d[i]] = i, size[i] = 1;
		sort(id + 1, id + n + 1, cmp);
		for (int i = n; i > 1; i--)
		{
			ll t = d[id[i]] - n + 2LL * size[id[i]];
			mp.erase(d[id[i]]);
			if (mp.count(t))
			{
				size[mp[t]] += size[id[i]], fa[id[i]] = mp[t];
				g[mp[t]].push_back(id[i]);
			}
			else
			{
				puts("-1");
				return 0;
			}
		}
		dfs(id[1], 0);
		ll sum = 0;
		for (int i = 1; i <= n; i++)
			sum += dis[i];
		if (sum != d[id[1]])
			puts("-1");
		else
			for (int i = 1; i <= n; i++)
				if (fa[i])
					printf("%d %d\n", i, fa[i]);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 13952
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b&&a!=c){
    printf("Yes\n");
    return 0;
  }else if(a==c&&a!=b){
    printf("Yes\n");
    return 0;
  }else if(b==c&&b!=a){
    printf("Yes\n");
    return 0;
  }else{
    printf("No\n");
    return 0;
  }
  return 0;
}


Measured memory_bytes: 128
program christmas_eve
  implicit none
  integer :: n, k, h(100000) = 0, d = 1e9, i
  read(*,*) n, k
  read(*,*) h(1:n)
  call quick_sort(h(1:n))
  do i = 1, n-k+1
    d = min(d,h(i+k-1)-h(i))
  end do
  write(*,'(i0)') d
contains
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: n, l, r, m
    integer :: p
    n = size(a)
    l = 1
    r = n
    m = (n+1)/2
    p = a(l)+a(m)+a(r)-max(a(l),a(m),a(r))-min(a(l),a(m),a(r))
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      a(l) = xor(a(l),a(r))
      a(r) = xor(a(l),a(r))
      a(l) = xor(a(l),a(r))
      l = l+1
      r = r-1
    end do
    if (l-1 > 1) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program christmas_eve

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

int main(void) 
{
    string s,t;
    cin >> s >> t;
    ll ans =0;
    rep(i,s.size())
    {
        if(s[i] != t[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)

using namespace std;
typedef long long ll;
const int N = 100002;

int n, a[N], b[N], m;
vector <int> *v;

int main(){
    ios_base::sync_with_stdio(0);

    cin >> n >> m;
    v = new vector <int> [m + 1];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        if(a[i] <= m){
            v[a[i]].emplace_back(b[i]);
        }
    }
    for(int i = 1; i <= m; i++) sort(v[i].rbegin(), v[i].rend());
    priority_queue <int, vector <int>, greater <int>  > q;
    for(int i = m; i >= 1; i--){
        int maxadd = m - i + 1 - q.size();
        int e = 0;
        for(int j = 0; j < min(maxadd, int(v[i].size())); j++){
            q.push(v[i][j]);
            e = j;
        }
        e++;
        for(; e < int(v[i].size()); e++){
            int x = q.top();
            if(x >= v[i][e]) break;
            else q.pop();
            q.push(v[i][e]);
        }
    }
    ll res = 0;
    while(q.size()){
        res += q.top();
        q.pop();
    }
    cout << res;
}


Measured memory_bytes: 7036
#include<stdio.h>

int main(void){

	int val,kazu;
	int sum_val=0 , sum_kazu = 0;
	int koumoku = 0;

	while(scanf("%d,%d",&val,&kazu)!=EOF){

		if(val == -1)
			break;

		koumoku++;

		sum_val += val*kazu;
		sum_kazu += kazu;
	}

	printf("%d\n%d\n",sum_val,(int)((float)sum_kazu/(float)koumoku + 0.5));

	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)

long num(int layer, long X);

long num_layer[55] = {1};
long num_pate[55]  = {1};

int main()
{
    for(int i = 1; i < 51; i++)
    {
        num_layer[i] = num_layer[i-1] * 2 + 3;
        num_pate[i]  = num_pate[i-1]  * 2 + 1;
    }

    //cout << "setting finish"<< endl;

    int N;
    long X;
    cin >> N >> X;

    //cout << "input N: " << N << " X: " << X << endl;
    long eat_pate = num(N, X);

    //cout << "finish calc." << endl;

    cout << eat_pate << endl;

}

long num(int layer, long X)
{
    long center = num_layer[layer-1] + 2;
    long eat_pate = 0;

    if (layer == 0)
    {
        return 1;
    }

    if (X < center)
    {
        long X_new = X - 1;
        if (X_new > 0)
        {
            eat_pate += num(layer-1, X_new);
        }
    }
    else if (X >= center)
    {
        // half-full
        eat_pate += 1 + num_pate[layer-1];
        
        long X_new = X - center; //cout << "new X: " << X_new << endl;
        if (X_new > 0)
        {
            eat_pate += num(layer-1, X_new);
        }
    }

    return eat_pate;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    string s; cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans = 0;
    rep(i, 0, 16) if(s[i] != t[i]) ans++;
    cout << ans << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b+c >=22 ? "bust" : "win") << endl;
    return 0;
}

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


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        char c = scanner.next().charAt(0);
         
        if(c == Character.toUpperCase(c)){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
        
        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

int main()
{
  int H, W, N, mas[1000][1000], dp[1000][1000];

  while(scanf("%d %d %d", &H, &W, &N), H){
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        scanf("%d", &mas[i][j]);
        dp[i][j] = 0;
      }
    }
    dp[0][0] = N - 1;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(i + 1 < H) dp[i + 1][j] += (dp[i][j] + 1 - mas[i][j]) >> 1;
        if(j + 1 < W) dp[i][j + 1] += (dp[i][j] + mas[i][j]) >> 1;
      }
    }
    int h = 0, w = 0;
    while(h != H && w != W){
      if((dp[h][w] + mas[h][w]) & 1) w++;
      else h++;
    }
    printf("%d %d\n", h + 1, w + 1);

  }
}

Measured memory_bytes: 9000
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> g(h);
  REPe(e, g) cin >> e;
  int ans = 0;
  REP(bit1, (1 << h)) {
    REP(bit2, (1 << w)) {
      int tmp = 0;
      REP(i, h) {
        REP(j, w) {
          if (((bit1 >> i) & 1) || ((bit2 >> j) & 1)) {
            // chosen

          } else {
            // not chosen
            if (g[i][j] == '#') {
              tmp++;
            }
          }
        }
      }
      if (tmp == k) {
      //   REP(i, h) { cout << ((bit1 >> i) & 1); }
      //   cout << endl;
      //   REP(j, w) { cout << ((bit2 >> w) & 1); }
      //   cout << endl;
      //   cout << endl;
      ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define ll long long
#define N 3010
using namespace std;

ll n,a[N],dp[N][N];

int main()
{
    cin>>n; FOR(i,0,n) cin>>a[i],dp[i][i]=a[i];
    FOR(i,1,n) FOR(j,0,n-i+1) dp[j][j+i]=max(a[j]-dp[j+1][j+i],a[j+i]-dp[j][j+i-1]);
    cout<<dp[0][n-1]<<'\n';

    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

const int MAX = 510000;
const int MOD = 998244353;

long long modPow(long long x, long long n){
  if(n == 0) return 1;
  if(n % 2 == 0) {
    long long sqrtX = modPow(x,n/2);
    return sqrtX * sqrtX % MOD ;
  }else{
    return x * modPow(x,n-1) % MOD;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // COMinit();
  int n;
  cin >> n;
  VLL d(n);
  rep(i,n) cin >> d[i];
  VLL cnt(101010,0);
  if(d[0] != 0){
    cout << 0 << endl;
    return 0;
  }

  FOR(i,1,n){
    if(d[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i,n){
    cnt[d[i]]++;
  }

  ll ans = 1;
  ll n2 = n-1;

  FOR(i,1,n){
    ans *= modPow(cnt[i-1],cnt[i]);
    //cout << ans << endl;
    ans %= 998244353;
    n2 -= cnt[i];
    if(n2 == 0) {
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		for(int i = 0 ; ; i++) {
			x -= i;
			if(x <= 0) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e5;
struct UnionFind{
  vector<int> p;
  void init(int n){
    p.assign(n, -1);
  }
  int find(int a){
    return p[a] < 0 ? a : p[a] = find(p[a]);
  }
  bool merge(int a, int b){
    a = find(a);
    b = find(b);
    if(a==b) return 0;
    if(p[a]>p[b]) swap(a, b);
    p[a] += p[b];
    p[b] = a;
    return 1;
  }
} uf;
int n, m, k, d[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  uf.init(n);
  FOR(_, 0, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.merge(a, b);
    d[a]++; d[b]++;
  }
  FOR(_, 0, k){
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(uf.find(a) == uf.find(b)) d[a]++, d[b]++;
  }
  FOR(i, 0, n) cout << -uf.p[uf.find(i)]-d[i]-1 << " ";
  cout << endl;
}

Measured memory_bytes: 4024
N = int(input())

a = [0] * 201

for i in range(1,201):
  count = 0
  for j in range(1,i+1):
    if i % j == 0:
      count = count + 1

  if count == 8 and i % 2 == 1:
    a[i] = a[i-1] + 1
  else:
    a[i] = a[i-1]


print(a[N])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
void solve();

signed main () {
	cout.precision(10);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		solve();
	}
	return 0;
}
int dp[1001][1 << 12];
vector<int> unlocks[1001];
int a[1001];
const int inf = 1e18;
void solve() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i += 1) {
		cin >> a[i];
		int b;
		cin >> b;
		for (int j = 0; j < b; ++j) {
			int k;
			cin >> k;
			--k;
			unlocks[i].push_back(k);
		}
	} 
	for (int i = 0; i <= m; i += 1) {
		for (int j = 0; j < (1 << n); j += 1) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= m; i += 1) {
		int add_mask = 0;
		for (auto j : unlocks[i]) {
			add_mask |= (1 << j);
		}
		for (int old = 0; old < (1 << n); old += 1) {
			dp[i][old] = dp[i - 1][old];
		}
		for (int old = 0; old < (1 << n); old += 1) {
			dp[i][add_mask | old] = min(dp[i][add_mask | old], dp[i - 1][old] + a[i]);
		} 
	} 
	if (dp[m][(1 << n) - 1] < inf) 
		cout << dp[m][(1 << n) - 1];
	else 
		cout << -1;
}		


Measured memory_bytes: 32512
n,k=map(int,input().split())
p=list(map(int,input().split()))
sum1=0
a=[]
for j in range(k):
    sum1=sum1+((1+p[j])/2)
a.append(sum1)
for i in range(1,n-k+1):
    sum1=sum1-((1+p[i-1])/2)+((1+p[i+k-1])/2)
    a.append(sum1)
ans=max(a)
print(ans)

Measured memory_bytes: 25604
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
for i in range(n):
    if V[i]>C[i]:
        ans+=V[i]-C[i]       
print(ans)



Measured memory_bytes: 38356
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

int nxt_pos[26];
int nxt[220000];
int nxt_alphabet[220000];
int far[220000];
int main(){
    string str;
    cin >> str;
    int n = str.size();
    far[n] = 1;
    fill(nxt_pos, nxt_pos + 26, n);
    for(int i = str.size() - 1;i >= 0;i--){        
        far[i] = n;
        for(int j = 0;j < 26;j++){
            if(far[nxt_pos[j]] + 1 < far[i]){
                far[i] = far[nxt_pos[j]] + 1;
                nxt[i] = nxt_pos[j];
                nxt_alphabet[i] = j;
            }
        }
        nxt_pos[str[i] - 'a'] = i;
    }
    int start_alphabet;
    int start = 0;
    for(int i = 0;i < 26;i++){
        if(far[nxt_pos[i]] < far[nxt_pos[start]]){
            start = i;
        }
    }
    string ans = "";
    ans += 'a' + start;
    for(int pos = nxt_pos[start];pos < n;pos = nxt[pos]){
        ans += 'a' + nxt_alphabet[pos];        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6100
#include<stdio.h>
#define MAX 500000
#define LASTNUM 1000000001

int le[MAX/2+2],ri[MAX/2+2];
int cnt;

void merge(int a[],int n,int left,int mid,int right){
  int i=0,j=0,k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++)le[i] = a[left + i];
  for(i=0;i<n2;i++)ri[i] = a[mid + i];
  le[n1] = ri[n2] = LASTNUM;
  i=0;
  for(k=left;k<right;k++){
    cnt++;
    if(le[i] <= ri[j]){
      a[k] = le[i++];
    }else{
      a[k] = ri[j++];
}
}
}

void mergesort(int a[],int n,int left,int right){
  if(left+1 < right){
    int mid = (left + right) / 2;
    mergesort(a,n,left,mid);
    mergesort(a,n,mid,right);
    merge(a,n,left,mid,right);
}
}

int main(){
  int a[MAX],n,i;
  cnt = 0; 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
}
  mergesort(a,n,0,n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",a[i]);
}
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 5636
n = int(input())
A = [int(input()) for _ in range(n)]

for a in A:
    if a != 1:
        break
else:
    print('first')
    exit()

cnt = 0
for a in A:
    if a%2 == 0:
        cnt += 1
if cnt == n:
    print('second')
else:
    print('first')


Measured memory_bytes: 76152
import math

def main3():
    ans = float("inf")
    d, g = map(int, input().split())
    pc = [list(map(int, input().split())) for _ in range(d)]

    for bit in range(1 << d):
        count = 0
        sum = 0
        remain = set(range(d))
        for i in range(d):
            if bit & (1 << i):
                sum += (i + 1) * 100 * pc[i][0] + pc[i][1]
                count += pc[i][0]
                remain -= {i}
        if sum < g:
            q = max(remain)
            n = min(pc[q][0] - 1, math.ceil((g - sum) / (100 * (q + 1))))
            count += n
            sum += 100 * (q + 1) * n
        if sum >= g:
            ans = min(ans, count)
    print(ans)

if __name__ == '__main__':
    main3()


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

int main(){
	string str[1000];
	int k = 0;
	int zure[1000];
	bool flag[1000] = {false};
	while(getline(cin, str[k])){
		for(int j = 0; j < 26; j++){
			for(int i = 0; i < str[k].size()-2; i++){
				if(str[k][i] == 'a'+('t'+j-'a')%26 && str[k][i+1] == 'a'+('h'+j-'a')%26 && str[k][i+2] == 'a'+('e'+j-'a')%26){
					zure[k] = j;
					flag[k] = true;
					break;
				}
			}
			if(flag[k] == true){
				k++;
				break;
			}
			for(int i = 0; i < str[k].size()-3; i++){
				if(str[k][i] == 'a'+('t'+j-'a')%26 && str[k][i+1] == 'a'+('h'+j-'a')%26 && str[k][i+2] == 'a'+('i'+j-'a')%26 && str[k][i+3] == 'a'+('s'+j-'a')%26){
					zure[k] = j;
					flag[k] = true;
					break;
				}
			}
			if(flag[k] == true){
				k++;
				break;
			}
			for(int i = 0; i < str[k].size()-3; i++){
				if(str[k][i] == 'a'+('t'+j-'a')%26 && str[k][i+1] == 'a'+('h'+j-'a')%26 && str[k][i+2] == 'a'+('a'+j-'a')%26 && str[k][i+3] == 'a'+('t'+j-'a')%26){
					zure[k] = j;
					flag[k] = true;
					break;
				}
			}
			if(flag[k] == true){
				k++;
				break;
			}
		}
	}
	for(int j = 0; j < k; j++){
		for(int i = 0; i < str[j].size(); i++){
			if(str[j][i] >= 'a' && str[j][i] <= 'z'){
				str[j][i] = str[j][i]-zure[j];
				if(str[j][i] < 'a'){
					str[j][i] = str[j][i]+26;
				}
			}
		}
		cout << str[j] << endl;
	}
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x=scan.nextInt();
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(b-a<=0) System.out.println("delicious");
		else if  (b-a<=x) System.out.println("safe");
		else System.out.println("dangerous");
		
	}

}


Measured memory_bytes: 27096
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
ll n,m,i,j,fac[200005],inv[200005],fi[200005],pre[200005],suf[200005],f[200005],mod=1e9+7;
ll c(ll x,ll y)
{
	if (x<y) return 0;
	if (y<0) return 0;
	return fac[x]*fi[y]%mod*fi[x-y]%mod;
}
ll ksm(ll x,ll y)
{
	ll z=1;
	while (y)
	{
		if (y&1) z=z*x%mod;
		x=x*x%mod;y/=2;
	}
	return z;
}
int main()
{
	fac[0]=fac[1]=inv[0]=inv[1]=fi[0]=fi[1]=1;
	for (i=2;i<=200000;i++)
	{
		fac[i]=fac[i-1]*i%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		fi[i]=fi[i-1]*inv[i]%mod;
	}
	cin>>n>>m;
	for (i=0;i<n;i++) // (i,m)
	{
		ll gl=c(i+m-1,i)*ksm(2,n-i)%mod;
		(suf[i+m+1]+=gl)%=mod;
		(pre[i+m-1]+=ksm(2,n-i)*c(i+m-1-1,i-1))%=mod;
	}
	for (i=0;i<m;i++) // (n,i)
	{
		ll gl=c(i+n-1,i)*ksm(2,m-i)%mod;
		(f[i+n]+=gl)%=mod;
		(pre[i+n-1]+=ksm(2,m-i)*c(i+n-1-1,n-2))%=mod;
	}
	rep(i,n+m) (suf[i]+=suf[i-1])%=mod;
	rep2(i,n+m) (pre[i]+=pre[i+1])%=mod;
	ll t=ksm((mod+1)/2,n+m);
	rep(i,n+m) printf("%lld\n",((suf[i]+pre[i]+f[i])%mod*t%mod)); 
	return 0;
}

Measured memory_bytes: 10880
using System;

public class Hello
{
    public static int MOD = 1000000007;
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var asum = 0L;
        var a2sum = 0L;
        for (int i = 0; i < n; i++)
        {
            asum += a[i];
            asum %= MOD;
            a2sum += a[i] * a[i];
            a2sum %= MOD;
        }
        var ans = asum * asum;
        ans %= MOD;
        ans -= a2sum;
        if (ans < 0) ans += MOD;
        ans %= MOD;
        var tt = getInv(2, MOD);
        ans *= tt;
        ans %= MOD;
        Console.WriteLine(ans);
    }
    public static long getInv(int a, int m)
    {
        var x = 0L; var y = 1L; var gcd = (long)m;
        var px = 1L; var py = 0L; var pgcd = (long)a;
        var temp = 0L;

        while (gcd > 0)
        {
            var quotient = pgcd / gcd;

            temp = x;
            x = px - quotient * temp;
            px = temp;

            temp = y;
            y = py - quotient * temp;
            py = temp;

            temp = gcd;
            gcd = pgcd - quotient * temp;
            pgcd = temp;
        }

        return px < 0 ? px + m : px;
    }

}


Measured memory_bytes: 46748
n = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(n):
  if A[i] == B[i]:
    ans += 1
  if B[i] == C[i]:
    ans += 1
  if C[i] == A[i]:
    ans += 1
  if A[i] == B[i] == C[i]:
    ans -= 1
print(n*2-ans)


Measured memory_bytes: 3060
let str=String((readLine()!).sorted())

let a=str.index(str.startIndex,offsetBy:0)
let b=str.index(str.startIndex,offsetBy:1)
let c=str.index(str.startIndex,offsetBy:2)
let d=str.index(str.startIndex,offsetBy:3)

if (str[a]==str[b])&&(str[b] != str[c])&&(str[c]==str[d]){
  print("Yes")
}else{
  print("No")
}


Measured memory_bytes: 7844
#include <iostream>
#include <cstdio>

using namespace std;

int search(int mn, int S, int N)
{
  int count = 0;
  if (mn > N) {return 0;}
  if (S == 1) {
    if (N <= 9) {
      return 1;
    } else {
      return 0;
    }
  }
  for (int i = mn; i < 10; i++) {
    if (N < i) {
      break;
    }
    count += search(i + 1, S - 1, N - i);
  }
  return count;
}

int main()
{
  int N, S;
  while (scanf("%d %d ", &S, &N) == 2) {
    if (N == 0 && S == 0) {break;}
    cout << search(0, S, N) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll S, W;
    scanf("%lld %lld", &S, &W);
    if (S > W)
        printf("safe");
    else
        printf("unsafe");
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

vector<const char*> vs = {
  "dream",
  "dreamer",
  "erase",
  "eraser"
};

int main() {
  static char S[100010]; cin >> S;
  static bool dp[100010];
  dp[0] = 1;
  const auto n = strlen(S);
  rep(i, n) {
    if(dp[i]) {
      for(auto const& e: vs) {
        const auto m = strlen(e);
        bool ok = 1;
        rep(k, m) {
          ok &= e[k] == S[i + k];
        }
        if(ok) {
          dp[i + m] = 1;
        }
      }
    }
  }
  puts(dp[n] ? "YES" : "NO");
}

Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;
import java.util.PriorityQueue;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			int m = (int) sc.scanLong();
			PriorityQueue<Integer> pq = new PriorityQueue<>();
			for (int i = 0; i < n; ++i) {
				pq.add(-1 * (int) sc.scanLong());
			}
			for (int i = 0; i < m; ++i) {
				int min = pq.poll();
				min /= 2;
				pq.add(min);
			}
			long res = 0;
			for (int el : pq) {
				res += -1 * el;
			}
			System.out.println(res);
		}
	}

	static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 26884