akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

int A, B;

int main() {
    cin >> A >> B;
    cout << max(2*max(A, B)-1, A+B) << endl;
}

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

int main(){
    double answer,x1,x2,y1,y2,a,b;
    cin >> x1 >> y1 >> x2 >> y2;

    a = pow(x1 - x2, 2.0);
    b = pow(y1 - y2, 2.0);
    answer = sqrt(a + b);
    //cout << answer << endl;

    printf("%lf\n",answer);  

    return 0;

}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 10000

typedef pair<long, long> P;

long N, d[MAX_N];
vector<P> edge[MAX_N];

void dijkstra(){
    bool seen[N];
    fill(seen, seen + N, false);
    priority_queue<P, vector<P>, greater<P> > todo;
    todo.push(P(0, 0));
    
    while(!todo.empty()){
        long dist = todo.top().first, v = todo.top().second;
        todo.pop();
        if(seen[v]) continue;
        d[v] = dist;
        seen[v] = true;
        for(long i = 0; i < edge[v].size(); i++){
            long w = edge[v][i].second, u = edge[v][i].first;
            if(d[v] + w < d[u]){
                d[u] = d[v] + w;
                todo.push(P(d[u], u));
            }
        }
    }
}

int main(){
    cin >> N;
    fill(d, d + MAX_N, LONG_MAX);
    for(long i = 0; i < N; i++){
        long v, k, u, c;
        cin >> v >> k;
        for(long j = 0; j < k; j++){
            cin >> u >> c;
            edge[v].push_back(P(u, c));
        }
    }
    
    dijkstra();
    
    for(long i = 0; i < N; i++)
        cout << i << " " << d[i] << endl;
    
    return 0;
}


Measured memory_bytes: 12196
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,k;
	cin>>n>>k;
	n=n-k;
	if(k==1){
		cout<<"0";
	}
	else cout<<n;
	return 0;
}


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

struct Edge {
    int from, to, cost;
    Edge(int f, int t, int c) : from(f), to(t), cost(c) { }
    bool operator <(const Edge& e) const {
        return cost < e.cost;
    }
};

struct UnionFind {
    vector<int> data;
    UnionFind(int n) : data(n, -1) { }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }

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

    void merge(int x, int y) {
        x = root(x), y = root(y);
        if(x != y) {
            data[x] += data[y]; data[y] = x;
        }
    }
};

int main() {
    int N; cin >> N;
    vector<Edge> es;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            int c; cin >> c;
            if(c != -1) {
                es.push_back(Edge(i, j, c));
            }
        }
    }
    sort(es.begin(), es.end());
    UnionFind uf(N);
    int ans = 0;
    for(int i = 0; i < (int)es.size(); i++) {
        int from = es[i].from;
        int to = es[i].to;
        int cost = es[i].cost;
        if(uf.same(from, to)) continue;
        uf.merge(from, to);
        ans += cost;
    }
    cout << ans << endl;
}

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

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    long long g = gcd(a, b);
    return a / g * b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
   int a[100001]={},b[100002]={},n,h;
   int cnt=0,sum=0,i;
   cin>>n>>h;
   for(i=0;i<n;i++){
       cin>>a[i]>>b[i];
       if(a[0]<a[i])a[0]=a[i];
   }
   sort(b,b+i,greater<int>());
   while(1){
       if(b[cnt]>=a[0]){sum+=b[cnt];cnt++;}
       else break;
       if(sum>=h)break;
   }
   if(h-sum>0)cnt+=(h-sum)/a[0];
   if(h-sum>0&&(h-sum)%a[0]!=0)cnt++;
   cout<<cnt<<endl;
   return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    for (ll i=0; i<N; ++i) {
        cin >> V[i];
    }

    ll res = 0;
    for (int p=0; p<=min(N, K); ++p) {
        for (int q=0; p+q<=min(N, K); ++q) {
            vector<ll> v;
            ll cur = 0;
            for (int i=0; i<p; ++i) {
                v.push_back(V[i]);
                cur += V[i];
            }
            for (int i=0; i<q; ++i) {
                v.push_back(V[N-1-i]);
                cur += V[N-1-i];
            }
            sort(v.begin(), v.end());
            for (int k=0; k<min(K-p-q, (ll)v.size()); ++k) {
                if (v[k] < 0) cur -= v[k];
            }
            res = max(res, cur);
        }
    }
    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
    
