akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,c=0;
  cin>>n;
  vector<int> a(n+1),b(n+1,0),d;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=n;i>0;i--){
      int cnt=0;
      for(int j=i;j<=n;j+=i){
        cnt+=b[j];
      }
      if(cnt%2!=a[i]){
        b[i]=1;
        c++;
        d.push_back(i);
      }
  }
  cout<<c<<endl;
  for(int i=c-1;i>=0;i--){
    cout<<d[i]<<" ";
  }
}


Measured memory_bytes: 3064
a1,a2,a3 = input().split(" ")
a1 = int(a1)
a2 = int(a2)
a3 = int(a3)
l = [a1,a2,a3]
jl = []

for i in range(3):
  jl.append(abs(l[(i+1)%3]-l[i%3]) + abs(l[(i+1)%3]-l[(i+2)%3]))
  jl.append(abs(l[(i+2)%3]-l[i%3]) + abs(l[(i+1)%3]-l[(i+2)%3]))


print(min(jl))

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

int main(){
  string s;
  cin >> s;
  for(size_t i=0 ; i<(s.size()-1)/2 ; i++){
    if (s.at(i) !=  s.at(s.size()-1-i)|| s.at(i) != s.at((s.size()-1)/2 -1-i)){
      cout << "No" << endl;
      return 0;
    } 
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int L, R, d; cin >> L >> R >> d;

    int ans = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) ans++;
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

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

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

int N, M;
vvi path;
int cnt;

void loop(int id, int flag)
{
  if( flag & (1 << id) ) return;
  flag |= 1 << id;
  if( flag == (0b11111111 >> (8-N)) ){
    cnt++;
    return;
  }
  for( auto iter : path[id] )
    loop( iter, flag );
}

int main()
{
  int a, b;

  cin >> N >> M;
  path.resize(N);
  rep(i,M){
    cin >> a >> b;
    a--;
    b--;
    path[a].pb(b);
    path[b].pb(a);
  }

  cnt = 0;
  loop( 0, 0 );
  cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
import collections as col
 
num_list = set(A)
ca = col.Counter(A)

num = 0

for i in num_list:
    if ca[i] == 1:
        continue
    else:
        num += (ca[i]*(ca[i]-1))//2
        
for i in A:
    ans = num - (ca[i]-1)
    print(ans)

Measured memory_bytes: 29312
from collections import deque

class Dinic:
    class Edge:
        def __init__(self,to,cap,rev):
            self.to = to
            self.cap = cap
            self.rev = rev

    def __init__(self,n,inf = 10**9+7):
        self.n = n
        self.inf = inf
        self.level = [-1]*n
        self.iter = [0]*n
        self.e = [[] for _ in range(n)]

    def add_edge(self, from_, to, cap):
        self.e[from_].append(self.Edge(to, cap, len(self.e[to])))
        self.e[to].append(self.Edge(from_, 0, len(self.e[from_])-1))

    def bfs(self, start):
        self.level = [-1]*self.n
        dq = deque()
        self.level[start] = 0
        dq.append(start)
        while dq:
            cur_vertex = dq.popleft()
            for edge in self.e[cur_vertex]:
                if edge.cap > 0 > self.level[edge.to]:
                    self.level[edge.to] = self.level[cur_vertex] + 1
                    dq.append(edge.to)

    def dfs(self, cur_vertex, end_vertex, flow):
        if cur_vertex == end_vertex:return flow
        while self.iter[cur_vertex] < len(self.e[cur_vertex]):
            edge = self.e[cur_vertex][self.iter[cur_vertex]]
            if edge.cap > 0 and self.level[cur_vertex] < self.level[edge.to]:
                flowed = self.dfs(edge.to, end_vertex, min(flow, edge.cap))
                if flowed > 0:
                    edge.cap -= flowed
                    self.e[edge.to][edge.rev].cap += flowed
                    return flowed
            self.iter[cur_vertex] += 1
        return 0

    def compute(self, source, sink):
        flow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:return flow
            self.iter = [0]*self.n
            while True:
                f = self.dfs(source, sink, self.inf)
                if f == 0:break
                flow += f

def main():
    v,e = map(int,input().split())
    MF = Dinic(v)
    for i in range(e):
        a,b,c = map(int,input().split())
        MF.add_edge(a,b,c)
    print(MF.compute(0,v-1))

if __name__ == '__main__':
    main()




Measured memory_bytes: 6336
package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var n, k int
	fmt.Fscanf(in, "%d%d", &n, &k)

	m := n / k
	m1 := (n + k/2) / k

	ans := 0
	if k%2 == 0 {
		ans = m*m*m + m1*m1*m1
	} else {
		ans = m * m * m
	}

	fmt.Fprintln(out, ans)
}


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

int main(){
  double n;
  cin>>n;
  vector<double> a,b;
  for(int i=0; i<n; i++){
    int x;
    cin>>x;
    a.push_back(x);
  }
  sort(a.begin(),a.end());
  double ans=a[0];
  for(int i=1; i<n; i++){
    ans=(ans+a[i])/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#define ll unsigned long long
using namespace std;

const ll MAX = 1e18;


int main() {
    int n;
    ll a[100100], prod = 1;
    cin >> n;

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

    for (int i = 0; i < n; ++i) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] <= MAX/prod) {
            prod *= a[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << prod << endl;
}


Measured memory_bytes: 4404
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int a,c,w;
    c=0;
    w=0;
    cin >> a;
    if(a>=111 && a<=999)
    {


        for(int i=0; i<3; i++)
        {

            if(a%10==9)
                w=1;

            if(a%10==1)
                w=9;

            c=c+w*pow(10,i);
            a=a/10;
        }
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())

AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))

AB.sort(key=lambda x: (x[0], x[1]))

ct = 0
money = 0
for i in AB:
    A, B = i[0], i[1]
    for i in range(B):
        money += A
        ct += 1
        if ct == M:
            break
    if ct == M:
        break

print(money)


Measured memory_bytes: 35296
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

struct edge {
    edge() : link_to(0), color(0) {}
    edge(int t, int c) : link_to(t), color(c) {}
    int link_to;
    int color;
};

void dfs(int node, std::vector<std::map<i64, edge>>& graph, int cl_max, const edge& from, bool root = false) {
    int used_watermark{0};

    for (auto& kv : graph[node]) {
        edge& e = kv.second;
        if (root) {
            dfs(e.link_to, graph, cl_max, e);
        }
        else if (e.color==0) {
            if (++used_watermark == from.color) {
                ++used_watermark;
            }
            if (used_watermark > cl_max) {
                cout << "  " << node << " " << e.link_to;
            }
            e.color = used_watermark;
            graph[e.link_to][node].color = used_watermark;
            dfs(e.link_to, graph, cl_max, e);
        }
    }
}

int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    std::vector<std::map<i64, edge>> graph(n);
    std::vector<P> input;

    for (int i=0; i<n-1; ++i) {
        i64 a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].insert(make_pair(b, edge(b, 0)));
        graph[b].insert(make_pair(a, edge(a, 0)));
        input.push_back(make_pair(a,b));
    }

    i64 max_{0}, root;
    for (size_t i=0; i<n; ++i) {
        if (graph[i].size() > max_) {
            max_ = graph[i].size();
            root = i;
        }
    }

    int i=1;
    for (auto& kv :graph[root]) {
        edge& e = kv.second;
        e.color = i;
        graph[e.link_to][root].color = i;
        ++i;
    }

    dfs(root, graph, max_, edge(), true);

    cout << max_ << endl;
    for (auto p : input) {
        cout << graph[p.first][p.second].color << endl;
    }

    return 0;
}

