akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = []
        for i in range(2, int(math.sqrt(m)) + 1):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False

    def is_prime(self, n):
        return self.A[n]

    def division(self, n):
        d = collections.defaultdict(int)
        for c in self.T:
            while n % c == 0:
                d[c] += 1
                n //= c
            if n < 2:
                break
        if n > 1:
            d[n] += 1
        return d.items()

    def sowa(self, n):
        r = 1
        for k,v in self.division(n):
            t = 1
            for i in range(1,v+1):
                t += math.pow(k, i)
            r *= t
        return r


def main():
    n = I()
    ac = collections.Counter(LI())
    if n == 2:
        return max(ac.keys())
    a = []
    aa = []
    for k,v in ac.items():
        if v > 1:
            aa.append(k)
        else:
            a.append(k)

    tr = -1
    if len(aa) > 0:
        tr = aa[0]
        for k in aa[1:]:
            tr = fractions.gcd(k,tr)

    l = len(a)
    if l < 2:
        return tr
    if l < 3:
        r = 1
        for i in a:
            kr = fractions.gcd(i,tr)
            if r < kr:
                r = kr
        return r

    m = max(a)
    lm = m // (l-1)
    pr = Prime(10**9)
    p = collections.defaultdict(int)

    for b in a:
        r = [1]
        for k, v in pr.division(b):
            for c in r[:]:
                for i in range(1,v+1):
                    t = c*(k**i)
                    if t > lm:
                        break
                    r.append(t)
        for k in r:
            p[k] += 1



    if tr == -1:
        r = 1
        for k,v in p.items():
            if v >= l-1 and r < k:
                r = k
        return r

    r = 1
    for k,v in p.items():
        kk = fractions.gcd(tr,k)
        if v >= l-1 and r < kk:
            r = kk

    return r


print(main())



Measured memory_bytes: 16860
import sys
input = sys.stdin.readline

import itertools

n, m, q = [int(x) for x in input().split()]
abcd = []
for _ in range(q):
    abcd.append([int(x) for x in input().split()])
ele = [int(x) for x in range(1, m + 1)]
p = list(itertools.combinations_with_replacement(ele, n))
ans = -1
for i in range(len(p)):
    p_ = p[i]
    res = 0
    for j in range(q):
        a, b, c, d = abcd[j]
        a -= 1
        b -= 1
        if p_[b] - p_[a] == c:
            res += d
    ans = max(ans, res)
print(ans)


Measured memory_bytes: 21560
#include <bits/stdc++.h>
typedef long long ll;

template<typename T> T maximum(T head, T tail) { return std::max(head, tail); }
template<typename Head, typename... Tail> Head maximum(Head head, Tail... tail) {
  return std::max(head, maximum(tail...));
}

template<typename T> T minimum(T head, T tail) { return std::min(head, tail); }
template<typename Head, typename... Tail> Head minimum(Head head, Tail... tail) {
  return std::min(head, minimum(tail...));
}

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main()
{
  ll Q, H, S, D, N;
  std::cin >> Q >> H >> S >> D >> N;

  ll x2 = minimum(D, 2*S, 4*H, 8*Q);
  ll x1 = minimum(S, 2*H, 4*Q);

  ll ans = N / 2 * x2 + (N % 2) * x1;
  print(ans);

  return 0;
}


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