def main(*args, **kwargs):
    # Initialize data
    H, W = map(int, sys.stdin.readline().split())
    total_cells = H * W
    existing_black_cells = 0
 
    grid = []
    for i in range(H):
        line = sys.stdin.readline()
        existing_black_cells += line.count('#')
        grid.append(line)
 
    # Initialize Search
    queue = deque()
    queue.append((0, 0))  # start point
    visited = set()
    visited.add((0, 0))
    movement = 0
 
    while len(queue) > 0:
        movement += 1
        for i in range(len(queue)):  # Process same level
            coodinate = queue.popleft()
            y = coodinate[0]
            x = coodinate[1]
 
            # Terminate condition
            if y == H - 1 and x == W - 1:
                print(total_cells - movement - existing_black_cells)
                return
 
            for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
                X = x + dx
                Y = y + dy
                adjacent = (Y, X)
                if 0 <= X < W and 0 <= Y < H and grid[Y][X] == '.' and adjacent not in visited:
                    queue.append(adjacent)
                    visited.add(adjacent)
    print(-1)
    return
main()

Measured memory_bytes: 40560
N, K = map(int, input().split())
TD = [tuple(map(int, input().split())) for _ in range(N)]
M = len(set([t for t, d in TD]))

TD.sort(key=lambda x: x[1], reverse=True)
p, S, V = 0, [], set()
for t, d in TD[:K]:
    p += d
    if t in V:
        S.append(d)
    else:
        V.add(t)
p += len(V) ** 2
ans = p
for t, d in TD[K:]:
    if len(S) == 0:
        break
    if t not in V:
        p += 2 * len(V) + 1 - S.pop() + d
        V.add(t)
        ans = max(ans, p)
print(ans)


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

int main() {  
  int n, r = 0;
  string s;
  cin >> n >> s;
  for(int i = 0; i < (int)s.size(); i++) {
    if(s[i] == 'R') r++;
  }
  cout << ( r > n-r ?"Yes" :"No") << "\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		MSPrimeGenerator msp = new MSPrimeGenerator();
		
		while (true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 1){
				break;
			}
			
			System.out.println(solve(n, msp));
		}

	}
	
	static String solve(int n, MSPrimeGenerator msp){
		StringBuffer sb = new StringBuffer();
		sb.append(n+":");
		
		for(int i = 6; i <= n; i++){
			if(n%i == 0 && msp.isPrime(i)){
				sb.append(" "+i);
			}
		}
		
		return sb.toString();
	}

}

class MSPrimeGenerator {
    private final int N = 300000;
    private boolean[] isPrime= new boolean[N + 1];
 
    public MSPrimeGenerator() {
        Arrays.fill(isPrime, true);
 
        isPrime[0] = false;
        isPrime[1] = false;
 
//        int limit = (int)Math.sqrt(N);
        for(int i = 6; i <= N ; i++){
 
            if(isPrime[i] == false){
                continue;
            }
            
            if(!(i%7 == 1 || i%7 == 6)){
            	isPrime[i] = false;
            	continue;
            }
 
            for(int j = i * 2; j <= N; j += i){
                isPrime[j] = false;
            }
        }
    }
 
    public boolean isPrime(int index){
        return isPrime[index];
    }
}



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

int main(){
    int i, j, a, b, q;
    string s, ssub, p, ins;
    cin >> s >> q;
    for (i = 0; i < q;i++){
        cin >> ins;
        if (ins == "print"){
            cin >> a >> b;
            cout << s.substr(a, b - a + 1) << endl;
        } else if (ins == "reverse"){
            cin >> a >> b;
            ssub = s.substr(a, b - a + 1);
            for (j = 0; j < b - a + 1; j++){
                s[a + j] = ssub[b - a - j];
            }
        } else if (ins == "replace"){
            cin >> a >> b >> p;
            s = s.replace(a, b - a + 1, p);
        }
    }
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (a == b){
        if (b == c){
            cout << 1 << endl;
        }
        else{
            cout << 2 << endl;
        }
    }
    else if (a == c){
        cout << 2 << endl;
    }
    else if (b == c){
        cout << 2 << endl;
    }
    else{
        cout << 3 << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}

int main () {
  int D;
  cin >> D;
  vector<int>les(26, 0);
  array<int, 26>c;
  for (int i = 0; i < 26; i ++) cin >> c.at(i);
  for (int i = 0; i < D; i ++) {
    array<int, 26>s;
    for (int j = 0; j < 26; j ++) {
      cin >> s.at(j);
    }
    pair<int, int>t = make_pair(0, 0);
    int t_ = -1;
    for (int j = 0; j < 26; j ++) {
      pair<int, int> kj = make_pair(s.at(j), -1 * c.at(j) * les.at(j));
      int p_ = j;
      if (t < kj) {
        t = kj;
        t_ = p_;
      }
      else if (t == kj && c.at(t_) < c.at(p_)) {
        t = kj;
        t_ = p_;
      }
    }
    cout << t_ + 1 << endl;
    for (int j = 0; j < 26; j ++) {
      if (j == t_) les.at(j) = 0;
      else les.at(j) ++;
    }
  }
}






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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var Q = int.Parse(Console.ReadLine());
            var simi = new int[100001];
            for (int i = 1; i < 100001; i++)
            {
                if (i % 2 == 0)
                {
                    simi[i] = simi[i - 1];
                }else
                {
                    if (IsPrime(i) && IsPrime((i + 1) / 2))
                    {
                        simi[i] = simi[i - 1] + 1;
                    }else
                    {
                        simi[i] = simi[i - 1];
                    }
                }
            }

            for (int i = 0; i < Q; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                Console.WriteLine(simi[input[1]] - simi[input[0] - 1]);
            }
        }

        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            for (int i = 3; i <= Math.Sqrt(num); i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }

            return true;
        }
    }
}