Measured memory_bytes: 19184
#include <iostream>

using namespace std;

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

int main()
{
    int X, Y;
    cin >> X >> Y;

    rep(i, X + 1)
    {
        if ((i * 2 + (X - i) * 4) == Y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3632
a = int(input())
b = int(input())
c = int(input())
x = int(input())
case = 0

for c500 in range(a+1):
  for c100 in range(b+1):
    for c50 in range(c+1):
      if 500*c500 + 100*c100 + 50*c50 ==x:
        case=case+1
print(case)


Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N, M;
    cin >> N >> M;
    VEC(int) Counts(N, 0);
    FOR(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        Counts[a]++;
        Counts[b]++;
    }

    FOR(i, 0, N)
        cout << Counts[i] << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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

int main(){
  int N;
  cin >> N;
  double ans=0;
  for(int i=0;i<N;i++){
    double x;
    string u;
    cin >> x >> u;
    if(u=="JPY"){
      ans+=x;
    }else{
      ans+=x*380000;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  ll K; cin >> K;
  ll memo[1000001];
  memo[1] = 7%K;
  for(int i=2 ; i<=K ; i++){
    memo[i] = (10*memo[i-1] + 7) % K;
  }
  for(int i=1 ; i<=K ; i++){
    if(memo[i] == 0){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 11432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N, M;

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

  vector<vector<int>> res(N);
  rep(i, M) {
    int p;
    string S;
    cin >> p >> S;
    res[p - 1].push_back(S == "AC");
  }

  int ac = 0;
  int p = 0;
  rep(i, N) {
    bool ok = false;
    int cp = 0;

    for (int r : res[i]) {
      if (!ok) {
        if (r) {
          ok = true;
          p += cp;
          ++ac;
        } else {
          ++cp;
        }
      }
    }
  }

  cout << ac << " " << p << endl;

  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  int keta = 0;
  while (0 < n) {
    n /= k;
    keta++;
  }
  cout << keta << endl;
  return 0;
}


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

using namespace std;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  long long k;
  cin >> s >> k;
  int i;
  for (i = 1; i <= s.size(); ++i) {
    if (s[i-1]!='1') break;
  }
  if (k<i) cout << 1 << endl;
  else cout << s[i-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>

using namespace std;

typedef long long signed int ll;

constexpr ll NIL = -20000000000;

int g[101][101],n,d[101],f[101];

int main() {
    cin >> n;
    for(int i = 0;i < n;i++) {
        int u,k,v;
        cin >> u >> k;
        for(int j = 0;j < k;j++) {
            cin >> v;
            g[u][v]++;
        }
    }
    stack<int> dfs;
    int time = 2;
    dfs.push(1);
    d[1] = 1;
    bool flag = true;
    while(flag) {
        while (!dfs.empty()) {
            int u = dfs.top();
            bool fl = false;
            for (int i = 1; i <= n; i++) {
                if (g[u][i] && d[i] == 0 && u != i) {
                    dfs.push(i);
                    d[i] = time++;
                    fl = true;
                    break;
                }
            }
            if (!fl) {
                dfs.pop();
                f[u] = time++;
            }
        }
        flag = false;
        for(int i =1;i <= n;i++) if(d[i] == 0){flag = true;dfs.push(i);d[i] = time++;break;}
    }
    for(int i = 1;i <=n;i++) {
        cout << i << " " << d[i] << " " << f[i] <<endl;
    }
}



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

int main() {
    ll n;cin >> n;
    vector<ll> v(n);
    ll center,sum = 0;
    rep(i,n){
        cin >> v[i];
        v[i] -= i+1;
    }
    sort(v.begin(),v.end());
    if(n%2!=0)center = v[n/2];
    else center = (v[n/2-1]+v[n/2])/2;
    rep(i,n){
        sum += abs(center-v[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>

using namespace std;

const int INF = 1e9;


int calc_mp(int *take, int a, int b, int c) {
  if (take[0] == 0 || take[1] == 0 || take[2] == 0) {
    return INF;
  }

  return std::abs(take[0]-a) + std::abs(take[1]-b) + std::abs(take[2]-c);
}
void copy(int *l, int *m) {
  m[0] = l[0];
  m[1] = l[1];
  m[2] = l[2];
}

int mp_min = INF;
int search(int *l, int n, int i, int *take, int a, int b, int c, int tmp_mp) {
  if (i == n) {
    int mp = calc_mp(take, a, b, c) + tmp_mp - 30;
    if (mp < mp_min) {
      mp_min = mp;
    }
    return 0;
  }
  int li = l[i];

  search(l, n, i+1, take, a, b, c, tmp_mp);
  int t2[3];
  copy(take, t2);
  t2[0] += li;
  search(l, n, i+1, t2, a, b, c, tmp_mp + 10);
  int t3[3];
  copy(take, t3);
  t3[1] += li;
  search(l, n, i+1, t3, a, b, c, tmp_mp + 10);

  int t4[3];
  copy(take, t4);
  t4[2] += li;
  search(l, n, i+1, t4, a, b, c, tmp_mp + 10);
  return mp_min;
}



int main() {
  ios::sync_with_stdio(false);
  int n, a, b, c;
  cin>> n >> a >> b >> c;
  int l[8];
  for (int i=0; i<n; i++) {
    int li;
    cin >> li;
    l[i] = li;

  }
  int take[3] = {0};
  cout <<  search(l, n, 0, take, a, b, c, 0);
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
//  pair<int,int>pa;
//  vector<pair<int,int>>vec;

int main(){
 int N,M=0;
  long long ans=0;
  cin>>N;
  vector<int>g(N);
  vector<int>v(N);
  for(int i=0;i<N;i++){
    cin >>g.at(i);
    v.at(i)=abs(g.at(i));
  }
  
  sort(g.begin(),g.end());
  
  for(int i=0;i<N;i++){
    if(g.at(i)<0){
      M=i+1;
    }
    else{break;}
  }
  if(M%2==0){
    for(int i=0;i<N;i++){
      ans+=v.at(i);
    }
  }
  
  else{
      sort(v.begin(),v.end());
    for(int i=1;i<N;i++){
      ans+=v.at(i);
    }
    ans-=v.at(0);
  }
  cout << ans<<endl; 
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int p[100000]={2};
  int i,j,n,c=1,s=0;
  for(i=3;i<1000000;i+=2){
    s=0;
    for(j=0;p[j]*p[j]<=i;j++){
      if(i%p[j]==0){
	s=1;
	break;
      }
    }
    if(s==0){
      p[c]=i;
      c++;
    }
  }
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    s=0;
    for(i=0;i<n;i++){
      s+=p[i];
    }
    printf("%d\n",s);
  }
  
  return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
struct ki
{
    int parent;
   // vector<int> child;
    int points=0;
};
int main()
{
    int n,q; cin>>n>>q;
    ki kis[n+1];
    for(int i=1;i<n;i++)
    {
        int a,b; cin>>a>>b;
        kis[b].parent=a;
    }
    for(int i=0;i<q;i++)
    {
        int a,b;cin>>a>>b;
        kis[a].points+=b;
    }
    cout<<kis[1].points<<' ';
    for(int i=2;i<=n;i++)
    {
        int parent=kis[i].parent;
        int pos=kis[parent].points+kis[i].points;
        kis[i].points=pos;
        cout<<pos<<' ';
    }
    /*for(int i=2;i<=n;i++)
    {
        cout<<kis[i].parent<<' ';
    }*/

    return 0;
}












Measured memory_bytes: 3968
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int l=sc.nextInt();
		sc.nextLine();
		String arr[]=new String[n];
		for(int i=0;i<n;i++) {
			arr[i]=sc.nextLine();
		}
		
		Arrays.sort(arr);
		for(int i=0;i<n;i++) {
			System.out.print(arr[i]);
		}

	}

}

Measured memory_bytes: 27656
#include <iostream>
int main(){
int W,H,x,y,r;
std::cin >>W>>H>>x>>y>>r;
if(0<=x-r&&x+r<=W&&0<=y-r&&y+r<=H){
std::cout <<"Yes"<<"\n";
}else{
std::cout <<"No"<<"\n";
}
return 0;
}

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

int main() {
	int N;
	cin >> N;
	set<string> S;
	rep(i, N) {
		string s;
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << endl;
	return 0;
}

Measured memory_bytes: 19224
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*
多倍長整数, cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	ll a, b, c, k;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	ll ans = 0;
	ans += min(a, k);
	k -= ans;
	k -= b;
	if (k > 0)ans -= k;
	printf("%lld\n", ans);

	Please AC;
}

Measured memory_bytes: 3808
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
 
const int MAX = 101;
const int SIZE = 1e5;
 
int main(){
  
    int n;
    cin >> n;
    vector <int> v(SIZE,0);
    for (int i = 1; i <= MAX; ++i){
        for (int j = 1; j <= MAX; ++j){
            for (int k = 1; k <= MAX; ++k){
                if (i*i + k*k + j*j + i*j + i*k + j*k <= 10000)
                v[i*i + k*k + j*j + i*j + i*k + j*k]++;
                
            }
        }
    }
    for (int i = 1; i <= n; ++i) cout << v[i] << endl;
 
 
}

Measured memory_bytes: 3112
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
using namespace std;
typedef pair<int, int> point;

int main(void) {
    int n, r=1;
    cin >> n;
    
    list<int> b;
    for(int i=1; i<=n; i++) {
        int a;
        cin >> a;
        if(r)
            b.push_back(a);
        else
            b.push_front(a);
        r=1-r;
    }
    
    if(r)for(auto i=b.begin();i!=b.end();i++)cout<<*i<<' ';
    else for(auto i=b.rbegin();i!=b.rend();i++)cout<<*i<<' ';

}


Measured memory_bytes: 8448
#include<stdio.h>
main()
{
    int a,b,i,j,sum=0,tem;
    scanf("%d %d",&a,&b);
    int c[a];
    for(i=0;i<a;i++)
        scanf("%d",&c[i]);
    for(i=0;i<a;i++)
    {
        for(j=i+1;j<a;j++)
            if(c[i]<c[j])
        {
            tem=c[i];
            c[i]=c[j];
            c[j]=tem;
        }
    }
    for(i=0;i<b;i++)
        sum=sum+c[i];
    printf("%d\n",sum);
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int to;
	ll cost;
	edge (int to, ll cost){
		this->to = to; this->cost=cost;
	}
};
 
int V,E;
typedef vector<edge> edges;


int n;
int visit[100005];
ll dist[100005];
vector<edges> G;

void dfs(int v, ll d) {
	dist[v] = d;
	visit[v] = true;
	for (auto e : G[v]) {
		if (visit[e.to] == false) {
			dfs(e.to, d + e.cost);
		}
	}
}

int main(){
	scanf("%d ", &n);
	G.resize(n+5);//
	rep(i, n-1) {
		int a, b, c;
		scanf("%d %d %d ", &a, &b, &c); //a--; b--;
		G[a].push_back(edge(b, c));
		G[b].push_back(edge(a, c));
	}
	int q, k;
	scanf("%d %d ", &q, &k);
	dfs(k, 0);
	rep(i, q) {
		int a, b;
		scanf("%d %d ", &a, &b);//
		cout << dist[a] + dist[b] << endl;
	}

	return 0;
}


Measured memory_bytes: 13184
// https://www.youtube.com/watch?v=UWbGRhF3Ozw
// https://atcoder.jp/contests/abc139/submissions/7330266
// https://qiita.com/drken/items/23a4f604fa3f505dd5ad#4-3-dag-%E3%81%AE%E3%83%88%E3%83%9D%E3%83%AD%E3%82%B8%E3%82%AB%E3%83%AB%E3%82%BD%E3%83%BC%E3%83%88
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;

class DAG {
  private:
    ll v, e;
    vector<vector<ll>> table;
    vector<ll> in_d; // 頂点の入力次数
    vector<ll> head;

  public:
    // v: 頂点数
    // e: 辺の数
    DAG(ll v) : v(v) {
        table.resize(v);
        in_d.resize(v);
        e = 0;
    }

    void add(ll from, ll to) {
        table[from].emplace_back(to);
        in_d[to]++;
        e++;
    }

    // O(v + e)
    vl sort() {
        stack<ll> st; // 入力次数が0の頂点集合
        for(int i = 0; i < v; i++) {
            if(in_d[i] == 0) {
                st.push(i);           // stack
                head.emplace_back(i); // head
            }
        }
        vl ans; // ソート後のグラフ

        while(!st.empty()) {
            ll in = st.top();
            st.pop();
            ans.emplace_back(in);
            for(auto &j : table[in]) {
                in_d[j]--;
                if(in_d[j] == 0)
                    st.push(j);
            }
        }

        return move(ans);
    }

    ll get_longest_path(void) {
        vector<bool> seen(v), calc(v);
        vector<ll> d(v, 0);
        auto dfs = [&](auto &&f, ll now) -> ll {
            if(seen[now]) {
                if(!calc[now])
                    return -1;
                return d[now];
            }
            seen[now] = true;
            d[now] = 1;
            for(auto &t : table[now]) {
                ll res = f(f, t);
                if(res == -1)
                    return -1;
                d[now] = max(res + 1, d[now]);
            }
            calc[now] = true;
            return d[now];
        };

        ll ans = 0;
        for(int i = 0; i < v; i++) {
            ll tmp = dfs(dfs, i);
            if(tmp == -1) {
                return -1;
            }
            ans = max(tmp, ans);
        }
        return ans;
    }
};

int main(void) {
    int V, E;
    cin >> V >> E;
    vector<int> s(E);
    vector<int> t(E);
    auto dag = DAG(V);
    for(int i = 0; i < E; i++) {
        cin >> s[i] >> t[i];
        dag.add(s[i], t[i]);
    }
    auto ans = dag.sort();
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

#define int 		long long
#define vi 			vector <int>
#define si 			set <int>
#define pii 		pair<int,int>
#define fr(n) 		for(__typeof(n) i=0;i<n;i++)
#define rep(i,a,b) 	for(__typeof(b) i=a;i<b;i++)
#define repi(i,b,a) for(__typeof(a) i=b;i>=a;i--)
#define tr(a) 		for(auto it=a.begin();it!=a.end();it++)
#define pb 			push_back
#define mp 			make_pair
#define F 			first
#define S 			second
#define FAST 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

void solve()
{
	int d,l,r;
	cin>>l>>r>>d;
	int ans=r/d - (l-1)/d;
	cout<<ans;
}

signed main()
{
	FAST
	int test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	cerr<<endl<<"Time elapsed : "<<time_passed<<endl;
	return 0;
}

Measured memory_bytes: 3792
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
typedef struct { int g, c, p; } j;
int main()
{
	string s;
	cin >> s;
	reverse(all(s));
	ll k = 1ll, r = 0;
	vector<ll> t;
	const ll M = 13;
	rep2(c, s) {
		if (c != '?')r += (c - '0') * k, r %= M;
		else t.push_back(k);
		k *= 10ll;
		k %= M;
	}
	vector<vector<ll>> dp(t.size() + 1, vector<ll>(13));
	dp[0][r]++;
	rep(i, 1, t.size() + 1) {
		rep(i2, 0, 13) {
			rep(i3, 0, 10) {
				dp[i][(i2 + t[i-1]*i3) % 13] += dp[i - 1][i2];
				dp[i][(i2 + t[i - 1] * i3) % 13] %= mod;
			}
		}
	}
	printf("%lld\n", dp[t.size()][5]);
	return 0;
}

Measured memory_bytes: 17232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}


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

	double x1, x2, x3;
    double y1, y2, y3;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    cin >> x3 >> y3;

    double a = hypot(abs(x1-x2), abs(y1-y2));
    double b = hypot(abs(x2-x3), abs(y2-y3));
    double c = hypot(abs(x3-x1), abs(y3-y1));
    double len = max(a, max(b, c));

    double s = (a+b+c)/2;
    double area = sqrt(s*(s-a)*(s-b)*(s-c));
    double r = area/s;

    double left = 0, right = r;
    double mid;
    for(int i=0; i<10000000; ++i){
        mid = (left+right)/2;
        if(2*mid*r <= len*(r-mid)) left = mid;
        else right = mid;
    }

    printf("%.15lf\n", left);
	
	return 0;
}


Measured memory_bytes: 256
def isEcho(N, S):
    if N % 2 != 0: # 偶数じゃなければ
        return False
    
    first_S = S[0:int(N/2)]
    last_S = S[int(N/2):N]
    if first_S == last_S:
        return True
    return False

N = int(input())
S = input()
isTrue = isEcho(N=N, S=S)
if isTrue:
    print('Yes')
else:
    print('No')

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

int main()
{
   ll n,x,t;
   cin>>n>>x>>t;
   if(n<=x)
   {
       cout<<t<<endl;return 0;
   }
   ll ans=0;
   ans+=(n/x)*t;
   if(n%x)
    ans+=t;
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int N,K;
  double top=0,total=0;
  int64_t x=0;
  vector<int> P(200000,0);
  vector<double> Q(1001,0);
  rep(i,1000){x+=i+1;Q.at(i+1)=x/((double)i+1);}
  cin>>N>>K;
  rep(i,N)
  {
    cin>>P.at(i);
    total+=Q.at(P.at(i));
    if(i<K){top=total;}
    else{total-=Q.at(P.at(i-K));top=max(total,top);}
  }
  cout<<fixed<<setprecision(12)<<top<<endl;
}

Measured memory_bytes: 1024
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-06 04:11:28
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int INF = 1e9 + 5;

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

  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  reverse(a.begin(), a.end());

  vector<int> dp(n, INF);

  for (int i = 0; i < n; ++i) {
    *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
  }

  //debug(dp);

  cout << distance(dp.begin(), lower_bound(dp.begin(), dp.end(), INF)) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   make_pair 
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
vll v(100000,0);

ll sum = 0;
ll md(ll n){
	if(n>0)return n;
	else return -n;
}

string str,str2;
void solve(){
	ll n,k,d;cin>>n>>k>>d;
	n=md(n);
	if(n/d>=k){
	    cout<<n-k*d;return;
	}
	ll k1=k-n/d;
	if(k1%2){
	    cout<<md(n-n/d*d-d);
	}
	else cout<<md(n-n/d*d);
}


int main(){

 
    	
	int t;
	t=1;
	//cin >> t;
	while(t--){
		solve();
		
	}
	
	
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3900
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), k=sc.nextInt(), r=sc.nextInt(),s=sc.nextInt(),p=sc.nextInt();
    String temp = sc.next();
	char[] t = temp.toCharArray();
    int ans=0;
    for(int i=0;i<n;i++){
      if(i>=k&&t[i]==t[i-k]){
        ans+=0;
        t[i]='n';
      }
	  else if(t[i]=='r')ans+=p;
      else if(t[i]=='s')ans+=r;
      else ans+=s;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26656
using System;
using System.Linq;

namespace _0598
{
	class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            char[,] flag = new char[x[0] + 2,x[1] + 2];
            for (int i = 0; i < x[0]; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < x[1]; j++) flag[i + 1,j + 1] = s[j];
            }
            char[,] emblem = new char[2,2];
            for (int i = 0; i < 2; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < 2; j++) emblem[i,j] = s[j];
            }
            int[,] flagcount = new int[x[0] + 2,x[1] + 2];
            int count = 0;
            for (int i = 1; i < x[0] + 1; i++)
            {
                for (int j = 1; j < x[1] + 1; j++)
                {
                    bool correct = true;
                    for (int k = 0; k < 2; k++)
                    {
                        for (int l = 0; l < 2; l++)
                        {
                            if (flag[i + k,j + l] != emblem[k,l]) correct = false;
                        }
                    }
                    if (correct)
                    {
                        count++;
                        for (int k = 0; k < 2; k++)
                        {
                            for (int l = 0; l < 2; l++)
                            {
                                flagcount[i + k,j + l]++;
                            }
                        }
                    }
                }
            }
            int ret = count;
            for (int i = 1; i < x[0] + 1; i++)
            {
                for (int j = 1; j < x[1] + 1; j++)
                {
                    char def = flag[i,j];
                    char[] JOI = new char[] { 'J','O','I' };
                    for (int k = 0; k < 3; k++)
                    {
                        flag[i,j] = JOI[k];
                        int now = count - flagcount[i,j];
                        for (int l = -1; l <= 0; l++)
                        {
                            for (int m = -1; m <= 0; m++)
                            {
                                bool correct = true;
                                for (int n = 0; n < 2; n++)
                                {
                                    for (int o = 0; o < 2; o++)
                                    {
										if (flag[i + l + n, j + m + o] != emblem[n, o]) correct = false;
                                    }
                                }
								if (correct) now++;
                            }
                        }
                        ret = Math.Max(ret,now);
                    }
                    flag[i,j] = def;
                }
            }
			Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 17696
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define ppi pair<int,pair<int,int> >
#define fr first
#define sc second
#define PI acos(-1)
#define mp make_pair

using namespace std;

#define sim template < class c

#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



char c[10];
int cnt[26];
int main()
{

    int n; cin >> n;
    map<vector<pair<int,int>>,int>m;
    ll ans = 0;
    for(int i = 0;i<n;i++){
        scanf("%s",c);
        memset(cnt,0,sizeof cnt);
        for(int j = 0;j<10;j++){
            c[j]-='a' , cnt[c[j]] ++ ;
        }
        vector<pair<int,int>>v;
        for(int j = 0;j<26;j++)
            if(cnt[j])v.push_back({j,cnt[j]});
        ans += m[v]++;
    }
    //debug() << imie(m);
    cout << ans << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  bool H=0;

  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(S=="Y"){
      H=1;
    }
  }
  
  if(H==0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" <<endl;
  }
    
    
}


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

int n, A[50];

int solve( int i, int m){
    int res;
    if( m == 0) return 1;
    if( i >= n ) return 0;
    res = solve( i + 1, m) || solve( i + 1, m - A[i]);
    return res;
}

int main(){
    int i, q, m;
    cin >> n;
    for( i = 0; i < n; i++) cin >> A[i];
    cin >> q;
    for( i = 0; i < q; i++){
        cin >> m;
        if( solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int a[5],k;
    for(int i = 0 ; i < 5 ; i++)
        cin >> a[i] ;
    cin >> k ;
    for(int i = 0 ; i < 5 ; i++){
        for(int j = i ; j >= 0 ; j--){
            if(abs(a[i]-a[j]) > k){
                cout << ":(" ;
                return 0 ;
            }
        }
    }
    cout << "Yay!";


























return 0 ;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main{

  public static void main (String[] args){
    
    Scanner scanner = new Scanner (System.in);
    
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    String[] list = new String[H];
    
    scanner.nextLine();
    for(int i=0; i<H; i++){
      String temp = scanner.nextLine();
      list[i] = temp;
    }
    
    for(int i=0; i<W+2; i++){
      System.out.print("#");
    }
    System.out.println();
    
    for (int i=0; i<H; i++){
      System.out.print("#");
      System.out.print(list[i]);
      System.out.println("#");
    }
    for(int i=0; i<W+2; i++){
      System.out.print("#");
    }
    System.out.println();
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, K;
    cin >> A >> B >> K;
    ll d = min(A, K);
    A -= d;
    K -= d;
    B = max(0LL, B - K);
    cout << A << " "<< B << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = gets.split(" ").map(&:to_i)
l=[]; r = []
M.times do |i|
  l[i], r[i] = gets.split(" ").map(&:to_i)
end
lt = l[0]; rt = r[0]
1.upto(M-1) do |i|
  if l[i] > lt
    lt = l[i]
  end
  if r[i] < rt
    rt = r[i]
  end
end
rslt = rt - lt + 1
if rslt > 0
  puts rslt
else
  puts 0
end

Measured memory_bytes: 16188
/************************** C ******************************/
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
	int N = 0;
	cin >> N;
	int T[N], A[N];
	for(int i = 0; i < N; i++){
		cin >> T[i] >> A[i];
	}
	long long votes[2];
	votes[0] = T[0];
	votes[1] = A[0];
	/* this is too slow */
	// for(int i = 1; i < N; i++){
	// 	while(votes[0] * A[i] != votes[1] * T[i]){
	// 		if(votes[0] * A[i] < votes[1] * T[i]) votes[0]++;
	// 		else if(votes[0] * A[i] > votes[1] * T[i]) votes[1]++;
	// 	}
	// }
	for(int i = 1; i < N; i++){
		long long n = votes[0]%T[i]? votes[0]/T[i] + 1 : votes[0]/T[i];
		n = max(n, (votes[1]%A[i]? votes[1]/A[i] + 1 : votes[1]/A[i]));
		votes[0] = T[i] * n;
		votes[1] = A[i] * n;
	}
	cout << votes[0] + votes[1] << endl;

	return 0;
}

Measured memory_bytes: 256