akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static int[][] DIR = new int[][]{{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

    static void update(int n, int x, int y, int[][] ret, int[][] grid) {
        Queue<Integer> q = new ArrayDeque<>();
        q.add(x*n+y);
        while (!q.isEmpty()) {
            int curr = q.poll();
            int i = curr / n, j = curr % n;
            int can = ret[i][j] + grid[i][j];
            for (int[] dir : DIR) {
                int ni = i + dir[0], nj = j + dir[1];
                if (ni >= 0 && ni < n && nj >= 0 && nj < n) {
                    if (ret[ni][nj] > can) {
                        ret[ni][nj] = can;
                        q.add(ni*n+nj);
                    }
                }
            }
        }
    }

    static void solve(int N, int[] P) {
        int[][] grid = new int[N][N];
        for (int[] g : grid) Arrays.fill(g, 1);
        int[][] ret = new int[N][N];
        for (int i=0;i<N;i++) {
            for (int j=0;j<N;j++) {
                ret[i][j] = Math.min(Math.min(i, N-1-i), Math.min(j, N-1-j));
            }
        }
        int r = 0;
        for (int p : P) {
            int x = p/N, y = p%N;
            r += ret[x][y];
            grid[x][y] = 0;
            update(N, x, y, ret, grid);
        }
        System.out.println(r);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] P = new int[N*N];
        for (int i=0;i<P.length;i++) P[i] = in.nextInt() - 1;
        solve(N, P);
    }
}


Measured memory_bytes: 62772
n = input()
A = [int(raw_input()) for i in xrange(n)]
B = [0]*n

can = 1
ans = 0
for i in xrange(n):
    cnt = (A[i]-1)/can
    ans += cnt
    B[i] = A[i] - cnt*can
    if cnt > 0 and can > 1 and B[i]==can:
        B[i] -= 1
    #print A[i], B[i], (A[i]-1)/can, can
    can = max(can, B[i]+1)
print ans


