akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;

  int ans = t.size();
  for (unsigned int i = 0; i <= s.size() - t.size(); ++i) {
    int n = 0;
    for (unsigned int j = 0; j < t.size(); ++j) {
      if (s.at(i+j) != t.at(j)) ++n;
    }
    if (n < ans) ans = n;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

string s;
int solve(int foot){
    int res=0;
    int n=s.size();
    for(int i=1;i<n;i++){
        int x = (s[i-1]-'1')%3;
        int y = (s[i]-'1')%3;
        if(foot){
            if(y<x)res++;
            else foot^=1;
        }else{
            if(y>x)res++;
            else foot^=1;
        }
    }
    return res;
}

int main(){
    while(cin>>s && s!="#"){
        cout << min(solve(0),solve(1)) << endl;
    }
}

Measured memory_bytes: 1320
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct r {
	int p;
	char s[11];
};

struct r rs[100];
int ind[100];

int cmp(const void *a, const void *b) {
	struct r ai = rs[*(int*)a], bi = rs[*(int*)b];
	int c = strcmp(ai.s, bi.s);
	if (c) return c;
	return bi.p - ai.p;
}

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

	for (int i = 0; i < n; i++) {
		scanf("%s%d", rs[i].s, &rs[i].p);
		ind[i] = i;
	}

	qsort(ind, n, sizeof ind[0], cmp);
	for (int i = 0; i < n; i++) printf("%d\n", ind[i]+1);
}


Measured memory_bytes: 128
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        Arrays.sort(a);
        List<Integer> list = new ArrayList<>(Arrays.asList(a));
        while (list.size() != 1) {
            int min = list.get(0);
            for (int i = 1; i < list.size(); i++) {
                list.set(i, list.get(i) % min);
            }
            list = list.stream().sorted().filter(j -> j != 0).collect(Collectors.toList());
        }
        int result = list.get(0);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 48788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

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

    int n1s = 0;
    int n2s = 0;
    int n4s = 0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(a%4==0){
            n4s++;
        }else if(a%2==0){
            n2s++;
        }else{
            n1s++;
        }
    }

    bool ans = false;
    if(n2s==0){
        if(n4s+1>=n1s){
            ans = true;
        }
    }else{
        if(n4s>=n1s){
            ans = true;
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
answer = [["S", str(i)] for i in range(1, 14)]
answer.extend([["H", str(i)] for i in range(1, 14)])
answer.extend([["C", str(i)] for i in range(1, 14)])
answer.extend([["D", str(i)] for i in range(1, 14)])
N = int(input())
for i in range(N):
    card = input().split()
    answer.remove(card)
for i in range(52-N):
    print(" ".join(answer[i]))


Measured memory_bytes: 5608
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println(s.replace("hi", "").length() == 0 ? "Yes" : "No");
	}
}


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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str, com, p;
	int a, b, n;
	char t;
	cin>>str;
	cin>>n;
	for(int i=0; i<n; ++i) {
		cin>>com>>a>>b;
		if(com=="print") {
			cout<<str.substr(a, b-a+1)<<'\n';
		} else if(com=="reverse") {
			while(a<b) {
				t=str[a];
				str[a]=str[b];
				str[b]=t;
				++a;
				--b;
			}
		} else if(com=="replace") {
			cin>>p;
			for(int j=0; j<p.length(); ++j) {
				str[a+j]=p[j];
			}
		}
	}
	
	return 0;
}



Measured memory_bytes: 3244
#define r return
#define a (int dx,int dy,int x,int y,char m,int c)
i,j,n,f[6];w[8]={1,1,0,-1,-1,-1,0,1};h[8]={0,1,1,1,0,-1,-1,-1};char t[10][10],mark[2]={'o','x'};l a{if(t[x][y]=='.'||t[x][y]=='0')r 0;if(t[x][y]==m)r c;r l(dx,dy,x+dx,y+dy,m,c+1);}s a{int k,d;d=0;if(t[x][y]!='.')r 0;for(k=0;k<8;k++)d+=l(w[k],h[k],x+w[k],y+h[k],m,0);r d;}p a{if(t[x][y]=='0'||t[x][y]=='.')r 0;if(t[x][y]==m)r 1;if(p(dx,dy,x+dx,y+dy,m,0)){t[x][y]=m;r 1;}else r 0;}o a{int k;t[x][y]=m;for(k=0;k<8;k++)p(w[k],h[k],x+w[k],y+h[k],m,0);r 0;}main(){for(i=0;i<10;i++)t[0][i]=t[9][i]='0';for(i=1;i<9;t[i][0]=t[i++][9]='0')scanf("%s",&t[i][1]);f[1]=-1;for(n=0;;n=(n+1)%2){f[n]=-1;for(i=n?8:1;n?i>-1:i<9;n?i--:i++)for(j=n?8:1;n?j>-1:j<9;n?j--:j++)f[n]<s(0,0,i,j,mark[n],0)?f[2+n]=i,f[4+n]=j,f[n]=s(0,0,i,j,mark[n],0):0;f[n]!=0?o(0,0,f[2+n],f[4+n],mark[n],0):0;if(f[0]==0&&f[1]==0)break;}for(i=1;i<9;i++){for(j=1;j<9;j++)printf("%c",t[i][j]);puts("");}r 0;}

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

