akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int n,m;
int d[76][151][1001];

int main(){
    while(true){
	cin >> n >> m;
	if(n == 0 && m == 0) break;
	memset(d,-1,sizeof(d));
	queue< pair<int,int> > qxy;
	queue<int> qm;
	queue<int> qs;
	vector< vector< pair<int,int> > > coor(n);
	int ans = INT_MAX/2;
	REP(i,n){
	    int k;
	    cin >> k;
	    REP(j,k){
		int a,b;
		cin >> a >> b;
		coor[i].PB( pair<int,int>(a,b));
		if(i==0){
		    qxy.push( pair<int,int>(a,i));
		    qm.push(m);
		    qs.push(b);
		    d[m][i][a] = 0;
		}else if(i == 1){
		    if(m == 0) continue;
		    qxy.push( pair<int,int>(a,i));
		    qm.push(m-1);
		    qs.push(b);
		    d[m-1][i][a] = 0;
		}
	    }
	}

	while(!qxy.empty()){
	    int x = qxy.front().first;
	    int y = qxy.front().second;
	    int tm = qm.front();
	    int ts = qs.front();
	    qxy.pop();
	    qm.pop();
	    qs.pop();
	    if(y+1 >= n || (tm > 0 && y+2 >= n)){
		ans = min(ans,d[tm][y][x]);
		continue;
	    }
	    REP(i,coor[y+1].size()){
		int nx = coor[y+1][i].first;
		int ny = y+1;
		int slip = coor[y+1][i].second;
		int v = d[tm][y][x] + (slip + ts)*abs(nx-x);
		if(d[tm][ny][nx] < 0 || d[tm][ny][nx] > v){
		    d[tm][ny][nx] = v;
		    qxy.push(pair<int,int>(nx,ny));
		    qm.push(tm);
		    qs.push(slip);
		}
	    }
	    if(y+2 >= n) continue;
	    REP(i,coor[y+2].size()){
		int nx = coor[y+2][i].first;
		int ny = y+2;
		int slip = coor[y+2][i].second;
		int v = d[tm][y][x] + (slip + ts)*abs(nx-x);
		if(tm>0 && (d[tm-1][ny][nx] < 0 || d[tm-1][ny][nx] > v )){
		    d[tm-1][ny][nx] = v;
		    qxy.push(pair<int,int>(nx,ny));
		    qm.push(tm-1);
		    qs.push(slip);
		}
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 46192
import re
s = input()

if s[0] == "A":
  if "C" in s[2:len(s)-1] and s[2:len(s)-1].count("C") == 1:
    rep = re.sub(r"[A,C]", "", s)
    if rep.islower():
      print("AC")
    else:
      print("WA")
  else:
    print("WA")
else:
  print("WA")
    

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

vector<int>from[100001];


int to[100001];
int visited[100001]={0};
ll dist[100001]={0};


void foo(int vec)
{
   visited[vec] = 1;
   for(int i=0; i<from[vec].size();i++)
   {
      dist[from[vec][i]] = max(dist[from[vec][i]], dist[vec]+1);
      to[from[vec][i]]--;
      visited[from[vec][i]] = 1;
      if(to[from[vec][i]] == 0)
        foo(from[vec][i]);
   }
}
int main()
{
   int n,m;
   cin>>n>>m;
   for(int i=0;i<m;i++)
   {
     int x,y;
     cin>>x>>y;
     from[x].push_back(y);
     to[y]++;
   }

   for(int i=1;i<=n;i++)
   {
      if(to[i] == 0 && visited[i] == 0)
      {
          foo(i);
      }
   }

   ll ans = 0;
   for(int i=1;i<=n;i++)
     ans = max(ans,dist[i]);
   cout<<ans<<endl;
}

Measured memory_bytes: 11904
import Data.List
main = do
  str <- getLine
  let xs=map read $ words str :: [Int]
  putStrLn $ poyo xs
poyo [w,h,x,y,r]
  | x<r = "No"
  | y<r = "No"
  | w<x+r = "No"
  | h<y+r = "No"
  |otherwise = "Yes"

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

int main() {
  int N, M;
  cin >> N >> M;
  
  int a = (N+M)*(N+M-1);
  int b = a/2;
  
  int c = N*M;
  
  cout << b-c << endl;
  
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;

long long n, m, q, ans = 0;
vector<int> a(50), b(50), c(50), d(50);

void func(int x, vector<int>& v){
  if(v.size() == n){
    //for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << endl;
    long long ret = 0;
    for(int i = 0; i < q; i++){
      if(v[b[i] - 1] - v[a[i] - 1] == c[i]) ret += d[i];
    }
    //cout << ret << endl;
    ans = max(ret, ans);
    return;
  }
  for(int i = x; i <= m; i++){
    v.push_back(i);
    func(i, v);
    v.pop_back();
  }
  return;
}

void solve(){
  cin >> n >> m >> q;
  for(int i = 0; i < q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  for(int i = 1; i <= m; i++){
    vector<int> v;
    v.push_back(i);
    func(i, v);
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

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

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];
    }
    mint p(int n, int k)
    {
        return fact[n] * ifact[n - k];
    }
} c(1000005);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<P> v(K);
    for (auto &it : v)
        cin >> it.first >> it.second;

    vector<mint> dp(N, 0), sdp(N + 1, 0);
    dp[0] = 1, sdp[1] = 1;
    for (int n = 1; n < N; n++)
    {
        for (auto p : v)
        {
            int left = max(0, n - p.second);
            int right = max(0, n - p.first + 1);
            dp[n] += sdp[right] - sdp[left];
        }
        sdp[n + 1] = sdp[n] + dp[n];
    }
    cout << dp[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 21944
#include<iostream>
#include<vector>
int main()
{
	int n;
	std::cin >> n;
	std::vector<bool>result(n);
	for (int i = 0; i < n; i++)
	{
		long double x1, y1, x2, y2, x3, y3, x4, y4;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		result[i] = x1 == x2 && x3 == x4 || (y1 - y2) / (x1 - x2) == (y3 - y4) / (x3 - x4);
	}
	for (auto i : result)
	{
		std::cout << (i ? "YES" : "NO") << std::endl;
	}
	return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll N;
  scanf("%lld", &N);

  vector<ll> list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = v;
  }
  sort(list.rbegin(), list.rend());

  ll a = list[0] / 2;
  for (ll i = 1; i < list.size(); i++) {
    a += list[i];
  }
  cout << a << endl;
}


Measured memory_bytes: 256
class DP2D(object):

    def __init__(self, item_n: int, border: int, initializer: int = 0):
        self.item_n = item_n
        self.border = border
        self.table = [[initializer for _ in range(self.item_n + 1)] for _ in range(self.border + 1)]

    def __str__(self):
        return "\n".join(list(map(lambda l:
                                  " ".join(list(map(str, l)))
                                  , self.table)))

    def __repr__(self):
        return "DynamicProgramming object:\n" + \
               "item_n: " + str(self.item_n) + ", border: " + str(self.border) + "\n" + \
               "table:\n" + self.__str__()

    def solve(self, expr: callable) -> list:
        raise NotImplementedError

    def fill_0_idx_with(self, value: int) -> "DP2D":
        self.table[0] = [value for _ in range(self.item_n + 1)]
        for i in range(1, self.border + 1):
            self.table[i][0] = value
        return self


class DP2DOptimizer(DP2D):

    def __init__(self, item_n: int, border: int, obj_coef: list, sbj_coef: list, initializer: int = 0):
        super(DP2DOptimizer, self).__init__(item_n, border, initializer=initializer)

        if len(obj_coef) == self.item_n:  # to 1-base
            obj_coef = [0] + obj_coef
        self.obj_coef = obj_coef

        if len(sbj_coef) == self.item_n:
            sbj_coef = [0] + sbj_coef
        self.sbj_coef = sbj_coef

    def solve(self, expr: callable) -> list:
        for weight_lim in range(1, self.border + 1):
            for item_idx in range(1, self.item_n + 1):
                self.table[weight_lim][item_idx] = expr(weight_lim, item_idx)

        return self.table

    def coin_expr(self, target, coin_idx) -> int:
        if self.sbj_coef[coin_idx] == 1:
            res = target
        else:
            res = self.table[target][coin_idx - 1]
            if target - self.sbj_coef[coin_idx] >= 0:
                res = min(res, self.table[target - self.sbj_coef[coin_idx]][coin_idx] + self.obj_coef[coin_idx])
        return res


if __name__ == '__main__':
    n, m = map(int, input().split())
    values = [int(i) for i in input().split()]
    dp = DP2DOptimizer(m, n, [1 for _ in range(m)], values, 50000).fill_0_idx_with(0)
    print(dp.solve(dp.coin_expr)[n][m])



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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if(a==0){
    cout << "1" <<endl;
  }
  else if(b==0){
    cout << "2" <<endl;
  }
  else if(c==0){
    cout << "3" <<endl;
  }
  else if(d==0){
    cout << "4" <<endl;
  }
  else if(e==0){
    cout << "5" <<endl;
  }
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
//int main(){
//    int n;
//    cin>>n;
//    long long sum =0;
//    for (int i = 1; i <= n ; ++i) {
//        if(i%3==0
//        ||i%5==0)
//            continue;
//        else
//            sum+=i;
//    }
//    cout<<sum<<endl;
//    return 0;
//}

int r;
int gcd(int x,int y){
    while(y){
        r = x%y;
        x=y;
        y =r;
    }
    return x;
}
int main(){
    int k;
    cin>>k;
    int tmp;
    long long sum=0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            tmp=gcd(i,j);
            for (int l = 1; l <= k; ++l) {
                sum+=gcd(tmp,l);
            }
        }
    }
    cout<<sum<<'\n';
    return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<pair<int, int> > v(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        v[i].first = a[i];
    }
    for(int i=0; i<n; ++i){
        cin >> b[i];
        v[i].second = b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(v.begin(), v.end());

    for(int i=0; i<n; ++i){
        if(a[i] > b[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=0; i<n-1; ++i){
        if(a[i] <= b[i+1] && a[i+1] <= b[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }

    vector<pair<int, int> > w(n);
    for(int i=0; i<n; ++i){
        w[i].first = v[i].second;
        w[i].second = i;
    }
    sort(w.begin(), w.end());

    int i = 0;
    int len = 0;
    vector<bool> check(n, false);
    while(!check[i]){
        check[i] = true;
        ++ len;
        i = w[i].second;
    }
    if(len == n)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
using namespace __gnu_pbds;

const int N=5e5+5;
int n,q,a[N],occ[N],res[N];
tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>cur;
vector<int>event[N];

struct T
{
    int l,r;
};
T query[N];

void solve()
{
    cin>>n>>q;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cur.insert(mp(0,i));
    }
    for(int i=1;i<=q;i++)
    {
        cin>>query[i].l>>query[i].r;
        event[query[i].r].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        cur.erase(mp(occ[a[i]],a[i]));
        occ[a[i]]=i;
        cur.insert(mp(i,a[i]));
        for(auto&id:event[i])
        {
            int l=query[id].l;
            res[id]=cur.size()-cur.order_of_key(mp(l,0));
        }
    }
    for(int i=1;i<=q;i++) cout<<res[i]<<'\n';
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //int t;
    //cin>>t;
    //while(t--)
        solve();
}


Measured memory_bytes: 65540
#include <bits/stdc++.h>
using namespace std;
int main()
{
string str;
cin>>str;
int n=str.length();
int i;
int count=0;
for(i=0; i<n; i++)
{
  if(str[i]=='o')
  count++;
}
if(15-n+count>=8)
cout<<"YES";
else cout<<"NO";
}

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

using namespace std;

int main(){
  
  string a, b, c;
  cin >> a >> b >> c;

  if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]){
      cout << "YES" << endl;
  }else{
      cout << "NO" << endl;
  }

}

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

using namespace std;

int main() {
    string s;   cin >> s;
    int ans = 0, l = s.length();

    for (int i = 0; i <= (l-2)/2; i++) {
        if (s[i] != s[l-1-i])
            ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <boost/math/constants/constants.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  cout << max(C-(A-B), 0) << endl;
  
}

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

int main() {
  int n;
  cin >> n;
  if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9)
    cout << "hon" << endl;
  if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8)
    cout << "pon" << endl;
  if(n%10 == 3)
    cout << "bon" << endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
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; }

int A, B;

int main() {
    cin >> A >> B;
    vector< vector<char> > smap(110, vector<char>(110, '.'));
    for(int i = 0; i < 50; ++i) {
        for(int j = 0; j < 100; ++j) {
            smap.at(i).at(j) = '#';
        }
    }

    for(int i = 0; i < A-1; ++i) {
        int row = i/50;
        if(row % 2 == 0) {
            smap.at(2*row).at(2*(i%50)) = '.';
        }else {
            smap.at(2*row).at(2*(i%50)+1) = '.';
        }
    }

    cout << 100 << " " << 100 << endl;
    for(int i = 0; i < B-1; ++i) {
        int row = i/50;
        if(row % 2 == 0) {
            smap.at(51+2*row).at(2*(i%50)) = '#';
        }else {
            smap.at(51+2*row).at(2*(i%50)+1) = '#';
        }
    }

    for(int i = 0; i < 100; ++i) {
        for(int j = 0; j < 100; ++j) {
            cout << smap.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    a = numinput()
    print('%d %d' % (a[0] * a[1], 2 * (a[0] + a[1])))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
int main() {
	char S[100000];
	scanf("%s", S);
	int i, frag = 0;
	for (i = 0; S[i] != '\0'; i++) {
		if (S[i] == 'd' && S[i + 1] == 'r' && S[i + 2] == 'e' && S[i + 3] == 'a' && S[i + 4] == 'm') {
			if (S[i + 5] == 'e' && S[i + 6] == 'r') {
				if (S[i + 7] == 'a' && S[i + 8] == 's' && S[i + 9] == 'e') {
					i += 4;
				}
				else {
					i += 6;
				}
			}
			else {
				i += 4;
			}
		}
		else if (S[i] == 'e' && S[i + 1] == 'r' && S[i + 2] == 'a' && S[i + 3] == 's' && S[i + 4] == 'e') {
			if (S[i + 5] == 'r') {
				i += 5;
			}
			else {
				i += 4;
			}
		}
		else /*if(S[i] == '\0' || S[i + 1] == '\0' || S[i + 2] == '\0' || S[i + 3] == '\0' || S[i + 4] == '\0'){
		 break;
	 } else */ {
			frag++;
			break;
		}
	}
	if (frag == 0) {
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 1824
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I a,b;
  cin >> a >> b;
  I t=0;
  if (a <= b * 2){
    t = 0;
  }else{
    t = a - b*2;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	double a, b, c, d, e, f,x,y;

	while (scanf("%lf %lf %lf %lf %lf %lf", &a,&b, &c, &d, &e, &f) !=EOF) {
		y=(c*d-f*a)/(b*d-e*a);
                x=(c-b*y)/a;
		printf("%.3lf %.3lf\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 652
# solve problem
def solve(n, m, targets, games):
    counter = [0 for i in range(n+1)]

    for i in range(m):
        for j in range(n):
            if games[i][j] == targets[i]:
                counter[j+1] += 1
            else:
                counter[targets[i]] += 1

    return counter


# main function
if __name__ == '__main__':
    n = int(input())
    m = int(input())
    tmp_targets = input().split()

    targets = []
    for i in range(m):
        targets.append(int(tmp_targets[i]))

    games = [[0 for i in range(n)] for j in range(m)]
    tmp_games = []
    for i in range(m):
        tmp_games = input().split()
        for j in range(n):
            games[i][j] = int(tmp_games[j])

    results = solve(n, m, targets, games)
    for i in range(1, n+1, 1):
        print(results[i])

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int N; cin >> N;
    vector<int> P(N), Q(N), A(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    rep(i, N) A[i] = i + 1;
    ll a = 0, b = 0, c = 0;
    do {
        c++;
        int cnt1 = 0, cnt2 = 0;
        rep(i, N) {
            if (P[i] == A[i]) {
                cnt1++;
            }
        }
        rep(i, N) {
            if (Q[i] == A[i]) {
                cnt2++;
            }
        }
        if (cnt1 == N) a = c;
        if (cnt2 == N) b = c;

    }while(next_permutation(all(A)));

    cout << abs(a - b) << endl;

}

Measured memory_bytes: 256
a=[[0]*3 for i in range(3)]
b=[]
for i in range(3):
  x=input().split()
  a[i][0]=x[0]
  a[i][1]=x[1]
  a[i][2]=x[2]
n=int(input())
for i in range(n):
  b.append(input())
for i in range(n):
  for j in range(9):
    if b[i]==a[j//3][j%3]:
      a[j//3][j%3]='X'
jud=[0,0,0,0]
z=0
res=0
for i in range(3):
  for j in range(2):
    if a[i][j]==a[i][j+1]:
      jud[0]+=1
    if a[j][i]==a[j+1][i]:
      jud[1]+=1
  if max(jud)>1:
    res-=1
  else:
    jud[0]=0
    jud[1]=0
for j in range(2):
  if a[j][j]==a[j+1][j+1]:
    jud[2]+=1
  if a[j][2-j]==a[j+1][2-j-1]:
    jud[3]+=1
if max(jud)>1:
  res-=1
if res<0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
typedef unsigned long long ULL;
ULL pw(ULL a, ULL n, int M){ ULL b=1; while(n){ if(n&1){ b=(b*a)%M; } a=(a*a)%M; n>>=1; } return b; }

int dfs(int x){
  if(x==0){ return 0; }
  int d=0, i=1;
  while(i<=x){ if((x&i)>0){ d++; } i*=2; }
  return dfs(x%d)+1;
}

int main(){
ULL N, ans=0, K=0, c=0; string X; cin >> N >> X;
REP(i, N){ if(X[i]=='1'){ K++; c=i; } }
if(K==0){ REP(i, N){ cout << "1\n"; } return 0; }

ULL A=0, B=0;
if(K==1){ 
  B=pw(2, N-c-1, K+1);
  REP(i, N){ 
    if(X[i]=='1'){ cout  << "0\n"; }
    if(X[i]=='0'){ cout << dfs((B+pw(2, N-i-1, K+1))%(K+1))+1 << "\n"; }
  }
  return 0;
}

REP(i, N){ if(X[N-i-1]=='1'){ A=(A+pw(2, i, K-1))%(K-1); B=(B+pw(2, i, K+1))%(K+1); } }
REP(i, N){ 
  if(X[i]=='1'){ cout << dfs((A-pw(2, N-i-1, K-1)+(K-1))%(K-1))+1 << "\n"; }
  if(X[i]=='0'){ cout << dfs((B+pw(2, N-i-1, K+1))%(K+1))+1 << "\n"; }
}
}

Measured memory_bytes: 3724
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int A,B,C;

signed main(){

    in(A,B,C);
    Yn(A<=C&&C<=B);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
double n,b,ans;
double poww[200001];
int main()
{
    double tmp=0.5;
    for(int i=1;i<=100000;i++)
    {
        poww[i]=tmp;
        tmp/=2;
    }
    cin>>n>>b;
    for(int i=1;i<=n;i++)
    {
        int cnt=0,w=i;
        while(w<b)
        {
            ++cnt;
            w*=2;
        }
        //cout<<cnt<<endl;
        //cout<<poww[cnt]<<endl;
        if(cnt==0)ans+=1.0/n;
        else ans+=(1.0/n)*poww[cnt];
	}
    cout<<fixed<<showpoint<<setprecision(10)<<ans;
    return 0;
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll Q;
    cin >> Q;

    multimap<string, ll> mp;

    while(Q--){
        ll a;
        cin >> a;
        string key;

        if(a==0){
            cin >> key;
            // insert
            ll x; cin >> x;
            mp.insert(make_pair(key, x));
        }
        else if(a==1){
            cin >> key;
            auto it = mp.lower_bound(key);
            auto end = mp.upper_bound(key);
            for(; it!=end; it++){
                p((*it).second);
            }
        }
        else if(a==2){
            cin >> key;
            // delete
            mp.erase(key);
        }
        else{
            // dump
            string L, R;
            cin >> L >> R;

            auto it = mp.lower_bound(L);
            auto end = mp.upper_bound(R);
            for(; it!=end; it++){
                p2((*it).first, (*it).second);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 24860
import Control.Applicative

data Dice = Dice [Int] deriving (Show)

roll :: Dice -> Char -> Dice
roll (Dice [top, front, right, left, back, bottom]) 'S' = Dice [back, top, right, left, bottom, front]
roll (Dice [top, front, right, left, back, bottom]) 'E' = Dice [left, front, top, bottom, back, right]

turn1 :: Dice -> Dice
turn1 (Dice [top, front, right, left, back, bottom]) = Dice [top, right, back, front, left, bottom]
turn2 = turn1 . turn1
turn3 = turn2 . turn1

turnAll :: [Dice] -> [Dice]
turnAll dices =  [id, turn1, turn2, turn3] <*> dices

dices :: Dice -> [Dice]
dices dice = [dice
             , rev dice
             , toS dice
             , toE dice
             , rev (toS dice)
             , rev (toE dice)
             ]

toS = flip roll 'S'
toE = flip roll 'E'
rev = toS . toS

solve :: [Dice] -> [Int] -> Maybe Int
solve [] _                     = Nothing
solve ((Dice (x:y:z:_)):rest) [top, front]
    | top == x && front == y = Just z
    | otherwise              = solve rest [top, front]

main :: IO ()
main = do
    init <- Dice . map read . words <$> getLine
    getLine
    let diceall = turnAll . dices $ init
    qs <- map (map ri . words) . lines <$> getContents
    mapM_ putStrLn $ map pmaybe $ map (solve diceall) qs
        where ri :: String -> Int
              ri = read
              pmaybe :: Maybe Int -> String
              pmaybe Nothing  = "Nothing"
              pmaybe (Just n) = show n


Measured memory_bytes: 4000
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = []
b_list = []
for i in range(0, n):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
a_list.sort()
b_list.sort()
if n % 2 == 0:
    x1 = n // 2 - 1
    x2 = n // 2
    print(b_list[x2] - a_list[x2] + b_list[x1] - a_list[x1] + 1)
else:
    x = n // 2
    print(b_list[x] - a_list[x] + 1)

Measured memory_bytes: 25384
package main

import (
        "fmt"
        "strconv"
)

func solution(a int, b string) int {
        x := make([]byte, 0, len(b))
        for i := range b {
                if b[i] != '.' {
                        x = append(x, b[i])
                }
        }
        bn, _ := strconv.Atoi(string(x))

        return a * bn / 100
}

func main() {
        var a int
        var b string
        fmt.Scan(&a, &b)
        fmt.Println(solution(a, b))
}

Measured memory_bytes: 1756
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REP_S(i, n, s) for(int i = s; i < (int)(n); i++)
int main()
{
	int num;
	cin >> num;

    vector<int> a(num);
    vector<int> colorList;
    REP(i, num)   
    {
        cin >> a[i];
    }

    int maxNo = a[num - 1];
    colorList.push_back(a[num - 1]);
    for(int i = num - 2; i >= 0; --i)
    {
        if(maxNo <= a[i])
        {
            colorList.push_back(a[i]);
            maxNo = a[i];
        }
        else
        {
            
            bool test = false;
            for(int j = 0; j < colorList.size(); ++j)
            {
                if(colorList[j] > a[i])
                {
                    colorList[j] = a[i];
                    test = true;
                    break;
                }
            }
            maxNo = colorList[colorList.size() - 1];
        }
    }

    cout << colorList.size() << endl;
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define INF 100000000
int main(){
    string S;
    cin>>S;
    sort(S.begin(),S.end());
    if(S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3])cout<<"Yes";
    else cout<<"No";
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const double pi(acos(-1.0));

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("io\\in.txt", "r", stdin);
    freopen("io\\out.txt", "w", stdout);
#endif

    int a, b, x;
    cin >> a >> b >> x;

    double l = 0, r = 90;
    while (l * (1 + 1e-9) < r) {
        double d = (l + r) / 2;
        double rad = d * pi / 180;

        double v;
        if (b * cos(rad) > a * sin(rad))
             v = a * a * b - a * a * a * tan(rad) +
                 0.5 * a * a * a * tan(rad);
        else v = 0.5 * a * b * b / tan(rad);
        if (x >= v) r = d;
        else l = d;
    }

    cout << setprecision(6) << fixed << l;

    return 0;
}


Measured memory_bytes: 4368
import sys

def main():
  s = input()
  p = input()

  len_s = len(s)
  can_make = False

  for i in range(len_s):
    first = s[0:i]
    second = s[i:]
    str = second + first

    if p in str:
      can_make = True
      break
  
  if can_make:
    print('Yes')
  else:
    print('No')

if __name__ == '__main__':
  main()


Measured memory_bytes: 5568
import math
N=int(input())

def primelist(x):
  limit=math.sqrt(x)
  
  prime=[]
  search=list(range(2,x+1))
  
  while 1:
    if search[0]>limit:
      return prime+search
     
    else:
      head_num = search.pop(0)
      prime.append(head_num)
      #head_numの倍数を取り除く
      search = [num for num in search if num % head_num != 0]
      
prime=primelist(55555)

i=0
for p in prime:
  if p%5==1:
    print(p,end=" ")
    i+=1
    if i==N:
      exit()
      

Measured memory_bytes: 42732
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int a, b;
    cin >> a >> b;

    if (a * b % 2 == 0) {
        cout << "Even";
    } else {
        cout << "Odd";
    }

    return 0;
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let mut i = 0;
    while (i + 1) * (i + 1) <= n {
        i += 1;
    }
    println!("{}", i * i);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
 int main(){
  int H,W,i,j,k;
  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0){
      break;
    }
    for(i = 0;i < H;i++){
      if(i == 0 || i == H - 1){
 
    for(k = 0;k < W;k++){
      printf("#");
    }
    printf("\n");
      }
      else{
    for(j = 0;j < W;j++){
      if(j == 0 || j == W - 1){
        printf("#");
      }
      else{
        printf(".");
      }
    }
    printf("\n");
      }
    }
    printf("\n");
  }
 
  return 0;
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  if(A==B){
    cout << C << endl;
  }
  else if(B==C){
    cout << A << endl;
  }
  else{
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
// cout<<fixed<<setprecision(10);
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;}

const int INF = 1e9;

int main() {
    int h, n; cin >> h >> n;
    vector<int> dp(h+1, INF);
    dp[0] = 0;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        rep(j, h) {
            int nj = min(j+a, h);
            chmin(dp[nj], dp[j]+b);
        }
    }
    cout << dp[h] << endl;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
l, r = [0]*m, [0]*m
for i in range(m):
    l[i], r[i] = map(int,input().split())
ml = max(l)
mr = min(r)
if ml > mr:
    print(0)
else:
    print(mr - ml + 1)


Measured memory_bytes: 10868
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define rg register
void read(int &x) {
	char ch; bool ok;
	for(ok=0,ch=getchar(); !isdigit(ch); ch=getchar()) if(ch=='-') ok=1;
	for(x=0; isdigit(ch); x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}
const int maxn=1e6+10;
int n,a,b,st[maxn],top,ans[maxn];char s[maxn];
void query(int x,int y){printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",s);}
int main()
{
	read(a),read(b),n=a+b;
	if(a<=b){printf("Impossible\n");return 0;}
	for(rg int i=0;i<n;i++)
	{
		if(!top)st[++top]=i;
		else {query(st[top],i);if(s[0]=='Y')st[++top]=i;else top--;}
	}
	int now=st[top];
	for(rg int i=0;i<n;i++)
	{
		query(now,i);
		if(s[0]=='Y')ans[i]=1;
	}
	printf("! ");
	for(rg int i=0;i<n;i++)printf("%d",ans[i]);
}

Measured memory_bytes: 2772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	string s;
	bool a = 0;
	cin>>s;
	rep(i,3){
		if(s[i] == s[i+1]) a = 1;
	}
	puts(a?"Bad":"Good");}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; string s; cin >> n >> s;
    int res=0;
    for(int i=1; i<n-1; i++){
        int tmp=0;
        set<char> s1,s2;
        for(int j=0; j<i; j++) s1.insert(s[j]);
        for(int j=i; j<n; j++) s2.insert(s[j]);
        for(char c='a'; c<='z'; c++){
            if(s1.count(c) && s2.count(c)) tmp++;
        }
        chmax(res,tmp);

    }   
    cout<<res<<endl;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	string s = to_string(a);
	string t = to_string(b);
	string temp = s + t;
	int x = stoi(temp);
	for (int i = 1; i <= 100000; ++i) {
		if(i * i == x){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    if(s=="Sunny")
    {
        cout << "Cloudy";
    }
    else if(s=="Cloudy")
    {
        cout << "Rainy";
    }
    else if(s=="Rainy")
    {
        cout << "Sunny";
    }
}


Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>

#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )
#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int m;
  int i, j;

  scanf ( "%d", &m );
  for ( i = 0; i < m; ++i )
  {
    int mu = 0, md = 0;
    int p;
    int n;

    scanf ( "%d%d", &n, &p );
    for ( j = 1; j < n; ++j )
    {
      int d;

      scanf ( "%d", &d );
      if ( d - p < 0 )
        md = MIN( md, d - p );
      else
        mu = MAX( mu, d - p );

      p = d;
    }

    printf ( "%d %d\n", mu, -md );
  }

  return ( EXIT_SUCCESS );
}

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

int max9(int N) {
	int x = 0;
	while (N >= pow(9, x)) {
		x++;
	}
	return x - 1;
}
int max6(int N) {
	int x = 0;
	while (N >= pow(6, x)) {
		x++;
	}
	return x - 1;
}

int ans(int N) {
	if (N <= 5) { return N; }
	else {
		int a = ans(N - pow(9, max9(N)));
		int b = ans(N - pow(6, max6(N)));
		return min(a, b) + 1;
	}
}
int main(void) {
	int N; cin >> N;
	cout << ans(N);
	return 0;
}

Measured memory_bytes: 256
class node():
    def __init__(self, key, parent, left, right):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right

root = None

def insert(r, z):
    global root

    y = None
    x = root

    while x != None:
        y = x

        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def Inorder_TreeWalk(node):
    if node is None:
        return

    Inorder_TreeWalk(node.left)
    print(" " + str(node.key), end="")
    Inorder_TreeWalk(node.right)

def Preorder_TreeWalk(node):
    if node is None:
            return
            
    print(" " + str(node.key), end="")
    Preorder_TreeWalk(node.left)
    Preorder_TreeWalk(node.right)

def Main():
    
    n = int(input())
    global root

    for i in range(n):
        inp = input().split()
        ope = inp[0]

        if ope == "insert":
            insert(root, node(int(inp[1]), None, None, None))

        elif ope == "print":
            Inorder_TreeWalk(root)
            print()
            Preorder_TreeWalk(root)
            print()
        else:
            pass
Main()


Measured memory_bytes: 105036
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define pb push_back
#define pr pair<int,int>
using namespace std;
using ll = long long;
// using mod = 1000000000 + 7;
void self_max(int &a,int b){
	a = max(a,b);
}

void self_min(int &a,int b){
	a = min(a,b);
}
int main(){
	int a,b; cin >> a >>b;

	if(a>b){
		cout << "a > b" << endl;
	}else if(a == b){
		cout << "a == b" << endl;
	}else{
		cout << "a < b" << endl;
	}

	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
const double eps = 1e-8;

ll ar[100010];
ll dp[100010];
ll n,k;
ll solve(ll i)
{
    if(i==n)
        return 0;
    if(i>n)
        return INT_MAX;

    if(dp[i]!=-1)
        return dp[i];
    ll arr[k+10],sz=0;
    for(ll step = 1; step<=k; ++step)
    {
        if(i+step<=n)
        {
            arr[sz++]=abs(ar[i]-ar[i+step])+solve(i+step);
        }
        else
            break;
    }
    ll mn=INT_MAX;
    for(ll x=0; x<sz; x++)
        mn=min(mn,arr[x]);
    return dp[i]=mn;

}

int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(ll i=1; i<=n; i++)
        cin>>ar[i];
    cout<<solve(1);

}








Measured memory_bytes: 97152
#include<bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9	
#define MOD 1000000007
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

void printV(VVI v) {
	for(VI k: v) {
		for(int i: k) cout << i << " ";
			cout << endl;
	}
	cout << endl;
}

void solve() {
	int n;
	cin >> n;
	VVI arr(n, VI(3));
	VVI dp(n, VI(3,0));
	int max_ = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin >> arr[i][j];
		}
	}
	// printV(arr);
	// for (int i = 0; i < n; ++i)
	// {
	// 	for (int j = 0; j < 3; ++j)
	// 	{
	// 	}
	// }
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			int ans = 0;
			if(i == 0) {
				dp[i][j] = arr[i][j];
			} else {
				if(j == 2) {
					ans = max(dp[i-1][j-1], dp[i-1][j-2]);
				}
				if(j == 1) {
					ans = max(dp[i-1][j-1], dp[i-1][j+1]);
				}
				if(j == 0) {
					ans = max(dp[i-1][j+1], dp[i-1][j+2]);
				}
				dp[i][j] = arr[i][j] + ans;
			}
			max_= max(max_,dp[i][j]);
		}
	}
	
	cout << max_;

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 14288