akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();
void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  if(c>=b){
    ans+=2*b;
    c-=b;
    if(a>=c){
      ans+=c;
    }
    else{
      ans+=a;
      c-=a;
      if(c)ans++;
    }
  }
  else{
    ans=b+c;
  }
  cout<<ans<<endl;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

struct point{
  int x;
  int y;
};

int main(){
  int houkou[5]={0,1,0,-1,0};
  int h,w,r,c;
  while(1){
    cin >> h >> w >> r >> c;
    if(h==0) return 0;
    vector<vector<int>> field(h+2,vector<int>(w+2,0));
    vector<vector<int>> horwall(h+1,vector<int>(w));
    vector<vector<int>> verwall(h,vector<int>(w+1));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> horwall[i][j];
      }
      for(int j=0;j<w+1;j++){
        cin >> verwall[i][j];
      }
    }
    for(int j=0;j<w;j++){
      cin >> horwall[h][j];
    }
    for(int i=0;i<h+2;i++){
      field[i][0]=1;
      field[i][w+1]=1;
    }
    for(int i=0;i<w+2;i++){
      field[0][i]=1;
      field[h+1][i]=1;
    }
    // for(int i=0;i<h+2;i++){
    //   for(int j=0;j<w+2;j++){
    //     cout << field[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    queue<struct point> q;
    bool ok[2];
    for(int i=1;i<=h;i++){
      q.push({1,i});
      q.push({w,i});
    }
    for(int i=1;i<=w;i++){
      q.push({i,1});
      q.push({i,h});
    }
    struct point now;
    while(!q.empty()){
      now=q.front();
      q.pop();
      if(!field[now.y][now.x]){
        ok[0]=ok[1]=false;
        // cout << now.x << " " << now.y << endl;
        if(field[now.y][now.x-1]){
          ok[verwall[now.y-1][now.x-1]]=true;
        }
        if(field[now.y][now.x+1]){
          ok[verwall[now.y-1][now.x]]=true;
        }
        if(field[now.y-1][now.x]){
          ok[horwall[now.y-1][now.x-1]]=true;
        }
        if(field[now.y+1][now.x]){
          ok[horwall[now.y][now.x-1]]=true;
        }
        if(ok[0]&ok[1]){
          field[now.y][now.x]=1;
          for(int i=0;i<4;i++){
            if(!field[now.y+houkou[i]][now.x+houkou[i+1]]) q.push({now.x+houkou[i+1],now.y+houkou[i]});
          }
          // for(int i=0;i<h+2;i++){
          //   for(int j=0;j<w+2;j++){
          //     cout << field[i][j] << " ";
          //   }
          //   cout << endl;
          // }
        }
      }
    }
    // for(int i=1;i<=h;i++){
    //   for(int j=1;j<=w;j++){
    //     cout << field[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    if((!horwall[r-1][c-1]&field[r-1][c])
    |(!horwall[r][c-1]&field[r+1][c])
    |(!verwall[r-1][c-1]&field[r][c-1])
    |(!verwall[r-1][c]&field[r][c+1])) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 5728
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int n, t, r=-1;
    cin >> n >> t;
    for(int i=0;i<n;++i){
        int c, tl;
        cin >> c >> tl;
        if (tl > t) continue;
        if (r < 0 || r > c) r = c;
    }
    if (r < 0) cout << "TLE";
    else
        cout << r;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
const ll INF = 1LL << 60;
// const int MOD = 1000000007;

vector<pii> edge[2500], redge[2500];
ll d[2500];
bool visited[2500];

int main() {
  int N, M, P;
  cin >> N >> M >> P;
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a].eb(mp(b, c - P));
    redge[b].eb(mp(a, c - P));
  }

  memset(visited, false, sizeof(visited));
  visited[N - 1] = true;
  queue<int> q;
  q.push(N - 1);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();

    rep(i, redge[cur].size()) {
      int next = redge[cur][i].F;
      if (visited[next]) continue;
      visited[next] = true;
      q.push(next);
    }
  }

  rep(i, N) d[i] = -INF;
  d[0] = 0;
  bool updated = true;
  rep(_, 2 * N) {
    updated = false;
    rep(i, N) if (d[i] != -INF) rep(j, edge[i].size()) {
      int next = edge[i][j].F;
      int cost = edge[i][j].S;
      if (d[next] < d[i] + cost) {
        d[next] = d[i] + cost;
        updated |= visited[next];
      }
    }
  }

  if (updated)
    cout << "-1" << endl;
  else
    cout << max(d[N - 1], 0LL) << endl;
}


