akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

//B - Break Number
int main(){
    int n;
    cin >> n;

    int num;
    int maxt = -1;
    int maxNum = -1;
    for(int i = 0; i < n; ++i){
        int t = 0;
        num = i + 1;
        int q = num;
        while(true){            
            if(q % 2 == 0){
                ++t;
                q = q/2;
            }else{break;}
        }
        if(maxt < t){
            maxt = t;
            maxNum = num;
        }
    }

    cout << maxNum;
}

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

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    char SR[30] = {0}, SL[30] = {0};
    for(int i = 0; i < n; ++i) SR[s[i] - 'a']++;
    for(int i = 0; i < n; ++i) {
        SL[s[i] - 'a']++;
        SR[s[i] - 'a']--;
        int sum = 0;
        for(int j = 0; j < 30; ++j) {
            if(SL[j] > 0 && SR[j] > 0) {
                sum++;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  100005
#define mod 1000000007
#define PII pair<int, int>
#define lowbit(x) (x&-x)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif

	ll x, y, d;
	while (cin >> x>>y)
	{
		if (x%y == 0)
			cout << -1 << endl;
		else
			cout << x << endl;
		
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
using namespace std;

int main(void) {
	string s;
	cin >> s;
	if (s[0] == s[2])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

const int LIMIT=100001;
const int NIL=-1;
struct node{
	int p,right,left,depth,height,sibling;
};
node Tree[LIMIT];

int calc_depthAndHeight(int p,int deep){
 	if(Tree[p].left==NIL&&Tree[p].right==NIL){
		Tree[p].depth=deep;
		Tree[p].height=0;
		return 1;
	}else{
		int h1=-1,h2=-1,h3;
		if(Tree[p].left!=NIL)h1=calc_depthAndHeight(Tree[p].left,deep+1);
		if(Tree[p].right!=NIL)h2=calc_depthAndHeight(Tree[p].right,deep+1);
		h3=h1>h2?h1:h2;
		Tree[p].height=h3;
		Tree[p].depth=deep;
		return h3+1;
	}
} 
 
void print(int n){
	for(int i=0;i<n;i++){
		printf("node %d: parent = %d, sibling = %d, ",i,Tree[i].p,Tree[i].sibling);
		int degree=(Tree[i].left!=-1)+(Tree[i].right!=-1);
		printf("degree = %d, depth = %d, height = %d, ",degree,Tree[i].depth,Tree[i].height);
		if(Tree[i].p==-1){
			printf("root\n");
		}else if(degree==0){
 			printf("leaf\n");
		}else{
			printf("internal node\n");
		}
	}
}

int main(){
	int n,l,r,no;
	scanf("%d",&n);
	for(int i=0;i<n;i++)Tree[i].p=Tree[i].sibling=NIL;
	for(int i=0;i<n;i++){
 		scanf("%d %d %d",&no,&l,&r);
		Tree[no].left=l;
		Tree[no].right=r;
		Tree[l].p=Tree[r].p=no;
		Tree[l].sibling=r;
		Tree[r].sibling=l;
	}
 	int p=0;
	for(int i=0;i<n;i++)if(Tree[i].p==NIL)p=i;
	int t=calc_depthAndHeight(p,0);
	print(n);
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
int main() {
    string str;
    while(getline(cin,str),str!=".") {
        stack<char> st;
        bool OK=1;
        for(int i=0;i<str.size();i++) {
            if(str[i]=='(') st.push('(');
            if(str[i]==')') {
                if(st.size()==0||st.top()!='(') {OK=0;break;}
                st.pop();
            }
            if(str[i]=='[') st.push('[');
            if(str[i]==']') {
                if(st.size()==0||st.top()!='[') {OK=0;break;}
                st.pop();
            }
        }
        if(st.size()==0&&OK) printf("yes\n"); else printf("no\n");
    }
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int a[3];

int main(void) {
  REP(i, 0, 3) cin >> a[i];
  sort(a, a + 3);
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}

Measured memory_bytes: 1184
fn main() {
    let v = read_vec::<String>();
    let mut ans = "".to_string();
    ans.push_str(&v[1]);
    ans.push_str(&v[0]);
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
k, a, b = map(int, input().split())
add = b - a
if k < a - 1:
    print(k + 1)
elif 2 >= add:
    print(k + 1)
else:
    k -= (a - 1)
    ans = a
    if k % 2:
        print(ans + add * (k // 2) + 1)
    else:
        print(ans + add * (k // 2))




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

using namespace std;

struct UnionFind { /* {{{ */
  vector<int> par;

  UnionFind(int n) {
    par.resize(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) { par[root(x)] = root(y); }
  bool same(int x, int y) { return root(x) == root(y); }
}; /* }}} */

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    X[i] = {x, i};
    Y[i] = {y, i};
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());

  vector<pair<int, pair<int, int>>> edges;
  for (int i = 0; i < N - 1; i++) {
    edges.push_back({abs(X[i].first - X[i + 1].first), {X[i].second, X[i + 1].second}});
    edges.push_back({abs(Y[i].first - Y[i + 1].first), {Y[i].second, Y[i + 1].second}});
  }
  sort(edges.begin(), edges.end());

  UnionFind uf(N);
  long long ans = 0;
  for (auto p : edges) {
    auto cost = p.first;
    auto e = p.second;
    if (uf.same(e.first, e.second)) continue;
    uf.unite(e.first, e.second);
    ans += cost;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 6388
import java.io.*;
import java.util.*;


public class Main {
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}



	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long)(1e9+7);
	static FastReader sc = new FastReader();
    static List<Integer>[] edge ;
	// static TreeSet<Integer>[] edge ;
	public static void main(String[] args) throws FileNotFoundException {	
	
		FastReader sc = new FastReader();
		 
		
		 int n = sc.nextInt();
		 int q = sc.nextInt();
		 edge = new ArrayList[n+1];
		   
		for(int i=0;i<=n;++i) {
			edge[i] = new ArrayList<>();
		}
		for(int i=0;i<n-1;++i) {
			int u = sc.nextInt();
			int v = sc.nextInt();
				edge[u].add(v);
				edge[v].add(u);
			
		}
		int[] subtree = new int[n+1];
		counter = 0;
		while(q-->0) {
			int idx = sc.nextInt();
			int val = sc.nextInt();
			subtree[idx] += val;
		}
		int[] node = subtree.clone();
		dfs(1,0,subtree,node);
		for(int i=1;i<=n;++i) out.print(node[i]+" ");
		out.close();
	}
	static int counter;
	
	
	private static void dfs(int v, int parent,int[] subtree,int[] node) {
		counter+=subtree[v];
		for(int child : edge[v]) {
			if(child != parent) { 
				node[child] += counter;
				dfs(child,v,subtree,node);
			}
		}
		counter-=subtree[v];
		
	}
}

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

typedef long long ll;
typedef pair<ll, ll> Pll;

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> ret;
    for (int i = 2; (ll)i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

long long gcd(long long a, long long b) {
    if (a < b) {
        return gcd(b, a);
    } else if (b == 0) {
        return a;
    } else {
        while (a % b != 0) {
            int r = b;
            b = a % b;
            a = r;
        }
        return b;
    }
}

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

    ll ans = 0;
    ll t = 1;

    for (auto p : prime_factor(N-1)) {
        t *= (p.second + 1);
    }
    ans += t - 1;
    for (ll x : divisor(N)) {
        if (x == 1) continue;
        ll temp = N;
        while (temp % x == 0) temp /= x;
        if (temp % x == 1) ans++;
    }
    cout << ans << endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
//template end



int main(){
    ll n,m; scanf("%lld%lld",&n,&m);
    string s,t; cin>>s>>t;
    ll g=__gcd(n,m);
    rep(i,0,n){
        if(m*i%n==0&&s[i]!=t[m*i/n]){
            printf("-1\n"); return 0;
        }
    }
    printf("%lld\n",n/g*m);
    return 0;
}

Measured memory_bytes: 512
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
class UnionFind:
    def __init__(self, N=None):
        if N is None or N < 1:
            self.parent = defaultdict(lambda: -1)
        else:
            self.parent = [-1]*int(N)

    def root_rec(self, n):
        if self.parent[n] < 0:
            return n
        else:
            m = self.root(self.parent[n])
            self.parent[n] = m
            return m

    def root(self, n):
        stack = []
        while n >= 0:
            stack.append(n)
            n = self.parent[n]
        m = stack.pop()
        while stack:
            self.parent[stack.pop()] = m
        return m

    def merge(self, m, n):
        rm = self.root(m)
        rn = self.root(n)
        if rm != rn:
            if -self.parent[rm] < -self.parent[rn]:
                rm, rn = rn, rm
            self.parent[rm] += self.parent[rn]
            self.parent[rn] = rm

    def size(self, n):
        return -self.parent[self.root(n)]
    
    def connected(self, m, n):
        return self.root(m) == self.root(n)

    def groups(self):
        if isinstance(self.parent,list):
            return list(filter(lambda i: self.parent[i]<0, range(len(self.parent))))
        else: # self.parent: defaultdict
            return list(filter(lambda i: self.parent[i]<0, self.parent.keys()))
 
    def groups_num(self):
        return len(self.groups())

    def elements(self):
        if isinstance(self.parent,list):
            return range(len(self.parent))
        else:
            return self.parent.keys()

N, K = inpl()
P = list(map(lambda x: x-1,inpl()))
C = inpl()

uf = UnionFind(N)
for i in range(N):
    uf.merge(i, P[i])

ans = C[0]
for g in uf.groups():
    L = uf.size(g)
    cycle = C[g]
    p = P[g]
    while p != g:
        cycle += C[p]
        p = P[p]
    q, r = K//L, K % L
    if cycle > 0:
        score = q * cycle
    else:
        score = 0

    s = g
    for _ in range(L):
        u = score
        t = s
        for i in range(L):
            u += C[t]
            t = P[t]
            if i == r:
                if q > 0 and cycle > 0:
                    u -= cycle
                elif q > 0 and cycle <= 0:
                    pass
                elif q == 0:
                    break
            if u > ans:
                ans = u
        s = P[s]

print(ans)


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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

const int MAXN = 1e5+10;
int n;
vector<int> a[MAXN];
ll dp[MAXN][3];

ll solve(int i, int last){
    if(i==n) return 0;
    ll &r = dp[i][last];
    if(r > 0) return r;
    fore(j,0,3){
        if(j != last){
            r = max(r, a[i][j]+solve(i+1, j));

        }
    }
    return r;
}

int main() {FIN;
    fill(dp, 0);
    cin>>n;
    fore(i,0,n){
        int b,c,d;
        cin>>b>>c>>d;
        a[i].pb(b); a[i].pb(c); a[i].pb(d);
    }
    cout<<solve(0, -1)<<"\n";
    return 0;
}


Measured memory_bytes: 15872
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {1,0,-1,0};

char stage[20][20];

int main(){
	int W,H;
	while(~scanf("%d %d",&W,&H)){
		if(W==H && H==0) break;
		for(int y=0;y<H;y++){
			char buf[32];
			scanf("%s",buf);
			for(int x=0;x<W;x++){
				stage[y][x] = buf[x];
			}
		}

		int sx=0;
		int sy=0;
		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				if(stage[y][x] == '@'){
					sx = x;
					sy = y;
					goto found;
				}
			}
		}
found:;
		queue<P> que;
		que.push(P(sx,sy));

		int res = 0;
		bool visited[20][20];
		memset(visited,0,sizeof(visited));

		visited[sy][sx] = true;
		while(!que.empty()){
			int sx = que.front().first;
			int sy = que.front().second;
			res++;
			que.pop();
			
			for(int i=0;i<4;i++){
				int dx = sx + tx[i];
				int dy = sy + ty[i];

				if(dx < 0 || dx >= W || dy < 0 || dy >= H) continue;
				if(stage[dy][dx]=='#') continue;
				if(visited[dy][dx]) continue;

				visited[dy][dx] = true;
				
				que.push(P(dx,dy));
			}
		}

		printf("%d\n",res);

	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;
int dp[52][52];

int N, M;
int n[52] = {};
void serch(int X) {
	
	n[X]=1;

	
		for (int k = 2; k <= N; k++) {
			
			if (dp[X][k] == 1&&n[k]==0) {
				serch(k);
			
			}

		}


		return;
}

int main() {

	int a, b;
	
	cin >> N >> M;

	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		dp[a][b] = 1;
		dp[b][a] = 1;
	}
	int Z;
	int Y = 0;
	for (int i = 1; i <= N-1; i++) {
		for (int k = i+1; k <= N; k++) {
		
			 Z = 0;
			if (dp[i][k] == 1) {
				dp[i][k] = 0;
				dp[k][i] = 0;

				serch(1);

				for (int m = 1; m <= N; m++) {
					if (n[m] == 1) {
						
						Z++;
					}
				}

				if (Z != N) {
					Y++;
				
				}

				for (int q = 1; q <= N; q++) {
					n[q] = 0;
				}
				

				dp[i][k] = 1;
				dp[k][i] = 1;
			}
		}
	}


	cout << Y << endl;
	return 0;


}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
  int x,i,n;
  scanf("%d",&n);
  for(i=1;i<=n;i++) {
    x = i;
    if(x%3==0){
      printf(" %d",i);
    }else{
      do{
        if(x%10==3) {
          printf(" %d",i);
          x=0;
        }
        x /= 10;
      }while(x);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int w, h, cnt;
int c[51][51];
void dfs(int i, int j){
    if(i-1 >= 0 && j-1 >= 0){
        if(c[i-1][j-1] == 1){
            c[i-1][j-1] = 0;
            dfs(i-1,j-1);
        }
    }
    if(i-1 >= 0){
        if(c[i-1][j] == 1){
            c[i-1][j] = 0;
            dfs(i-1,j);
        }
    }
    if(i-1 >= 0 && j+1 < w){
        if(c[i-1][j+1] == 1){
            c[i-1][j+1] = 0;
            dfs(i-1,j+1);
        }
    }
    if(j-1 >= 0){
        if(c[i][j-1] == 1){
            c[i][j-1] = 0;
            dfs(i,j-1);
        }
    }
    if(j+1 < w){
        if(c[i][j+1] == 1){
            c[i][j+1] = 0;
            dfs(i,j+1);
        }
    }
    if(i+1 < h && j-1 >= 0){
        if(c[i+1][j-1] == 1){
            c[i+1][j-1] = 0;
            dfs(i+1,j-1);
        }
    }
    if(i+1 < h){
        if(c[i+1][j] == 1){
            c[i+1][j] = 0;
            dfs(i+1,j);
        }
    }
    if(i+1 < h && j+1 < w){
        if(c[i+1][j+1] == 1){
            c[i+1][j+1] = 0;
            dfs(i+1,j+1);
        }
    }

}

int main(void){
    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0)    break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> c[i][j];
            }
        }

        cnt = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(c[i][j] == 1){
                    dfs(i, j);    
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


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

int main() {
	int a,b;
	cin>>a>>b;
	int ans = 0;
	if(a> b){
	    ans += a;
	    ans += a-1;
	} else if (a == b){
	    ans += 2 * a;
	} else {
	    ans += b;
	    ans += b-1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

  int i,j,k;
  int n,x;
  int count = 0;
  

  while(1){
    scanf(" %d %d",&n,&x);
    if(n == 0 && x == 0){
      break;
    }
  
      for(i = 1;i <= n;i++){
	for(j = i+1;j <= n;j++){
	  for(k = j+1;k <= n;k++){
	    if(i+j+k == x){
	      count++;
	    }
	  }
	}
      }

    printf("%d\n",count);
    count = 0;
  }
  return 0;
}
	    
	    
  

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int x,y;
cin >> x;
if(x==25) {
  cout << "Christmas" << endl;
} else if(x==24) {
  cout << "Christmas Eve" << endl;
} else if(x==23) {
  cout << "Christmas Eve Eve" << endl;
} else {
  cout << "Christmas Eve Eve Eve" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

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

    int n;
    cin >> n;
    if( n == 3 || n == 5 || n == 7 ) cout << "YES";
    else cout << "NO";
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=1012345678;
int main(){
	vector<int> A(5),P(5);
	cin>>A[0]>>A[1]>>A[2]>>A[3]>>A[4];
	for(int i=0;i<5;i++)P[i]=i;
	int final_answer=INF;
	do{
		int ans=0;
		for(int i=0;i<5;++i){
			while(ans%10!=0)ans+=1;
			ans+=A[P[i]];
		}
		final_answer=min(final_answer,ans);
	}while(next_permutation(P.begin(),P.end()));
	cout<<final_answer;
	return 0;
}

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

set<pair<int, int>> best[3][3];

int main() {
    //ifstream cin("c.in");
    ios_base :: sync_with_stdio(false);

    int x, y, z; cin >> x >> y >> z;
    int n = x + y + z;

    vector<vector<int>> m(n, vector<int> (3, 0));
    vector<int> who(n, -1);

    auto insert = [&] (int where, int index) {
        for(int i = 0; i < 3; ++i)
            if(where != i) {
                best[where][i].insert(make_pair(m[index][i] - m[index][where], index));
            }
        who[index] = where;
    };

    auto erase = [&] (int where, int index) {
        for(int i = 0; i < 3; ++i)
            if(where != i) {
                best[where][i].erase(make_pair(m[index][i] - m[index][where], index));
            }
        who[index] = -1;
    };

    for(int i = 0; i < x + y + z; ++i) {
        cin >> m[i][0] >> m[i][1] >> m[i][2];
        if(i < x) {
            insert(0, i);
        } else if(i >= x and i < x + y) {
            insert(1, i);
        } else {
            insert(2, i);
        }
    }

    bool change = false;
    while(true) {
        change = false;

        for(int i = 0; i < 3; ++i)
            for(int j = 0; j < 3; ++j) {
                if(i == j)
                    continue;
                auto best_i = (*best[i][j].rbegin());
                auto best_j = (*best[j][i].rbegin());

                if(best_i.first + best_j.first > 0) {
                    erase(i, best_i.second);
                    erase(j, best_j.second);
                    insert(i, best_j.second);
                    insert(j, best_i.second);
                    change = true;
                }
            }

        vector<int> p(3, 0);
        for(int i = 0; i < 3; ++i)
            p[i] = i;
        
        do {
            bool bad = false;
            for(int i = 0; i < 3; ++i)
                if(p[i] == i) {
                    bad = true;
                } 
            if(bad)
                continue;
            vector<pair<int, int>> gains;

            for(int i = 0; i < 3; ++i) {
                gains.push_back((*best[i][p[i]].rbegin()));
            }

            if(1LL * gains[0].first + 1LL * gains[1].first + 1LL * gains[2].first > 0) {
                for(int i = 0; i < 3; ++i) {
                    erase(i, gains[i].second);
                    insert(p[i], gains[i].second);
                }
                change = true;
            }

        } while(next_permutation(p.begin(), p.end()));

        if(not change)
            break;
    } 
        
    long long ans = 0;

    for(int i = 0; i < n; ++i) {
        ans += m[i][who[i]];    
    }

    cout << ans << "\n";
}

Measured memory_bytes: 15616
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void){
 double r,PI;
 cin >> r;
 PI=3.141592653589;


  cout << fixed << setprecision(6);
  cout << r*r*PI << " " << 2*r*PI << endl;
  cout << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int n;
ll ret;
string s;

map<pair<string, string>, int> MP;

int main() {
	cin >> n >> s;

	rep(i, 1 << n) {
		string p, q;

		rep(j, n) {
			if ((i >> j) & 1) {
				p.pb(s[n + j]);
			} else {
				q.pb(s[n + j]);
			}
		}
		++MP[mp(p, q)];
	}

	rep(i, 1 << n) {
		string p, q;

		rep(j, n) {
			if ((i >> j) & 1) {
				q.pb(s[j]);
			} else {
				p.pb(s[j]);
			}
		}

		reverse(ALL(p)); reverse(ALL(q));

		if (MP.count(mp(p, q))) {
			ret += MP[mp(p, q)];
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 46080
N = int(input())
Ps = list(map(int, input().split()))

iPs = [0] * (N+1)
for iP, A in enumerate(Ps):
    iPs[A] = iP

ans = 0
iLs = list(range(N+1))
iRs = list(range(N+1))
for P in range(1, N+1):
    i = iPs[P]
    iL, iR = iLs[i], iRs[i]
    if iL <= 1:
        iL2 = 0
    else:
        iL2 = iLs[iL-1]
    if iR >= N-2:
        iR2 = N-1
    else:
        iR2 = iRs[iR+1]
    num = 0
    if iL != 0:
        num += (iL-iL2)*(iR-i+1)
    if iR != N-1:
        num += (i-iL+1)*(iR2-iR)
    ans += P * num
    iLs[iR+1] = iL
    iRs[iL-1] = iR

print(ans)


Measured memory_bytes: 53772
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define vect(x) vector<x>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;



ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }

ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;}

ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}

ll dp[100010][2];
ll n;

ll get(ll a[], ll k, int x)
{
    if(k>=0 && dp[k][x]!=-1) return dp[k][x];
    for(ll i=0;i<n;i++)
    {
        if(a[i]<=k)
        {
            ll ch = get(a , k - a[i], x^1 );
            
            if(x==1 && ch) return dp[k][x] =  1;
            if(x==0 && !ch) return dp[k][x] = 0;
        }
        
    }
    
   if(x==0) return dp[k][x] = 1;
   else return dp[k][x] = 0;         
     
}

void solve()
{
    ll k;
    cin >> n >> k;
    ll a[n];
    forr(i,n) cin >> a[i];
    memset(dp,-1,sizeof(dp));
    ll ch = get(a,k,1);
    if(ch) cout << "First";
    else cout << "Second";
    
    
    
    return;
}


int main()
{
    
    
    fastio
    
    ll tc=1;
  //  read(tc);
    while(tc--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	double minValue= 1000000000;
	double maxValue= -1;
	double tmp;
	while(cin>>tmp){
		maxValue=max(maxValue,tmp);
		minValue=min(minValue,tmp);
	}
	cout<<maxValue-minValue<<endl;

	return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())
v = list(map(int, input().split()))

results = []
for a in range(n + 1):
    for b in range(min(n - a, k - a) + 1):
        p = v[:a] + v[n - b:]
        p.sort()
        for i in range(k - a - b + 1):
            results.append(sum(p[i:]))
print(max(results))


Measured memory_bytes: 5144
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define deb(x) cout << #x << ' ' << x << '\n'
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define per(i,ini) for(int i=ini;i>=0;i--)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 4e2+2;

ll dp[N][N], a[N];

int main()
{
	int n;
	scn(n);

	rep(i, 0, n)
	lscn(a[i]);

	for(int len=2; len<=n; len++)
	{
		for(int i=0; i+len-1<n; i++)
		{
			int j=i+len-1;

			dp[i][j] = 1e18;

			ll sum = 0;

			for(int k=i; k<=j; k++)
			sum += a[k];

			for(int k=i; k<j; k++)
			dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]+sum);
		}
	}  

	lprin(dp[0][n-1]);

    return 0;
}

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)

using namespace std;

typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }



int n, m;

int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }


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


        cout << (b +a)%24 << endl;



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long inf = 4523372036854775807;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	char a, b;
	cin >> a >> b;
	if (a > b)
		cout << ">" << endl;
	else if (a < b)
		cout << "<" << endl;
	else
		cout << "=" << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if P[i] == i+1:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1

if P[-1] == n:
    ans += 1

print(ans)


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

int main() {
  int N;
    int a=0,b=0,c=0,d=0;
  cin>>N;
  vector<string>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
    if(vec.at(i)=="AC"){a++;}
    else if(vec.at(i)=="WA"){b++;}
    else if(vec.at(i)=="TLE"){c++;}
    else if(vec.at(i)=="RE"){d++;}
}
  cout<< "AC"<<" "<<"x"<<" "<<a<<endl;
    cout<< "WA"<<" "<<"x"<<" "<<b<<endl;
    cout<< "TLE"<<" "<<"x"<<" "<<c<<endl;
    cout<< "RE"<<" "<<"x"<<" "<<d<<endl;
}

Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define pb push_back
#define mp make_pair
#define ip pair<int, int>
#define it pair<int, pair<int, int>>
#define F first
#define S second
#define fori(p, n) for(int i = p; i < n; i++)
#define forj(q, m) for(int j = q; j < m; j++)
#define fork(r, l) for(int k = r; k < l; k++)
#define revi(h) for(int i = h; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define PI 3.14159265358
#define debug(x) cout<<"DEBUGGING --- "<<x<<endl;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file freopen("output.txt", "w", stdout);
vector<int>A(3005);
vector<vector<int>>dp(3005, vector<int>(3005, 0));
int solve(int l, int r){
    if(dp[l][r] != 0) return dp[l][r];
    if(l == r) return dp[l][r] = A[l];
    if(l > r) return 0;
    return dp[l][r] = max(A[l] - solve(l + 1, r), A[r] - solve(l, r - 1));    
}
signed main(){
    fastio;
    //input_from_file; 
    //output_to_file;
    int n; cin>>n;
    fori(0, n) cin>>A[i];
    cout<<solve(0, n - 1)<<endl;
}

Measured memory_bytes: 71040
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>

using namespace std;

int main() {
  string n;
  cin >> n;
  if(n[0] == '7' || n[1] == '7' || n[2] == '7') {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,s1,s2,s3;

  cin >> a;

  s1 = a / 100;
  s2 = (a / 10) % 2;
  s3 = a % 2;
  cout << s1 + s2 + s3 << endl;

}

Measured memory_bytes: 256
function Main(inp) {
    var input = inp.split('\n')[0].split(' ').map(function(n) {
        return Number(n);
    });
    var count = 0;
    for(var i = 0; i <= 100; i++) {
        var onA = false, onB = false;
        if (input[0] <= i && i < input[1]) {
            onA = true;
        }
        if (input[2] <= i && i < input[3]) {
            onB = true;
        }
        if (onA && onB) {
            count += 1;
        }
    }
    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n, k;
	cin >> n >> k;
	ll c = n / k;
	if (k % 2 == 1) {
		cout << (c * c * c) << endl;
		return 0;
	}
	ll d = n / (k/2) - c;
	cout << (c * c * c + d * d * d) << endl;
	return 0;
}


Measured memory_bytes: 256
from copy import deepcopy

n, k = map(int, input().split())
r, s, p = map(int, input().split())
l = list(input())

ans = 0
for i in range(k):
  n_ = (n - i) // k + (1 if (n-i) % k > 0 else 0)
  rsp = [0] * 3
  for j in range(n_):
    bef = deepcopy(rsp)
    if l[j * k + i] == "r":
      rsp[2] = max(bef[0], bef[1]) + p
      rsp[1] = max(bef[0], bef[2])
      rsp[0] = max(bef[1], bef[2])
    elif l[j * k + i] == "s":
      rsp[2] = max(bef[0], bef[1])
      rsp[1] = max(bef[0], bef[2])
      rsp[0] = max(bef[1], bef[2]) + r
    elif l[j * k + i] == "p":
      rsp[2] = max(bef[0], bef[1])
      rsp[1] = max(bef[0], bef[2]) + s
      rsp[0] = max(bef[1], bef[2])
  ans += max(rsp)
      
print(ans)

Measured memory_bytes: 78584
#include<iostream>
#include<cstring>

int N, K;
// dp[i][j][k]: i日目にパスタjを食べる。k == true: 前日もパスタjを食べた。 k == false: 前日は違うパスタ。
int dp[100][3][2];
// plan[i]: i日目に予定があればパスタの番号、なければ-1。
int plan[100];

int main()
{
	memset( plan, -1, sizeof( plan ) );
	std::cin >> N >> K;
	for( int i = 0; i != K; ++i )
	{
		int A, B;
		std::cin >> A >> B;
		plan[A-1] = B - 1;
	}

	if( plan[0] != -1 )
	{
		dp[0][plan[0]][0] = 1;
	}
	else
	{
		for( int i = 0; i != 3; ++i )
				dp[0][i][0] = 1;
	}

	for( int i = 0; i != N - 1; ++i )
	{
		if( plan[i+1] != -1 )
		{
			for( int j = 0; j != 3; ++j )
				if( j != plan[i+1] )
					dp[i+1][plan[i+1]][0] = ( dp[i+1][plan[i+1]][0] + dp[i][j][0] + dp[i][j][1] ) % 10000;
		
			dp[i+1][plan[i+1]][1] = ( dp[i+1][plan[i+1]][1] + dp[i][plan[i+1]][0] ) % 10000;
		}
		else
		{
			for( int j = 0; j != 3; ++j )
			{
				for( int k = 0; k != 3; ++k )
					if( j != k )
						dp[i+1][j][0] = ( dp[i+1][j][0] + dp[i][k][0] + dp[i][k][1] ) % 10000;

				dp[i+1][j][1] = ( dp[i+1][j][1] + dp[i][j][0] ) % 10000;
			}
		}
	}

	int ans = 0;
	for( int i = 0; i != 3; ++i )
		ans = ( ans + dp[N-1][i][0] + dp[N-1][i][1] ) % 10000;

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1160
n,m= map(int, input().split())
l = list(map(int, input().split()))

l.sort()
# print(l)
list=[]
if n < m:
    for i in range(m - 1):
        list.append(abs(l[i + 1] - l[i]))

    list.sort()
    # print(list)
    print(sum(list[0:(m - n)]))
else:
    print(0)

Measured memory_bytes: 20432
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 22 18:21:55 2018
CADDi2018C
@author: maezawa
""" 
import collections

n, p = list(map(int, input().split()))

if n == 1:
    ans = p
else:
    np = int(p**(1/n))
    
    # making a prime number list
    is_prime = [True]*(np+1)

    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, np//2+1): # Sieve of Eratosthenes
        if is_prime[i] == True:
            for j in range(2*i,np+1,i):
                is_prime[j] = False
    
    prime_numbers = [i for i in range(np+1) if is_prime[i]]

    # prime factorization
    num = p # a number to be factorized. 
    # The maximum number to factrize is np**2. 
    
    facts = [] # list of prime factors
    for prime in prime_numbers:
        if prime > num//2:
            break
        dnum = num
        while dnum%prime == 0: 
            facts.append(prime)
            dnum = dnum//prime
    
    mul = 1
    for i in facts:
        mul *= i
    if mul != num: # if large prime number (> np) is missing
        facts.append(num//mul) # append it
    
    pfs = collections.Counter(facts)
    mostcommon = pfs.most_common()
    ans = 1
    for i, j in mostcommon:
        if j < n:
            break
        m = j // n
        ans *= i**m

print(ans)
    

Measured memory_bytes: 13092
#include <cstdio>
using namespace std;

int main() {
  int l, r, d;
  scanf("%d%d%d", &l, &r, &d);
  int ans=0;
  for(int i=l;i<=r;i++) if(i%d==0) ans++;
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1684
//Gvs Akhil (Vicennial)
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int N=1000006;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T> T power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
int32_t main(){
	string s; cin>>s;
	if(s.size()>=4){
		string b=s.substr(0,4);
		if(b=="YAKI"){
			cout<<"Yes"; return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	long long int k, n,i,a,b,c,result=0;
	scanf("%lld%lld", &n, &k);

	if (k % 2 == 1) {
		printf("%lld", (n/k)*(n/k)*(n/k));
	}
	else {
		if (n%k >= k / 2) {
			printf("%lld", (n/k)*(n/k)*(n/k)+ (n/k+1)*(n/k+1)*(n/k+1));
		}
		else {
			printf("%lld", 2*(n/k)*(n/k)*(n/k));
		}
	}
	
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String S = br.readLine();
		int result = 0;
		int fin = 0;
		for(int i = 0;i<S.length();i++){
			result = 0;
			List<Character> left = new ArrayList<Character>();
			List<Character> right = new ArrayList<Character>();
			for (int l = 0;l<i;l++){
				char now = S.charAt(l);
				if(!left.contains(now))left.add(now);
			}
			for (int r = i;r<S.length();r++){
				char now = S.charAt(r);
				if(!right.contains(now))right.add(now);
			}

			for(int p = 0;p<left.size();p++){
				char now = left.get(p);
				if(right.contains(now))result++;
			}
			fin = Math.max(fin, result);

		}
		System.out.println(fin);
	}


}


Measured memory_bytes: 22996
import itertools
N = int(input())
P = A = tuple(map(int, input().split()))
Q = A = tuple(map(int, input().split()))

permutations = list(itertools.permutations(range(1, N+1)))
p = permutations.index(P)
q = permutations.index(Q)

ans = abs(p - q)
print(ans)

Measured memory_bytes: 8052
c = [[int(x) for x in input().split()] for _ in range(3)]

ans = False
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            ok = True
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1
            if c[1][0] != a2 + b1 or \
               c[1][1] != a2 + b2 or \
               c[1][2] != a2 + b3 or \
               c[2][0] != a3 + b1 or \
               c[2][1] != a3 + b2 or \
               c[2][2] != a3 + b3:
               ok = False
            if ok:
                ans = True

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





Measured memory_bytes: 9228
def main():
    mod = 10**9+7
    fact = [1, 1]
    for i in range(2, 200000):
        fact.append(fact[-1]*i % mod)
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]
    g2 = [set(i) for i in g]
    child = [1]*n  # 子の数
    q = [-1, 0]
    while len(q) > 1:  # DFS
        i = q[-1]
        if g2[i]:
            j = g2[i].pop()
            g2[j].remove(i)
            q.append(j)
        else:
            q.pop()
            if len(q) > 1:
                child[q[-1]] += child[i]
    rank = [(j, i) for i, j in enumerate(child)]
    rank = [j for i, j in sorted(rank)]
    dp = [1]*n
    for i in rank:
        c = child[i]
        ans = fact[c-1]
        temp = 1
        for j in g[i]:
            if child[j] < c:
                ans = ans*dp[j] % mod
                temp = temp*fact[child[j]] % mod
        dp[i] = ans*pow(temp, mod-2, mod) % mod
    dp2 = [0]*n
    dp2[0] = dp[0]
    g2 = [set(i) for i in g]
    q = [-1, 0]
    while len(q) > 1:  # DFS
        i = q[-1]
        if g2[i]:
            j = g2[i].pop()
            c = child[j]
            temp = fact[n-c]*fact[c-1]
            dp2[j] = dp2[i]*(fact[c]*fact[n-c-1])*pow(temp, mod-2, mod) % mod
            g2[j].remove(i)
            q.append(j)
        else:
            q.pop()
            if len(q) > 1:
                child[q[-1]] += child[i]

    for i in dp2:
        print(i)


main()

Measured memory_bytes: 188592
n=0
t=1
def adjacent_matrix():
    global n
    n=int(input())
    v=[]
    array=[]
    for i in range(n):
        zero=[0 for i in range(n)]
        a=list(map(int,input().split()))
        a=a[2:]
        for j in a:
            zero[j-1]=1
        array.append(zero)
    return array
def dfs(array,i,d,f):
    global t
    if i == n:
        return
    else:
        if(d[i] == 0):
            d[i] = t
            t += 1
            for (j,x) in enumerate(array[i]):
                if x == 1:
                    dfs(array,j,d,f)
            f[i] = t
            t += 1
    return 


def main():
    array=adjacent_matrix()
    d=[0 for i in range(n)]
    f=[0 for i in range(n)]
    for i in range(n):
        dfs(array,i,d,f)
    for i in range(n):
        print("{} {} {}".format(i+1,d[i],f[i]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5692
from math import log, floor

def formula(x, y):
    # This fails because of precision issues: log((2 ** 59) - 1) = 59
    return 1 + floor(log(y / x, 2))

def naive(x, y):
    count = 0
    n = x
    while n <= y:
        count += 1
        n *= 2
    return count
        

if __name__ == '__main__':
    x, y = map(int, input().split())
    print(naive(x, y))

Measured memory_bytes: 3060
C = input()
ans_n=0
h=""
f=1
for i in range(len(C)):
    if(f==2):
        ans_n+=1
        f=1
        h=C[i]
    elif(f==0):
        ans_n+=1
        f=2
        h=C[i]
    elif(h!=C[i]):
        ans_n+=1
        f=1
        h=C[i]
    else:
        f=0
        h=C[i]
print(ans_n)

Measured memory_bytes: 3500
#include<stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);

	int val1, val2, val3;
	val1 = a + b;
	val2 = a - b;
	val3 = a * b;

	int max = val1;

	if (max < val1) {
		max = val1;
	}
	if (max < val2) {
		max = val2;
	}
	if (max < val3) {
		max = val3;
	}

	printf("%d", max);

	return 0;
}

Measured memory_bytes: 128