int main() {
	long long A,B,x,r,tmp;
	cin >> A >> B;
	if(A<B){
	    tmp = A;
	    A = B;
	    B = tmp;
    }
    x=A*B;
    /* ユークリッドの互除法 */
	r = A % B;
	while(r!=0){
		A = B;
	    B = r;
	    r = A % B;
	}
	cout << x/B << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int main() {
  double x1, y1, x2, y2, d;
  scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

  d = dist(x1, y1, x2, y2);
  printf("%.6lf\n", d);
  
  return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

vector<ll>r[100010];
ll rd[100010];
int main(void){
    ll n,m;
    cin>>n>>m;
    vector<ll>x(n);
    map<ll,ll>cnt;
    for(ll i=0;i<n;i++)cin>>x[i],cnt[x[i]]++;
    sort(x.begin(),x.end());
    for(ll i=0;i<n;i++)r[x[i]%m].push_back(x[i]);
    for(auto itr=cnt.begin();itr!=cnt.end();++itr){
        rd[(itr->first)%m]+=(itr->second)/2;
    }
    ll ans = 0;
    for(ll i=0;i<=m/2;i++){
        //cout<<r[i].size()<<" "<<r[m-i].size()<<endl;
        if(i==0)ans+=(ll)r[0].size()/2;
        else{
            if(2*i==m)ans+=(ll)r[i].size()/2;
            else{
                if(r[i].size()==0){
                    ans+=rd[m-i];
                    continue;
                }
                if(r[m-i].size()==0){
                    ans+=rd[i];
                    continue;
                }
                if(r[m-i].size()==r[i].size()){
                    ans+=r[i].size();
                    continue;
                }
                ll ri = r[i].size();
                ll rmi = r[m-i].size();
                ll d1 = rmi-ri;
                ll d2 =ri-rmi;
                if(d1>0){
                    ll p = rd[m-i];
                    if(2*p>=d1)ans+=ri+d1/2;
                    else ans+=ri+p;
                }
                if(d2>0){
                    ll p = rd[i];
                    if(2*p>=d2)ans+=rmi+d2/2;
                    else ans+=rmi+p;
                }
            }
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13568
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod 998244353
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 1000005


// Driver code to test above functions
int32_t main()
{
   
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b, n;
    cin >> a >> b >> n;

    int x = min(b-1, n);

    cout << (a*x)/b;


    return 0;

} 


Measured memory_bytes: 3688
N = int(input())
list_A = [int(m) for m in input().split()]

for i in list_A:
    if i % 2 != 0:
       continue
    elif not (i % 3 == 0 or i % 5 == 0):
            print("DENIED")
            exit()

else:
    print("APPROVED")

Measured memory_bytes: 9160
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
const i64 mod = 1e9 + 7;
i64 fact_memo[200000];
i64 fact(i64 x) {
    if (fact_memo[x] > 0) return fact_memo[x];
    return fact_memo[x] = x > 0 ? x * fact(x - 1) % mod : 1;
}
i64 powi(i64 x, i64 k) {
    i64 y = 1, z = x;
    while (k > 0) {
        if (k & 1) y = y * z % mod;
        k >>= 1;
        z = z * z % mod;
    }
    return y;
}
i64 inv(i64 x) {
    return powi(x, mod - 2);
}
i64 perm(i64 a, i64 b) {
    return fact(a) * inv(fact(a - b)) % mod; 
}
i64 conb(i64 a, i64 b) {
    return perm(a, b) * inv(fact(b)) % mod;
}
i64 h, w, n;
vector<i64> dp;
vector<pair<i64, i64>> ps;
int main() {
    cin >> h >> w >> n;
    ps.resize(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> ps[i].first >> ps[i].second;
    }
    ps[n] = { h, w };
    sort(begin(ps), end(ps));
    dp.resize(n + 1);
    for (int i = 0; i <= n; ++i) {
        i64 x1, y1;
        tie(x1, y1) = ps[i];
        cerr << x1 << ',' << y1 << endl;
        dp[i] = conb(x1 + y1 - 2, x1 - 1);
        for (int j = 0; j < i; ++j) {
            i64 x2, y2;
            tie(x2, y2) = ps[j];
            if (y1 < y2) continue;
            dp[i] -= dp[j] * conb((x1 - x2) + (y1 - y2), x1 - x2) % mod;
        }
        (dp[i] += n * mod) %= mod;
    }
    cout << dp[n] << endl;
    return 0;
}

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

int main(){
	
	int N,K,Q;
	cin >> N >> K >> Q;
	
	int A[Q];
	for(int i=0;i<Q;i++){cin >> A[i];}
	
	int B[N];
	for(int i=0;i<N;i++){B[i]=0;}
	for(int i=0;i<Q;i++){B[A[i]-1] += 1;}
	
	for(int i=0;i<N;i++){
		if(Q-B[i]>=K){cout << "No" << endl;}
		else{cout <<"Yes" << endl;}
	}
	return 0;		
}


Measured memory_bytes: 1408
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

from heapq import *

def get(q,a):
    v = sum(q)
    res = [v]
    for i in a[n:2*n]:
        x = heappushpop(q,i)
        v += i-x
        res.append(v)
    return res

q = a[:n]
heapify(q)
res1 = get(q,a)

a = [-i for i in a[::-1]]
q = a[:n]
heapify(q)
res2 = get(q,a)

#print(res1)
#print(res2)

print(max(i+j for i,j in zip(res1,res2[::-1])))









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

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; }

constexpr int MAX_N = 50000;
constexpr int MAX_M = 20;
constexpr int INF = 1e9+9;

int dp[MAX_N+1];
int c[MAX_M];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i{}; i < m; ++i)
    cin >> c[i];
  fill_n(dp, MAX_N+1, INF);
  dp[0] = 0;

  for (int i{}; i < m; ++i) {
    for (int j{0}; j+c[i] <= n; ++j) {
      chmin(dp[j+c[i]], dp[j]+1);
    }
  }

  cout << dp[n] << endl;
  return 0;
}



Measured memory_bytes: 3300
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    int H, W;
    readf("%d %d\n", &H, &W);
    auto N = readln.chomp.to!int;
    auto a = readln.split.to!(int[]);
    int color = 1;
    foreach (y; 0..H) {
        int[] res;
        while (res.length < W) {
            if (res.length + a.front <= W) {
                res ~= color.repeat(a.front).array;
                a.popFront;
                color++;
            } else {
                a.front -= W-res.length;
                res ~= color.repeat(W-res.length).array;
            }
        }
        if (y % 2) reverse(res);
        auto str = res.map!(x => x.to!string).join(" ").dup;
        str.writeln;
    }
}



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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

int main()
{
  int N, M, K, X[100000], Y[100000];

  cin >> N >> M >> K;

  map< pair< int, int >, int > vs;
  for(int i = 0; i < K; i++) {
    cin >> X[i] >> Y[i];
    vs[{X[i], Y[i]}] = i;
  }

  UnionFind tree(K);
  for(int i = 0; i < K; i++) {
    for(int j = -1; j <= 1; j++) {
      for(int k = -1; k <= 1; k++) {
        int x = X[i] + j, y = Y[i] + k;
        if(vs.count({x, y})) tree.unite(vs[{x, y}], i);
      }
    }
  }


  set< int > link1, link2;
  for(int i = 0; i < K; i++) {
    if(X[i] == 0 || Y[i] == M - 1) link1.emplace(tree.find(i));
    if(X[i] == N - 1 || Y[i] == 0) link2.emplace(tree.find(i));
  }

  for(auto &v : link1) {
    if(link2.count(v)) {
      cout << 0 << endl;
      return (0);
    }
  }

  for(int i = 0; i < K; i++) {
    for(int j = -1; j <= 1; j++) {
      for(int k = -1; k <= 1; k++) {
        int x = X[i] + j, y = Y[i] + k;
        if(x < 0 || y < 0 || x >= N || y >= M) continue;
        if(x == 0 && y == 0) continue;
        if(x == N - 1 && y == M - 1) continue;
        if(vs.count({x, y})) continue;

        bool up = false, down = false;
        up |= link1.count(tree.find(vs[{X[i], Y[i]}]));
        down |= link2.count(tree.find(vs[{X[i], Y[i]}]));

        if(x == 0 || y == M - 1) up = true;
        if(x == N - 1 || y == 0) down = true;

        for(int l = -1; l <= 1; l++) {
          for(int m = -1; m <= 1; m++) {
            int xx = x + l, yy = y + m;
            if(xx < 0 || yy < 0 || xx >= N || yy >= M) continue;
            if(!vs.count({xx, yy})) continue;
            up |= link1.count(tree.find(vs[{xx, yy}]));
            down |= link2.count(tree.find(vs[{xx, yy}]));
          }
        }

        if(up && down) {
          cout << 1 << endl;
          return (0);
        }
      }
    }
  }


  cout << 2 << endl;
}

Measured memory_bytes: 10160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  string s;
  string A;
  cin >> s;
  rep(i, s.size()) {
    if (A.size() == 0) {
      A+=s[i];
      continue;
    }
    if (A[A.size()-1] == 'S' && s[i] == 'T') {
      A.pop_back();
    } else {
      A+=s[i];
    }
  }
  cout << A.size() << endl;
  return 0;
}