Measured memory_bytes: 8964
#include<stdio.h>
int main(void)
{
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
scanf("%d",&e);
scanf("%d",&f);
scanf("%d",&g);
scanf("%d",&h);
scanf("%d",&i);
scanf("%d",&j);
scanf("%d",&k);
scanf("%d",&l);
scanf("%d",&m);
scanf("%d",&n);
o=a-b;
p=c-d;
q=e-f;
r=g-h;
s=i-j;
t=k-l;
u=m-n;
printf("%d\n",o);
printf("%d\n",p);
printf("%d\n",q);
printf("%d\n",r);
printf("%d\n",s);
printf("%d\n",t);
printf("%d\n",u);
return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main(){
  int a[5], k;
  string ans="Yay!";
    for(int i=0; i<5; i++)
      cin >> a[i];
    cin >> k;
    sort(a, a+5);
    for(int i=0; i<4; i++)
      for(int j=i+1; j<5; j++)
        if(k<a[j]-a[i]) ans = ":(";



    cout << ans << endl;

}

Measured memory_bytes: 256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_B() {}


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S; cin >> S;
    
    string ans = "yes";
    set<char> st;
    for(char c : S) {
        if (st.count(c) > 0) {
            ans = "no";
            break;
        } else {
            st.insert(c);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int ans=0;
    if(a>b) ans=a+a-1;
    else if(a<b) ans=b+b-1;
    else ans=a+b;
    cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);

		while(true){
			String s = in.nextLine();
			if(s.equals("."))break;
			int count = 0;
			for(int p = 0; p < 3; p++){
				for(int q = 0; q < 3; q++){
					for(int r = 0; r < 3; r++){
						n = 0;
						int value = formula(s, p, q, r);
						if(value == 2){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
	int n = 0;
	int formula(String s, int p, int q, int r){
		if(s.charAt(n) == '('){
			char operand = ' ';
			Stack<Integer> stack = new Stack<Integer>();
			while(true){
				n++;
				char next = s.charAt(n);
				if(next == ')')break;
				else if(next == '('){
					stack.push(formula(s, p, q, r));
					n--;
				}
				else if(next == '+' || next == '*')operand = next;
				else if(next == '-'){
					n++;
					stack.push(not(formula(s, p, q, r)));
					n--;
				}
				else {
					char c = s.charAt(n);
					if(c == '0' || c == '1' || c == '2'){
						int result = Integer.parseInt(""+s.charAt(n));
						stack.push(result);
					}else{
						if(c == 'R')stack.push(r);
						else if(c == 'Q')stack.push(q);
						else stack.push(p);
					}
				}
			}
			n++;
			int a = stack.pop();
			int b = stack.pop();
			int result = 0;
			if(operand == '+')result = or(a,b);
			else result = and(a,b);
			return result;
		}else if(s.charAt(n) == '-'){
			n++;
			int a = not(formula(s, p, q, r));
			return a;
		}else{
			char c = s.charAt(n);
			if(c == '0' || c == '1' || c == '2'){
				int result = Integer.parseInt(""+s.charAt(n));
				n++;
				return result;
			}else{
				n++;
				if(c == 'R')return r;
				else if(c == 'Q')return q;
				else return p;
			}
		}
	}
	int not(int a){
		if(a == 0){
			return  2;
		}else if(a == 1){
			return  1;
		}else{
			return  0;
		}
	}
	int and(int a, int b){
		if(a == 0 || b == 0){
			return  0;
		}else if(a == 1 || b == 1){
			return  1;
		}else{
			return  2;
		}
	}
	int or(int a, int b){
		if(a == 0 && b == 0){
			return  0;
		}else if(a == 2 || b == 2){
			return  2;
		}else{
			return  1;
		}
	}

}

Measured memory_bytes: 33296
//Author: Lixiang
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=100001;
struct D{
	int N,K,a[maxn],b[maxn];
	void init(){
		cin>>N>>K;
		for(int i=1;i<=N;i++)
			scanf("%d%d",&a[i],&b[i]);
	}
	long long check(int now){
		long long ans=0;
		for(int i=1;i<=N;i++)
			if((a[i]|now)==now)
				ans+=b[i];
		return ans;
	}
	void work(){
		bitset <30> k=K;
		int len=k.size();
		long long ans=check(K);
		for(int i=0;i<len;i++){
			if(k[i]==1){
				k[i]=0;
				ans=max(ans,check(k.to_ulong()));
				k[i]=1;
			}
			else k[i]=1;
		}
		cout<<ans<<endl;
	}
}sol;
int main(){
	sol.init();
	sol.work();
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  string s;
  while(cin>> s)
  {
    int ans1 = 0, ans2 = 0;
    REP(i,s.size()) {
      if ((s[i] == '0') ^ (i % 2 == 0)) {
        ans1++;
      }
      if ((s[i] == '1') ^ (i % 2 == 0)) {
        ans2++;
      }
    }
    cout << min(ans1, ans2) << endl;
  }
}


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

int main() {
    int N, x;
    cin >> N >> x;
    bool flag = true;
    if (N == 2 && x != 2) flag = false;
    if (N >= 3 && (x == 1 || x == 2 * N - 1)) flag = false;
    if (!flag) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        vector<int> ans(2 * N + 1, 0);
        for (int i = 1; i <= 2 * N - 1; i++) {
            ans[i] = i;
        }
        if (N != x) swap(ans[N], ans[x]);
        if (ans[N - 1] > ans[N]) swap(ans[1], ans[N - 1]);
        if (ans[N + 1] < ans[N]) swap(ans[N + 1], ans[N * 2 - 1]);
        for (int i = 1; i <= 2 * N - 1; i++) {
            cout << ans[i] << endl;
        }
    }
}

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

#define ll long long
#define mod 998244353
ll n, m, k, ans=0;
ll fac[200002]; 

ll power(ll x, ll y) { 
    ll res = 1LL;
    x = x % mod;

    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % mod; 

        y = y>>1;
        x = (x*x) % mod; 
    } 
    return res; 
} 

ll modInverse(ll n) { 
    return power(n, mod-2); 
} 
 
ll nCr(ll n, ll r) { 
    if (r==0) 
        return 1; 
    return (fac[n]* modInverse(fac[r]) % mod * modInverse(fac[n-r]) % mod) % mod; 
} 


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

    fac[0] = 1LL; 
    for (ll i=1;i<=200001;++i) 
        fac[i] = fac[i-1]*i%mod; 
	
	cin >> n >> m >> k;
	for(int i=n-k;i<=n;i++) {
		ans = (ans + (nCr(n-1, i-1) * m % mod *(power(m-1, i-1)))%mod) % mod;
	}
	cout << ans;
}

Measured memory_bytes: 5184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int temp = 0;
            ArrayList<Integer> a = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                a.add(in.nextInt());
            }
            Collections.sort(a);
            for (int i = 0; i < n - 1; i++) temp += a.get(i);
            if (temp > a.get(n - 1)) out.println("Yes");
            else out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

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


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};

int main(){
    int N,K;cin>>N>>K;
    vector<int> V(N),tmp;
    for(int i=0;i<N;++i) cin>>V[i];
    int P=min(N,K);
    int ans=0;
    for(int i=1;i<=P;++i){
        for(int l=0;l<=i;++l){
            int r=i-l;
            tmp.clear();
            for(int j=0;j<l;++j) tmp.push_back(V[j]);
            for(int j=0;j<r;++j) tmp.push_back(V[N-1-j]);
            sort(tmp.begin(),tmp.end());
            int mn=lower_bound(tmp.begin(),tmp.end(),0)-tmp.begin();
            int sum=0;
            for(auto it:tmp) sum+=it;
            for(int j=0;j<min(mn,K-i);++j) sum-=tmp[j];
            ans=max(ans,sum);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll A, B, C;
    cin >> A >> B >> C;

    auto ab_lcm = A / __gcd(A, B) * B;
    for (ll a = A; a <= ab_lcm; a += A) {
        if (a % B == C) {
            cout << "YES\n";
            return;
        }
    }
    cout << "NO\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

typedef long long ll;
typedef vector<ll> v1;

typedef vector<vector<ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll a[3];

int main(){
    cin >> a[0] >> a[1] >> a[2];
    if(accumulate(a,a+3,0ll) >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}


Measured memory_bytes: 256
N, R, L = gets.split.map(&:to_i)
time = Array.new(N, 0)
score = Array.new(N, 0)
lastTime = 0
topScore = 0
topTeam = 0
R.times do
  d, t, x = gets.split.map(&:to_i)
  d -= 1
  time[topTeam] += t - lastTime
  score[d] += x
  case d
    when topTeam
      if x >= 0
        topScore = score[d]
      else
        topScore = score.max
        topTeam = score.index(topScore)
      end
    else
      if x >= 0
        if score[d] == topScore
          topTeam = [d, topTeam].min
        elsif score[d] > topScore
          topScore = score[d]
          topTeam = d
        end
      else
      end
  end
  lastTime = t
end
time[topTeam] += L - lastTime
p time.index(time.max) + 1

Measured memory_bytes: 7680
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<cstdint>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

template<ll mod> class modint{
public:
  ll val=0;
  constexpr modint(ll x=0) noexcept : val(x%mod){
    while(x<0)x+=mod;
  }
  constexpr ll getmod(){return mod;}
  constexpr ll getvalue(){return val;}
  constexpr const ll &value() const noexcept {return val;}
  constexpr modint operator+(const modint &r) const noexcept{return modint(*this)+=r;}
  constexpr modint operator-(const modint &r) const noexcept{return modint(*this)-=r;}
  constexpr modint operator*(const modint &r) const noexcept{return modint(*this)*=r;}
  constexpr modint operator/(const modint &r) const noexcept{return modint(*this)/=r;}
  constexpr modint& operator+=(const modint &r) noexcept{
    val += r.val;
    if(val >= mod){
      val -= mod;
    }
    return *this;
  }
  constexpr modint& operator-=(const modint &r) noexcept{
    if(val < r.val){
      val += mod;
    }
    val -= r.val;
    return *this;
  }
  constexpr modint& operator*=(const modint &r) noexcept{
    val = val * r.val % mod;
    return *this;
  }
  constexpr modint& operator/=(const modint &r) noexcept{
    ll a=r.val,b=mod,u=1,v=0;
    while (b) {
      ll t = a/b;
      a -= t*b;swap(a,b);
      u -= t*v;swap(u,v);
    }
    val = val * u % mod;
    if(val < 0)val += mod;
    return *this;
  }
  constexpr bool operator == (const modint& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator < (const modint& r) const noexcept {
    return this->val < r.val;
  }
  constexpr bool operator != (const modint& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const modint<mod>& x) noexcept {
    return os << x.val;
  }
  friend constexpr modint<mod> modpow(const modint<mod> &a,ll n) noexcept {
    if(n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if(n & 1) t = t * a;
    return t;
  }
};

using mint = modint<MOD>;

//n個の場合のlcmも2個で比べて順に適用していくだけ
signed main(){
  int n;cin >> n;
  vector<ll> a(n);for(int i=0;i<n;i++){cin >> a[i];}
  vector< map<mint,int> > prime_factors(n);
  for(int i=0;i<n;i++){
    for(int j=2;j<=1000;j++){
      while(a[i]%j==0){prime_factors[i][mint(j)]++;a[i]/=j;}
    }
    if(a[i]!=1) prime_factors[i][mint(a[i])]=1;
  }
  map<mint,int> lcm_all;
  for(ll i=0;i<n;i++){
    map<mint,int> now=prime_factors[i];
    for(auto& now_sub : now){
      lcm_all[now_sub.first]=max(now_sub.second,lcm_all[now_sub.first]);
    }
  }
  mint lcm_ans=mint(1);
  for(auto& lcm_all_sub : lcm_all){
    lcm_ans*=modpow(lcm_all_sub.first,lcm_all_sub.second);
  }
  mint cnt=0;
  for(int i=0;i<n;i++){
    mint cnt_sub=lcm_ans;
    map<mint,int> now=prime_factors[i];
    for(auto& now_sub : now){
      cnt_sub/=modpow(now_sub.first,now_sub.second);
    }
    cnt+=cnt_sub;
  }
  cout << cnt << endl;
}


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

namespace Contests
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select((x) => int.Parse(x)).ToArray();
            var val = inputs[0] * 100 + inputs[1] * 10 + inputs[2];
            if (val % 4 == 0) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
const int INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int> h(n);
    for(int& x:h)
    {
        cin>>x;
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
 
            }
        }
    }
    cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

/* Prototype Declaration */
void depthFirstSearch(void);
void dfsVisit(int);

/* Global Variables */
int AM[MAX+1][MAX+1]; //Adjacency Matrix
int color[MAX], d[MAX], f[MAX];
int n, time;

int main() {
  int i, j;
  int u, k, v;

  scanf("%d", &n);

  //Initialize Adjacency Matrix
  for ( i = 0; i < n; i++ )
    for ( j = 0; j < n; j++ )
      AM[i][j] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%d%d", &u, &k);
    for ( j = 0; j < k; j++ ) {
      scanf("%d", &v);
      AM[u - 1][v - 1] = 1;
    }
  }

  //Depth First Search for The Graph
  depthFirstSearch();

  for ( i = 0; i < n; i++ )
    printf("%d %d %d\n", i + 1, d[i], f[i]);

  return 0;
}

/* Depth First Search Statements */
void depthFirstSearch() {
  int i;
  for ( i = 0; i < n; i++ )
    color[i] = WHITE;

  for ( i = 0; i < n; i++ )
    if ( color[i] == WHITE )
      dfsVisit(i);
}

void dfsVisit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++time;
  for ( v = 0; v < n; v++ ) {
    if ( AM[u][v] == 1 && color[v] == WHITE )
      dfsVisit(v);
  }
  color[u] = BLACK;
  f[u] = ++time;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;

int main()
{
    int n,m;
    int num[35];
    while(cin>>n>>m)
    {
        for(int i=1;i<=m;i++) num[i]=0;
        for(int i=0;i<n;i++)
        {
            int k;
            cin>>k;
            for(int j=0;j<k;j++)
            {
                int ans;
                cin>>ans;
                num[ans]++;
            }
        }
        int solve=0;
        for(int i=1;i<=m;i++)
        {
            if(num[i]==n) solve++;
        }
        cout<<solve<<"\n";

    }
}


Measured memory_bytes: 256
require 'prime'
N = gets.chomp.to_i
array = Prime.prime_division(N)
count = 0

(0..array.length-1).each do |i|
  if array[i][1] >= 36
    count += 8
  elsif array[i][1] >= 28
    count += 7
  elsif array[i][1] >= 21
    count += 6
  elsif array[i][1] >= 15
    count += 5
  elsif array[i][1] >= 10
    count += 4
  elsif array[i][1] >= 6
    count += 3
  elsif array[i][1] >= 3
    count += 2
  elsif array[i][1] >= 1
    count += 1
  end
end

puts count

Measured memory_bytes: 14460
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 100010;
char ch[N];
int ans = 0x3f3f3f3f;
int main() {
	cin >> ch + 1;
	int len = strlen(ch + 1);
	for(int i = 1; i <= len; i++) 
		if(ch[i] != ch[i + 1])
			ans = min(ans, max(i, len - i));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int inputS,h,m,s;
  scanf("%d", &inputS);

  h = inputS / 3600;
  m = (inputS - (h * 3600)) / 60;
  s = (inputS - (h * 3600) - (m * 60));

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

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

long long  N;

int main(){
	cin >> N;
	if(N==1){
		cout<<N<<endl;
		return 0;
	}
	if(N==0){
		cout<<2<<endl;
		return 0;
	}
	
	long long last = 1;
	long long llast = 2;
	N-=1;
	while(N--){
		long long temp = last;
		last = last + llast;
		llast = temp;
	}
	cout << last << endl;
	return 0;
}



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

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.length() - 1; ++i){
        if(s.substr(i, 2) == "AC"){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,MAX = -5;
  cin >> N;
  int dan = 0;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
     cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = 0; i < N; i++){
    MAX = -5;
    MAX = v.at(i);
   if (MAX != -1){
     dan++;
     for (int i = 0; i < N; i++){
       if (MAX == v.at(i)){
         v.at(i) = -1;
       }
     }
   }
  }

  cout << dan << endl;
}


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

int main(){
    int n;
    cin >> n;
    int s1=0;
    int s2=0;
    int s3=0;
    int s4=0;
    string s;

    rep(i,n){
        cin >> s;
        if(s=="AC"){
            ++s1;
        }
        else if(s=="WA"){
            ++s2;
        }
        else if(s=="TLE"){
            ++s3;
        }
        else if(s=="RE"){
            ++s4;
        }
        
        
    }


    cout << "AC x ";
    cout << s1 << endl; 
    

    cout << "WA x ";
    cout << s2 << endl; 

    cout << "TLE x ";
    cout << s3 << endl; 

    cout << "RE x ";
    cout << s4 << endl; 

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define forn1 for(i=1; i<=n; i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g,bb;
    string ss,s;
//    cin>>_;
//    while(_--)
//    {
//        c
//
//    }
    double dd,cc;
    cin>>dd;
    cc=acos(-1);
    cout<<2*dd*cc<<endl;
}


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


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int H=scanner.nextInt();
        final int W=scanner.nextInt();
        final Point startPoint=new Point(0,0);
        final Point goalPoint=new Point(H-1,W-1);
        final char[][] map=new char[H][W];
        final int[][] route=new int[H][W];
        int white=0;
        for(int i=0;i<H;i++){
            String line=scanner.next();
            for(int j=0;j<W;j++){
                map[i][j]=line.charAt(j);
                if(map[i][j]=='.') white++;
            }
        }
        Deque<Point> shouldSearchPoints=new ArrayDeque<>();
        shouldSearchPoints.addLast(startPoint);
        while(shouldSearchPoints.size()>0){
            Point currentSearchPoint=shouldSearchPoints.removeFirst();
            int x=currentSearchPoint.x;
            int y=currentSearchPoint.y;
            int currentRouteCount=route[currentSearchPoint.x][currentSearchPoint.y];
            List<Point> nearPoint=new ArrayList<>();
            nearPoint.add(new Point(x,y+1));
            nearPoint.add(new Point(x,y-1));
            nearPoint.add(new Point(x+1,y));
            nearPoint.add(new Point(x-1,y));
            List<Point> nextPoints=nearPoint.stream().filter(point -> {
                if(point.x<0||point.x>=H||point.y<0||point.y>=W){
                    return false;
                }
                if(map[point.x][point.y]=='#'||(point.x==startPoint.x&&point.y==startPoint.y)||route[point.x][point.y]!=0){
                    return false;
                }
                return true;
            }).collect(Collectors.toList());
            nextPoints.forEach(point -> {
                if(route[point.x][point.y]==0){
                    route[point.x][point.y]=currentRouteCount+1;
                }
            });
            shouldSearchPoints.addAll(nextPoints);
            if(route[goalPoint.x][goalPoint.y]!=0){
                System.out.println(white-route[goalPoint.x][goalPoint.y]-1);
                return;
            }
        }
        System.out.println(-1);


    }
}
class Point{
    final int x;
    final int y;
    public Point(int x,int y){
        this.x=x;
        this.y=y;
    }
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t p, q, r;
  std::cin >> p >> q >> r;
  std::cout << std::min({p + q, q + r, r + p}) << std::endl;
  return 0;
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> pi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 1e5+5;
const LL INF = 1e18;
int W,H;

LL cw[maxn];
LL ch[maxn];

int main()
{
    cin >> W >> H;
    _for(i,0,W){
        cin >> cw[i];
    }
    cw[W] = INF;
    sort(cw,cw+W);
    _for(i,0,H){
        cin >> ch[i];
    }
    ch[H] = INF;
    sort(ch,ch+H);

    int pi = 0;
    int pj = 0;
    int restj = H;
    int resti = W;

    LL need = (W+1)*(LL)(H+1) - 1;

    LL res = 0;
    while(need){
        LL itake = (pi == W)?INF:(restj+1) * cw[pi];
        LL jtake = (pj == H)?INF:(resti+1) * ch[pj];
        if(cw[pi] < ch[pj]){
            res += itake;
            need -= restj + 1;
            pi++;
            resti--;
        }
        else{
            res += jtake;
            need -= resti + 1;
            pj++;
            restj--;
        }
        //cout << "need:"<<need<<" "<<"res:"<<res<< endl;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	ll d=n/500;
	ll e=n-(d*500);
	ll f=e/5;
	cout<<d*1000+f*5<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
  if (a < b) std::swap(a, b);
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
  llong g = gcd(a, b);
  return a * b / g;
}
//ここまで共通
llong N;
int main() {
	cin >> N;
	llong A = N - 1;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			A = min(A, i - 1 + N / i - 1);
		}
	}
	cout << A << endl;
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  for(int i = n; i < 1000; ++i) {
    string s = to_string(i);
    if(s[0] == s[1] && s[1] == s[2]) {
      cout << i << endl;
      return 0;
    }
  }
}

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

using namespace std;
using ll = long long;



int main()
{
    int m,d;
    int ans = 0;
    cin >> m >> d;

    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            int a = j%10;
            int k = j/10;
            if(a < 2 || k < 2)continue;
            if(a * k == i)ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int H,W,K;
char c[805][805];
int sx,sy;
int dis[805][805];
signed main(){
	cin>>H>>W>>K;
	rep(i,H)rep(j,W){
		cin>>c[i][j];
		dis[i][j]=inf;
		if(c[i][j]=='S'){
			sx=i,sy=j;
			dis[i][j]=0;
		}
	}
	queue<P>que;
	que.push({sx,sy});
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	while(!que.empty()){
		P p=que.front();que.pop();
		if(dis[p.first][p.second]==K)break;
		rep(i,4){
			int nx=dx[i]+p.first,ny=dy[i]+p.second;
			if(nx<0||ny<0||nx>=H||ny>=W||c[nx][ny]=='#')continue;
			if(dis[nx][ny]==inf){
				dis[nx][ny]=dis[p.first][p.second]+1;
				que.push({nx,ny});
			}
		}
	}
	int ans=inf;
	rep(i,H)rep(j,W){
		if(dis[i][j]!=inf){
			int mi=min({i,H-i-1,j,W-j-1});
			chmin(ans,1+(mi+K-1)/K);
		}
	}
	cout<<ans<<endl;
}


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

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

            //var result = "No";  //Ans用

            //入力
            string[] str = Console.ReadLine().Split(' ');
            var d = long.Parse(str[0]);  //距離
            var t = long.Parse(str[1]);  //制限時間（分）
            var s = long.Parse(str[2]);  //速度（分速）

            if (t*s>=d)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27520
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll t = abs(x / d);
    if (x < d) {
        t = 1;
    }
    if (abs(x - d * t) > abs(x - d * (t + 1))) {
        ++t;
    }

    if (k < t) {
        cout << abs(x - d * k);
        return 0;
    }
    k -= t;
    x -= d * t;
    x = abs(x);
    if (k % 2) {
        cout << abs(x - d) << endl;
    }
    else {
        cout << abs(x);
    }
}

/*
*/


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int> > l, r, v;
	vector<bool> ischecked(n, false);
	for(int i = 0; i < n; i++){
		int tmpl, tmpr;
		cin >> tmpl >> tmpr;
		l.push_back(make_pair(-tmpl, i));
		r.push_back(make_pair(tmpr, i));
		v.push_back(make_pair(tmpl, tmpr));
	}
	sort(l.begin(), l.end());
	sort(r.begin(), r.end());
	long long int res1 = 0;
	int pos = 0;
	int il = 0, ir = 0;
	while(il < n || ir < n){
		while(il < n && ischecked[l[il].second]) il++;
		if(il < n){
			int nowi = l[il].second;
			ischecked[nowi] = true;
			int nowl = v[nowi].first;
			int nowr = v[nowi].second;
			if(pos > nowr){
				res1 += pos - nowr;
				pos = nowr;
			} else if(pos < nowl){
				res1 += nowl - pos;
				pos = nowl;
			}
		}
		// cout << pos << endl;
		while(ir < n && ischecked[r[ir].second]) ir++;
		if(ir < n){
			int nowi = r[ir].second;
			ischecked[nowi] = true;
			int nowl = v[nowi].first;
			int nowr = v[nowi].second;
			if(pos > nowr){
				res1 += pos - nowr;
				pos = nowr;
			} else if(pos < nowl){
				res1 += nowl - pos;
				pos = nowl;
			}
		}
		// cout << pos << endl;
	}
	res1 += abs(pos);
	// cout << "res1 : " << res1 <<  endl;
	long long int res2 = 0;
	pos = 0;
	il = 0;
	ir = 0;
	ischecked = vector<bool>(n, false);
	while(il < n || ir < n){
		while(ir < n && ischecked[r[ir].second]) ir++;
		if(ir < n){
			int nowi = r[ir].second;
			ischecked[nowi] = true;
			int nowl = v[nowi].first;
			int nowr = v[nowi].second;
			if(pos > nowr){
				res2 += pos - nowr;
				pos = nowr;
			} else if(pos < nowl){
				res2 += nowl - pos;
				pos = nowl;
			}
		}
		// cout << pos << endl;
		while(il < n && ischecked[l[il].second]) il++;
		if(il < n){
			int nowi = l[il].second;
			ischecked[nowi] = true;
			int nowl = v[nowi].first;
			int nowr = v[nowi].second;
			if(pos > nowr){
				res2 += pos - nowr;
				pos = nowr;
			} else if(pos < nowl){
				res2 += nowl - pos;
				pos = nowl;
			}
		}
		// cout << pos << endl;
	}
	res2 += abs(pos);
	// cout << "res2 : " << res2 << endl;
	cout << max(res1, res2) << endl;
}

Measured memory_bytes: 2912
#include<stdio.h>
 
int main(void)
 
 
{
 
 
int a,b,menseki,syuu;
 
 
scanf("%d",&a);
 
 
scanf("%d",&b);
 
 
menseki=a*b;
 
 
syuu=2*a+2*b;
 
 
printf("%d %d\n",menseki,syuu);
 
 
return 0;
 
 
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    int p;//    vector<int> price(n);
    for(int i=0;i<n;i++)
    {
        cin>>p;
        q.push(p);
    }
    while(m-- && !q.empty())
    {
        int t=q.top();
        q.pop();
        t/=2;
        if(t>0)
            q.push(t);
    }
    long long ans=0;
    while(!q.empty())
    {
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 892
while True:
	a,op,b = raw_input().split()
	a = int(a)
	b = int(b)
	if op == '+':
		r = a + b
	elif op == '-':
		r = a - b
	elif op == '*':
		r = a * b
	elif op == '/':
		r = a / b
	else:
		break
	print r

Measured memory_bytes: 6316
def isReverse(s):
    p1 = 0
    p2 = len(s) - 1
    flag = True
    while p1 <= p2:
        if s[p1] != s[p2]:
            flag = False
        p1 += 1
        p2 += -1
    return flag
if __name__ == "__main__":
    s = input()
    s1 = s[:int((len(s) - 1) / 2)]
    s2 = s[int((len(s) + 1) / 2):]
    # print(s, s1, s2)
    # print(isReverse(s), isReverse(s1), isReverse(s2))
    if isReverse(s) and isReverse(s1) and isReverse(s2):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
class WeightedUnionFind:
    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [0] * n
        self.weight = [0] * n
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y
    def unite(self, x, y, w):
        p, q = self.find(x), self.find(y)
        if self.rank[p] < self.rank[q]:
            self.par[p] = q
            self.weight[p] = w - self.weight[x] + self.weight[y]
        else:
            self.par[q] = p
            self.weight[q] = -w - self.weight[y] + self.weight[x]
            if self.rank[p] == self.rank[q]:
                self.rank[p] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
n, m = map(int, input().split())
UF = WeightedUnionFind(n)
for i in range(m):
    l, r, d = map(int, input().split())
    if UF.same(l - 1, r - 1):
        if UF.diff(l - 1, r - 1) != d:
            exit(print("No"))
    else:
        UF.unite(l - 1, r - 1, d)
print("Yes")

Measured memory_bytes: 15736
N=int(input())
T=[int(x) for x in input().split()]
A=[[0]*2 for a in range(N)]
for i in range(N):
	A[i][0]=T[i]
	A[i][1]=i+1
A.sort()


t=0
for i in zip(*A):
	if t==0:
		t+=1
		continue
	print(*i)

Measured memory_bytes: 29924
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
typedef struct pair_{
    int x;
    int y;
}pair_t;

int main(){
    char s[4];scanf("%s",s);
    for(int i=0;i<2;i++){
        if(s[i]!=s[i+1]){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int K,A,B,i;
	cin>>K;
	cin>>A>>B;
	for (i=A;i<=B;i++){
		if (i%K==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 100005

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

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

	int n;
	cin >> n;
	int v[n], c;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> c;
		v[i] -= c;
	}

	sort(v, v + n, greater<int>());
	int sum = 0, i = 0;
	while(i < n && v[i] > 0)
	{
		sum += v[i++];
	}
	cout << sum <<"\n";
	return 0;
}

Measured memory_bytes: 384
n=int(input())
s=input()
alpha=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
ans=""
for i in range(len(s)):
    si=s[i]
    si_ind=alpha.index(si)
    si_ind+=n
    if(si_ind>=len(alpha)):
        si_ind-=len(alpha)
    ans+=alpha[si_ind]
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int N;
    cin >>N;
    if(N<=999) cout <<"ABC";
    if(N>999) cout <<"ABD";

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
v = [int(z) for z in input().split()]
ans = []
m = min(n,k)

for a in range(0,min(n,k)+1):
    for b in range(0,min(n,k)-a+1):
        vm = []
        cd = k-a-b
        vm.extend(v[0:a])
        vm.extend(v[n-b:n])
        vm.sort()
        for i in range(0,min(cd,len(vm))):
            if vm[i] < 0:
                vm[i] = 0
        ans.append(sum(vm))

print(max(ans))

Measured memory_bytes: 3064
(declaim (optimize (speed 0) (safety 3) (debug 3)))
#+sbcl (declaim (sb-ext:unmuffle-conditions sb-ext:compiler-note))
;;(declaim (optimize (speed 3) (safety 0) (debug 0)))

(defvar *sheep-n* (read))
(defvar *wolf-n* (read))

(format t "~:[safe~;unsafe~]" (>= *wolf-n* *sheep-n*))


Measured memory_bytes: 23836