Measured memory_bytes: 17976
#include <stdio.h>
int main() {
  int a[3][3];
  int c[3][3];
  int result;

  int i, j = 0;
  while(i < 3) {
    j = 0;
    while(j < 3) {
      scanf("%d", &a[i][j]);
      j++;
    }
    i++;
  }

  int n;
  scanf("%d", &n);

  int b[n];
  int k = 0;
  while(k < n) {
    scanf("%d", &b[k]);
    k++;
  }

  i = 0;
  while(i < 3) {
    j = 0;
    while(j < 3) {
      k = 0;
      while(k < n) {
        if(b[k] == a[i][j]) {
          c[i][j] = 1;
          break;
        } else {
          c[i][j] = 0;
        }
        k++;
      }
      j++;
    }
    i++;
  }

  if (
    (c[0][0] && c[1][0] && c[2][0]) || (c[0][1] && c[1][1] && c[2][1]) || (c[0][2] && c[1][2] && c[2][2]) ||
    (c[0][0] && c[0][1] && c[0][2]) || (c[1][0] && c[1][1] && c[1][2]) || (c[2][0] && c[2][1] && c[2][2]) ||
    (c[0][0] && c[1][1] && c[2][2]) || (c[0][2] && c[1][1] && c[2][0])
  ) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

int main() {

    IO; 

    ll m,n;
    cin>>m>>n;
    char c[m][n];
    char d[2*m][n];
    for(ll i=0;i<m;i++){
        for(ll j=0;j<n;j++){
            cin>>c[i][j];
        }
    }
    for(ll i=0;i<2*m;i++){
        for(ll j=0;j<n;j++){
            cout<<c[(i)/2][j];
        }
        cout<<endl;
    }
    
    

}

Measured memory_bytes: 256
def dfs(n):
    if n == 1:
        return d
    if n == 0:
        return 0
    if n in dic:
        return dic[n]
    ans = min(n * d, dfs(n // 2) + a + (n % 2) * d, dfs((n + 1) // 2) + a + ((-1 * n) % 2) * d, dfs(n // 3) + b + (n % 3) * d, dfs((n + 2) // 3) + b + ((-1 * n) % 3) * d, dfs(n // 5) + c + (n % 5) * d, dfs((n + 4) // 5) + c + ((-1 * n) % 5) * d)
    dic[n] = ans
    return ans
t = int(input())
for i in range(t):
    n, a, b, c, d = map(int, input().split())
    dic = dict()
    print(dfs(n))

Measured memory_bytes: 11004
#include<iostream>
#include<vector>
#include<algorithm>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  vector<vector<int> > len,tree;
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;

  HeavyLight(vector<vector<int> > t)
    :tree(t),n(tree.size()),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 24696
// 2012/05/14 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1){
		prime[0] = false;
	}
	if(n>=2){
		prime[1] = false;
	}

	for(int i=2; i<n; i++){
		prime[i] = true;
	}

	for(int i=2; i*i<n; i++){
		if(!prime[i])
			continue;

		for(int j=i+i; j<n; j+=i){
			prime[j] = false;
		}
	}
}

int main()
{
	bool P[246913];
	eratos(P, 246913);

	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int cnt = 0;
		for(int i=n+1; i<=2*n; i++){
			if(P[i]){
				cnt++;
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>


using namespace std;


int sum(int n) {
    return n * (n + 1) / 2;
}

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

    int diff = b - a;
    int x = -1;
    for (int i = 1; i < 999; ++i) {
        int d = sum(i + 1) - sum(i);
        if (d == diff) {
            x = sum(i) - a;
            break;
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 888
import numpy as np
n, l = list(map(int, input().split()))
ringos = np.array([l + i for i in range(n)])
eatringo = min(np.abs(ringos))
if eatringo in ringos :
    print(sum(ringos)-eatringo)
else :
    print(sum(ringos)+eatringo)

Measured memory_bytes: 21924
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				int temp = sc.nextInt() - 1;
				A[i][temp] = 1;
				//System.out.println(i + ":" + temp);
			}
		}
		
		int flag[] = new int[M];
		for(int i = 0; i < M; i++) {
				flag[i] = 1;
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				if(A[i][j] != 1) {
					//System.out.println(i + " : " + j);
					flag[j] = 0;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(flag[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[60][2];
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    ll K;
    cin >> n >> K;
    ll A[100100];
    rep(i,0,n) cin >> A[i];
    rep(i,0,60){
      dp[i][0] = -1;
      dp[i][1] = -1;
    }
    dp[45][0] = 0LL;
    for(int i=44;i>=0;i--){
        ll add = 1LL << i;
        ll cnt = 0;
        rep(i,0,n) if(A[i] & add) cnt++;
        if(dp[i+1][1] >= 0){
                chmax(dp[i][1], dp[i+1][1] + add * max(n-cnt, cnt));
        }
        if(dp[i+1][0] >= 0){
            if(K & (1LL << i)){
              chmax(dp[i][1], dp[i+1][0] + add * cnt);
              chmax(dp[i][0], dp[i+1][0] + add * (n-cnt));
            }else{
              chmax(dp[i][0], dp[i+1][0] + add * cnt);
            }   
        }
    }

    ll ans = max(dp[0][0], dp[0][1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4376
#include<iostream>
using namespace std;
int main(){
    int f=1,n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        if(f*2 > f+k){
            f+=k;
        }else{
            f*=2;
        }
    }
    cout << f << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final int COUNT = 4;
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		String[] dice = str.split(" ");
		str = scan.nextLine();
		String[] direction = str.split("");
		
		//??±=>E, ?\?=>W, ???=>S, ???=>N
		for (int i = 0; i < direction.length; i++) {
			if(direction[i].equals("E")){
				str = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = str;
			}else if(direction[i].equals("W")){
				str = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = str;
			}else if(direction[i].equals("S")){
				str = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = str;
			}else if(direction[i].equals("N")){
				str = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = str;
			}
		}
		System.out.println(dice[0]);
		
	}
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    int a[n + 1], b[n + 1];
    int c[10001] = {};

    rep(i, n)
    {
        cin >> a[i + 1];
        c[a[i + 1]]++;
    }

    for (int i = 1; i <= 10000; i++)
    {
        c[i] += c[i - 1];
    }

    for (int i = 1; i <= n; i++)
    {
        b[c[a[i]]] = a[i];
        c[a[i]]--;
    }

    for (int i = 1; i <= n; i++)
        i != n ? cout << b[i] << " " : OP(b[i]);

    return 0;
}


Measured memory_bytes: 18732
#! /usr/bin/env python3

def gcd(m, n):
    while n: m, n = n, m % n
    return m

def lcm(m, n):
    return m // gcd(m, n) * n

class congruence(object):
    def __init__(self):
        self.sol = 0
        self.mod = 1
    def append(self, a, q):
        x = self.sol
        p = self.mod
        l = lcm(p, q)
        while x < l:
            if (x % q) == a:
                self.sol = x
                self.mod = l
                return
            x += p
        else:
            raise ValueError('nyan')
    def get(self):
        return (self.sol, self.mod)

def main():
    N, M, D = list(map(int, input().split()))
    A = list(map(int, input().split()))

    for i in range(D):
        R = list(map(int, input().split()))
        crt = congruence()
        for r, a in zip(R, A):
            if r == -1: continue
            crt.append(r, a)

        x, p = crt.get()
        if N < x:
            print(-1)
            return 0

        y = (N-x) // p * p + x
        if not 0 <= y <= N:
            print(-1)
            return 0

        N = y

    print(N)
    return 0

try:
    main()
except ValueError:
    print(-1)



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

int main() {
  
  int N; cin >> N;
  
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 15; j++) {
      if (i * 4 + j * 7 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x)) 
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
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; }

using namespace std;
struct Info
{
    int a;
    int b;

    Info() {}
    Info(int a, int b)
    {
      this->a = a;
      this->b = b;
    }
    bool operator<(const Info &another) const
    {
        return b < another.b;
    };
};

vector<Info> is;
int main() {
  int n, a, b;
  cin >> n;
  rep(i, n) {
    cin >> a >> b;
    Info* in = new Info(a, b);
    is.push_back(*in);
  }
  sort(is.begin(), is.end());
  int pre = is[0].b;
  int l = 0;
  int i = 0;
  for(auto e : is){
    l += e.a;
    if(l > e.b) {
      cout << "No" << endl;
      return 0;
    }

  }
  cout << "Yes" << endl;
}



Measured memory_bytes: 8048
N = int(input())
import sys

all_list = []
counter = 1
for line in sys.stdin:
    a, b = [int(x) for x in line.strip().split(" ")]
    all_list += [("a", counter, a), ("b", counter, b)]
    counter += 1

all_list = sorted(all_list, key = lambda x : x[2])

sp_c = all_list[N][1]
sp_i_p = all_list[N][2]
sp_i_pp = all_list[N+1][2]

flag = True
ss = sum([i[2] for i in all_list[:N]])
d = set()
temp = None
for ab, c, i in all_list[:N]:
    if temp != None and temp != ab:
        flag = False
    if c in d:
        flag = True
        break
    d.add(c)
    temp = ab
if flag:
    print(ss)
else:
    candidates = []
    for ab, c, i in all_list[:N]:
        if sp_c != c:
            candidates.append(ss - i + sp_i_p)
        else:
            candidates.append(ss - i + sp_i_pp)
    print(min(candidates))


Measured memory_bytes: 38000
#include<bits/stdc++.h>
typedef long long ll;
#define vll vector<long long> 
#define pll pair<ll,ll>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define all(v)  (v).begin(),(v).end()
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main(){
	ll n,x=0;cin>>n;
	ll a[n];
	f(i,0,n){
		cin>>a[i];
		x = x^a[i];
	}
	f(i,0,n){
		ll ans = a[i]^x;
		cout<<ans<<" ";
	}
	cout<<"\n";
}

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

int main(){
    int N;
    string S;
    cin >> S;
    N= (int) S.size()+1;
    int a[N];
    int iflag;
    long ans;
    bool flag;

    flag=false;
    for(int i=0; i<N-1; i++){

        if(i==0){
            a[i]=0;
        }

        if( flag ){
            if( S[i]=='<' ){
                for(int j=iflag; j<=i; j++){
                    if( a[i]>0 && j==iflag ){
                        continue;
                    }
                    a[j]=a[j]-a[i];
                }
                a[i+1]=a[i]+1; //always 1
                flag=false;
            }else{
                //cout << "true i+1= " << i+1 << endl;
                a[i+1]=a[i]-1;
            }
        }else{
            if( S[i]=='>' ){ //flag on
                flag=true;
                iflag=i;
                //cout << "iflag= " << iflag << endl;
                a[i+1]=a[i]-1;
            }else{
                a[i+1]=a[i]+1;
            }
        }
    }

    if( flag ){
        for(int j=iflag; j<=N-1; j++){
            if( a[N-1]>0 && j==iflag ){
                continue;
            }
            a[j]=a[j]-a[N-1];
        }        
        flag=false;
    }

    ans=0;
    //cout << a[0] << " ";
    ans+= (long) a[0];
    for( int i=0; i<N-1; i++ ){
        //cout << S[i] << " " << a[i+1] << " ";
        ans+= (long) a[i+1];
    }
    //cout << endl;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 1e9+7;

int main() {
    int N,f,r=-INF;
    cin >> N;
    vector<int> F(N,0);
    vector<vector<int>> P(N, vector<int>(11));

    rep(i,N)
        rep(j,10) {
            cin >> f;
            F.at(i) += pow(2,9-j)*f;
        }

    rep(i,N)
        rep(j,11)
            cin >> P.at(i).at(j);
    
    rep(i,pow(2,10)-1) {
        int tr=0;
        rep(j,N) {
            int t=(i+1)&F.at(j), c=0;
            rep(k,10)
                if(t>>k & 1)
                    ++c;
            tr += P.at(j).at(c);
        }
        r = max(r,tr);
    }

    cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int MAX = 1000000000;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s;
    cin >> s;
    int x2, x3, y2, y3;

    for (x2 = MAX; x2 >= 1; x2--)
    {
        if (s % x2 == 0)
        {
            y3 = s / x2;
            x3 = 0;
            y2 = 0;
            break;
        }
        else
        {
            x3 = x2 - (s % x2);
            y2 = 1;
            y3 = (s + x3) / x2;

            break;
        }
    }

    cout << 0 << " " << 0 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, x, b = 1, count = 0;
	cin >> n >> x;
	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l.at(i);
	}
	for (int i = 0; i < n; i++) {
		count += l.at(i);
		if (count <= x) {
			b++;
		}
		else {
			break;
		}
	}
	cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0;
  cin >> N;
 
  long old_L = 2LL;
  long old_A = 1LL;
  long new_A = 1LL;
  
  for (int i = 1; i < N; i++) {
    new_A = old_L + old_A;
    old_L = old_A;
    old_A = new_A;
  }
  
  cout << new_A << endl;
}

Measured memory_bytes: 3628
//https://atcoder.jp/contests/arc072/tasks/arc072_a 
#include<bits/stdc++.h>
using namespace std;//前缀和正负想错的最小修改次数 
#define ll long long
const int N=1e5+100;
ll a[N],sum; 
ll ans1,ans2; 
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	ans1=0;
	sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		if(i&1)
		{
			if(sum<=0) ans1+=1-sum,sum=1;
			 
		} 
		else 
		{
			if(sum>=0) ans1+=sum+1,sum=-1;;
			 
		} 
	} 
	ans2=0;
	sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		if(i%2==0)
		{
			if(sum<=0) ans2+=1-sum,sum=1;;
			 
		} 
		else 
		{
			if(sum>=0) ans2+=1+sum,sum=-1;;
			 
		} 
	} 
	cout<<min(ans1,ans2)<<endl;
	return 0;
} 

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

using namespace std;

int main(){
    long long h, w;
    cin >> h >> w;
        
    vector<long long> sz, sz2;
    long long minx = 1000000000000000;
    for(int i=1;i<h;i++){
        sz = {i*w, (h-i)*(w/2), (h-i)*(w-w/2)};
        sz2 = {i*w, (h-i)/2*w, (h-i-(h-i)/2)*w};
        sort(sz.begin(), sz.end());
        sort(sz2.begin(), sz2.end());
        minx = min(minx, sz[2]-sz[0]);
        minx = min(minx, sz2[2]-sz2[0]);

        
    }
    for(int i=1;i<w;i++){
        sz = {i*h, (w-i)*(h/2), (w-i)*(h-h/2)};
        sz2 = {i*h, (w-i)/2*h, (w-i-(w-i)/2)*h};
        sort(sz.begin(), sz.end());
        sort(sz2.begin(), sz2.end());
        minx = min(minx, sz[2]-sz[0]);
        minx = min(minx, sz2[2]-sz2[0]);
    }
    cout << minx << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
//------------------------------------------------------------
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer[] sticks = new Integer[n];
		for (int i=0;i<n;i++) {
			int stick=sc.nextInt();
			sticks[i] =stick;
		}
		Arrays.sort(sticks,Collections.reverseOrder());

		int longSnake =0;
		for (int i=0;i<k;i++) {
			longSnake += sticks[i];
		}
		System.out.println(longSnake);
//------------------------------------------------------------
	}
}

Measured memory_bytes: 21840
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// 2
// 158260522 877914575
// 24979445 602436426
// 1297111035

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

    vector<long long> min_array(N);
    vector<long long> max_array(N);

    for(int i=0; i<N; ++i){
        long long A, B; cin >> A >> B;
        min_array[i] = A;
        max_array[i] = B;
    }

    double max = 1e9;
    double min = 1;
    double res = 1;

    sort(min_array.begin(), min_array.end());
    sort(max_array.begin(), max_array.end());
    if(min_array.size()%2 == 1){
        min = min_array[N/2];
        max = max_array[N/2];
        res = max - min +1;
    }else{
        min = (min_array[N/2] + min_array[N/2-1])/2.0;
        max = (max_array[N/2] + max_array[N/2-1])/2.0;
        res = (max - min)*2.0 +1.0;
    }

    cout << (long long)res << endl;
}

Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
#define MAX 10001

vector< pair<int,int> > p[MAX];
int b[MAX],c[MAX];

int main(){
	int N,M;	cin>>N>>M;
	int S,T,E;
	while(1){
		cin>>S>>T>>E;	if(S==0 && T==0 && E==0)break;
		p[S].push_back({T,E});
	}

	int L;	cin>>L;
	for(int i=0;i<L;i++){
		for(int j=1;j<=M;j++){
			cin>>b[j];
		}

		for(int j=1;j<=N;j++){
			if(j>1)cout<<" ";
			c[j]=0;
			for(pair<int,int>tmp:p[j]){
				int work=tmp.first, cnt=tmp.second;
				c[j]+=b[work]*cnt;
			}
			cout<<c[j];
		}
		cout<<endl;

	}

	return 0;
}



Measured memory_bytes: 4144
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	sort.Ints(p)

	ans := 0
	for i := 0; i < k; i++ {
		ans += p[i]
	}

	fmt.Println(ans)
}


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

int main() {
  int k;
  cin >> k;
  int x = 7%k;

  for (int i = 1; i <= k; ++i) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    x = (x*10+7)%k;
  }
  cout << -1 << endl;
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1e8
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define POW (long long)pow
#define BIT(i) (long long)pow(2, i)
typedef long long Lint;

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> vcNumProb;
  vector<int> vcBonusScore;
  REP(i, d) {
    int p, c;
    cin >> p >> c;
    vcNumProb.push_back(p);
    vcBonusScore.push_back(c);
  }

  int ans = INF;
  REP(k, BIT(d)) {
    int nSolved = 0, nNowScore = 0;
    REP(category, d) {
      if (k & BIT(category)) {
        nSolved += vcNumProb[category];
        nNowScore +=
            vcNumProb[category] * (category + 1) * 100 + vcBonusScore[category];
      }
    }

    vector<int> vcUnsolvedCategory;
    for (int category = d - 1; category >= 0; category--) {
      if ((k & BIT(category)) == 0) {
        vcUnsolvedCategory.push_back(category);
      }
    }

    while (nNowScore < g and vcUnsolvedCategory.size()) {
      int nNowCategory = vcUnsolvedCategory[0];
      int nSolvedInNowCategory = 0;
      while (nNowScore < g and
             nSolvedInNowCategory < vcNumProb[nNowCategory] - 1) {
        nNowScore += (nNowCategory + 1) * 100;
        nSolved++;
        nSolvedInNowCategory++;
      }
      vcUnsolvedCategory.erase(vcUnsolvedCategory.begin());
    }
    if (nNowScore >= g) {
      ans = min(ans, nSolved);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from pprint import pprint

bingo = [[] for _ in range(3)]
for i in range(3):
    bingo[i] = list(map(int, sys.stdin.readline().strip().split()))

N = int(sys.stdin.readline().strip())
B = set()
for _ in range(N):
    B.add(int(sys.stdin.readline().strip()))

bingo_flag = False
for i in range(3):
    tmp = []
    for j in range(3):
        if bingo[i][j] not in B:
            break
    else:
        bingo_flag = True

for i in range(3):
    for j in range(3):
        if bingo[j][i] not in B:
            break
    else:
        bingo_flag = True

for i in range(3):
    if bingo[i][i] not in B:
        break
else:
    bingo_flag = True

for i in range(3):
    if bingo[2-i][i] not in B:
        break
else:
    bingo_flag = True


if bingo_flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3700
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<pair<int ,pair<int,int> > >v(n);
	
	for(int i=0;i<n;++i){
		int a,b,c;
		cin >> b >> c;
		a = c;
		pair<int,int> tmp = pair<int,int>(b,c);
		v[i] = pair<int,pair<int,int> >(a,tmp);
	}
	
	//,grater<int,pair<int,int> >()
	sort(v.begin(),v.end());
	
	bool f = true;
	int cur = 0;
	for(int i=0;i<n;++i){
		int a = v[i].first;
		int b = v[i].second.first;
		int c = v[i].second.second;
//		cout << cur << endl;
		cur += b;
//		cout << cur <<endl;
//		cout << a << " " << b << " " << c <<endl;
		if(cur >  c){
			f = false;
			break;
		}
	}
	
	if(f) cout << "Yes" << endl;
	else cout << "No" <<endl;
	
	return 0;
}


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

int main()
{
	long long N,K;
	cin >> N >> K;
	long long solution;
	solution = 0;
	for(long long i = K; i <= N + 1;i++)
	{
		solution += i*(N-i+1)+1 ;
		solution = solution % 1000000007;
	}
	cout << solution << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int n;
  cin>>n;
  cout<<jo(n,3);

      
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//

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

int main() {
    string s;
    cin >>s;
    string t;
    cin >>t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if(s.at(i) == t.at(i))ans++;
    }
    cout << s.length() - ans <<endl;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    for(ll i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for(ll i = 0; i < N; i++){
        cin >> B.at(i);
    }
    for(ll i = 0; i < N; i++){
        cin >> C.at(i);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    ll key, sum = 0;
    for(ll i = 0; i < N; i++){
        key = B.at(i);
        vector<ll>::iterator d1, d2;
        d1 = lower_bound(A.begin(), A.end(), key);
        d2 = upper_bound(C.begin(), C.end(), key);
        ll rd1 = distance(A.begin(), d1);
        ll rd2 = N - distance(C.begin(), d2);

        sum += rd1 * rd2;
    }
    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m;
typedef pair<int,int> pii;
#define ull unsigned long long
const int maxn = 5000+10;
const ll inf=1e18;
int u[maxn],v[maxn],c[maxn];
ll d[maxn];
int main(void)
{
    int n,m,p;cin>>n>>m>>p;
    for(int i = 2;i <= n;++i)
        d[i] = -inf;
    for(int i = 1;i <= m; ++i){
        scanf("%d%d%d",&u[i],&v[i],&c[i]);
        c[i] -= p;
    }
    for(int i = 1;i <= 2*n; ++i){
        for(int j = 1;j <= m; ++j){
            if(d[u[j]]==-inf) continue;
            if(d[v[j]] < d[u[j]]+c[j]) d[v[j]] = i <= n?d[u[j]]+c[j]:1e18;
        }
    }
    if(d[n] == inf)
        cout<<-1<<endl;
    else
        cout<<max(0LL,d[n])<<endl;

    return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, W;
  cin >> N >> W;
  int v[111], w[111], m[111];
  FOR(i,0,N) cin >> v[i] >> w[i] >> m[i];
  int dp[10010] = {};
  FOR(i,0,N) {
    // 0 ~ 7 -> 1, 2, 4
    for(int k = 0; m[i] > 0; k++) {
      int key = min(m[i], (int)(1<<k));
      m[i] -= key;
      for(int j = W; j - key * w[i] >= 0; j--) {
        dp[j] = max(dp[j], dp[j - key * w[i]] + v[i] * key);
      }
    }
  }
  int ans = 0;
  FOR(i,0,W+1) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  
  int A[110];
  vector<bool> vec(N, true);
  
  rep(i,N){
    cin >> A[i];
  }
  
  int count = 0;
  rep(i,N){
    if(vec[i] == true){
      for(int j = i+1; j<N; j++){
        if(A[j] == A[i]) vec[j] = false;
      }
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int ab, ac, bc;
	ab = a + b;
	bc = b + c;
	ac = a + c;
	if(a == bc || b == ac || c == ab)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll n,m;
  cin>>n>>m;
  ll ans = 0;
  if(m >= n * 2) {
    ans += n;
    m -= n * 2;
    ans += m / 4;
  } else {
    ans += m / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#define INF 1e+9
#define int long long
using namespace std;
 
signed main(){
	int n,a,b,v[50],ma,mcnt = 0,comb[51][51] = {},res = 0;
	for(int i = 0;i <= 50;i++){
		comb[i][0] = 1;
		comb[i][i] = 1;
	}
	for(int i = 1;i <= 50;i++){
		for(int j = 1;j <= 50;j++){
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
	cin >> n >> a >> b;
	for(int i = 0;i < n;i++){
		cin >> v[i];
	}
	sort(v,v + n,greater<int>());
	ma = v[0];
	for(int i = 0;i < n;i++){
		if(v[i] < ma) break;
		mcnt++;
	}
	if(mcnt >= a){
		printf("%.9f\n",(double)ma);
		for(int i = a;i <= min(mcnt,b);i++){
			res += comb[mcnt][i];
		}
		cout << res << endl;
		return 0;
	}
	int sum = 0,cnt;
	for(int i = 0;i < a;i++) {
		if(ma == v[i]) mcnt++;
		else if(ma > v[i]){
			mcnt = 1;
			ma = v[i];
		}
		sum += v[i];
	}
	cnt = mcnt;
	for(int i = a;i < n;i++){
		if(ma > v[i]) break;
		mcnt++;
	}
	printf("%.9f\n",(double)sum / (double)a);
	cout << comb[mcnt][cnt] << endl;
	return 0;
}

Measured memory_bytes: 256
s = int(input())

tmp_list = [0]*1000000

for i in range(1000000):
    if i == 0:
        tmp = s
        tmp_list[tmp] = 1

    else:
        #print(tmp)
        if tmp % 2 == 0:
            tmp = tmp//2
        else:
            tmp = 3*tmp+1
        
        if tmp_list[tmp] == 0:
            #print('tmp_list')
            #print(tmp_list[tmp])
            tmp_list[tmp] = 1

        elif tmp_list[tmp] == 1:
            #print('break')
            print(i+1)
            break

Measured memory_bytes: 10868