Measured memory_bytes: 776
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *right, *left, *parent;
};

void insert(int f);
void inorder(struct Node *v);
void preorder(struct Node *w);

struct Node *root, *NIL;

int main(){
  char C[10];
  int n, i, x;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", C);
    if(strcmp(C, "insert") == 0){
      scanf("%d", &x);
      insert(x);
    } else if (strcmp(C, "print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int f){
  struct Node *x = root;
  struct Node *y = NIL;
  struct Node *z;

  z = ((struct Node *)malloc(sizeof(struct Node)));
  z->key = f;
  z->left = NIL;
  z->right = NIL;

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

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

void inorder(struct Node *v){
  if(v == NIL) return;
  inorder(v->left);
  printf(" %d", v->key);
  inorder(v->right);
}
 
void preorder(struct Node *w){
  if(w == NIL) return;
  printf(" %d", w->key);
  preorder(w->left);
  preorder(w->right);
}

Measured memory_bytes: 24040
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int N,M;
int S[2004],T[2004];
int dp[2004][2004];
int ans=0;
int mod=1000000007;
signed main(){
    scanf("%lld %lld",&N,&M);
    rep(i,N){
        scanf("%lld",&S[i]);
    }
    rep(i,M){
        scanf("%lld",&T[i]);
    }
    rep(i,N){
        rep(j,M){
            //int tnum=upper_bound(ti[S[i]].begin(), ti[S[i]].end(), j)-ti[S[i]].begin();
            if(i>0&&j>0)dp[i][j]+=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
            else if(i>0)dp[i][j]+=dp[i-1][j];
            else if(j>0)dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
            if(S[i]==T[j]){
                if(j>0&&i>0)dp[i][j]+=dp[i-1][j-1]+1;
                else dp[i][j]+=1;
                dp[i][j]%=mod;
            }
        }
    }
    ans=(dp[N-1][M-1]+1+mod)%mod;
    printf("%lld\n",ans%mod);
}

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

#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)

string s;
void input() { cin >> s; }

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
  getchar();
}

Measured memory_bytes: 3628
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    int A[N];
    REP(i, N) {
        cin >> A[i];
    }
    int ans = 0;
    REP(i, N - 1) {
        for (int j = i + 1; j < N; j++) {
            int tmp = abs(A[i] - A[j]);
            ans = max(tmp, ans);
        }
    }
    printAns(ans);
}


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

int main()
{
    long int n, p = 0;
    cin>>n;
    long int arr[n];
    for(int i = 0; i < n; i++)
    {
        cin>>arr[i];
    }
    int q = sizeof(arr)/sizeof(arr[0]);
    sort(arr, arr+q);
    for(int i = 0; i < n; i++)
    {
        if(arr[i] == arr[i+1])
        {
            p++;
            break;
        }
    }    
    if(p != 0)
    {
        cout<<"NO";
    }
    else
    {
        cout<<"YES";
    }
    return 0;
}

Measured memory_bytes: 1792
n, a, b, c, d = (int(i) for i in input().split())  
s = str(input())
n = len(s)

m = max([c, d])
if n>m:
    n = m
    s = s[:n]
    
if '##' in s[a-1:]:
    print('No')
elif b>c:
    print('Yes')
else:
    if c>d:
        if '...' in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes') 

Measured memory_bytes: 3572
n,m,x,y = [int(i) for i in input().split()]

xl = [int(i) for i in input().split()]
yl = [int(i) for i in input().split()]

x_max = max(xl)
y_min = min(yl)
z = {i for i in range(x+1,y+1)}
x_y_interval = {i for i in range(x_max+1,y_min+1)} 


if not x_y_interval:
    print('War')
elif z &x_y_interval:
    print('No War')
else:
    print('War')

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

typedef long long ll;

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

    ll n,ans=0; cin >> n;    
    if(n%2==1) ans = 0;
    else{
        for(ll i=5;i<=n;i*=5){
            ans += n / i / 2;;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

ans1 = L[0]*L[1]*(L[2]//2-(L[2]-L[2]//2))
ans2 = L[0]*L[2]*(L[1]//2-(L[1]-L[1]//2))
ans3 = L[1]*L[2]*(L[0]//2-(L[0]-L[0]//2))
print(min(abs(ans1), abs(ans2), abs(ans3)))


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

constexpr char A = 'A';
constexpr char B = 'B';
constexpr char C = 'C';
constexpr char X = 'X';

constexpr char ABC[] = {A, B, C};

char S[5050];
char T[5050];

int main() {
    cin >> S;

    int len = strlen(S);

    while (len > 3) {
        for (int j = 0; j < len; ++j) { T[j] = S[j]; }

        int count[4] = {0,0,0,0};
        int next_len = 0;
        int state = 0;
        for (int j = 0; j < len; ++j) {
            if (state == 0 && S[j] == A) {
                state = 1;
            } else if (state == 1 && S[j] == B) {
                state = 2;
            } else if (state == 2 && S[j] == C) {
                T[next_len++] = X;    
                ++count[3];
                state = 0;
            } else {
                for (int k = 0; k < state; ++k) { T[next_len++] = ABC[k]; }
                for (int k = 0; k < state; ++k) { ++count[k]; }
                if (S[j] == A) {
                    state = 1;
                } else {
                    state = 0;
                    T[next_len++] = S[j];
                    ++count[S[j] - A];
                }
            }
        }
        for (int k = 0; k < state; ++k) { T[next_len++] = ABC[k]; }
        for (int k = 0; k < state; ++k) { ++count[k]; }


        int empty = -1;
        for (int j = 0; j < 3; ++j) {
            if (count[j] == 0) {
                empty = j;
                break;
            }
        }
        if (count[3] == 0) { cout << "No" << endl; return 0; }
        if (empty == -1) { cout << "No" << endl; return 0; }
        for (int j = 0; j < next_len; ++j) {
            if (T[j] == X) {
                T[j] = ABC[empty];
            }
        }
        for (int j = 0; j < next_len; ++j) {
            S[j] = T[j];
        }
        len = next_len;
    }
    cout << (S[0] == A && S[1] == B && S[2] == C ? "Yes" : "No")<< endl;
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#include <math.h>

int main() {

	int n, m, a[200];
	string ans ="No";

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

	int count = 0;

	for (int i = 0; i < n; i++) {
		if (a[i] >= sum / (4.0 * m)) {
			count++;
		}
	}

	if (count >= m) {
		ans = "Yes";
	}

	cout << ans;

	cin >> ans;

	return 0;


}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

ll dp[5050][5050];

int main() {
	
	int n, k;
	cin >> n >> k;
	vi p(n), c(n);
	rep(i, n) {
		cin >> p[i];
		p[i]--;
	}
	rep(i, n)cin >> c[i];

	vi looplen(n);

	rep(i, n) {
		int now = i;
		V<bool> visit(n, false);
		ll score = 0;
		int loop = 0;
		while(!visit[p[now]]){
			now = p[now];
			score += c[now];
			visit[now] = true;
			dp[i][loop + 1] = score;
			loop++;
		}
		looplen[i] = loop;
	}
	
	ll ans = -LINF;
	rep(i, n)ans = max(ans, (ll)c[i]);

	rep(i, n) {

		if (k / looplen[i] >= 1 && dp[i][looplen[i]] >= 0) {
			ll cnt = k / looplen[i] - 1;
			ll res = k % looplen[i];

			ll m = -LINF;
			rep(j, looplen[i])m = max(m, dp[i][j + 1]);
			rep(j, res)m = max(m, dp[i][looplen[i]] + dp[i][j + 1]);
			
			//cout << i + 1 << " " << (cnt - 1) * dp[i][looplen[i]] + m << endl;
			ans = max(ans, cnt * dp[i][looplen[i]] + m);
			

		}
		else {
			ll m = -LINF;
			rep(j, min(looplen[i], k))m = max(m, dp[i][j + 1]);
			ans = max(ans, m);
		}
	}

	cout << ans << endl;

}

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

using namespace std;

void func_A() {

    int n;
    cin >> n;

    while (n > 0) {
        if (n % 10 == 7) {
            cout << "Yes";
            return;
        }

        n /= 10;
    }

    cout << "No";
}

void func_B() {

    unsigned long long n;
    cin >> n;

    unsigned long long sum = 0;
    for (unsigned long long i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) sum += i; 
    }

    cout << sum;
}

int gcd(int x, int y) {

    if (y == 0) return x;

    return gcd(y, x % y);
}

void func_C() {

    int k;
    cin >> k;

    int sum = 0;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    cout << sum;

}

void func_D() {

    int n;
    cin >> n;
    string s;
    cin >> s;

    int count = 0;

    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (j - i == k - j) continue;
                if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ++count;
            }
        }
    }

    cout << count;
}

int main()
{
    //func_A();
    func_B();
    //func_C();
    //func_D();

    return 0;

}

Measured memory_bytes: 3632
A,B,H,M = map(int,input().split(' '))
import math
pi = math.pi
sec = M*60
Ht = pi/6*H + pi/360*M
Mt = M * pi/30
cos = abs(Mt-Ht)
ans = math.sqrt(A*A - 2*A*B*math.cos(cos) + B*B)
print(ans)

Measured memory_bytes: 9324
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)



using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {
    string s,t;
    int n;
    bool ans = false;

    cin >> s >> t;
    n = s.length();
    if(s == t) cout << "Yes";
    else {
        for(int i = 0; i < n; i ++){
            s = s[n-1] + s.substr(0,n-1);
            if(s == t) ans = true;
        }

        cout << ((ans)?"Yes":"No");
    }

    return 0;
}











Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int n,m;
int adjmat[105][105];
int main(){
    scanf("%d%d",&n,&m);
    int a[m], b[m], c[m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++){
            adjmat[i][j] = 1000000000;
        }
        adjmat[i][i] = 0;
    }
    for (int i = 0; i < m; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        a[i]--, b[i]--;
        adjmat[a[i]][b[i]] = adjmat[b[i]][a[i]] = min(adjmat[a[i]][b[i]],c[i]);
    }

    for (int k = 0; k < n; k++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                adjmat[i][j] = min(adjmat[i][j],adjmat[i][k]+adjmat[k][j]);
            }
        }
    }
    int ans = m;
    for (int x = 0; x < m; x++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                if (adjmat[i][a[x]] + c[x] + adjmat[b[x]][j] == adjmat[i][j]) {
                    ans--;
                    goto stop;
                }
            }
        }
        stop:;
    }
    printf("%d ",ans);

}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def root(x):
        if par[x] == x:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
    n,m = LI()
    rank = [0]*n
    par = [i for i in range(n)]
    for _ in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        if root(a) != root(b):
            unite(a,b)
    cnt = [0]*n
    for i in range(n):
        cnt[root(i)] += 1
    print(max(cnt))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 88488
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    int n,m;
    cin>>n>>m;
    vll dp(n+10);
    vi v(m);
    rep(i,m){
        cin>>v[i];
        dp[v[i]]=-1;
    }
    dp[0]=1;
    for(int i=0;i<n;i++){
        if(dp[i]==-1)continue;
        if(dp[i+1]!=-1){
            dp[i+1]+=dp[i];
            dp[i+1]%=MOD;
        }
        if(dp[i+2]!=-1){
            dp[i+2]+=dp[i];
            dp[i+2]%=MOD;
        }
    }
    fin(dp[n]);
}



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

