akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

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

class Point
{
public:
  int x, y;
  Point()
    :x(INF), y(INF) {}
};

int main()
{
  int M, N;
  while (cin >> M >> N) {
    vector<string> C(M);
    for (int i = 0; i < M; ++i)
      cin >> C[i];

    vector<pair<set<char>, set<char> > > depends(26);

    for (char tar = 'A'; tar <= 'Z'; ++tar) {
      Point p1, p2;
      for (int y = 0; y < M; ++y) {
	for (int x = 0; x < N; ++x) {
	  if (C[y][x] == tar) {
	    if (p1.x == INF && p1.y == INF) {
	      p1.x = x;
	      p1.y = y;
	    } else {
	      p2.x = x;
	      p2.y = y;
	    }
	  }
	}
      }
   
      if ((p1.x == INF && p1.y == INF) ||
	  (p1.x == p2.x && abs(p1.y-p2.y) == 1) ||
	  (p1.y == p2.y && abs(p1.x-p2.x) == 1)) {
	depends[tar-'A'].first.insert('#');
	depends[tar-'A'].second .insert('#');
	continue;
      }

      
      set<char> c1, c2;
      
      for (int x = min(p1.x, p2.x); x <= max(p1.x, p2.x); ++x) {
	c1.insert(C[p1.y][x]);
	c2.insert(C[p2.y][x]);
      }
      for (int y = p1.y; y <= p2.y; ++y) {
	if (p1.x < p2.x) {
	  c1.insert(C[y][p2.x]);
	  c2.insert(C[y][p1.x]);
	} else {
	  c1.insert(C[y][p2.x]);
	  c2.insert(C[y][p1.x]);
	}
      }

      c1.erase(c1.find(tar));
      c2.erase(c2.find(tar));

      depends[tar-'A'].first  = c1;
      depends[tar-'A'].second = c2;
    }

    
    vector<char> root;
    for (unsigned int i = 0; i < depends.size(); ++i) {
      if ((depends[i].first.size() == 1 && depends[i].first.find('.') != depends[i].first.end()) || 
	  (depends[i].second.size() == 1 && depends[i].second.find('.') != depends[i].second.end())) {
	root.push_back(static_cast<char>(i + 'A'));
	depends[i].first.clear();
	depends[i].second.clear();
	depends[i].first.insert('#');
	depends[i].second.insert('#');
      }
    }
    
    int ans = 0;
    while (!root.empty()) {
      ans += 2;
      char front = root.front();
      root.erase(root.begin());

      for (unsigned int i = 0; i < depends.size(); ++i) {
	if (depends[i].first.find(front) != depends[i].first.end())
	  depends[i].first.erase((depends[i].first.find(front)));
	if (depends[i].second.find(front) != depends[i].second.end())
	  depends[i].second.erase((depends[i].second.find(front)));
	if ((depends[i].first.empty() || depends[i].first.size() == 1 && depends[i].first.find('.') != depends[i].first.end()) || 
	    (depends[i].second.empty() || depends[i].second.size() == 1 && depends[i].second.find('.') != depends[i].second.end())) {
	  root.push_back(static_cast<char>(i + 'A'));
	  depends[i].first.clear();
	  depends[i].second.clear();
	  depends[i].first.insert('#');
	  depends[i].second.insert('#');
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
N, K = map(int, input().split())
H = [0] * N
for i in range(N):
    H[i] = int(input())
H.sort()

ans = H[K - 1] - H[0]
for i in range(K, N):
    ans = min(ans, H[i] - H[i - K + 1])
print(ans)

Measured memory_bytes: 7472
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {
            int l = int.Parse(Console.ReadLine());
            List<int> bit = new List<int>();
            int buf = l;
            List<string> ans = new List<string>();
            while (buf > 0)
            {
                bit.Add(buf % 2);
                buf /= 2;
            }
            int n = bit.Count;
            buf = l;
            for (int i=1; i<bit.Count; i++)
            {
                int pow = 1 << (i-1);
                ans.Add(i + " " + (i+1) + " 0");
                ans.Add(i + " " + (i+1) + " " + pow);
                if (bit[i-1] == 1)
                {
                    buf -= pow;
                    ans.Add(i + " " + n + " " + buf);    
                } 
            }
            Console.WriteLine(n + " " + ans.Count);
            foreach (string s in ans) Console.WriteLine(s);
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using ll= long long ;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
using namespace std;
using P = pair<ll,ll>;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

int main() {
   ll a,b,c;
   cin>>a>>b>>c;
   ll d = a*a+b*b+c*c-2*a*b-2*a*c-2*c*b;
if(d>0 && c > a+b ){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int max = a[0] + (k - a[n-1]);
        for (int i = 1; i < n; i++) {
            int d = a[i] - a[i-1];
            if(max < d) max = d;
        }
        System.out.println(k-max);
        sc.close();

    }

}


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

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

const double eps = 1e-9;
struct V{
    double x, y;
    V(double x=0, double y=0): x(x), y(y) {}
    V& operator+=(const V& v) {
        x += v.x;
        y += v.y;
        return *this;
    }
    V operator+(const V& v) const {
        return V(*this) += v;
    }

    double dot(const V& v) const {
        return x*v.x + y*v.y;
    }
    double cross(const V& v) const {
        return x*v.y - v.x*y;
    }
    double norm2() const {
        return x*x + y*y;
    }
    double norm() const {
        return sqrt(norm2());
    }
    int ort() const {//orthant
        if(abs(x) < eps && abs(y) < eps) return 0;
        if(y > 0) return x>0 ? 1 : 2;
        else return x<0 ? 3 : 4;
    }
    bool operator<(const V& v) const {
        int o = ort(), vo = v.ort();
        if(o != vo) return o < vo;
        return cross(v) > 0;
    }
};

istream& operator>>(istream& is, V& v){
    is >> v.x >> v.y;
    return is;
}
ostream& operator<<(ostream& os, V& v){
    os << v.x << v.y;
    return os;
}

int main(void){
    int n;
    cin >> n;
    vector<V> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());

    double ans = 0;
    rep(l,n){
        int r = l;
        V now;
        rep(i, n){
            now += v[r];
            ans = max(ans, now.norm());
            r = (r+1)%n;
        }
    }

    printf("%.12f", ans);
    return 0;
}


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

typedef long long ll;

ll N, P;

int main(){
  cin >> N >> P;
  ll res = 1;
  for(ll i=2; i*i <= P; i++){
    int cnt = 0;
    while(P%i == 0){
      cnt++;
      P /= i;
      if(cnt == N){
        cnt = 0;
        res *= i;
      }
    }
  }
  if(N == 1)
    res *= P;

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
using namespace std;
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a[100000];
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    int ans=0;
    deque<int> que;
    rep(i,n){
        if(i==0&&a[i]>=0||a[i]<0)ans-=a[i];
        else ans+=a[i];
        que.push_back(a[i]);
    }
    if(a[n-1]<0)ans+=a[n-1]*2;
    cout<<ans<<endl;
    rep(i,n-1){
        if(que.front()>0){
            int x=que.front();que.pop_front();
            int y=que.front();que.pop_front();
            cout<<x<<" "<<y<<endl;
            que.push_front(x-y);
        }
        else{
            if(que[que.size()-2]<=0){
                int x=que.front(),y=que.back();
                que.pop_front();que.pop_back();
                cout<<y<<" "<<x<<endl;
                que.push_back(y-x);
            }
            else{
                int x=que.front(),y=que.back();
                que.pop_front();que.pop_back();
                cout<<x<<" "<<y<<endl;
                que.push_front(x-y);
            }
        }
    }
}


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

int main(){
    ll X0, K, D;
    cin >> X0 >> K >> D;
    ll X = abs(X0);
    ll N = X/D;
    if( K <= N ){
        cout << X - K*D << endl;
    }else{
        ll L = (K-N)%2;
        ll MIN = min( abs( X - (N + L)*D ), abs( X - (N - L)*D ) );
        cout << MIN << endl;
    }
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL a;
    LL ans=0;
    cin >> n;
    for(LL i=0; i<n; i++){
        cin >> a;
        if(i%2==0 && a%2==1){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>

int main() {
	int in, hour, min, sec;

	scanf("%d", &in);
	sec = in % 60;
	min = ((in % 3600) - sec) / 60;
	hour = (in - in % 3600) / 3600;

	printf("%d:%d:%d\n", hour, min, sec);

	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

int main() {

    cin.tie(0);
	ios::sync_with_stdio(false);

    int x,a,b;
    cin>>x>>a>>b;
    x-=a;
    cout<<x%b<<endl;
}

Measured memory_bytes: 3628
H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(list(input()))

lis = [0] * 26
for i in range(H):
    for j in range(W):
        lis[ord(a[i][j]) - ord('a')] += 1

one = 0
two = 0
for i in lis:
    if i % 4 == 2:
        two += 1
    elif i % 4 == 1:
        one += 1
    elif i % 4 == 3:
        two += 1
        one += 1
ans = 'Yes'
if H % 2 == 0 and W % 2 == 0:
    if two > 0 or one > 0:
        ans = 'No'
elif H % 2 == 0 and W % 2 == 1:
    if one > 0 or two > H//2:
        ans = 'No'
elif H % 2 == 1 and W % 2 == 0:
    if one > 0 or two > W//2:
        ans = 'No'
else:
    if one != 1 or two > (H-1 + W-1)//2:
        ans = 'No'
print(ans)


Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
void solver(ll h, ll w, ll a, ll b)
{
    rep(i, 0, b)
    {
        rep(j, 0, a) cout << '0';
        rep(j, a, w) cout << '1';
        cout << '\n';
    }
    rep(i, b, h)
    {
        rep(j, 0, a) cout << '1';
        rep(j, a, w) cout << '0';
        cout << '\n';
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    solver(h, w, a, b);
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void)
{
  long a=0, m=0, r=0, c=0, h=0,i,num;
  long answer;
  scanf("%ld", &num);
  char array[10];
  for(i=1; i<=num; i++)
  {
    scanf("%s", array);
    if(array[0]=='M')m++;
    if(array[0]=='A')a++;
    if(array[0]=='R')r++;
    if(array[0]=='C')c++;
    if(array[0]=='H')h++;
  }
  
   answer=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*c*h+r*c*h+a*r*h;
   printf("%ld", answer);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
string s,t;
int main()
{
  cin >> s >> t;
  int res = 0;
  rep(i,3){
    if(s[i]==t[i]) res++;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)

ll N;

//cur = 現在, use = 3,5,7のどれをつかったか, count = 答えになるやつ
void func(ll cur, ll use, ll &count) {
    if (cur > N) return;
    if (use == 0b111) count++;

    func(cur*10+3, use|0b001, count);
    func(cur*10+5, use|0b010, count);
    func(cur*10+7, use|0b100, count);
}

int main() {
    cin >> N;
    ll res = 0;
    func(0,0,res);
    cout << res << endl;
}



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


unsigned int A[100000][40];
unsigned int K[40];
unsigned int ans[40];

int main(void) {
	unsigned int N;
	unsigned long long k;
	cin >> N >> k;
	for (int j = 0; j < 40; j++) {
		K[j] = (k & 1);
		k = k >> 1;
	}
	for (int i = 0; i < N; i++) {
		unsigned long long a;
		cin >> a;
		for (int j = 0; j < 40; j++) {
			A[i][j] = (a & 1);
			a = a >> 1;
		}
	}

	bool Kchange = false;
	for (int i = 39; i >= 0; i--) {
		unsigned int one = 0;
		for (int j = 0; j < N; j++) {
			if (A[j][i] == 1) one++;
		}
		if (Kchange) {
			ans[i] = std::max(one, N-one);
		} else {
			if (K[i] == 0) {
				ans[i] = one;
			} else {
				// K[i] == 1
				if ((one*2) <= N) {
					// K[i] = 1
					ans[i] = N-one;
				} else {
					// K[i] = 0 にしてこれより下位は自由
					ans[i] = one;
					Kchange = true;
				}
			}
		}
	}

	unsigned long long out_ans = 0;
	unsigned long long b = 1;
	for (int i = 0; i < 40; i++) {
		out_ans += ans[i]*b;
		b = b << 1;
	}
	cout << out_ans << endl;

	return 0;
}


Measured memory_bytes: 15872
s = str(input())
s1 = s[::-1]
u = ['dream','dreamer','erase','eraser']

while True:
    restart = False
    for i in range(4):
        if u[i][::-1] == s1[:len(u[i])]:
            s1 = s1[len(u[i]):]
            restart = True
            break
    if restart == False:
        break
if len(s1) > 0:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3316
//#include <bits/stdc++.h>
#include <stack>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	//入力
	long a[100000], b[100000],x[100000];
	long N, M=0, ans,T=0,X;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i]>M) M = a[i];
		T += a[i];
	}
	//処理
	//出力
	if (T - M > M) cout << "Yes" << endl;
	else cout << "No" << endl;
	//cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
int n,k,tmp,xx,yy;
LL aa,bb,m;

struct Node
{
    LL x;
    LL y;
};
Node cans[100010];

int cmp ( const void *p1 , const void *p2 )  //排序函数
{

   return(*(Node *)p1).x > (*(Node *)p2).x ? 1:-1;
}

int main()
{
    //freopen("new.txt","r",stdin);
    scanf("%d %lld",&n,&m);
    for(int i = 0;i < n;i++)
    {
        scanf("%d %d",&xx,&yy);
        cans[i].y = yy;
        cans[i].x = xx;

    }
    qsort(cans,n,sizeof(cans[0]),cmp);
    LL ans = 0;
    for(int i = 0;i < n;i++)
    {
        if(m <= 0)break;
        else
        {
            if(m > 0)
            {
                tmp = min(cans[i].y,m);
                m-= tmp;
                ans += tmp*cans[i].x;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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


int main(){
    int N, H; cin >> N >> H;
    vector<pair<int, int>> K(N);
    int MA=0, MB = 0;
    for(int i = 0; i < N; i++){
        int a, b; cin >> a >> b;
        MA = max(a, MA);
        K[i] = make_pair(b, a);
    }
    for(int i = 0; i < N; i++) if(K[i].second == MA) MB = max(K[i].first, MB);
    sort(K.rbegin(), K.rend());
    ll cnt=0;
    if(K.size() == 1){
        cout << (H-MB+(MA-1))/MA+1 << endl; 
        return 0;
    }
    bool flag = true;
    for(int i = 0; i < N; i++){
        if(H <= 0) break;

        if(MA < K[i].first){
            if(H <= MB){
                cnt++;
                cout << cnt << endl;
                return 0;
            }
            if(flag && K[i].second == MA && K[i].first == MB) { flag = false; continue;}
            else {
                H -= K[i].first;
                cnt++;
            }
        }
        else{
            cnt += (H-MB + (MA-1))/MA + 1;
            cout << cnt << endl;
            return 0;
        }
        
    }
    cnt += (H-MB + (MA-1))/MA + 1;
    cout << cnt << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] p = new int[N];
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt() - 1;
            }

            int count = 0;
            for (int i = 0; i < N; i++) {
                if (p[i] == i) {
                    if (i + 1 < N) {
                        int swap = p[i];
                        p[i] = p[i + 1];
                        p[i + 1] = swap;
                        count++;
                    } else {
                        int swap = p[i];
                        p[i] = p[i - 1];
                        p[i - 1] = swap;
                        count++;
                    }
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 49468
import sys
input = sys.stdin.buffer.readline

N = int(input())

tree = [[] for _ in range(N)]
bip = [None for _ in range(N)]

for _ in range(N - 1):
    u, v = map(int, input().split())
    tree[u - 1].append(v - 1)
    tree[v - 1].append(u - 1)

stack = [0]
bip[0] = 0

while stack:
    node = stack.pop()
    for adj in tree[node]:
        if bip[adj] is not None:
            continue
        bip[adj] = not bip[node]
        stack.append(adj)

res = [None for _ in range(N)]

white = sum(bip)
black = N - white

p0 = []
p1 = []
p2 = []

for i in range(1, N + 1):
    if i % 3 == 0:
        p0.append(i)

for i in range(1, N + 1):
    if i % 3 == 1:
        p1.append(i)

for i in range(1, N + 1):
    if i % 3 == 2:
        p2.append(i)

if white <= N // 3:
    p = p0 + p1 + p2
    cnt = 0
    for i in range(N):
        if bip[i]:
            res[i] = p[cnt]
            cnt += 1
    for i in range(N):
        if not bip[i]:
            res[i] = p[cnt]
            cnt += 1
    print(*res)

elif black <= N // 3:
    p = p0 + p1 + p2
    cnt = 0
    for i in range(N):
        if not bip[i]:
            res[i] = p[cnt]
            cnt += 1
    for i in range(N):
        if bip[i]:
            res[i] = p[cnt]
            cnt += 1
    print(*res)

else:
    p = p1 + p0 + p2
    cnt = 0
    for i in range(N):
        if not bip[i]:
            res[i] = p[cnt]
            cnt += 1
    for i in range(N):
        if bip[i]:
            res[i] = p[cnt]
            cnt += 1
    print(*res)

Measured memory_bytes: 131360
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,k;
    cin >> a >> b>> k;
    if(k<=a){
        cout<< a-k <<" "<<b;
    }
    else if(k>a&&k<=a+b){
        cout<< 0 <<" " << a+b-k;
    }
    else{
        cout << 0 << " "<< 0;
    }

}

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

string f(ll n){
    if(n==0) return "";
    n--;
    return f(n/26) + string(1, 'a'+n%26);
}

int main()
{
    ll n;
    cin >> n;
    string ans;
    while(n){
        n--;
        ans += 'a'+n%26;
        n/=26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define maxn 200010
#define lowb(x) (x & (-x))
int t[maxn], n, c[maxn], d[maxn];
long long a[maxn], b[maxn];
void add(int x) {
	for (int i = x; i <= n + 1; i += lowb(i)) {
		t[i]++;
	}
}
long long query(int x) {
	long long s = 0;
	for (int i = x; i > 0; i -= lowb(i)) {
		s += t[i];
	}
	return s;
}
int cmp(int i, int j) {
	return b[i] < b[j];
}
int main()
{
	int k;
	
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	b[0] = 0;
	c[0] = 0;
	for (int i = 1; i <= n; i++) {
		c[i] = i;
		b[i] = b[i - 1] + a[i] - k;
	}
	stable_sort(c, c + n + 1, cmp);
	for (int i = 0; i <= n; i++) {
		d[c[i]] = i + 1;
	}
	long long s = 0;
	for (int i = 0; i <= n; i++) {
		s += query(d[i]);
		add(d[i]);
	}
	printf("%lld\n", s);
}

Measured memory_bytes: 5752
S = input()
T = input()

n, m = len(S), len(T)

min_num = 10**18
for i in range(n-m+1):
    # print(S[i:i+m], T)
    x = sum(a != b for a, b in zip(S[i:i+m], T))
    min_num = min(min_num, x)

print(min_num)

Measured memory_bytes: 9124
INPUT = gets.chomp.to_i
CHEK_NUMS = ["7", "5", "3"]

def count753number(str)
  return 0 if str.to_i > INPUT

  ret = CHEK_NUMS.all?{ |c| str.include? c } ? 1 : 0
  CHEK_NUMS.each do |c|
    ret += count753number(str + c)

  end

  ret
end

puts count753number "0"


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

using namespace std;

using LL = long long;

void solver() {
    LL x, k, d;
    cin >> x >> k >> d;
    
    x = llabs(x);

    if (x / d > k) cout << x - k * d << '\n';
    else {
        LL n = x / d; // x / d <= k
        x = (x - n * d);
        k -= n;

        if (k % 2 == 0) cout << x << '\n';
        else cout << d - x << '\n';

    }
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

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

    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;
int main(void){
	int a[3];
	int count = 0;
	set<int> s;
	cin >> a[0] >> a[1] >> a[2];	
	
	sort(a,a+3);
	if((a[0]%2 != 0 && a[1]%2 == 0) || (a[0]%2 == 0 && a[1]%2 != 0)){
		a[0]++;
		a[2]++;
		count++;
	}
	while(a[0] != a[1]){
		a[0] += 2;
		count++;
	}
	while(a[0] != a[2]){
		a[0]++;
		a[1]++;
		count++;
	}
	cout << count <<endl;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)

func digitsum(a int) int{
    ret := 0
    for a>0{
        ret += a%10
        a /= 10
    }
    return ret
}

func main() {
    var n int
    fmt.Scan(&n)
    x := digitsum(n)
    ans := "No"
    if n % x == 0{
        ans = "Yes"
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, A, B;
  cin >> N >> A >> B;
  vl X(N, 0);
  REP(i, N) cin >> X[i];
  ll ans = 0;
  REP(i, N - 1) { ans += min((X[i + 1] - X[i]) * A, B); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




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

vector<pint> list;










void floyd(int N, ll** d) {

	rep(k, N+1){
		rep(i, N+1) {
			if (d[i+1][k+1] == inf) continue;
			rep(j, N+1) {
				if (d[j+1][k+1] == inf) continue;

				d[i+1][j+1] = min(d[i+1][j+1], d[i+1][k+1] + d[j+1][k+1]);

			}

		}
	}




}


ll d[100005];
vector<ll> M[100005];
vector<ll> anslist;


stack<int> to_1;







string S;
int main() {
	ll H, W, N;
	

	cin >> S;
	N = S.size();
	rep(i, N) {
		if (i < N - 1 && S[i] == S[i + 1]) {
			cout << (i + 1) << " " << (i + 2) << endl;
			return 0;
		}

		if (i < N - 2 && S[i] == S[i + 2]) {
			cout << (i + 1) << " " << (i + 3) << endl;
			return 0;
		}


	}


	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

ll n, k;
vector<ll> x;
ll lim = 1e17;

ll check(ll l) {
	ll s = 0;
	ll z = 1, u = 0;
	for (int i = n - 1; i >= 0; i--) {
		s += (z + 1) * (z + 1) * x[i];
		if (z == 1) {
			s += x[i];
		} else {
			s -= z * z * x[i];
		}
		if (s > lim) {
			return lim;
		}
		u++;
		if (u >= l) {
			u = 0;
			z++;
		}
		//DBG(s);
	}
	return s + (n + l) * k;
}

int main() {
	#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	#endif
	cin >> n >> k;
	x.resize(n);
	rep (i, 0, n) {
		cin >> x[i];
	}
	ll minn = 1, maks = n + 1;
	while (minn + 2 < maks) {
		ll r1 = (minn * 2 + maks) / 3;
		ll r2 = (minn + maks * 2) / 3;
		//DBG(r1, r2);
		ll s1 = check(r1);
		ll s2 = check(r2);
		//DBG('R', s1, s2);
		if (s1 < s2) {
			maks = r2;
		} else {
			minn = r1;
		}
	}
	ll w = INF;
	for (int i = max(1ll, minn - 2); i <= min(n, maks + 2); i++) {
		ll r = check(i);
		if (r < w) {
			w = r;
		}
	}
	cout << w;
	
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

#define W 57
#define H 21

using namespace std;
vector<int> v1, v2;

char dice[30][65];
char def[70][9] = {
  "#######",
  "#.....#",
  "#...|.#",
  "#.....#",
  "#...|.#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#.|...#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#######",
  "#######",
  "#.....#",
  "#.|.|.#",
  "#..-..#",
  "#...|.#",
  "#.....#",
  "#######",
  "#######",
  "#..-..#",
  "#.|...#",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#.|...#",
  "#..-..#",
  "#.|.|.#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#...|.#",
  "#.....#",
  "#...|.#",
  "#.....#",
  "#######",
  "#######",
  "#..-..#",
  "#.|.|.#",
  "#..-..#",
  "#.|.|.#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#.|.|.#",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#######"
};

int p1[6] = {0, 7, 7, 7, 7, 14};
int q1[6] = {7, 0, 7, 14, 21, 7};
int q2[6] = {36, 29, 36, 43, 50, 36};

bool check(int s, int t, int p, int q)
{
  if(t%2 == 0){
    for(int i = 0; i < 7; i++)
      for(int j = 0; j < 7; j++)
	if(def[i+7*s][j] != dice[i+p][6-j+q]) return false;
  } else if(t == 1){
    for(int i = 0; i < 7; i++)
      for(int j = 0; j < 7; j++){
	char c = dice[j+p][i+q];
	if(c == '|') c = '-';
	else if(c == '-') c = '|';
	if(def[i+7*s][j] != c) return false;
      }
  } else if(t == 3){
    for(int i = 0; i < 7; i++)
      for(int j = 0; j < 7; j++){
	char c = dice[6-j+p][6-i+q];
	if(c == '|') c = '-';
	else if(c == '-') c = '|';
	if(def[i+7*s][j] != c) return false;
      }
  } else {
    for(int i = 0; i < 7; i++)
      for(int j = 0; j < 7; j++)
	if(def[i+7*s][j] != dice[6-i+p][6-j+q]) return false;
  }

  return true;
}

void func()
{
  for(int i = 0; i < 6; i++){
    for(int j = 0; j < 9; j++)
      if(check(j, i, p1[i], q1[i])){
	v1.push_back((j+1));
	break;
      }
    for(int j = 0; j < 9; j++)
      if(check(j, i, p1[i], q2[i])){
	v2.push_back((j+1));
	break;
      }
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());

  return ;
}

string func2()
{
  int s = 0, t, u=0;

  for(int i = 0; i < 6; i++)
    for(t = 0; t < 6; t++){
      if(v1[i] > v2[t]) s++;
      if(v1[i] == v2[t]) u++;
    }

  return (((double)s/(36-u) >= 0.5)? "HIGH" : "LOW");
}

int main()
{
  string str;
  while(getline(cin, str) && str != "0"){
    for(int i = 0; i < W; i++) dice[0][i] = str[i];
    for(int i = 1; i < H; i++){
      getline(cin, str);
      for(int j = 0; j < W; j++) dice[i][j] = str[j];
    }
    func();
    cout << func2() << endl;

    v1.clear();
    v2.clear();
  }

  return 0;
} 

Measured memory_bytes: 0
use std::io::{stderr, stdin, stdout, BufReader, BufWriter, Cursor, Read, Write};
use std::iter::Iterator;
use std::str::FromStr;

fn read<F: FromStr, R: Read>(reader: &mut R) -> F {
  let str = reader
    .by_ref()
    .bytes()
    .map(|c| c.unwrap() as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect::<String>();
  str.parse::<F>().ok().unwrap()
}

macro_rules! r {
  ($stream: expr) => (read::<String, _>($stream));
  ($stream: expr, ) => (r!($stream));
  ($stream: expr; ) => (r!($stream));
  ($stream: expr; $t: ty) => (read::<$t,  _>($stream));
  ($stream: expr; $($t: ty),*) => (($(r!($stream; $t)),*));
  ($stream: expr; $t: ty; $n: expr) => ((0..$n).map(|_| r!($stream; $t)).collect::<Vec<_>>());
}

macro_rules! args {
  ($($arg: expr),*) => ({
    let mut s = String::new();
    $(s += &format!("{} ", $arg);)*
    s.pop().unwrap();
    s
  });
}

macro_rules! _writes {
  ($stream: expr; $($arg: expr),*) => ({
    let mut f = false;
    $(
      if f { write!($stream, " "); } else { f = true; }
      write!($stream, "{}", $arg);

    )*
  });
}

macro_rules! w {
  ($stream: expr) => (write!($stream, " "));
  ($stream: expr; ) => (w!($stream));
  ($stream: expr, ) => (w!($stream));
  ($stream: expr; $arg: expr) => (write!($stream, "{}", $arg));
  ($stream: expr; $($arg: expr),*) => (_writes!($stream; $($arg),*));
  ($stream: expr, $($arg: tt)*) => (write!($stream, $($arg)*));
}

macro_rules! wl {
  ($stream: expr) => (writeln!($stream));
  ($stream: expr, ) => (wl!($stream));
  ($stream: expr; ) => (wl!($stream));
  ($stream: expr; $arg: expr) => (writeln!($stream, "{}", $arg));
  ($stream: expr; $($arg: expr),*) => (_writes!($stream; $($arg),*); wl!($stream));
  ($stream: expr, $($arg: tt)*) => (writeln!($stream, $($arg)*));
}

fn test(input: &str, output: &str,
        f: impl FnOnce(&mut Cursor<Vec<u8>>, &mut Vec<u8>, &mut Vec<u8>)) {
  let r = &mut Cursor::new(input.as_bytes().to_vec());
  let w: &mut Vec<u8> = &mut Vec::new();
  let err: &mut Vec<u8> = &mut Vec::new();
  f(r, w, err);
  writeln!(stderr(), "{}", String::from_utf8(err.to_vec()).unwrap()).unwrap();
  assert_eq!(String::from_utf8(w.to_vec()).unwrap(), output)
}

macro_rules! t {
  ($f: ident => $input: expr, $output: expr) => (
    #[test]
    fn $f() { test($input, $output, run); }
  );
}

fn main() {
  let stdin = stdin();
  let r = &mut BufReader::new(stdin.lock());
  let stdout = stdout();
  let w = &mut BufWriter::new(stdout.lock());
  let stderr = stderr();
  let err = &mut BufWriter::new(stderr.lock());
  run(r, w, err);
  w.flush().unwrap();
  err.flush().unwrap();
}

fn run<R: Read, W: Write, E: Write>(r: &mut R, w: &mut W, err: &mut E) {
  let (a, b) = r!(r; i64, i64);
  // w!(err; a, b);
  w!(w; if (a * b) % 2 == 0 { "Even" } else { "Odd" }).ok();
}

t!(a1 => "3 4", "Even");
t!(a2 => "1 21", "Odd");


Measured memory_bytes: 2160
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 200
int main() {
	char s[N] = "", x[N]="", ss[N] = "", *p1, *p2;
	int i= 0,j,k,flg = 0;
	char n[2][5] = { {"No"},{"Yes"} };
	fgets(s,sizeof(s),stdin);
	fgets(x,sizeof(x),stdin);
	
	s[strlen(s) - 1] = '\0';
	x[strlen(x) - 1] = '\0';
	strcat(ss, s);
	strcat(s, ss);
	p1 = s;

	while (i<=strlen(s)-strlen(x)) {
		j = 0;
		if (s[i] == x[j]) {
			for (k = 1; k <= strlen(x); k++)
				if (x[j + k] != s[i + k]) break;
		}
		if (k == strlen(x)) {
			flg = 1;
			break;
		}
		j++;
		i++;
	}

	printf("%s\n", n[flg]);
	return 0;
}

Measured memory_bytes: 524
using System;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var a = Console.ReadLine();

            if (char.IsUpper(a[0]))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25868
#include <stdio.h>

#define SIZE 200
#define NUM 1001

const int Mod = 998244353;

int main()
{
	int i, N, Q;
	char S[200001];
	scanf("%d %d", &N, &Q);
	
	char block[NUM];
	int j, k, l, r, d, q, n = (N - 1) / SIZE, m = N - n * SIZE, flag[NUM];
	long long ans, ans_block[NUM] = {}, fill_block[10], pow[200001];
	for (i = 1, pow[0] = 1; i < N; i++) pow[i] = pow[i-1] * 10 % Mod;
	for (i = 1; i <= 9; i++) {
		for (j = 1, fill_block[i] = i; j < SIZE; j++) fill_block[i] = (fill_block[i] * 10 + i) % Mod;
	}
	for (i = 0; i <= n; i++) {
		block[i] = 1;
		flag[i] = 1;
		if (i < n) ans_block[i] = fill_block[1] * pow[m+(n-i-1)*SIZE] % Mod;
		if (i == n) for (j = 0, ans_block[i] = 0; i * SIZE + j < N; j++) ans_block[i] = (ans_block[i] * 10 + 1) % Mod;
	}
	
	for (q = 1; q <= Q; q++) {
		scanf("%d %d %d", &l, &r, &d);
		l--;
		r--;
		i = l / SIZE;
		if (flag[i] == 1) {
			for (j = i * SIZE; j < N && j < (i + 1) * SIZE; j++) S[j] = block[i];
			flag[i] = 0;
		}
		for (j = l, i = j / SIZE; j <= r && j < (i + 1) * SIZE; j++) {
			ans_block[i] = (ans_block[i] + pow[N-j-1] * (Mod - S[j]) % Mod + pow[N-j-1] * d) % Mod;
			S[j] = d;
		}
		if (j <= r) {
			for (i++; i < r / SIZE; i++) {
				flag[i] = 1;
				block[i] = d;
				ans_block[i] = fill_block[d] * pow[m+(n-i-1)*SIZE] % Mod;
			}
			if (flag[i] == 1) {
				for (j = i * SIZE; j < N && j < (i + 1) * SIZE; j++) S[j] = block[i];
				flag[i] = 0;
			}
			for (j = i * SIZE; j <= r; j++) {
				ans_block[i] = (ans_block[i] + pow[N-j-1] * (Mod - S[j]) % Mod + pow[N-j-1] * d) % Mod;
				S[j] = d;
			}
		}
		
		for (i = 0, ans = 0; i < n; i++) ans += ans_block[i];
		ans = (ans + ans_block[n]) % Mod;
		printf("%lld\n", ans);
	}
	fflush(stdout);
	return 0;
}

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

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<bool>a(n,false);
    for(int i=0;i<m;i++){
        int ind;
        cin>>ind;
        a[ind]=true;
    }
    int ans1=0,ans2=0;
    for(int i=x;i<n;i++){
        if(a[i])ans1++;
    }
    for(int i=x;i>=0;i--){
        if(a[i])ans2++;
    }
    cout<<min(ans1,ans2)<<endl;
    return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] a = new int[n];
        
        for(int i = 0;i < n; i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i< n; i++){
            System.out.print(a[n - 1 - i]);
            if( i != n-1) System.out.print(" ");
        }
        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26264
#include <iostream>
#include <string>

int main()
{
  std::string S, result = "yes";
  std::cin >> S;
  
  for(int i = 0; S[i] != NULL; i++)
  {
    for(int k = i + 1; S[k] != NULL; k++)
    {
      if(S[i] == S[k])
      {
        result = "no";
      }
    }
  }
  
  std::cout << result;  
  return 0;
}

Measured memory_bytes: 3132
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
ans = []

max_a = [-float('inf'), 100]
min_a = [float('inf'), 100]

for i in range(n):
    if a[i] >= max_a[0]:
        max_a = [a[i], i]
    if a[i] <= min_a[0]:
        min_a = [a[i], i]

if abs(max_a[0]) >= abs(min_a[0]):
    for i in range(n):
        if i != max_a[1]:
            a[i] += max_a[0]
            ans.append([max_a[1], i])
    for i in range(1, n):
        if a[i] < a[i - 1]:
            a[i] += a[i - 1]
            ans.append([i - 1, i])
else:
    for i in range(n):
        if i != min_a[1]:
            a[i] += min_a[0]
            ans.append([min_a[1], i])
    for i in range(n - 1, 0, -1):
        if a[i] < a[i - 1]:
            a[i - 1] += a[i]
            ans.append([i, i - 1])
print(len(ans))
for i in ans:
    x, y = i
    print(x + 1, y + 1)






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

int main(){
  int A, B, C;
  cin >> A >> B >> C;

  int capacity = A - B;
  int ans = C - capacity;
  if(ans < 0){
    ans = 0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   string s;
   cin >> s;
   int ans = 0, cnt = 0;
   rep(i, 0, 3) {
      if (s[i] == 'R') {
         cnt++;
         ans = max(ans, cnt);
      } else
         cnt = 0;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a=0,b=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		if(i%2)
			++a;
		else
			++b;
	cout<<a*b;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <sstream>
#define BIT(nr) (1UL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;


void solve(ostringstream& aout, long long N, long long M, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d) {

	int ans = -1;
	function<void(int, int, vector<int>)> dfs = [&](int leng, int before, vector<int> arr) {
		if (leng == N) {
			int cand = 0;
			rep(i, Q) {
				if (arr[b[i]] - arr[a[i]] == c[i]) {
					cand += d[i];
				}
			}
			chmax(ans, cand);
			return;
		}

		rep(i, M) {
			int nxt = before + i;
			if (nxt > M) {
				return;
			}
			arr.push_back(nxt);
			dfs(leng + 1, nxt, arr);
			arr.pop_back();
		}
	};

	dfs(0, 1, vector<int>());

	cout << ans << "\n";
}

void solve_TLE(ostringstream& aout, long long N, long long M, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d) {

}

signed main() {
	long long N;
	scanf("%lld", &N);
	long long M;
	scanf("%lld", &M);
	long long Q;
	scanf("%lld", &Q);
	std::vector<long long> a(Q);
	std::vector<long long> b(Q);
	std::vector<long long> c(Q);
	std::vector<long long> d(Q);
	for (int i = 0; i < Q; i++) {
		scanf("%lld", &a[i]);
		scanf("%lld", &b[i]);
		scanf("%lld", &c[i]);
		scanf("%lld", &d[i]);
		a[i]--;
		b[i]--;
	}
	ostringstream ansStream;
	solve(ansStream, N, M, Q, std::move(a), std::move(b), std::move(c), std::move(d));

	cout << ansStream.str();
	return 0;
}


Measured memory_bytes: 3712
N,X = gets.split.map(&:to_i)
P = Array.new(N + 1, 1)
H = Array.new(N + 1, 1)
(1 .. N).each do |n|
  H[n] = 3 + 2 * H[n - 1]
  P[n] = 1 + 2 * P[n - 1]
end

def answer(n, h)
  if h.zero?
    return 0
  elsif n > 0 && h == 1
    return 0
  elsif h == H[n]
    return P[n]
  end
  
  if h == H[n - 1] + 2
    return P[n - 1] + 1
  elsif h > H[n - 1] + 2
    return P[n - 1] + 1 + answer(n - 1, h - (H[n - 1] + 2))
  else
    return answer(n - 1, h - 1)
  end
end

puts answer(N, X)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n;
cin>>n;
string ans;
ll siz;
if(n>=1 && n<=26)
{
	char c='a'+(n-1);
	cout<<c<<endl;
	return 0;
}

if(n%26!=0)
siz=log((n-n%26)*25/26+1)/log(26)+1;
else
siz=log((n-26)*25/26+1)/log(26)+1;
// n-=pow(26,siz-1);
while(n>0)
{
	if(n%26==0)
	{
	ans+='z';
	n=n/26-1;
	}
	else
	{ans+='a'+(n%26-1);
	n/=26;
	}
}
reverse(all(ans));
cout<<ans;
return 0;
}
// Problem : C - One Quadrillion and One Dalmatians
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 3808
def main():
    n = int(input())
    if n == 0:
        print("Yes")
        return
    slup = []
    sldown = []
    for i in range(n):
        height, mi = 0, 0
        for si in input():
            if si == "(":
                height += 1
            else:
                height -= 1
                mi = min(mi, height)
        if height >= 0:
            slup.append([mi, height])
        else:
            sldown.append([mi-height, -height])

    slup.sort(key = lambda x: -x[0])
    sldown.sort(key = lambda x: -x[0])
    if sum([si[1] for si in slup]) + sum([-si[1] for si in sldown]):
        print("No")
        return
    h = 0
    for si in slup:
        if h+si[0] < 0:
            print("No")
            return
        h += si[1]
    h = 0
    for si in sldown:
        if h+si[0] < 0:
            print("No")
            return
        h += si[1]
    print("Yes")
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 250520
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int ans1=0;
  int ans2=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      ans1+=vec[i];
    }
    else{
      ans2+=vec[i];
    }
  }
  cout<<ans1-ans2<<endl;
}

Measured memory_bytes: 3600
from collections import deque


def main():
    lst = deque()
    n = int(input())
    for _ in range(n):
        inputs = input().split(' ')
        command = inputs[0]
        if command == 'insert':
            lst.appendleft(inputs[1])
        elif command == 'delete':
            try:
                lst.remove(inputs[1])
            except Exception:
                pass
        elif command == 'deleteFirst':
            lst.popleft()
        elif command == 'deleteLast':
            lst.pop()
    result = ''
    while len(lst) > 0:
        result += lst.popleft() + ' '
    print(result.strip())


if __name__ == '__main__':
    main()


Measured memory_bytes: 69732