int main()
{
	int n,m;
	cin>>n>>m;
	int matrix[100][100];
	int vector[100];
	int ans[100] = {0};
	for(int i = 0; i < n; i++){
		for(int j = 0 ; j < m; j++){
			cin>>matrix[i][j];
		}
	}
	for(int j = 0 ; j < m; j++){
		cin>>vector[j];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0 ; j < m; j++){
			ans[i] += matrix[i][j]*vector[j];
		}
	}
	for(int i = 0; i < n; i++){
		cout<<ans[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
  
int main(void)
{
	int a, b, i;
	char op;
	for (i = 1; i > 0; i++){
		scanf("%d %c %d", &a, &op, &b);
		if (op == '+')
		{
			printf("%d\n", a + b);
		}
		else if (op == '-')
		{
			printf("%d\n", a - b);
		}
		else if (op == '*')
		{
			printf("%d\n", a*b);
		}
		else if (op == '/'){
			printf("%d\n", a / b);
		}
		else if (op == '?') {
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 2112
from heapq import*
I=float("inf")
def m():
 n=int(input())
 A=[[]]*n
 for _ in range(n):
  e=list(map(int,input().split()))
  A[e[0]]=zip(e[2::2],e[3::2])
 d=[0]+[I]*n
 H=[(0,0)]
 while H:
  u=heappop(H)[1]
  for v,c in A[u]:
   t=d[u]+c
   if d[v]>t:
    d[v]=t
    heappush(H,(t,v))
 for i in range(n):print(i,d[i])
m()


Measured memory_bytes: 39980
import java.io.*;
public class Main {
		
	public static void main(String[] args)throws IOException {
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		
		String[] num=str.split(" ");
		int a=Integer.parseInt(num[0]);
		int b=Integer.parseInt(num[1]);
		
		int d=(a/b);
		int r=(a%b);
		double f=(double)a/b;
		
		System.out.printf("%d %d %.5f",d,r,f);
	}
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var T = new int[100000];
            var X = new int[100000];
            var Y = new int[100000];
            for (int i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                T[i] = input[0];
                X[i] = input[1];
                Y[i] = input[2];
            }

            for (int i = 0; i < N; i++)
            {
                if ((X[i] + Y[i]) > T[i])
                {
                    Console.WriteLine("No");
                    return;
                }

                if ((T[i] % 2) != ((X[i] + Y[i]) % 2))
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}



Measured memory_bytes: 16352
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    println!(
        "{}",
        if n % 10 == 9 || n / 10 == 9 {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
x, y, z = map(int,input().split())

max_lines = [[x * 10 + y, z],
                 [x * 10 + z, y],
                 [y * 10 + x, z],
                 [y * 10 + z, x],
                 [z * 10 + x, y],
                 [z * 10 + y, x]]

max_point = 0
one_point = 0
for max_line in max_lines:
    if max_line[0] >= max_point:
        max_point = max_line[0]
        one_point = max_line[1]

print(max_point + one_point)

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

//正整数について最上位の数字を与える関数
int top_digit(Int x) {
    if (x <= 0) return 0;
    for (Int n = 1; n <= x; n = n*10) {
        if (n*10 <= x) continue;
        return x / n;
    }
}

//正整数について一の位を与える関数
int bottom_digit(Int x) {
    return x % 10;
}



int main(){ 
    Int N;
    cin >> N;
    map<pair<int,int>,Int> f;

    rep1(i,N) {
        f[make_pair(top_digit(i),bottom_digit(i))]++;
    }

    Int ans = 0;

    rep1(i,9) {
        rep1(j,9) {
            ans += f[make_pair(i,j)] * f[make_pair(j,i)];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s;
    u64 K;
    cin >> s >> K;

    int i = 0;
    while (s[i] == '1' && i < K && i < s.size()) ++i;

    cout << (i < K && i < s.size() ? s[i] : '1') << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by on 2018/1/8.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str=in.nextLine();
        String substring = str.substring(4);
        System.out.println("2018"+substring);
    }
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, D1, D2;

signed main() {
    cin >> N >> D1 >> D2;
    int p1 = 0, p2 = 0;
    while (D1 % 2 == 0) {D1 /= 2; p1++;}
    while (D2 % 2 == 0) {D2 /= 2; p2++;}
    int n = 0;
    for (int i = 0; i < 2 * N; i++) {
        for (int j = 0; j < 2 * N; j++) {
            bool sw1, sw2;

            if (p1 % 2 == 0)sw1 = (i / (1 << (p1 / 2)) % 2 == j / (1 << (p1 / 2)) % 2);
            else sw1 = (i / (1 << (p1 / 2)) % 2 == 0);

            if (p2 % 2 == 0)sw2 = (i / (1 << (p2 / 2)) % 2 == j / (1 << (p2 / 2)) % 2);
            else sw2 = (i / (1 << (p2 / 2)) % 2 == 0);

            if (sw1 && sw2) {cout << i << " " << j << endl; n++;}
            if (n == N * N)return 0;
        }
    }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Dinic{
  const int INF=1<<28;
  
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.push(e.to);
        }
      }
    }
  }
  
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        int d = dfs(e.to,t,min(f,e.cap));
        if(d>0){
          e.cap-=d;
          G[e.to][e.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }
  
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
        fl+=f;
        lim-=f;
      }
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

  //cap==1 only
  bool back_edge(int s,int t,int from, int to){
    for(int i=0;i<(int)G[from].size();i++) {
      edge& e=G[from][i];
      if(e.to==to) {
        if(e.cap==0&&flow(from,to,1)==0) {
          flow(from,s,1);
          flow(t,to,1);
          return 1;
        }
      }
    }
    return 0;
  }
};

//INSERT ABOVE HERE
signed main(){
  int n,m;
  cin>>n>>m;
  string s;
  cin>>s;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];

  Dinic f(n+2);
  int S=n,T=n+1;
  for(int i=0;i<m;i++){
    int x,y,z;
    cin>>x>>y>>z;
    x--;y--;
    if(x>y) swap(x,y);
    f.add_edge(x,y,z);
  }
  for(int i=0;i<n;i++){
    if(s[i]=='R') f.add_edge(S,i,a[i]);
    if(s[i]=='L') f.add_edge(i,T,a[i]);
  }
  cout<<f.flow(S,T)<<endl;
  return 0;
}



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

int main()
{
    int A,B;
    char op[3];
    scanf("%d%s%d",&A,op,&B);

    if(op[0]=='+')
    {
        printf("%d",A+B);
    }
    else
    {
        printf("%d",A-B);
    }
    return 0;
}


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

int main(){
  string sol,ans;
  int i,j;


  while( cin >> sol >> ans ){
    if(sol=="0" &&  ans=="0" ) break;
    int hit=0,blow=0;
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(sol[i]==ans[j] && i == j){
	  hit++;
	  break;
	}else if(sol[i]==ans[j]){
	  blow++;
	  break;
	}
      }
    }
    cout << hit << " " << blow << endl;
    hit=0;
    blow=0;
  }
  
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
bool comp(pair <lli,lli> a,pair<lli,lli> b){
	if(a.ft<b.ft)
	return true;
	else if(a.ft==b.ft)
	return a.sc<b.sc;
	else
	return false;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    vector <pair<lli,lli> > vect;
    lli x,y;
    rep(i,n){
    	cin>>x>>y;
    	vect.pb(mp(y,x));
	}
	sort(all(vect),comp);
	lli pre_sum=0;
	lli check=0;
	rep(i,n){
		pre_sum+=vect[i].sc;
		if(pre_sum>vect[i].ft){
			check=1;
			break;
		}
	}
	if(check==0)
	cout<<"Yes";
	else
	cout<<"No";
    return 0;
}


Measured memory_bytes: 6256
#include <iostream>
using namespace std;
int calc(int x) {
	int ret = 0;
	while(x % 100 == 0) {
		x /= 100;
		++ret;
	}
	return ret;
}
int main() {
	int D, N;
	cin >> D >> N;
	int cnt = 0, val = 0;
	while(cnt < N) {
		++val;
		if(calc(val) == D) ++cnt;
	}
	cout << val << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  string s;
  cin >> s;
  bool ok = true;
  REP(i, s.size()) {
    if(i%2 == 0) {
      if(s[i] == 'L') {
        ok = false;
        break;
      }
    } else {
      if(s[i] == 'R') {
        ok = false;
        break;
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

int m[100010];

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

    int n,k,q;
    cin>>n>>k>>q;

    for(int i=0;i<q;i++)
    {
        int a;
        cin>>a;

        m[a-1]++;
    }

    for(int i=0;i<n;i++)
    {
        cout<<(k-q+m[i]>0?"Yes":"No")<<"\n";
    }

    return 0;
}


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

int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(a<=b&&b<=a+w)cout << 0 << endl;
  else if(a<=b+w&&b+w<=a+w)cout << 0 << endl;
  else cout << min(abs(b-a-w),abs(b+w-a));
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))
#define num(x, y) ((x)*400+(y))

Int u[216000];
Int cnt1[216000];
Int cnt2[216000];
Int r(Int x){
  if(u[x] == x)return x;
  return u[x] = r(u[x]);
}
string str[410];
void unite(Int x, Int y){
  x = r(x);
  y = r(y);
  u[x] = y;
}

int main(){
  Int h, w, res = 0;
  for(Int i = 0;i < 216000;i++)u[i] = i;
  cin >> h >> w;
  for(Int i = 0;i < h;i++)cin >> str[i];
  for(Int i = 0;i < h;i++){
    for(Int j = 0;j < w;j++){
      if(i && str[i-1][j] != str[i][j])unite(num(i-1,j), num(i,j));
      if(j && str[i][j-1] != str[i][j])unite(num(i,j), num(i,j-1));
    }
  }

  for(Int i = 0;i < h;i++){
    for(Int j = 0;j < w;j++){
      if(str[i][j] == '#')cnt1[r(num(i,j))]++;
      if(str[i][j] == '.')cnt2[r(num(i,j))]++;
    }
  }
  for(int i = 0;i < 216000;i++){
    res += cnt1[i] * cnt2[i];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int cnt;
  int A, B;
  int i;
  int r1;

  cnt = scanf("%d %d", &A, &B);

  r1 = MAX((A+B), (A-B));
  r1 = MAX(r1, (A*B));
  
  
  printf("%d", r1);

  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) For(i,s,x+1)
#define FoR(i,s,x) for(i=s-1;i>=x;i--)
#define ForE(i,s,x) FoR(i,s+1;x)
#define fi(i,s,x) for(int i=s;i<x;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define prA(a,m,n) fi(z,m,n+1) pr(a[i]); nl 
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define mod 1000000007
#define MAX 200005


int main() {
    FASTIO;
    ll t=1, i, j, k, l;
    ll n;
    cin>>n;
    ll a[n], b[n], c[n];
    For(i,0,n) cin>>a[i]>>b[i]>>c[i];
    ll da[n]={a[0]}, db[n]={b[0]}, dc[n]={c[0]};
    For(i,1,n) {
        da[i]=a[i]+max(db[i-1],dc[i-1]);
        db[i]=b[i]+max(dc[i-1],da[i-1]);
        dc[i]=c[i]+max(da[i-1],db[i-1]);
    }    
    i--;
    cout<<max(da[i],max(db[i],dc[i]));
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long LL; //打板子留下的习惯~
LL n;
char s[11],s2[11]; //存储i 和 n / i,便于计算位数
int main()
{
    cin >> n;
    for (int i = sqrt(n); i >= 1; -- i) //正方形的启发
    {
        if (n % i == 0)
        {
            int i2 = n / i; //存储n / i
            sprintf(s,"%d",i);
            sprintf(s2,"%d",i2);//写入字符串
            cout << max(strlen(s),strlen(s2)) << endl; //strlen()函数直接搞定位数问题
            break;//由于从大到小枚举因数，故找到的一定是最优解，找到一组解直接跳循环
        }
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
char s[100010];
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	int n;
	while(cin>>n){
        vector<char>v;
        scanf("%s",s+1);
        for(int i=1;i<=n;i++) v.push_back(s[i]);
        vector<char>::iterator new_end=unique(v.begin(),v.end());
        v.erase(new_end,v.end());
        if(v.size()==0) cout<<1<<endl;
        else cout<<v.size()<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm> 
using namespace std;
int a[1000],b[1000],c[10000],min1=100000,min2=100000,x[1000];
int main(){
	int n,sum=0,s,n1;
	cin>>n;
	for(int i=0;i<n;i++)
	  {cin>>a[i];
	  if(min1>a[i]) min1=a[i];
	  b[i]=a[i];
	  }
	  sort(b,b+n);
	  for(int i=0;i<n;i++)
	  c[b[i]]=i;
	  for(int i=0;i<n;i++){
	  	s=0;min2=100000;n1=0;
	  	   while(a[i]!=b[i]&&x[i]==0)
	  	     { x[i]=1;n1++;
			   s+=a[i];
	  	    min2=min(a[i],min2);
			   i=c[a[i]];
	  	      if(x[i]) sum+=min(s+(n1-2)*min2,s+min2+(n1+1)*min1);
	  	    }  	    	  
	  }
	  cout<<sum<<endl;
} 


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define MAX 1005
#define NIL -1

struct node {
	int prnt, left, right;
};

node tr[MAX];
int n, sb[MAX], dg[MAX], dp[MAX], ht[MAX];



void setDp(int me, int d) {
	dp[me] = d;
	if (tr[me].left != NIL) setDp(tr[me].left, d + 1);
	if (tr[me].right != NIL) setDp(tr[me].right, d + 1);

	return;
}

int setHt(int me) {
	int hl = 0, hr = 0, mx;
	if (tr[me].left == NIL && tr[me].right == NIL) {
		ht[me] = 0;
		return 0;
	}
	else {
		if (tr[me].left != NIL) hl = setHt(tr[me].left) + 1;
		if (tr[me].right != NIL)  hr = setHt(tr[me].right) + 1;

		mx = max(hl, hr);
		ht[me] = mx;
		return mx;
	}
}


int main() {

	int i, j, chdCnt, me, c, l, r, left, right;
	cin >> n;
	for (i = 0; i < n; i++) tr[i].prnt = tr[i].left = tr[i].right = sb[i] = NIL;

	for (i = 0; i < n; i++) {
		cin >> me >> left >> right;

		tr[me].left = left;
		tr[me].right = right;

		int dgr = 0;

		if (left != NIL) {
			tr[left].prnt = me;
			dgr++;

			if (right != NIL) sb[left] = right;
		}
		if (right != NIL) {
			tr[right].prnt = me;
			dgr++;

			if (left != NIL) sb[right] = left;
		}

		dg[me] = dgr;
	}

	r = tr[0].prnt;
	while (tr[r].prnt != NIL)
	{
		r = tr[r].prnt;
	}

	setDp(r, 0);
	setHt(r);


	for (int i = 0;i < n;i++) {
			
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
			, i, tr[i].prnt, sb[i], dg[i], dp[i], ht[i]);

		if (tr[i].prnt == -1)
			printf("root");
		else if (tr[i].left >= 0 || tr[i].right >= 0)
			printf("internal node");
		else
			printf("leaf");
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;

void solve(){
    vector<vector<int>> G(4);
    vector<int> R(4);
    for(int i = 0; i < 3; i++){
        int a, b;
        scanf("%d%d", &a, &b);
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0; i < 4; i++)R[i] = G[i].size();
    sort(R.begin(), R.end());
    if(R[0] == 1 && R[1] == 1 && R[2] == 2 && R[3] == 2)printf("YES\n");
    else printf("NO\n");
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; ll K; cin >> N >> K;
  std::map<int, ll> mp;
  rep(i, N) {
    int a, b; cin >> a >> b;
    mp[a] += b;
  }

  for (auto iter = mp.begin(); iter != mp.end(); ++iter) {
    K -= mp[iter->first];
    if (K <= 0) {
      std::cout << iter->first << "\n";
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 4224
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var map = getMap();
        putDot(map, a - 1);
        putSharp(map, b - 1);
        display(map);
    }
    public static char[,] getMap ()
    {
        var a = new char[100, 100];
        for (int i = 0; i < 100; i++)
        {
            for (int j = 0; j < 50; j++) a[i, j] = '#';
            for (int k = 50; k < 100; k++) a[i, k] = '.';
        }
        return a;
    }
    public static void display(char[,] map)
    {
        Console.WriteLine("100 100");
        for (int i = 0; i < 100; i++)
        {
            var a = new char[100];
            for (int j = 0; j < 100; j++)
                a[j] = map[i, j];
            Console.WriteLine(string.Join("", a));
        }
    }
    public static void putDot(char[,] map, int a)
    {
        if (a == 0) return;
        var count = 0;
        for (int i = 1; i <= 61; i += 2)
            for (int j = 1; j <= 39; j += 2)
            {
                map[i, j] = '.';
                count++;
                if (count == a) return;
            }
    }
    public static void putSharp(char[,] map, int a)
    {
        if (a == 0) return;
        var count = 0;
        for (int i = 1; i <= 61; i += 2)
            for (int j = 52; j <= 90; j += 2)
            {
                map[i, j] = '#';
                count++;
                if (count == a) return;
            }
    }
}

Measured memory_bytes: 13240
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,T = map(int,(input().split()))
a = list(map(int,(input().split())))
a.append(0)
m = a[0]
p = []
for i in range(1,N):
    if m < a[i] > a[i+1]:
        M = a[i]
        p.append(M-m)
    elif a[i] < m:
        m = a[i]

ans = p.count(max(p))
print(ans)

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<ll,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

vector<vector<pii>> r;
const ll INF = 1LL<<60;
VL dijkstra(int s){
	priority_queue< pii, vector<pii>, greater<pii> > que;
	VL  d(sz(r), INF);
	d[s] = 0;
	que.push(pii(0, s));
	while(!que.empty()){
		ll cost, v; tie(cost, v) = que.top();
		que.pop();
		if(d[v] < cost) continue;
		for(const auto& rp : r[v]){ 
			ll rct, rto; tie(rto, rct) = rp;
			if(d[rto] > d[v] + rct){
				d[rto] = d[v] + rct;
				que.push(pii(d[rto], rto));
			}
		}
	}
	return d;
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,q,k;
	cin >>n;
	r.resize(n);
	rep(i, n-1){
		int a, b, c;
		cin >>a >>b >>c;
		r[a-1].emplace_back(b-1, c);
		r[b-1].emplace_back(a-1, c);
	}
	cin >>q >>k;
	auto rc = dijkstra(k-1);
	rep(i, q){
		int x, y;
		cin >>x >>y;
		
		ll ans = rc[x-1] + rc[y-1];
		cout << ans <<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 11120
#include<stdio.h>
#include<string.h>
int main(){
	char m[9][9],s[9][9];
	int i,j,k=0;
	for(j=0;j<8;j++){
		scanf("%s",m[j]);
		strcpy(s[j],m[j]);
	}
	for(k=90;k<360;k+=90){
		printf("%d\n",k);
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				s[j][7-i]=m[i][j];
			}
		}
		for(j=0;j<8;j++){
			printf("%s\n",s[j]);
			strcpy(m[j],s[j]);
		}
	}
    return 0;
}

Measured memory_bytes: 2692
import java.util.*;
public class Main {
	static long bur [][];
	public static void main (String [] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long X = sc.nextLong();
		
		bur = new long [N + 1][2]; /// N levels ... 0: (bun or patty) ... 1: patty
		bur[0][0] = 1; bur[0][1] = 1;
		
		for (int i = 1; i <= N; i++) {
			bur[i][0] = 2 * bur[i - 1][0] + 3;
			bur[i][1] = 2 * bur[i - 1][1] + 1;
		}
		
		solve(X, N);
		System.out.println(pat);
	}
	static long pat = 0;
	public static void solve (long x, int n) {// n is the level and x is the layers
			x--;
			if (n == 0) {pat++; return;}
			
			for (int i = 0; i < 2; i++) {
				if (x > 0 && x < bur[n - 1][0]) {
					solve(x, n -1);
					break;
				}else if (x >= bur[n - 1][0]) {
					x -= bur[n - 1][0];
					pat += bur[n - 1][1];
				}
				if (i == 0 && x > 0)
					{x--; pat++;}
			}
	}
}


Measured memory_bytes: 23764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func solve(n int) string {
	digit := 1
	limit := 26
	for n > limit {
		n -= limit
		digit++
		limit *= 26
	}

	n--
	nums := make([]int, digit)
	for i := digit - 1; i >= 0; i-- {
		nums[i] = n % 26
		n /= 26
	}

	alphabet := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	ans := ""
	for _, v := range nums {
		ans += alphabet[v]
	}

	return ans
}

func main() {
	n, _ := strconv.Atoi(input())
	fmt.Println(solve(n))
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;
int main()
{
	SPEED
	int n;
	cin >> n;

	vector<int> arr(n);

	cin >> arr[0];
	int net_xor = arr[0];
	
	for (int i = 1; i < n; ++i)
	{
		cin >> arr[i];
		net_xor = net_xor ^ (arr[i]);
	}

	for (int i = 0; i < n; ++i)
	{
		int temp = net_xor ^ (arr[i]);
		cout << temp << " ";
	}
	return 0;
}

Measured memory_bytes: 3912
import sys
from collections import Counter
n = int(input())
res = Counter(sys.stdin.readline().strip())
for i in range(n - 1):
    s = sys.stdin.readline().strip()
    ct = Counter(s)
    ls = []
    for k, v in res.items():
        if ct[k] < v:
            ls.append(k)
    for l in ls:
        res[l] = ct[l]
res = "".join([i*j for i, j in res.items()])
print("".join(sorted(res)))

Measured memory_bytes: 3828
k = int(input())
n = len(input())
mod = pow(10,9)+7
c = 1
ans = pow(26,k,mod)
for i in range(1,k+1):
    c *= (i+n-1)*pow(i,mod-2,mod)
    c %= mod
    ans += (c*pow(25,i,mod)*pow(26,k-i,mod))
    ans %= mod
print(ans)

Measured memory_bytes: 69732
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, K;
string s;

bool achievable(int n)
{
    //cout << n << endl;
    string ss(s);
    int l = 0, r = 0, nrev = 0, t = 0;
    queue<int> lq, rq;
    bool rev = false;
    while(true){
        while(r < N){
            //cout << __LINE__ << " " << l << " " << r << " " << nrev << " " << t << endl;
            while(r < N && !rev && s[r] == '1'){
                nrev++;
                r++;
            }
            while(r < N && rev && s[r] == '0'){
                nrev++;
                r++;
            }
            //cout << __LINE__ << " " << l << " " << r << " " << nrev << " " << t << endl;
            if(nrev >= n) return true;
            if(rev && s[r] == '1'){
                rq.push(r);
                rev = false;
            }
            if(t >= K && s[r] == '0') break;
            if(!rev && s[r] == '0' && t < K){
                lq.push(r);
                rev = true;
                t++;
            }
            //cout << __LINE__ << " " << l << " " << r << " " << nrev << " " << t << endl;
        };
        //cout << __LINE__ << " " << l << " " << r << " " << nrev << " " << t << endl;
        if(r >= N) return (nrev >= n);
        while(t >= K){
            if(s[l] == '1'){
                nrev--;
                l++;
            }
            else if(s[l] == '0' && l == lq.front()){
                while(l < rq.front()){
                    nrev--;
                    l++;
                }
                t--;
                lq.pop();
                rq.pop();
            }
        }
    }
    //cout << __LINE__ << endl;
    return false;
}


void solve()
{
    int l = 0, r = N+1;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(achievable(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout << l << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    cin >> s;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

int main(){
    string s;cin>>s;
    int k;cin>>k;
    set<string> sub; 
    for(char c='a';c<='z';c++){
        for(int i=0;i<s.size();i++){
            if(s[i]==c){
                string cc;
                cc=s[i];
                sub.insert(cc);
                for(int j=i+1;j<s.size();j++){
                    if(j-i>=5) break;
                    cc+=s[j];
                    sub.insert(cc);
                }
            }
        }
        if(sub.size()>=5) break;
    }
    vector<string> v(sub.begin(),sub.end());
    cout<<v[k-1]<<endl;
}


Measured memory_bytes: 256
fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut map = std::collections::HashMap::new();

    for _ in 0..n {
        let s: String = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            buf.trim_end().to_owned()
        };
        *map.entry(s).or_insert(0) += 1;
    }

    println!("AC x {}", *map.entry("AC".to_owned()).or_insert(0));
    println!("WA x {}", *map.entry("WA".to_owned()).or_insert(0));
    println!("TLE x {}", *map.entry("TLE".to_owned()).or_insert(0));
    println!("RE x {}", *map.entry("RE".to_owned()).or_insert(0));
}

Measured memory_bytes: 2184
using System;
using System.Linq;
using System.Collections.Generic;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = new List<string>();

            for (int i = 0; i < n; i++)
            {
                s.Add(Console.ReadLine());
            }

            s = s.Distinct().ToList();
            Console.WriteLine(s.Count);

            
        }
    }
}

Measured memory_bytes: 42812
import sys
def input():
    return sys.stdin.readline()[:-1]
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
d=[[0 for i in range(w)] for j in range(h)]
maxd=1
for i in range(h):
    for j in range(w):
        d[i][j] = abs(a[i][j]-b[i][j])
        maxd=max(maxd,d[i][j])
dp=[[0 for j in range(w)] for k in range(h)]
c=20000
dp[0][0] |= 1 << c+d[0][0]
for i in range(h):
    for j in range(w):
        if i+1<h:
            dp[i+1][j] |= dp[i][j] << d[i+1][j]
            dp[i+1][j] |= dp[i][j] >> d[i+1][j]
        if j+1<w:
            dp[i][j+1] |= dp[i][j] << d[i][j+1]
            dp[i][j+1] |= dp[i][j] >> d[i][j+1]
m=1000000
cnt = 0
for x in bin(dp[h-1][w-1])[2:][::-1]:
    if x=='1':
        m=min(m,abs(cnt-c))
    cnt+=1
print(m)

Measured memory_bytes: 70492
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int a,b,c;cin>>a>>b>>c;
    int k;cin>>k;

    rep(x, 0, k+1){
        int bb = b;
        int cc = c;
        rep(_, x) bb *= 2;
        rep(_, k-x) cc *= 2;
        if (a < bb && bb < cc) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

int bottomUp(vector<int> &h, int k)
{
	int min = 0, i, j, n = h.size() - 1;
	vector<int> dp(h.size());
	dp[n] = 0;

	for(i = n-1;i >= 1;i--)
	{
		min = -1;
		for(j = 1;j <= k;j++)
		{
			if(i+j > n)
				break;

			if(min == -1 || (dp[i + j] + abs(h[i] - h[i+j]) < min))
			{
				min = dp[i + j] + abs(h[i] - h[i+j]);
			}
		}

		dp[i] = min;
	}

	return dp[1];
}

int main()
{
	int n, k;

	cin>>n>>k;
	vector<int> h(n+1);

	for(int i = 1;i <= n;i++)
		cin>>h[i];

	cout<<bottomUp(h, k)<<'\n';
	return 0;
}


Measured memory_bytes: 1024
import math
while True:
    n=int(input())
    if n==0:
        break
    else:
        s=list(map(int,input().split()))
        S=sum(s)
        m=S/n
        a2=0
        for j in range(n):
            a2+=(s[j]-m)**2
        a2=a2/n
        a=math.sqrt(a2)
        print(f'{a:.4f}')


Measured memory_bytes: 5712
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

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

    list<int> ls;

    bool right = true;
    rep(i,n){
        int x;
        cin >> x;
        if(right){
            ls.push_front(x);
            right = !right;
        }else{
            ls.push_back(x);
            right = !right;
        }
    }

    if(right){
        for(auto it = --ls.end(); it != ls.begin(); it--){
            if(it == --ls.end()) cout << *it;
            else cout << ' ' << *it;
        }
        cout << ' ' << *ls.begin();
    }else{
        for(auto it = ls.begin(); it != ls.end(); it++){
            if(it == ls.begin()) cout << *it;
            else cout << ' ' << *it;
        }
    }
    cout << endl;
}


Measured memory_bytes: 8448
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 29 August 2020 05:40:47 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

const int N = 2e5+1;

class Solver{
    vector < int > gr[N];
    bool vis[N];
    int curLen;
    public:

    void test(){
        //int t; cin>>t; for(int i=1; i<=t; ++i)
        {
            //cout<<"Case #"<<i<<": ";
            this->solve();
        }
    }
    void solve(){
        int n,m;
        cin>>n>>m;

        for(int i=0; i<m; ++i){
            int x,y;
            cin>>x>>y;
            gr[x].push_back(y);
            gr[y].push_back(x);
        }

        memset(vis, 0, sizeof(vis));
        int ans = 1;
        for(int i=1; i<=n; ++i){
            if(!vis[i]){
                curLen = 0;
                dfs(i);
                ans = max(ans, curLen);
            }
        }

        cout<<ans<<endl;
    }

    void dfs(int cur){
        //cout<<cur<<endl;
        ++curLen;
        vis[cur] = 1;
        for(auto x: gr[cur]){
            if(!vis[x]){
                dfs(x);
            }
        }
    }


};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



Measured memory_bytes: 21016
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
int N;
void dfs(int K,string S,int m){
    if(K>=N){
        cout << S << endl;
        return ;
    }
    for(int i=0;i<m+1;i++){
        string T=S;
        T.push_back('a'+i);
        dfs(K+1,T,max(i+1,m));
    }
}

signed main(void){
    cin >> N;
    dfs(0,"",0);
    return 0;
}



Measured memory_bytes: 1536
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let mut k=read::<i32>();
    let mut i=101;
    while k>0{
        i-=1;
        if a%i==0&&b%i==0{k-=1}
    }
    println!("{}",i)
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int b[55],a[55],n;
bool check(int x,int y)
{
	if (y>n) return 1;
	for (int i=1;i<=2;i++)
	{
		if (i==1) b[y]=a[y]; else b[y]=-a[y];
		int flag=1;
		for (int j=0;j<y;j++)
		{
			int xx=b[y]+12,yy=b[j]+12;
			int t=min(abs(xx-yy),24-abs(xx-yy));
		    if (t<x) flag=0;
		}
	    if (flag==1)
		    if (check(x,y+1)) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int l=0,r=12;
	while (l<r)
	{
		int mid=(l+r+1)/2;
		if (check(mid,1)) l=mid;
		else r=mid-1;
	}
	printf("%d\n",r);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,ans=0,h;cin>>n>>k;
  rep(i,n) {cin>>h;if(h>=k) ans++;}
  print(ans);
  return 0;
}

Measured memory_bytes: 256