int main() {
  int A, B, K, N, cnt = 0;
  cin >> A >> B >> K;
  if (A > B)
    N = A;
  else
    N = B;

  for (int i = N; i > 0; i--) {
    if (A % i == 0 && B % i == 0) {
      cnt++;
      // cout << i << " " << cnt << endl;
    }
    if (cnt == K) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
s = int(input())
x_1 = y_1 = 0
if s < 10**9:
    x_2 = y_3 = 0
    x_3 = s
    y_2 = 1
elif s == 10**18:
    x_2 = 10**9
    x_3 = 0
    y_2 = 0
    y_3 = 10**9
else:
    digitnum = len(str(s))
    y_2 = 10**(digitnum-9)
    x_3 = s//y_2 + 1
    x_2 = x_3*y_2 - s
    y_3 = 1

print(x_1, y_1, x_2, y_2, x_3, y_3)

Measured memory_bytes: 38384
#include <stdlib.h>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	while (true) {
		int n, m;
		cin >> n;
		cin >> m;
		if (n == 0 && m == 0) break;

		vector<int>* r = new vector<int>[n + 1];
		for (int i = 0; i < m; i++) {
			int a, b;
			cin >> a >> b;
			r[a].push_back(b);
			r[b].push_back(a);
		}

		bool inv[500 + 1];
		for (int i = 1; i <= 500; i++) inv[i] = false;
		for (int i = 0; i < r[1].size(); i++) {
			int friendNo = r[1][i];
			inv[friendNo] = true;
			for (int j = 0; j < r[friendNo].size(); j++) {
				inv[r[friendNo][j]] = true;
			}
		}

		inv[1] = false;
		int num = 0;
		for (int i = 1; i <= 500; i++) {
			if (inv[i]) num++;
		}
		cout << num << endl;
	}

	return 0;
}

