akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>

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

using namespace std;

int n,k,card[100];

int calc(){
	int res=0;
	rep(i,n-k+1){
		int tmp=1;
		for(int j=i;j<i+k;j++) tmp*=card[j];
		res=max(res,tmp);
	}
	return res;
}

int main(){
	for(;scanf("%d%d",&n,&k),n;){
		rep(i,n) scanf("%d",card+i);

		int c1=calc(),c2=0;
		rep(i,n) rep(j,i) {
			swap(card[i],card[j]);
			c2=max(c2,calc());
			swap(card[i],card[j]);
		}
		if(c2>=c1) printf("%d\n",c2-c1); else puts("NO GAME");
	}

	return 0;
}

Measured memory_bytes: 760
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()

    for i in range(len(l)-1):
        if l[i] == l[i+1]:
            print("NO")
            return
    
    print("YES")

if __name__ == "__main__":
    main()


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

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

vector<bool> seen;  
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto e : G[v]) {
        if (!seen[e.to]) { 
            dfs(G, e.to);
        }
    }
}

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

    Graph G(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back({b-1});
        G[b-1].push_back({a-1});
    }

    seen.assign(n, false); 
    int cnt = 0; 
    for (int i = 0; i < n; i++) {
        if (!seen[i]) {
            dfs(G, i);
            cnt++; 
        }
    }
    cout << cnt-1 << endl;

    return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

template <class T> struct BIT {
  int n;
  vector<T> bit;

  BIT(int node) : n(node), bit(node + 1, 0) {}

  void init(int node = -1) {
    if(node != -1) n = node;
    bit.clear();
    bit.resize(n + 1, 0);
  }

  inline T sum(int i) {
    T s = 0;
    while(i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }

  inline T sum(int a, int b) {
    return sum(b) - sum(a - 1);
  }

  inline void add(int i, T x) {
    while(i <= n) {
      bit[i] += x;
      i += i & -i;
    }
  }

  int get(long long k) {
    ++k;
    int res = 0;
    int N = 1;
    while(N < bit.size()) N *= 2;
    for(int i = N / 2; i > 0; i /= 2) {
      if(res + i < bit.size() && bit[res + i] < k) {
        k -= bit[res + i];
        res += i;
      }
    }
    return res + 1;
  }
};

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

  int n, q;
  cin >> n >> q;
  BIT<int> bit(n);
  rep(i, 0, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if(com) cout << bit.sum(x, y) << endl;
    else bit.add(x, y);
  }
}



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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2==0)COUT("Alice");
    else COUT("Borys");
    return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e09

using namespace std;