Measured memory_bytes: 640
def main():
    A, B = (int(x) for x in input().split())
    ans = -1
    for i in range(1001):
        if int(i * 0.08) == A and int(i * 0.1) == B:
            ans = i
            break

    if ans == -1:
        print(ans)
    else:
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>
#include<stack>

using namespace std;
#define INF 1000000007

#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, a, b;

int main(){
	cin >> n >> a >> b;
	
	if(abs(a-b) % 2){
		if(a > b) swap(a,b);
		cout << min(n-b, a-1) + abs(a-b)/2 + 1 << endl;
	}
	else{
		cout << abs(a-b)/2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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

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


ll W, H;
ll x, y;


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

  double area = (double)H * (double)W / 2;
  int ans;

  if (x == (double)W / 2 && y == (double)H / 2) {
    ans = 1;
  } else {
    ans = 0;
  }

  printf("%.10f %d\n",area,ans);
}

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

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    string s1 = "", s2 = "";
    while (true)
    {
        if ((int)s1.size() == n)
            break;
        string ret;
        string t1 = s1 + ".", t2 = s2 + ".";
        cout << t1 << endl;
        cout << t2 << endl;
        cin >> ret;
        if (ret == "T" || ret == "end")
        {
            s1 = t1;
            s2 = t2;
            continue;
        }
        t1 = s1 + ".", t2 = s2 + "#";
        cout << t1 << endl;
        cout << t2 << endl;
        cin >> ret;
        if (ret == "T" || ret == "end")
        {
            s1 = t1;
            s2 = t2;
            continue;
        }
        t1 = s1 + "#", t2 = s2 + ".";
        cout << t1 << endl;
        cout << t2 << endl;
        cin >> ret;
        if (ret == "T" || ret == "end")
        {
            s1 = t1;
            s2 = t2;
            continue;
        }
        t1 = s1 + "#", t2 = s2 + "#";
        cout << t1 << endl;
        cout << t2 << endl;
        cin >> ret;
        if (ret == "T" || ret == "end")
        {
            s1 = t1;
            s2 = t2;
            continue;
        }
        break;
    }
    while (true)
    {
        if ((int)s1.size() == n)
            break;
        string ret;
        string t1 = "." + s1, t2 = "." + s2;
        cout << t1 << endl;
        cout << t2 << endl;
        cin >> ret;
        if (ret == "T" || ret == "end")
        {
            s1 = t1;
            s2 = t2;
            continue;
        }
        t1 = "." + s1, t2 = "#" + s2;
        cout << t1 << endl;
        cout << t2 << endl;
        cin >> ret;
        if (ret == "T" || ret == "end")
        {
            s1 = t1;
            s2 = t2;
            continue;
        }
        t1 = "#" + s1, t2 = "." + s2;
        cout << t1 << endl;
        cout << t2 << endl;
        cin >> ret;
        if (ret == "T" || ret == "end")
        {
            s1 = t1;
            s2 = t2;
            continue;
        }
        t1 = "#" + s1, t2 = "#" + s2;
        cout << t1 << endl;
        cout << t2 << endl;
        cin >> ret;
        if (ret == "T" || ret == "end")
        {
            s1 = t1;
            s2 = t2;
            continue;
        }
        break;
    }
    return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define rep(i, a, b) for (ll i = a; i < (b); ++i)
#define reb(i, a, b) for (ll i = a; i >= (b); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
int main()
{
   fast;
  int k;
  cin>>k;
  rep(i,1,360+1)
  {
    if((k*i)%360==0)
    {
      cout<<i;
      return 0;
    }
  }
    
}

Measured memory_bytes: 3620
s=input()
n=len(s)
if n==1:
  print(int(s))
  exit()
if n==2:
  m=int(s)
  print(m+m//10+m%10)
  exit()

t=[int(s[i]) for i in range(n)]
wa=0
for i in range(n-1):
  wa+=(10**i)*(2**(n-2-i))*(sum(t[0:n-i])+t[n-1-i])
wa+=10**(n-1)*t[0]
print(wa)
  

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

int main() {
  int n,k;
  string s;
  cin >> n >> k >>s;
  if (s.at(k-1)=='A') {
    s.at(k-1)='a';
  }
  else if (s.at(k-1)=='B') {
    s.at(k-1)='b';
  }
  else {
    s.at(k-1)='c';
  }
  cout << s << endl;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total =0;
  
  for (int n = 0; n <= N; ++n)
  {
    int num = n;
    int div = 0;
  	while(num != 0)
    {
      div += num%10;
      num = num/10;
    }
    if (A <= div && div <= B)
    {
      total += n;
    }
  }
  
  cout << total << endl;
  return 0;
}

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

const int INF = 0x3f3f3f3f;

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

  ll a,b,n; cin>>a>>b>>n;
  n = min(n, b-1);
  ll res=0, sum=0;
  for (ll i=0; i<a; ++i) {
    sum += n;
    if (sum>b) {
      res++;
      sum-=b;
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

int tn, n;
int hs[MAX_N];

/* subroutines */

/* main */

int main() {
  cin >> tn;
  while (tn--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> hs[i];

    int max_up = 0, max_dn = 0;

    for (int ph = hs[0], i = 1; i < n; ph = hs[i], i++) {
      int dh = hs[i] - ph;
      if (dh > 0) {
	if (max_up < dh) max_up = dh;
      }
      else {
	if (max_dn < -dh) max_dn = -dh;
      }
    }

    printf("%d %d\n", max_up, max_dn);
  }

  return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int h,w;
    cin>>h>>w;
    char c;
    int s[105][105]={};
    REP(i,h)REP(j,w){
        cin>>c;
        if(c=='#')s[i][j]=1;
        else s[i][j]=0;
    }
    ll dp[105][105]={};
    REP(i,h)REP(j,w)dp[i][j]=-1;
    dp[0][0]=s[0][0];
    REP(i,h)REP(j,w){
        if(i==0&&j==0)continue;
        if(i==0){
            dp[i][j]=dp[i][j-1]+s[i][j]*(1-s[i][j-1]);
        }
        else if(j==0){
            dp[i][j]=dp[i-1][j]+s[i][j]*(1-s[i-1][j]);
        }
        else{
            dp[i][j]=min(dp[i-1][j]+s[i][j]*(1-s[i-1][j]), dp[i][j-1]+s[i][j]*(1-s[i][j-1]));
        }
    }
    /*
    REP(i,h){
        REP(j,w)cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 384
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

l = []
T,A = 0,0

for a,b in AB:
  l.append(a+b)
  T += a
  A += b

ans = -A
l.sort(reverse = True)

check = 0

for i in range(N):
  if check == 0:
    ans += l[i]
    check = 1
  else:
    check = 0
print(ans)

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

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M; cin >> N >> M;
    int AC = 0, WA = 0;
    map<int, int> cnt;
    unordered_set<int> processed;
    rep(i, M) {
        int p;
        string s;
        cin >> p >> s;
        if (processed.count(p)) {
            continue;
        }
        if (s == "WA") {
            cnt[p]++;
        } else {
            WA += cnt[p];
            processed.insert(p);
        }
    }
    AC = processed.size();
    cout << AC << ' ' << WA << endl;
}


Measured memory_bytes: 9124
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

typedef pair<int, int> Pa;
typedef long long ll;

int main() {
    double N;
    cin >> N;
    cout << (int)((N+1)/2)/N;
}


Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int n,m;
	int a[100010];
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d",&a[i]);
		n-=a[i];
	}
	if(n<=0)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 512
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N = int(input())
    f = np.array([list(map(int, input().split())) for i in range(N)])
    p = np.array([list(map(int, input().split())) for i in range(N)])

    ans = -int(1e10)
    for i in range(1, 2**10):
        count = np.zeros((N), dtype=int)
        # print(count)
        for j in range(10):
            if i&1:
                count += f[:,j]
            i >>= 1
        ans = max(ans, sum([p[i,count[i]] for i in range(N)]))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21864
import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

for i in range(N-1):
    a, b = [int(n)-1 for n in input().split()]
    tree_list[a].append(b)
    tree_list[b].append(a)

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)

Measured memory_bytes: 223452
// Try KEYENCE Programming Contest 2019
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
	macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut xs = vec![];
    let mut x_sum = 0;
    for _ in 0..n {
    	let x = get!();
        x_sum += x;
    	xs.push(x);
    }
    let mut ys = vec![];
    let mut y_sum = 0;
    for _ in 0..n {
    	let y = get!();
        y_sum += y;
    	ys.push(y);
    }
    
    if x_sum < y_sum {
    	println!("-1");
        return;
    }
    
    let mut us = vec![];
    let mut es = vec![];
    for i in 0..n {
    	if xs[i] == ys[i] {
        	continue;
        }
        if xs[i] < ys[i] {
        	us.push(ys[i]-xs[i]);
        } else {
        	es.push(xs[i]-ys[i]);
        }
    }
    if us.len() == 0 {
    	println!("0");
        return;
    }
    let mut ans = us.len();
    us.sort();
    es.sort();
    let mut rems = 0;
    while let Some(u) = us.pop() {
    	while rems < u {
        	let e = es.pop().unwrap();
            rems += e;
            ans += 1;
        }
        rems -= u;
    }
    println!("{}", ans);
}

Measured memory_bytes: 10492
#include<algorithm>
#include<iostream>
#include<cstdio>

using namespace std;

int a[1001],n,x,ans=0;

int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-1;i++)  if(a[i]<=x) x-=a[i],ans++;
	if(a[n]==x) ans++;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
x, y = map(str, input().split())

dict_num = {'A': 10,
            'B': 11,
            'C': 12,
            'D': 13,
            'E': 14,
            'F': 15}

if dict_num[x] == dict_num[y]:
    print('=')
elif dict_num[x] > dict_num[y]:
    print('>')
else:
    print('<')


Measured memory_bytes: 9092
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;
const ll INF = (ll)1e12;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll dp[20][2][2]; // 桁決めた桁、未満フラグ、４or9を含むフラグ

int main() {
    ll a,b ;cin >> a >> b;

    if(a <= 5) pl(0)
    else if(a <= 12) pl(b/2)
    else pl(b)
}

Measured memory_bytes: 256
while True:
    l = list(map(int, input().split()))
    S = l[0]
    p = [0 for i in range(S)]
    M = l[1]
    i = 0
    N = M
    if M == 0 and S == 0:
        break

    while True:
        if p[i] == M:
            print(i)
            break

        if N == 0:
            N = p[i]
            p[i] = 0
            i += 1
            i %= S

        else:
            N -= 1
            p[i] += 1
            i += 1
            i %= S


Measured memory_bytes: 5596
using System;
using System.Linq;
 class Program {
    static void Main() {
     int []candy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
Array.Sort(candy);
 
if(candy[0] + candy[1] == candy[2]){
Console.WriteLine("Yes");
}else{
Console.WriteLine("No");
}
 
    }
}

Measured memory_bytes: 13268
X,Y = input().split()
X,Y = int(X),int(Y)

if(X==Y and X==1):
    print(1000000)
    
else:
    if(X>=4):
        X = 0
    if(Y>=4):
        Y = 0

    if(X==1):
        X = 3
    elif(X==3):
        X = 1

    if(Y==1):
        Y = 3
    elif(Y==3):
        Y = 1
        
    print((X+Y)*100000)


Measured memory_bytes: 3060
n, m, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
x_max = max(xs)
y_min = min(ys)
def get_war(x_max, y_min, X, Y):
    if y_min > x_max:
        for z in list(range(x_max+1, y_min + 1)):
            if (z > X) and (z <= Y):
                return 'No War'
            else:
                pass
        else:
            return 'War'
    else:
        return 'War'
print(get_war(x_max, y_min, X, Y))

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

using namespace std;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;

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

    int vcnt[N + 1][M + 1];
    fill(vcnt[0], vcnt[N + 1], 0);
    // vcnt[i][j] = (1, 1)~(i, j)中の青マスの数
    // vcnt[i][0] = vcnt[0][j] = 0

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            // indexのズレに注意
            vcnt[i + 1][j + 1] = vcnt[i][j + 1] + vcnt[i + 1][j] - vcnt[i][j] + (S[i][j] == '1');
        }
    }

    int ercnt[N + 1][M + 1];
    fill(ercnt[0], ercnt[N + 1], 0);
    // ercnt[i][j] = (1, 1)~(i, j)中での青マスの横連結箇所数(row)

    int eccnt[N + 1][M + 1];
    fill(eccnt[0], ercnt[N + 1], 0);
    // eccnt[i][j] = (1, 1)~(i, j)中での青マスの縦連結箇所数(column)

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            ercnt[i + 1][j + 1] = ercnt[i][j + 1] + ercnt[i + 1][j] - ercnt[i][j];
            ercnt[i + 1][j + 1] += (j > 0 && S[i][j] == '1' && S[i][j - 1] == '1');

            eccnt[i + 1][j + 1] = eccnt[i][j + 1] + eccnt[i + 1][j] - eccnt[i][j];
            eccnt[i + 1][j + 1] += (i > 0 && S[i][j] == '1' && S[i - 1][j] == '1');
        }
    }

    for (int q = 0; q < Q; ++q) {
        int x[2], y[2];
        for (int i = 0; i < 2; ++i) {
            cin >> x[i] >> y[i];
        }

        int v = vcnt[x[1]][y[1]] - vcnt[x[0] - 1][y[1]] - vcnt[x[1]][y[0] - 1] + vcnt[x[0] - 1][y[0] - 1];

        int e = 0;
        e += ercnt[x[1]][y[1]] - ercnt[x[1]][y[0]] - ercnt[x[0] - 1][y[1]] + ercnt[x[0] - 1][y[0]];
        e += eccnt[x[1]][y[1]] - eccnt[x[0]][y[1]] - eccnt[x[1]][y[0] - 1] + eccnt[x[0]][y[0] - 1];

        cout << v - e << endl;
    }

    return 0;
}

Measured memory_bytes: 54016
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int ans;
int a[200];
double val;
double dif=1000;

signed main(){
    int n;cin>>n;
    rep(i,n){
        cin>>a[i];
        val+=a[i];
    }
    val /= (double)n;
    rep(i,n){
        if(abs(a[i]-val)<dif){
            dif=abs(a[i]-val);
            ans=i;
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

//typedefリスト
typedef long long int llint;
typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int N;
	cin >> N;
	vint a(N);
	for (int i = 0; i < N; i++)cin >> a[i];

	sort(a.begin(), a.end());
	cout << a[N - 1] - a[0] << endl;
}


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

int main() {
  int sx, sy, tx, ty, x, y, i;
  cin >> sx >> sy >> tx >> ty;
  
  x = tx - sx;
  y = ty - sy;
  
  for(i = 0; i < y; i++) cout << "U";
  for(i = 0; i < x; i++) cout << "R";
  for(i = 0; i < y; i++) cout << "D";
  for(i = 0; i < x; i++) cout << "L";
  
  cout << "L";
  for(i = 0; i < y + 1; i++) cout << "U";
  for(i = 0; i < x + 1; i++) cout << "R";
  cout << "D";
  cout << "R";
  for(i = 0; i < y + 1; i++) cout << "D";
  for(i = 0; i < x + 1; i++) cout << "L";
  cout << "U" << endl;
}


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

using namespace std;

#define pii pair<int,int>
#define point pair<double,double>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define MOD 1e9+7
#define ll long long int

ll gcd(ll x,ll y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}

int main()
{
	int t;
	scanf("%d",&t);
	long long int ans=1;
	while(t--)
	{
		long long int x;
		cin>>x;
		ans/=gcd(ans,x);
		ans*=x;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())

n = a*x+b*y

m = 2*c*max(x,y)

if x<y:
    p = b
else:
    p = a

l = 2*c*min(x,y) + p*abs(x-y)

ans = min(n,min(m,l))

print(ans)

Measured memory_bytes: 9028
#include <iostream>
using namespace std;
#define MAX 100
#define INFTY 1<<22
#define WHITE 0
#define GRAY 1
#define BLACK 2

int gMatrix[MAX][MAX];

void dijkstra(int n){
    // 最小の重みを記録する
    int minV;
    // weight[v]に始点sからvまでの最短コストを保存する
    int weight[MAX];
    // 訪問状態を記録
    int color[MAX];
    // 1.初期化
    for(int i = 0;i < n;++i){
        weight[i] = INFTY;
        color[i] = WHITE;
    }
    // 始点
    weight[0] = 0;
    color[0] = GRAY;
    
    while(1){
        minV = INFTY;
        // 頂点を示す
        int u = -1;
        // 2.1weight[u]が最小である頂点を決定する
        for(int i = 0;i < n;++i){
            if(minV > weight[i] && color[i] != BLACK){
                u = i;
                minV = weight[i];
            }
        }
        if(u == -1)break;
        color[u] = BLACK;
        
        for(int v = 0;v < n;++v){
            // 辺が存在する
            if(color[v] != BLACK && gMatrix[u][v] != INFTY){
                // 2.2最短コストを更新する
                // この処理の終了後weight[v]sからS内の頂点のみを経由したvまでの最短コストが記録される
                if(weight[v] > weight[u] + gMatrix[u][v]){
                    weight[v] = weight[u] + gMatrix[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    // 出力
    for(int i = 0;i < n;++i){
        cout << i << " " << ( weight[i] == INFTY ? -1 : weight[i] ) << endl;
    }
}

int main(){
    int n;
    cin >> n;
    
    for(int i = 0;i < n;++i){
        for(int j = 0;j < n;++j){
            gMatrix[i][j] = INFTY;
        }
    }
    
    int k,c,u,v;
    for(int i = 0;i < n;++i){
        cin >> u >> k;
        for(int j = 0;j < k;++j){
            cin >> v >> c;
            gMatrix[u][v] = c;
        }
    }
    dijkstra(n);
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
#define ull     		unsigned long long int
#define ll      		long long int
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define IP(n) int n;cin>>n
#define IP2(a, b) int a,b;cin>>a>>b
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define set(a,n) memset(a,n,sizeof(a))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int INF = 1<<29;
inline int two(int n) { return 1 << n; }
inline int last_bit(int n) { return n & (-n); }
inline int test(int n, int b) { return (n>>b)&1; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline void set_bit(int & n, int b) { n |= two(b); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////////////////
int main()
{
IP(t);
int s=0;
  s=t/500;
  s*=1000;
  int p=t%500;
  p/=5;
  p*=5;
  cout<<s+p;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n,m;cin>>n>>m;
    vl a(m);
    rep(i,m){
        ll k;cin>>k;
        ll bit=0;
        rep(j,k){
            ll s;cin>>s;s--;
            bit|=1<<s;
        }
        a[i]=bit;
    }
    vl b(m);rep(i,m)cin>>b[i];

    ll ans=0;
    rep(i,1<<n){
        bool ok=1;
        rep(j,m){
            if((__builtin_popcount(i&a[j])+b[j])%2==1){
                ok=0;
                break;
            }
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double r = sc.nextDouble();
		double p = 3.141592653589;
		double ca;
		double cm;

		ca = r * r * p;
		cm = r * 2 * p;
		
		String str1 = String.format("%8f",ca);
		String str2 = String.format("%8f",cm);

		System.out.printf(str1 + " " + str2);
		sc.close();
	}

}

Measured memory_bytes: 28256
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false), cin.tie(0)
typedef long long ll;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
ll a[maxn];
ll dp[maxn];

int main()
{
    IO;
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    memset(dp, inf, sizeof(dp));
    dp[1] = 0;
    for (int i = 2; i <= n; ++i)
    {
        for (int j = 1; j <= k; ++j)
        {
            dp[i] = min(dp[i], dp[max(i - j, 1)] + abs(a[i] - a[max(i - j, 1)]));
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 10496
S = input()
YYMM = True
MMYY = True
if int(S[:2]) >= 13 or S[:2] == "00":
  MMYY = False
if int(S[2:]) >= 13 or S[2:] == "00":
  YYMM = False
if YYMM and MMYY:
  print("AMBIGUOUS")
elif YYMM == True and MMYY == False:
  print("YYMM")
elif MMYY == True and YYMM == False:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
set<int> s;
int n,k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    while (n--){
        cin>>k;
        if (s.find(k)!=s.end()){
            cout<<"NO";
            return 0;
        }
        s.insert(k);
    }
    cout<<"YES";
}

Measured memory_bytes: 9600
def main():
    import sys
    input = sys.stdin.readline
    s = list(input().strip())

    def solve(c, s):
        if c not in s:
            return float('inf')
        ret = 0
        while s != [c] * len(s):
            f = True
            ret += 1
            s_ = [''] * (len(s)-1)
            for i in range(len(s)-1):
                if s[i] == c or s[i+1] == c:
                    s_[i] = c
                else:
                    s_[i] = s[i]
                    f = False
            s = s_[:]
            if f:
                break
        
        return ret
        
    ret = float('inf')
    for c in 'abcdefghijklmnopqrstuvwxyz':
        ret = min(ret, solve(c, s[:]))

    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
from collections import deque

S = input()
Q = int(input())
a = deque(S)

flag = 0

for i in range(Q):
  A = input().split()
  if A[0] == "1":
    if flag == 0:
      flag = 1
    else:
      flag = 0
  else:
    if A[1] == "1" and flag == 0 or A[1] == "2" and flag == 1:      
      a.appendleft(A[2])
    else:
      a.append(A[2])

if flag == 1:
  a.reverse()
print("".join(a))

Measured memory_bytes: 8564
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int r, w, c, p;
    while(cin >> r >> w >> c >> p, r|w|c|p){
        int ans = 0;
        while((r+ans*p) < w*c) ans++;
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3040
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 

int main() {
  int a,b;
  int s = 0;
  while(cin>>a>>b,a+b) {
    int f = 0;
    if (s)
      cout << endl;
    else
      s++;
    for(int i=a;i<=b;i++) {
      if (i%4==0&&i%100!=0 || i%400==0) {
        cout << i << endl;
        f++;
      }
    }
    if (f==0) cout << "NA" << endl;
  }
}


Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int main()
{
int a,b,c,y;
int t=0;
int s=0;
cin>>a;
cin>>b;
cin>>c;
cin>>y;

t=a-b;

if(t<=0){s=(a*c);}
else{
s=(b*c)+(t*y);
}
cout<<s;



    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A___ABC_Swap
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arrLine1;
            string strline1 = Console.ReadLine();
            //文字列が格納
            arrLine1 = strline1.Split(' ');
            
            string anser = "";
            anser = arrLine1[2] + " " + arrLine1[0] + " " + arrLine1[1];
            Console.WriteLine(anser);

        }
    }
}


Measured memory_bytes: 13140
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def main():
  n, m = map(int, input().split())
  G = [[] for _ in range(n)]
  for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
  q = int(input())
  vdc = [list(map(int, input().split())) for _ in range(q)][::-1]
  dp = [[0]*11 for _ in range(n)]
  def dfs(v, d, c):
    if dp[v][d]:
      return dp[v][d]
    if d == 0:
      dp[v][d] = c
      return
    for u in G[v]:
      dfs(u, d-1, c)
    dfs(v, d-1, c)
    dp[v][d] = c
  for v, d, c in vdc:
    dfs(v-1, d, c)
  for i in range(n):
    print(dp[i][0])
if __name__ == "__main__":
  main()

Measured memory_bytes: 63460
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin >> k >> n;
	vector<int> vec(n);
	for(int i = 0; i < n; i++)
		cin >> vec[i];
	vector<int> diff(n);
	for(int i = 1; i < n; i++)
		diff[i] = vec[i] - vec[i-1];
	diff[0] = k + vec[0] - vec[n-1];
	// for(int i = 0; i < n ;i++)
	// 	cout << diff[i] << " ";
	// cout << endl;
	sort(diff.begin(), diff.end(), greater<int>());
	long long total = 0;
	for(int i = 1; i < n;i++)
		total += diff[i];
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 1792
#ABC043 C

n = int(input())
a = list(map(int,input().split()))
c = sum([(a[j]-min(a)) ** 2 for j in range(n)])
for i in range(min(a),max(a) + 1):
    b = [(a[j]-i) ** 2 for j in range(n)]
    s = sum(b)
    if s < c:
        c = s
print(c)

Measured memory_bytes: 3060
import java.util.*;

public class Main{

    int m,n;
    String[] FizzBuzz = new String[10000];

    void solve(){
        Scanner sc = new Scanner(System.in);

        getFizzBuzz();

        while(true){
            m = sc.nextInt();
            n = sc.nextInt();
            if(m==0 && n==0) break;

            int[] player = new int[m];
            String[] s = new String[n];
            for(int i=0; i<n; i++) s[i] = sc.next();
            int num = m;


            int idx = 0;
            for(int i=0; i<n; i++){
                if(!s[i].equals(FizzBuzz[i])){
                    player[idx] = -1;
                    num--;
                }
                if(num==1) break;
                idx++; idx %= m;
                while(player[idx]!=0){
                    idx++; idx %= m;
                }
            }

            idx = 0;
            int[] ans = new int[num];
            for(int i=0; i<m; i++){
                if(player[i]==0){
                    ans[idx] = i+1;
                    idx++;
                }
            }

            for(int i=0; i<num-1; i++) System.out.print(ans[i]+" ");
            System.out.println(ans[num-1]);

        }
    }

    void getFizzBuzz(){
        for(int i=1; i<=10000; i++){
            if(i%3==0 && i%5==0) FizzBuzz[i-1] = "FizzBuzz";
            else if(i%5==0) FizzBuzz[i-1] = "Buzz";
            else if (i%3==0) FizzBuzz[i-1] = "Fizz";
            else FizzBuzz[i-1] = String.valueOf(i);
        }
    }

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

Measured memory_bytes: 16000
N,M = map(int, input().split())
A = [list(str(input())) for i in range(N)]
B = [list(str(input())) for i in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        if B[0] == A[i][j:j+M]:
            for k in range(1,M):
                if B[k] != A[i+k][j:j+M]:
                    break
            else:
                print('Yes')
                exit()
            
print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    
    int p,q;
    string P,Q;
    vector<int> array;
    for(int i=0;i<N;i++){
        cin >> p;
        P += to_string(p);
        array.push_back(i+1);
    }
    for(int i=0;i<N;i++){
        cin >> q;
        Q += to_string(q);
    }
    
    vector<string> a;
    string S;
    do{
        for(int i=0;i<N;i++){
            S = S+to_string(array[i]);
        }
        a.push_back(S);
        S = "";
    }while(next_permutation(array.begin(),array.end()));
    
    
    int A=0,B=0;
    for(int i=0;i<a.size();i++){
        if(P == a[i]) A = i;
        if(Q == a[i]) B = i;
    }
    
    cout << abs(A-B) << endl;
    
    return 0;
}


Measured memory_bytes: 2424
#include <cstdio>
#include <cctype>
#include <climits>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	// bool minus = false; if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

template <typename T>
struct heap{
	vector<T> h = {T()};

	void insert(T x) {
		h.push_back(x);
		int c = h.size() - 1;
		for (int p = c / 2; p; c = p, p /= 2)
			if (h[p] < x)
				h[c] = move(h[p]);
			else
				break;
		h[c] = move(x);
	}
	T extract() {
		T res = move(h[1]);
		h[1] = h.back();
		T v = move(h[1]);
		h.pop_back();

		int p = 1, H = h.size();
		for (int c = 2; c < H; p = c, c = p * 2) {
			if (c + 1 < H && h[c] < h[c + 1])
				c++;
			if (h[c] < v)
				break;
			h[p] = move(h[c]);
		}
		h[p] = move(v);

		return move(res);
	}

	bool empty() {
		return h.size() == 1;
	}
};

#define v vector
struct graph {
	struct node {int n, w;};
	v<v<node>> nodes;

	void read(int n) {
		nodes.resize(n);
		for (auto &x: nodes) {
			in();
			for (int k = in(); k--;) {
				int c = in();
				x.push_back({c, in()});
			}
		}
	}

	v<node> dks() {
		v<node> w(nodes.size(), {0, INT_MAX});
		w[0].w = 0;
		heap<node> q;
		q.insert({0, 0});
		while (!q.empty()) {
			node n = q.extract();
			if (w[n.n].n)
				continue;
			w[n.n].n = 1;
			for (node &x: nodes[n.n]) {
				int a = n.w + x.w;
				if (w[x.n].w > a) {
					w[x.n].w = a;
					q.insert({x.n, a});
				}
			}
		}
		return move(w);
	}
};

bool operator < (const graph::node &a, const graph::node &b) {
	return a.w > b.w;
}

int main() {
	graph g;
	g.read(in());
	int i = 0;
	for (auto &x: g.dks())
		out(i++, ' ', x.w, '\n');
}


Measured memory_bytes: 7244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        String s = ns();
        String t = ns();
        for (int i = 0; i <= s.length(); i++) {
            if (i + t.length() < n) continue;
            String tmp = s.substring(0, i) + t;
            if (tmp.startsWith(s) && tmp.endsWith(t)) {
                out.println(i + t.length());
                return;
            }
        }
        out.println(n);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8276
#include <cstdio> 
#include <ctime> 
#include <cmath>   
#include <cstring>
#include <cstdlib>          
#include <iostream>                                      
#include <map>                
#include <queue>                
#include <stack>                 
#include <vector>             
#include <string>  
#include <algorithm>  
#define e 2.718281828459045     
#define pi 3.141592653589793239 
using namespace std;
typedef long long ll;            //>10^18
typedef long double ld;          //3.3621e-4932 ~ 1.18937e4932
typedef unsigned long long ull;  //>10^20
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
const int INF = 0x3f3f3f3f;      
const int INFS = 0xc0c0c0c0;     
const double eps = 1e-8;         
int main(int argc, char *argv[]){
	int n; cin >> n;
	int a[100], b[100];
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
	for(int i = 0; i < n - 2; i++){
		if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3640