Measured memory_bytes: 1404
import itertools
n,m,q=list(map(int,input().split()))
abcd=[[] for i in range(q)]
for i in range(q):
    abcd[i]=list(map(int,input().split()))
ans=0
l=list(itertools.combinations_with_replacement([a for a in range(1,m+1)],n))
x=(len(l))
for i in range(x):
    e=l[i]
    
    wa=0
    for t in range(q):
        if e[abcd[t][1]-1]-e[abcd[t][0]-1]==abcd[t][2]:
            wa+=abcd[t][3]
    ans=max(ans,wa)
print(ans)
            



Measured memory_bytes: 84568
def inpl():
    return list(map(int, input().split()))


A, B, M = inpl()
A = inpl()
B = inpl()
xyc = [inpl() for _ in range(M)]

tmp = min(A) + min(B)

for x, y, c in xyc:
    tmp = min(tmp, A[x - 1] + B[y - 1] - c)

print(tmp)


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

int main()
{
    std::string s;
    std::cin >> s;
    
    int cnt=0;

    if(s[0]=='1'){cnt++;}
    if(s[1]=='1'){cnt++;}
    if(s[2]=='1'){cnt++;}

    std::cout << cnt << std::endl;

    return 0;
}

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


int main(void){
  int n,h,i,j,a[1005],b[1005];
  
  cin >> h >> n;
  for (i=0;i<n;i++) cin >> a[i] >> b[i];
  
  int dp[10005];
  dp[0]=0;
  for (i=1;i<=h;i++){
    dp[i]=1e9;
    for (j=0;j<n;j++){
      dp[i]=min(dp[i],dp[max(0,i-a[j])]+b[j]);
    }
  }
  
  cout << dp[h] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int cnt = 0;
    for (int x = 0; x <= n; x++) {
        //cout << "x " << x << endl;
        double y = (double)(n - 4 * x) / 7;
        //cout << y << endl;
        int y2 = y;
        //cout << y2 << endl;
        if (y == y2 && y >= 0) {
            cout << "Yes" << endl;
            cnt++;
            break;
        }
    }
    if (cnt == 0) cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def wartosc_bezwgledna(A): 
    if A >= 0: 
        return A
    else: 
        return -A 
    
def silnia(A): 
    if A == 0:
        return 0
    odp = 1
    for i in range(1, A+1):
        odp *= i
    return odp

from itertools import permutations 

def generuj_permutacje(N):
    lista = []
    if N == 0:
        return []
    if N == 1:
        return [1]
    else: 
        for i in range(1,N+1):
            lista.append(i)
    perm = permutations(lista)
    odp = []
    for i in list(perm): 
        odp.append(i)
    return odp  

def caunt_order(): 
    N = wczytaj_liste()[0]
    P = tuple(wczytaj_liste())
    Q = tuple(wczytaj_liste())
    permutacje = generuj_permutacje(N)
    for i in range(len(permutacje)):
        if P == permutacje[i]:
            nr_P = i
        if Q == permutacje[i]:
            nr_Q = i
    odp = nr_P - nr_Q
    print(wartosc_bezwgledna(odp))

caunt_order()

Measured memory_bytes: 45552
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int l,r;
cin>>l>>r;
int mod = 2019;
if(r-l+1>=mod) cout<<0;
else{
    int ans = 2*(1e9+7);
    for(int i=l;i<=r;i++) {
        for(int j=l;j<=r;j++) 
        if(j!=i)
        ans = min(ans,(i*j)%mod);
    } 
    cout<<ans;
}

return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        vec: [usize; 5],
    }
    let mut idx = 0;
    let mut val = 9;
    for (i, v) in vec.iter().enumerate() {
        if v % 10 != 0 && val > v % 10 {
            val = v % 10;
            idx = i;
        }
    }
    let mut ans = 0;
    for (i, v) in vec.into_iter().enumerate() {
        let val = if i == idx {
            v
        } else {
            if v % 10 != 0 {
                v - v % 10 + 10
            } else {
                v
            }
        };
        ans += val;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
const int mod=1000000007;
int n,m;
int s[2002],t[2002];
int dp[2002][2002];

int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++)
		cin>>s[i];
	for (int i=1;i<=m;i++)
		cin>>t[i];
	for (int i=0;i<=n;i++){
		dp[i][0]=1;
	}for (int i=0;i<=m;i++){
		dp[0][i]=1;
	}
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++){
		dp[i][j]=(dp[i-1][j]+dp[i][j-1]-(s[i]==t[j]?0:dp[i-1][j-1]))%mod;
		dp[i][j]=(dp[i][j]+mod)%mod;
	}
	cout<<dp[n][m]%mod<<endl;
	return 0;
}