int main(){
  int n, r;
  while(cin >> n and cin >> r and n+r){
    vector<int> card(n);
    iota(ALL(card), 1);
    reverse(ALL(card));
    REP(i, r){
      int p, c;
      cin >> p >> c;
      p--;
      int tmp[c];
      REP(j, c) tmp[j] = card[p+j];
      for(int j=p-1; j>=0; j--) card[j+c] = card[j];
      REP(j, c) card[j] = tmp[j];
    }
    cout << card[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
import collections

n = int(input())
a = [int(n) for n in input().split()]

l = collections.Counter(a)
bars = filter(lambda x: l[x] >= 2 , l)
bars_ = sorted(bars, reverse=True)



if len(list(bars_)) <= 1:
    s = 0
else:
    if l[bars_[0]] >= 4:
        s = bars_[0] ** 2
    else:
        s = bars_[0] * bars_[1]

print(s)

Measured memory_bytes: 18600
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int h, w;
    while (cin >> h >> w, h != 0) {
        rep(i, h) {
            if (i == 0 || i == h-1) cout << string(w, '#') << endl;
            else cout << '#' << string(w-2, '.') << '#' << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3128
loop {
    n = gets.to_i
    break if n == 0
    a = (1..n).map{ gets.chomp.split("")}

    square = (1..n).map{ [0] * n }
    (0..n-1).each{|i|
        square[0][i] = (a[0][i] == '.' ? 1 : 0)
        square[i][0] = (a[i][0] == '.' ? 1 : 0)
    }

    max = 0
    (1..n-1).each{|i|
        (1..n-1).each{|j|
            if a[i][j] == '*'
                square[i][j] = 0
            else
                square[i][j] = square[i-1][j-1]
                l = square[i][j-1]
                u = square[i-1][j]
                square[i][j] = l if l < square[i][j]
                square[i][j] = u if u < square[i][j]
                square[i][j] += 1
                max = square[i][j] if square[i][j] > max
            end
        }
    }
    p max
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

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

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

	if(s[2]==s[3]&&s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}



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

typedef struct Card{ char suit, value; }Card;



void bubbleSort(Card A[], int N)
{
  int flag = 1;
  while(flag)
  {
    flag = 0;
    for(int j = N-1; j > 0; j--)
    {
      if(A[j].value < A[j-1].value)
      {
        swap(A[j], A[j-1]);
        flag = 1;
      }
    }
  }
}



void selectionSort(Card A[], int N)
{
	// i is sorted element index
	for (int i = 0; i < N - 1; i++)
	{
		int minj = i;
		for (int j = i; j < N; j++)
		{
			if (A[j].value < A[minj].value) minj = j;
		}
		swap(A[i], A[minj]);
	}
}


void print(Card C[], int N)
{
  int i;
  for(i = 0; i < N - 1; i++) cout << C[i].suit << C[i].value << " ";
  cout << C[i].suit << C[i].value << endl;
}


bool isStable(Card C1[], Card C2[], int N)
{
  for(int i = 0; i < N; i++)
  {
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}


int main(int argc, char const *argv[]) {
  const int MAX = 36;

  int N;
  cin >> N;

  Card c1[MAX], c2[MAX];
  for(int i = 0; i < N; i++) cin >> c1[i].suit >> c1[i].value;
  for(int i = 0; i < N; i++) c2[i] = c1[i];
  bubbleSort(c1, N);
  selectionSort(c2, N);

  print(c1, N);
  cout << "Stable" << endl;
  print(c2, N);
  cout << (isStable(c1, c2, N) ? "Stable" : "Not stable") << endl;

  return 0;
}



Measured memory_bytes: 3080
import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    int total = 0;
    int data[] = new int[N];

    for (int i = 0 ; i < N ; i++ ) {
      data[i] = sc.nextInt();
    }

    for (int i = 0 ; i < N ; i++ ) {
        total = data[i] + total;
    }
    //System.out.println(total);

    if (total >= H) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 49156
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {

   int n;
   cin >> n;
   int l, m=0;
  
   int a[n]={};
  
   while(cin>>l){
     
        a[m] = l;
       
        m++;
    }
  
   int min = a[0];
   int max = a[0];
 
   for(int i = 0;i<n;i++){
     
     if(min>a[i]){
       
       min = a[i];
       
     }
     
     if(max<a[i]){
       max = a[i];
     }
     
   }
   
  

   
   
   int minsum = 0;
  
  if(max==min){
   
    cout << 0 << endl;
    
  }else{
  

   for(int t = min;t<=max;t++){
     
     int sum=0;
      
      for(int x = 0;x<n;x++){
        
         
        
         sum = sum+pow(a[x]-t, 2);
        
        
        
      }
     
     if(minsum==0){
          
         minsum = sum;
          
        }
     
     if(minsum >sum && sum>0){
      
       minsum = sum;
       
     }
     
   }
  
  //int ansmin = pow(min, 2);
  
  cout << minsum << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
int ans;
int main(){
  string s;
  cin>>s;

  int n=s.size();
  int now=-1;
  rep(i,n){
  //  cerr<<s[i]<<endl;
    if(s[i]=='W' && now==1){
      ans++;
      now=0;
    }
    if(s[i]=='B' && now==0){
      ans++;
      now=1;
    }
    if(s[i]=='W')now=0;
    if(s[i]=='B')now=1;

  }

  

  cout<<ans<<endl;
}


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

std::vector<int> dfs(int n,int a,int b){
    if(n==1) return {a,b};
    b^=a;
    int step=-1;
    for(int i=0;i<n;i++) if(b&(1<<i)) {step=i;break;}
    std::vector<int> p=dfs(n-1,0,1);
    std::vector<int> q=dfs(n-1,1,(b^(1<<step))>>1);
    std::vector<int> v;
    for(int i=0;i<(int)p.size();i++) {
        int a=p[i]>>step,b=p[i]&((1<<step)-1);
        v.push_back((a<<(step+1))+b);
    }
    for(int i=0;i<(int)q.size();i++) {
        int a=q[i]>>step,b=q[i]&((1<<step)-1);
        v.push_back((a<<(step+1))+(1<<step)+b);
    }
    for(int i=0;i<(int)v.size();i++) v[i]^=a;
    return v;

}
int main (){
    int n,a,b;cin>>n>>a>>b;
    if(__builtin_parity(a^b)==0) {
        puts("NO");
        return 0;
    }
    std::vector<int> vec = dfs(n,a,b);
    puts("YES");
    for(auto x:vec) cout<<x<<endl;
    return 0;
}




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

int main(){
    
	int K, S, count=0;
	scanf("%d%d", &K,&S);
	for (int i = 0; i <= K; i++){
		for (int j = 0; j <= K; j++) {
				if (i+j>=S-K && i+j<=S) count++;
		}
	}
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 256
use std::io::*;

mod disjoint_set {
    pub struct DisjointSet {
        parent: Vec<usize>,
        size: Vec<usize>,
    }
    impl DisjointSet {
        pub fn new(n: usize) -> DisjointSet {
            DisjointSet {
                parent: (0..n).collect(),
                size: vec![1; n],
            }
        }
        fn root(&mut self, x: usize) -> usize {
            if x == self.parent[x] {
                x
            } else {
                let tmp = self.parent[x];
                self.parent[x] = self.root(tmp);
                self.parent[x]
            }
        }
        pub fn merge(&mut self, x: usize, y: usize) {
            let x = self.root(x);
            let y = self.root(y);
            if x == y {
                return;
            }
            if self.size[x] > self.size[y] {
                self.size[x] += self.size[y];
                self.parent[y] = x;
            } else {
                self.size[y] += self.size[x];
                self.parent[x] = y;
            }
        }
        pub fn same(&mut self, x: usize, y: usize) -> bool {
            self.root(x) == self.root(y)
        }
        pub fn size(&mut self, x: usize) -> usize {
            let x = self.root(x);
            self.size[x]
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();

    // 条件4: 友人関係のグラフ上でa, bは連結成分
    let mut ds = disjoint_set::DisjointSet::new(100010);
    let mut graph = vec![Vec::new(); 100010];
    for _ in 0..m {
        let a = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let b = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        ds.merge(a, b);
        graph[a].push(b);
        graph[b].push(a);
    }
    for _ in 0..k {
        let c: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let d: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        graph[c].push(d);
        graph[d].push(c);
    }

    let mut out = Vec::new();
    for i in 0..n {
        let mut ans = ds.size(i);
        for &v in graph[i].iter() {
            if ds.same(i, v) {
                ans -= 1;
            }
        }
        writeln!(out, "{}", ans - 1).ok();
    }
    stdout().write_all(&out).ok();
}


Measured memory_bytes: 21112
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,x) memset(a,x,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std; 
 
const int N=1<<11,oo=1e9;

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef bitset<N> Bit; 

int n,ans=oo,req[N],lef[N],rig[N];
Bit a,b;

Bit read(){
	string s;
	cin>>s;
	reverse(s.begin(),s.end()) ;
	n=s.length(); 
	return Bit(s); 
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	a=read(); 
	b=read(); 
	if(b.count()==0){
		if(a.count()==0)puts("0"); 
		else puts("-1"); 
		return 0; 
	}
	//cout<<a<<endl;
	//cout<<b<<endl;
	lop(i,0,n){
		int x=i,c;
		//cout<<b[0]<<endl;
		for(c=0;b[x]!=1;x=(x-1+n)%n,++c);
		//cout<<x<<" "<<i<<endl;
		lef[i]=c;
		x=i;
		for(c=0;b[x]!=1;x=(x+1)%n,++c);
		rig[i]=c;
			}
	rep(d,-n+1,n-1){
		mem(req,0); 
		int sum=oo,tot=0;
		lop(i,0,n){
			if(a[i]!=b[(i+d+n)%n]){
				cmax(req[lef[i]],rig[i]);	
				++tot;
			}
		}
		dec(i,n-2,0)cmax(req[i],req[i+1]);
		lop(l,0,n){
			if(d<=0)cmin(sum,max(-d,l)+req[l+1]);
			else cmin(sum,l+max(d,req[l+1]));
		}
		cmin(ans,tot+sum*2-abs(d));
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 384
import math as m
a,b,C = map(int,input().split())
r = m.radians(C)
print(f'{a*b*m.sin(r)/2:.5f}')
print(f'{a+b+m.sqrt(a**2+b**2-2*a*b*m.cos(r)):.5f}')
print(f'{b*m.sin(r):.5f}')



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

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

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG 0x3fffFFFFffffFFFFL
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef pair<int, int> ipair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

signed main()
{
   int A, B; cin >> A >> B;

   if (A >= 13) cout << B << endl;
   else if (A >= 6) cout << B / 2 << endl;
   else puts("0"); 

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    long long int i, j, z, n;
    int k;
    cin >> k;
    for (i = -1000; i <= 1000; i++) {
        for (j = -1000; j <= 1000; j++) {
            z = powl(i, 5);
            n = powl(j, 5);
            if ((z - n) == k) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3688
from collections import deque



def bfs(maze, visited, queue, H, W):
    count = 0
    while queue:
        y, x = queue.popleft()
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y + i, x + j
            if -1 < new_y < H and -1 < new_x < W:
                if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])

    ans = -1
    for i in range(H):
        for j in range(W):
            ans = max(ans,visited[i][j])
    return ans

H, W = map(int,input().split())

maze = [input() for i in range(H)]
visited = [[-1] * W for i in range(H)]

queue = deque([])
for i in range(H):
    for j in range(W):
        if maze[i][j] == "#":
            visited[i][j] = 0
            queue.append([i, j])

print(bfs(maze, visited, queue, H, W))

Measured memory_bytes: 140892
var d,td,x1,x2,x3 : integer;
    
procedure readnum(var n:integer);
var c : char;
begin
  read(c);
  n := Ord(c) - 48
end;

begin
  d := 753;
  readnum(x1);
  readnum(x2);
  while not eoln do begin
    readnum(x3);
    td := abs(100 * x1 + 10 * x2 + x3 - 753);
    if d > td then d := td;
    x1 := x2;
    x2 := x3
  end;
  writeln(d)
end.

Measured memory_bytes: 128
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    int n;
    cin >> n;
    if(n % 2 == 0){
        print(n);
    }else{
        print(n * 2);
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int a,b,c,x,y;
  cin >> a >> b>>c>>x>>y;
  
  int ans = 0;
  if(a+b>=2*c){
  ans+=2*c*min(x,y);
    if(x>y) ans+=min(a,2*c)*(x-y);
    if(x<y) ans+=min(b,2*c)*(y-x);
  }
  
  else ans+=a*x+b*y;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: str, op: str, B: str):
    print(eval(A + op + B))

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = (next(tokens))  # type: int
    op = next(tokens)  # type: str
    B = (next(tokens))  # type: int
    solve(A, op, B)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;
#define debug_ printf("OK\n")

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)

const long long mod = 1000000007;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    std::cin>>s>>t;
    std::cout<<t+s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const ll INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,k;
    cin >> n >> k;
    ld a[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
        a[i]=(a[i]+1)/2;
    }
    ld ans=0,count=0;
    for (ll i=0;i<k;i++){
        count+=a[i];
    }
    ans=count;
    for (ll i=k;i<n;i++){
        count-=a[i-k];
        count+=a[i];
        ans=max(ans,count);
    }
    cout << setprecision(150) <<  ans << endl;
    return 0;
}

Measured memory_bytes: 6800
apple = []
for _ in range(3):
    apple.append(list(map(int, input().split())))
a = apple[0]
b = apple[1]
c = apple[2]
if a[0]-a[1]==b[0]-b[1]==c[0]-c[1] and a[0]-a[2]==b[0]-b[2]==c[0]-c[2] and a[1]-a[2]==b[1]-b[2]==c[1]-c[2]:
    if a[0]-b[0]==a[1]-b[1]==a[2]-b[2] and a[0]-c[0]==a[1]-c[1]==a[2]-c[2] and c[0]-b[0]==c[1]-b[1]==c[2]-b[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
    

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;


int main(void) {
	string s;
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	cin >> s;
	int numa = 0, numb = 0;
	if (c < b) {
		for (int i = a;i < c - 1;i++) {
			if (s[i] != '#')numa++;
			else {
				if (s[i + 1] == '#') {
					cout << "No" << endl;
					return 0;
				}
				else numa += 2;
			}
		}
		for (int i = b;i < d - 1;i++) {
			if (s[i] != '#')numb++;
			else {
				if (s[i + 1] == '#') {
					cout << "No" << endl;
					return 0;
				}
				else numb += 2;
			}
		}
		cout << "Yes" << endl;
	}
	else {
		if (c < d) {
			for (int i = b;i < d - 1;i++) {
				if (s[i] != '#')numb++;
				else {
					if (s[i + 1] == '#') {
						cout << "No" << endl;
						return 0;
					}
					else numb += 2;
				}
			}
			for (int i = a;i < c - 1;i++) {
				if (s[i] != '#')numa++;
				else {
					if (s[i + 1] == '#') {
						cout << "No" << endl;
						return 0;
					}
					else numa += 2;
				}
			}
			cout << "Yes" << endl;
		}
		else {
			int i = 0;
			for (i = b - 1;i < d ;i++) {
				if (((i - 1) != a - 1) &&((i + 1) != c - 1) && (s[i - 1] == '.') && (s[i] == '.') && (s[i + 1] == '.'))break;
				if (i == d - 1)break;
			}
			//cout << i + 1 << " " << c - 1 << endl;
			if (i + 1 == c - 1) {
				cout << "No" << endl;
				return 0;
			}
			b = i;
			s[i] = '#';
			for (i = a;i < c - 1;i++) {
				if (s[i] != '#')numa++;
				else {
					if (s[i + 1] == '#') {
						cout << "No" << endl;
						return 0;
					}
					else numa += 2;
				}
			}
			for (i = b;i < d - 1;i++) {
				if (s[i] != '#')numb++;
				else {
					if (s[i + 1] == '#') {
						cout << "No" << endl;
						return 0;
					}
					else numb += 2;
				}
			}
			cout << "Yes" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>

#define Flash ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define F first
#define S second
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define sz size()
#define mp make_pair
#define y1 asdf
#define rc(x) return cout << x, 0

const long long MXN = 2e3 + 1;
const long long MNN = 1e5 + 1;
const long long MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const long long OO = 1e9 + 500;

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, m, cnt, dp[10][10];
char t[10][10];

int main() {
    cin >> n >> m;
    int a = 0, b = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            cin >> t[i][j];
            if(t[i][j] == '#'){
                cnt ++;
            }
        }
    }
    if(cnt > n + m - 1 || cnt < n + m - 1 || t[1][1] != '#' || t[n][m] != '#') return cout << "Impossible", 0;
    for(int i = 1; i <= n;){
        for(int j = 1; j <= m;){
            if(t[i][j + 1] == '#'){
                j ++;
                continue;
            }
            if(t[i + 1][j] == '#'){
                i ++;
                continue;
            }
            if(i == n && j == m) return cout << "Possible", 0;
            return cout << "Impossible", 0;
        }
    }
    EX;
}


Measured memory_bytes: 256
s = list(input())
n = len(s)
s.sort()
#print(n,s)
num_0 = 0
num_1 = 0
for i in range(n):
    if s[i] == "1":
        num_0 = i
        break
num_1 = n - num_0
#print(num_0,num_1)

ans = 2*min(num_0,num_1)
print(ans)

Measured memory_bytes: 50544
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
 
int main(){
	io;
	ll n,k;
	cin>>n>>k;
	n=n%k;
	ll ans=abs(n-k);
		ans=min(n,ans);
		cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    for (int i = 1; i <= 10000; i++){
        int x;
        cin >> x;
        if(x == 0){
            return 0;
        }
        printf("Case %d: %d", i, x);
        printf("\n");
    }
}



Measured memory_bytes: 3044
def prime(p):
    flag = True
    for i in range(2,(int(p**0.5)+1)):
        if p%i==0:
            flag = False
            break
    return flag

X = int(input())

while True:
    result = prime(X)
    if result:
        break
    else:
        X += 1

print(X)

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    for(int i=0; i<n; i++) cin >> v[i];
    for(int i=0; i<n; i++) cin >> c[i];
    int ans = 0;
    for(int i=0; i<n; i++){
        if(v[i] - c[i] >= 0) ans += v[i] - c[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by 26019 on 2020/6/14/014.
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
vector<int> arr;

void solve() {
    string s;
    cin >> s;
    if (s == "MON") {
        cout << 6;
    } else if (s == "TUE") {
        cout << 5;
    } else if (s == "WED") {
        cout << 4;
    } else if (s == "THU") {
        cout << 3;
    } else if (s == "FRI") {
        cout << 2;
    } else if (s == "SAT") {
        cout << 1;
    } else {
        cout << 7;
    }
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int h1,h2;
  int m1,m2;
  int k;


  scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
  int time1=h1*60+m1;
  int time2=h2*60+m2;



  printf("%d\n",time2-time1-k);
  return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>

int main(){
 int A,B;
  scanf("%d %d", &A, &B);
  
  if(A>=13){
    printf("%d", B);
  }else if(6<=A && A<=12){
    printf("%d", B/2);
  }else{
    printf("%d", 0);
  }
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	vector<ll>V(N);
	for (int i = 0; i < N; ++i) {
		cin >> V.at(i);
	}
	sort(V.begin(), V.end(), greater<ll>());
	int count = 1;
	int flag = 0;
	ll b = 0, c = 0;
	for (int i = 1; i < N; ++i) {
		if (V.at(i - 1) != V.at(i)) {
			count = 1; 
			continue;
		}
		else count++;
		if (count == 2 && flag == 0) {
			b = V.at(i);
			flag = 1;
			continue;
		}
		if (count == 4) {
			c = V.at(i);
			break;
		}
		if (count == 2 && flag == 1) {
			c = V.at(i);
			break;
		}
	}
	ll ans = b * c;
	cout << ans << endl;
	return 0;
}

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


int main(int argc, char const *argv[]) {
    int  N;
    double T,A;
    cin >> N >> T >> A;

    double H[N];

    for(int i=0;i<N;i++)cin >> H[i];

    double min = abs(T - 0.006*H[0]-A);
    int min_i=0;
    for(int i=1;i<N;i++){

        if(abs(T - 0.006*H[i]-A) < min){
            min = abs(T - 0.006*H[i]-A);
            min_i = i;
        }
    }
    cout << min_i + 1 <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	int a;
	int v[n];
	for(a=0;a<n;a++){
		scanf("%d",&v[a]);
	}
	int c[n];
	for(a=0;a<n;a++){
		scanf("%d",&c[a]);
	}
	int sum=0;
	for(a=0;a<n;a++){
		if(v[a]-c[a]>0){
			sum+=(v[a]-c[a]);
		}
	}
	printf("%d",sum);
return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll LL_INF = LLONG_MAX;
const long double PI = (acos(-1));
const ull MOD = 1000000007;


struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main(){
    int N;
    cin >> N;
    map<int,int> A;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        A[a]++;
    }
    int max_n = 0;
    for(int i = 1; i < 100000; i++){
        max_n = max(max_n, A[i - 1] + A[i] + A[i + 1]);
    }
    cout << max_n << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

bool isPath(vector<string> &grid, int i ,int j) { 
  return i >= 0 && i < grid.size() && j >= 0 && j < grid[0].size() && grid[i][j] == '.';
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  for (int i = 0; i < H; i++) {
    cin >> grid[i];
  }
  int res = 0;
  vector<vector<int>> dirs = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid[i][j] != '#') {
        vector<vector<int>> visited(H, vector<int>(W, 0));
        queue<pii> Q;
        Q.push({i, j});
        int step = 0;
        while (!Q.empty()) {
          int q_size = Q.size();
          for (int k = 0; k < q_size; k++) {
            auto p = Q.front();
            Q.pop();
            if (!isPath(grid, p.first, p.second) || visited[p.first][p.second] == 1) {
              continue;
            }
            res = max(res, step);
            visited[p.first][p.second] = 1;
            for (auto &dir : dirs) {
              Q.push({dir[0] + p.first, dir[1] + p.second});
            }
          }
          step++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}

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

int main() {
    int A[3];
    for (int i=0; i<3; ++i) {
        cin >> A[i];
    }
    sort(A, A+3, greater<int>());

    int result = 0;
    result += A[0] - A[1];
    A[1] += result;
    A[2] += result;
    if ((A[0] - A[2])%2 == 0) {
        result += (A[0] - A[2])/2;
    } else {
        A[0] += 1;
        A[1] += 1;
        result += (A[0] - A[2])/2;
        result += 1;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 2000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li][10],c[li];
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d",&n);
	FOR{
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	FOR{
		dp[i][1]=max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
		dp[i][2]=max(dp[i-1][1]+b[i],dp[i-1][3]+b[i]);
		dp[i][3]=max(dp[i-1][1]+c[i],dp[i-1][2]+c[i]);
	}
	cev=max(dp[n][1],dp[n][2]);
	cev=max(cev,dp[n][3]);
	printf("%d\n",cev);
	return 0;
}



Measured memory_bytes: 8840
#include <bits/stdc++.h>
#define ll long long
const ll MOD = 1e9+7;

ll q_pow(ll a, ll b){
        ll ans = 1;
        while(b>0) {
                if(b&1) {
                        (ans*=a)%=MOD;
                }
                (a*=a)%=MOD;
                b/=2;
        }
        return ans;
}

int main(){
  using namespace std;
  int n,k;
  ll ans=0;
  cin >> n >> k;
  ll sumGCD[k+1];
  for(int i=k; i>=1; i--){
    sumGCD[i]=q_pow(k/i,n);
    for(int j=2;; j++){
      if(i*j>k) break;
      sumGCD[i]=(sumGCD[i]-sumGCD[i*j]+MOD)%MOD;
    }
    ans=(ans+i*sumGCD[i])%MOD;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b<c)
    swap(b,c);
  if(a<b)
    swap(a,b);
  if(b<c)
    swap(b,c);
  cout<<10*a+b+c<<endl;
}
    
  

Measured memory_bytes: 256
e,y=map(int, input().split())
if e == 0:
    if 1868 <= y <= 1911:
        print('M'+str(y-1867))
    elif 1912 <= y <= 1925:
        print('T'+str(y-1911))
    elif 1926 <= y <= 1988:
        print('S'+str(y-1925))
    elif 1989 <= y <= 2016:
        print('H'+str(y-1988))
elif e == 1:
    print(1867+y)
elif e == 2:
    print(1911+y)
elif e == 3:
    print(1925+y)
elif e == 4:
    print(1988+y)


Measured memory_bytes: 5596
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input().rstrip()
    k = len(s)
    win = s.count("o")
    print("YES" if 15 - k >= 8 - win else "NO")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start();
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int x = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];  // 偶数
			int m = vs[1];  // 奇数
			long ans = 0;
			if (n >= 2) {
				ans += CombinationDP(n, 2, mod);
			}
			if (m >= 2) {
				ans += CombinationDP(m, 2, mod);
			}
			Console.WriteLine(ans);


			//Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(sw.Elapsed);
		}
		#region 場合の数（DP計算版） long CombinationDP(int n, int r, int mod)
		static long CombinationDP(int n, int r, int mod)
		{
			r = Math.Min(r, n - r);
			long[,] dp = new long[n + 1, r + 1];
			dp[0, 0] = 1;
			for (int i = 1; i <= n; i++) {
				dp[i, 0] = 1;
				for (int j = 1; j <= i && j <= r; j++) {
					dp[i, j] = (dp[i - 1, j - 1] + dp[i - 1, j]) % mod;
				}
			}
			return dp[n, r];
		}
		#endregion
	}
}

Measured memory_bytes: 13396
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

long long par[200007],mx=1,sz[200007];

void mk(long long n)
{
    long long i;
    for(i=0;i<=n;i++)
    {
        par[i]=i;
        sz[i]=1;
    }
}

long long fin(long long a)
{
    if(par[a]==a)
    {
        return a;
    }
    return par[a]=fin(par[a]);
}

void uni(long long a,long long b)
{
    a=fin(a);
    b=fin(b);
    if (a != b) {
        if (sz[a] < sz[b])
            swap(a, b);
        par[b] = a;
        sz[a] += sz[b];
        mx=max(mx,sz[a]);
    }
     mx=max(mx,sz[a]);mx=max(mx,sz[b]);
}

int main()
{
    long long n,m,i,x,y;
    cin>>n>>m;
  mk(n+1);
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        uni(x,y);
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 6724
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	string a;
	cin>>a;
	int leftR[n],rightR[n],leftW[n],rightW[n];
	int R=0,W=0;
	leftR[0]=0,leftW[0]=0,rightR[n-1]=0,rightW[n-1]=0;
	for(int i=1;i<n;i++){
	    if(a[i-1]=='R'){
	        R++;
	    }
	    else{
	        W++;
	    }
	}
	for(int i=1;i<n;i++){
	    if(a[i-1]=='R'){
	        leftR[i]=leftR[i-1]+1;
	    }
	    else{
	        leftR[i]=leftR[i-1];
	    }
	}
	for(int i=1;i<n;i++){
	    if(a[i-1]=='W'){
	        leftW[i]=leftW[i-1]+1;
	    }
	    else{
	        leftW[i]=leftW[i-1];
	    }
	}
	for(int i=n-2;i>=0;i--){
	    if(a[i+1]=='R'){
	        rightR[i]=rightR[i+1]+1;
	    }
	    else{
	        rightR[i]=rightR[i+1];
	    }
	}
	for(int i=n-2;i>=0;i--){
	    if(a[i+1]=='W'){
	        rightW[i]=rightW[i+1]+1;
	    }
	    else{
	        rightW[i]=rightW[i+1];
	    }
	}
	int ans=INT_MAX;
	for(int i=R;i<n;i++){
	    int y=leftW[i];
	    int z=rightR[i];
	    int p=max(y,z)-min(y,z);
	    ans=min(ans,(min(y,z)+p));
	}
	cout<<ans<<"\n";
} 

Measured memory_bytes: 6856
import numpy as np
# 複数個格納
# A,B = map(int, input().split())
#A = int(input())
# 行列化
# A = np.array(A)
# A=A.reshape(1,-1)
# A=A.T
#行列の比較
#C=((A%2 == vector0).all())
#行列の作成
#A=(np.arange(0,2000,500)).reshape(1,-1)

A,B = map(int, input().split())
print(A*B)



Measured memory_bytes: 27004
#include<iostream>
using namespace std;
#define MAX 100


int main(){
	int fibonacci_number[MAX] = {1,1};
	int n;
	
	cin>>n;
	for(int i = 2; i <= n; i++)
		fibonacci_number[i] = fibonacci_number[i-1] + fibonacci_number[i-2];
	
	cout<<fibonacci_number[n]<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define N 210
#define M 10000010
#define ll long long
#define inf 2147483647
using namespace std;

struct edge{int x, y, l, next;}a[100010];
int n, m, last, x, w[N], l, P[M], p[N], flag[M], T, q[N], ans, lev[N], sum[2];

inline void prev(){
	l=0; memset(flag, 0, sizeof(flag)); flag[1]=1;
	for(int i=2; i<=10000000; i++){
		if(!flag[i])P[++l]=i;
		for(int j=1; j<=l&&(ll)i*P[j]<=10000000; j++){
			flag[i*P[j]]=1;
			if(i%P[j]==0)break;
		}
	}
}

inline void add(int x, int y, int z){
	a[++l].x=x; a[l].y=y; a[l].l=z; a[l].next=p[x]; p[x]=l;
	a[++l].x=y; a[l].y=x; a[l].l=0; a[l].next=p[y]; p[y]=l;
}
inline int bfs(){
	queue<int>q; q.push(0);
	memset(lev, 0, sizeof(lev)); lev[0]=1;
	while(!q.empty()){
		int v=q.front(); q.pop();
		for(int i=p[v]; i; i=a[i].next)
			if(a[i].l&&!lev[a[i].y]){
				lev[a[i].y]=lev[v]+1;
				if(a[i].y==T)return 1;
				q.push(a[i].y);
			}
	}
	return 0;
}
inline int dfs(int x, int ss){
	if(x==T||!ss)return ss;
	int s1=ss;
	for(int i=q[x]; i&&ss; i=a[i].next)
		if(lev[a[i].y]==lev[x]+1){
			int tt=dfs(a[i].y, min(a[i].l, ss));
			ss-=tt; a[i].l-=tt; a[i^1].l+=tt; q[x]=i;
		}
	if(s1==ss)lev[x]=-1;
	return s1-ss;
}

int main(){
	scanf("%d", &m); n=0; last=0;
	for(int i=1; i<=m; i++){
		scanf("%d", &x);
		if(last&&last+1<x){w[++n]=last+1; w[++n]=x;}
		if(!last)w[++n]=x;
		last=x;
	}
	prev();
	w[++n]=last+1; sum[0]=sum[1]=0;
	l=1; memset(p, 0, sizeof(p)); T=n+1;
	for(int i=1; i<=n; i++){
		if(w[i]&1){sum[1]++; add(i, T, 1);}
		else{sum[0]++; add(0, i, 1);}
	}
	for(int i=1; i<=n; i++)if(!(w[i]&1))
		for(int j=1; j<=n; j++)if(w[j]&1){
			x=max(w[i]-w[j], w[j]-w[i]);
			if(!flag[x])add(i, j, 1);
		}
	ans=0; while(bfs()){memcpy(q, p, sizeof(q)); ans+=dfs(0, inf);}
	sum[0]-=ans; sum[1]-=ans;
	printf("%d", ans+sum[0]/2*2+sum[1]/2*2+(sum[0]&1)*3);
	return 0;
}

Measured memory_bytes: 43392
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N;
std::vector<ll> A;
ll ans = 0;

int main()
{
  scanf( "%lld", &N );
  A.resize( N );
  rep( i, N )
    scanf( "%lld", &A[i] ), A[i] -= i+1;

  std::sort( all(A) );

  ll b = N%2 ? A[N/2] : int((A[N/2-1]+A[N/2])/2.0+0.5);

  rep( i, N )
    ans += llabs(A[i]-b);

  printf( "%lld\n", ans );
  
  return 0;
}

Measured memory_bytes: 1792
L,R=map(int,input().split())
mod=10**9+7

DP_ini=[[[0 for i in range(2)] for j in range(2)] for k in range(64)]

import copy
ANS=0

for begin in range(64):
    DP=copy.deepcopy(DP_ini)

    if L<(1<<(begin+1)) and (1<<begin)<=R:

        if not(1<<begin <= L <  1<<(begin+1)) and not(1<<begin <= R <  1<<(begin+1)):
            DP[begin][0][0]=1

        elif 1<<begin <= L <  1<<(begin+1) and not(1<<begin <= R <  1<<(begin+1)):
            DP[begin][1][0]=1

        elif not(1<<begin <= L <  1<<(begin+1)) and 1<<begin <= R <  1<<(begin+1):
            DP[begin][0][1]=1

        else:
            DP[begin][1][1]=1

    for keta in range(begin-1,-1,-1):

        if L & (1<<keta)==0 and R & (1<<keta)==0:
            DP[keta][0][0]=DP[keta][0][0]+DP[keta+1][0][0]*3+DP[keta+1][0][1]*0+DP[keta+1][1][0]*1+DP[keta+1][1][1]*0
            DP[keta][0][1]=DP[keta][0][1]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*1+DP[keta+1][1][0]*0+DP[keta+1][1][1]*0
            DP[keta][1][0]=DP[keta][1][0]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*0+DP[keta+1][1][0]*2+DP[keta+1][1][1]*0
            DP[keta][1][1]=DP[keta][1][1]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*0+DP[keta+1][1][0]*0+DP[keta+1][1][1]*1

        elif L & (1<<keta)!=0 and R & (1<<keta)==0:
            DP[keta][0][0]=DP[keta][0][0]+DP[keta+1][0][0]*3+DP[keta+1][0][1]*0+DP[keta+1][1][0]*0+DP[keta+1][1][1]*0
            DP[keta][0][1]=DP[keta][0][1]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*1+DP[keta+1][1][0]*0+DP[keta+1][1][1]*0
            DP[keta][1][0]=DP[keta][1][0]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*0+DP[keta+1][1][0]*1+DP[keta+1][1][1]*0
            DP[keta][1][1]=DP[keta][1][1]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*0+DP[keta+1][1][0]*0+DP[keta+1][1][1]*0

        elif L & (1<<keta)==0 and R & (1<<keta)!=0:
            DP[keta][0][0]=DP[keta][0][0]+DP[keta+1][0][0]*3+DP[keta+1][0][1]*1+DP[keta+1][1][0]*1+DP[keta+1][1][1]*0
            DP[keta][0][1]=DP[keta][0][1]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*2+DP[keta+1][1][0]*0+DP[keta+1][1][1]*1
            DP[keta][1][0]=DP[keta][1][0]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*0+DP[keta+1][1][0]*2+DP[keta+1][1][1]*1
            DP[keta][1][1]=DP[keta][1][1]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*0+DP[keta+1][1][0]*0+DP[keta+1][1][1]*1
        else:
            DP[keta][0][0]=DP[keta][0][0]+DP[keta+1][0][0]*3+DP[keta+1][0][1]*1+DP[keta+1][1][0]*0+DP[keta+1][1][1]*0
            DP[keta][0][1]=DP[keta][0][1]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*2+DP[keta+1][1][0]*0+DP[keta+1][1][1]*0
            DP[keta][1][0]=DP[keta][1][0]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*0+DP[keta+1][1][0]*1+DP[keta+1][1][1]*0
            DP[keta][1][1]=DP[keta][1][1]+DP[keta+1][0][0]*0+DP[keta+1][0][1]*0+DP[keta+1][1][0]*0+DP[keta+1][1][1]*1

    #print(begin,DP[0])
    ANS+=sum(DP[0][0])+sum(DP[0][1])

print(ANS%mod)

Measured memory_bytes: 3720
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,i,ans=0;
    string a,b,c;
    cin >> n >> a >> b >>c;
    char p,q,r;
    for(i=0;i<n;i++){
        p = a.at(i);
        q = b.at(i);
        r = c.at(i);
        if(p-q==0&&q-r==0&&r-p==0){;}
        else if(p-q!=0&&q-r!=0&&r-p!=0){ans += 2;}
        else {ans += 1;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,a,b[100010],i,c,d;
  double s;
  while(scanf("%d %d",&n,&m),n){
    c=d=0;
    for(i=0;i<110;i++)b[i]=0;
    for(i=s=0;i<n;i++){
      scanf("%d",&a);
      b[a/m]++;
      if(c<a/m)c=a/m;
      if(d<b[a/m])d=b[a/m];
    }
    for(i=0;i<=c;i++)s+=1.0*b[i]*(c-i)/(c);
    printf("%.10lf\n",s/d+0.01);
  }
  return 0;
}



Measured memory_bytes: 2028