Measured memory_bytes: 15872
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int n = s.length();
        for (int i = 0; i < n; i++) {
            boolean ok = true;
            for (int j = 0; j < n; j++) {
                if (s.charAt((i + j) % n) != t.charAt(j)) ok = false;
            }
            if (ok) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int X[2];
  cin>>X[0]>>X[1];
  ll ans(0);
  for (int i(0);i<2;i++){
    if (X[i] == 1) ans+=300000;
    else if (X[i] == 2) ans+= 200000;
    else if (X[i] == 3) ans+= 100000;
  }
  if (X[1] == 1&&X[0] == 1)ans+=400000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char op[10];
int n,a[4001];
int b[4001][2],bit[4001];
bool c[4001];
int f[2001][2001];
int Min(int a,int b){
	return a<b?a:b;
}
void Add(int x,int ad){
	for(int i=x;i<=n+n;i+=(i&(-i))) bit[i]+=ad;
	
}
int query(int x){
	int sum=0;
	for(int i=x;i;i-=(i&(-i))) sum+=bit[i];
	return sum;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n+n;i++){
		scanf("%s%d",op,&a[i]);
		if(op[0]=='W') c[i]=0;else c[i]=1;
		b[a[i]][c[i]]=i;
	}
	memset(f,127/3,sizeof(f));
	f[0][0]=0;
	for(int i=0;i<=n;i++){
		memset(bit,0,sizeof(bit));
		for(int j=1;j<=n+n;j++) Add(j,1);
		for(int j=1;j<=i;j++) Add(b[j][0],-1);
		for(int j=0;j<=n;j++){
			if(j>0) Add(b[j][1],-1);
			if(i>0) f[i][j]=Min(f[i][j],f[i-1][j]+query(b[i][0]));
			if(j>0) f[i][j]=Min(f[i][j],f[i][j-1]+query(b[j][1]));
		}
	}
	printf("%d",f[n][n]);
	return 0;
}

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

using namespace std;

int main()
{
	int n, a[100], x, r = 0;
	cin >> n >> x;
	
	for (int i = 0; i < n; i++)
		cin >> a[i];
		
	sort(a, a+n);
	
	for (int i = 0; i < n; i++)
	{
		r++;
		x -= a[i];
	}
	
	cout << r+x/a[0];
}

Measured memory_bytes: 256
def solve(bit):
    nums = []
    i, j = 1, 0
    num = s[0]
    while i < len(s):
        if bit[j] == 1:
            nums.append(int(num))
            num = s[i]
        else:
            num += s[i]
        i += 1
        j += 1
    else:
        nums.append(int(num))
    return sum(nums)

s = str(input())
l = len(s)
ans = 0
for i in range(2**(l-1)):
    bit = [0] * (l - 1)
    for j in range(l-1):
        if ((i >> j) & 1):
            bit[j] = 1
    ans += solve(bit)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

    int cnt=0;
    REP(n, 999+1){
        int tmp_n=n;
        int c = tmp_n%10;
        tmp_n/=10;
        int b = tmp_n%10;
        tmp_n/=10;
        int a = tmp_n%10;
        bool flg_a = false;
        bool flg_b = false;
        bool flg_c = false;
        //cout << a<<" "<<b<<" "<<c << endl;
       // printf("\n%03d: ", n);
        REP(i, N){
            int sn = S[i]-'0';
            if(!flg_a&&sn == a) {
                flg_a = true;
                //cout << a <<": ";
                continue;
                }
            else if(!flg_b&&flg_a&&sn==b){
                flg_b=true;
                //cout << b <<"; ";
                continue;
            }
            else if(!flg_c&&flg_a&&flg_b&&sn==c){
                flg_c=true;
                //cout << c <<"@";
                break;
            }
        }
        if(flg_a&&flg_b&&flg_c) {
            //printf(">> %03d\n", n);
            cnt++;
        }
    }

    cout << cnt << endl;   

    return 0;
}

Measured memory_bytes: 256
class DisjointSetElement():
    def __init__(self):
        self.parent = None
        self.anc = self

    def ancestor(self):
        s = self.anc
        while s.parent is not None:
            s = s.parent
        self.anc = s
        return s

    def unite(self, y):
        ax = self.ancestor()
        ay = y.ancestor()
        if ax is not ay:
            ax.parent = ay
            ax.anc = ay.anc

    def same(self, y):
        return self.ancestor() is y.ancestor()


def main():
    n, q = [int(x) for x in input().split()]
    elems = [DisjointSetElement() for _ in range(n)]

    for _ in range(q):
        com, x, y = [int(x) for x in input().split()]
        if com == 0:
            elems[x].unite(elems[y])
        else:
            print(1 if elems[x].same(elems[y]) else 0)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7360