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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define P pair<int,int>
typedef long long ll;

using namespace std;

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

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//s.find(w[i])==string::npos
//findの使い方

long long int n,cnt=0,ans=1,a,b,c,cmp,data,m,h,x,y;

string s,w;

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

	cin >> n >> a;
	ans*=a;
	rep(i,n-1){
	    ans*=a-1;
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
a,b = map(lambda x:
          int(format(int(x),'b')),input().split())
a -= 1
A = str(a)
la = len(A)
ga = [0]*la
if a%4 == 1 or a%4 == 2:
  ga[-1] = 1
for ai in range(0,la-1):
  if A[ai] == '1' and A[-1] == '0':
    ga[ai] = 1
aa = 0
for ai in range(la):
  aa *= 2
  aa += ga[ai]
B = str(b)
lb = len(B)
gb = [0]*lb
if b%4 == 1 or b%4 == 2:
  gb[-1] = 1
for bi in range(0,lb-1):
  if B[bi] == '1' and B[-1] == '0':
    gb[bi] = 1
bb = 0
for bi in range(lb):
  bb *= 2
  bb += gb[bi]
if a < 0:
  print(bb)
else:
  print(aa^bb)

Measured memory_bytes: 3064
import java.util.*;
import java.math.*;
import java.lang.*;
import java.io.*;

public class Main{
  public static void main(String args[]) throws IOException{
    Scanner s=new Scanner(System.in);
    int a=s.nextInt();
    int b=s.nextInt();
    if(a>(2*b))
      System.out.println(a-(2*b));
    else
      System.out.println(0);
  }
}


Measured memory_bytes: 21844
N, K = map(int, input().split())
d = 0
A = []
l = [1]*N
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(len(A)):
    l[A[j]-1] = 0
    
print(sum(l))

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if(a < b) {a = b; return true;}
    return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if(a > b) {a = b; return true;}
    return false;
}

template<class T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;

template<typename T>
T med3(T a, T b, T c) {
    vector<T> v{a,b,c};
    if (v[1] > v[2]) swap(v[1], v[2]);
    if (v[0] > v[1]) swap(v[0], v[1]);
    if (v[1] > v[2]) swap(v[1], v[2]);
    return v[1];
}

template<typename T>
void quick_sort(vector<T>& a, int l, int r) {
    if (l >= r) return;
    int i = l, j = r - 1;
    T pivot = med3(a[l], a[(l + r) / 2], a[r - 1]);
    while (true) {
        while (a[i] < pivot) ++i;
        while (pivot < a[j]) --j;
        if (i >= j) break;
        swap(a[i], a[j]);
        ++i, --j;
    }
    quick_sort(a, l, i);
    quick_sort(a, j + 1, r);
}


int main() {

    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    quick_sort(a, 0, n);

    int alice = 0, bob = 0;
    REP(i, n) {
        (i & 1 ? bob : alice) += a[n-1-i];
    }

    cout << alice - bob << endl;

    return 0;
}


Measured memory_bytes: 3612
N, M = tuple([int(x) for x in input().split(' ')])

minN = 1
maxN = N
for i in range(M):
    L, R = tuple([int(x) for x in input().split(' ')])
    minN = max(L, minN)
    maxN = min(R, maxN)
print(max(maxN-minN+1,0))

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

namespace MyProgram
{
    public class Program
    {
        public static void Main(){
            int n = int.Parse(Console.ReadLine());
            　
            int[] dp = new int[n+1];
            for(int i = 0 ; i <= n ; i++) dp[i] = 99999999;
            dp[0] = 0;
            
            for(int i = 1 ; i <= n ; ++i)
            {
                for(int six = 1; six <= i; six *= 6)
                {
                    dp[i] = Math.Min(dp[i], dp[i-six]+1);
                }
                for(int nine = 1 ; nine <= i ; nine *= 9)
                {
                    dp[i] = Math.Min(dp[i], dp[i-nine]+1);
                }
            }
            
            Console.WriteLine(dp[n]);
        }
    }
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b-a)%2==0) cout << ((b-a)/2) << endl;
    else {
        cout << (min(a-1, n-b)+1+(b-a)/2) << endl;
    }
    return 0;
}


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

int A[100100];
int n;

void replace(int i,int j){
    int temp=A[i];
    A[i]=A[j];
    A[j]=temp;
}

int partition(int p,int r){
    int x=A[r];
    int i=p-1;
    for(int j=p;j<r;++j){
        if(A[j]<=x){
            //++i;
            replace(++i,j);
        }
    }
    //replace(i+1,r);
    //return i+1;
    replace(++i,r);
    return i;
}

int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>A[i];
    }
    int result=partition(0,n-1);

    for(int i=0;i<n;++i){
        if(i==result){
            cout<<"[";
        }
        cout<<A[i];
        if(i==result){
            cout<<"]";
        }
        if(i!=n-1){
            cout<<" ";
        }
        else{
            cout<<"\n";
        }
    }
}


Measured memory_bytes: 3480
#include <iostream>
#include <map>
#include <utility>
using namespace std;

int main () {
  int n, t;
  cin >> n >> t;
  int a[n];
  pair<int, int> ans[n - 1];
  for (int i = 0; i < n; i++) {
    cin >> a[i];  
  }
  for (int i = n - 2; i >= 0; i--) {
    // iについて考える 
    if (i == n - 2) {
      ans[i] = make_pair(a[i + 1], 1);  
    }     
    else {
      if (ans[i + 1].first == a[i + 1]) {
        ans[i] = make_pair(ans[i + 1].first, ans[i + 1].second);  
      }  
      else {
        if (ans[i + 1].first > a[i + 1]) {
          ans[i] = ans[i + 1];  
        }    
        else {
          ans[i] = make_pair(a[i + 1], 1);  
        }
      } 
    }
  }
  int max = -1;
  for (int i = 0; i < n - 1; i++) {
    if (ans[i].first - a[i] > max) {
      max = ans[i].first - a[i];    
    }  
  }
  int num = 0;
  for (int i = 0; i < n - 1; i++) {
    if (ans[i].first - a[i] == max) {
      num = num + ans[i].second;  
    }  
  }
  cout << num << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[2];
  for(int j=0;j<2;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  bool f=false;
  
  
  for(int i=0;i<4;i++){
    d[1].roll('R');
    for(int j=0;j<4;j++){
      d[1].roll('N');
      if(same(d[0],d[1])) f=true;
    }
  }
  d[1].roll('E');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }

  d[1].roll('W');
  d[1].roll('W');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
  
  cout << (f?"Yes":"No") << endl;
  return 0;
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	char s1[20], s2[20], s3[20];
	scanf("%s %s %s", &s1, &s2, &s3);
	printf("%c%c%c\n", s1[0] - 32 , s2[0] - 32, s3[0] - 32);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;

  vector<ll> v(n + 1);
  v[0] = 2;
  v[1] = 1;
  REP(i, n - 1) v[i + 2] = v[i + 1] + v[i];

  cout << v[n] << endl;
  return 0;
}


Measured memory_bytes: 256
let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let z = Array.fold_left (+) 0 a in
  let ans = ref max_int in
  let x = ref 0 in
  for i = 0 to n - 2 do
    x := !x + a.(i);
    let t = abs (z - 2 * !x) in
    if t < !ans then ans := t;
  done;
  Printf.printf "%d\n" !ans

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

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    int ans = t/a;
    ans *= b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
// C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
 
//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
 
int dp[5010] = {};
bitset<5010> flag[5010] = {};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	sort(all(a));
	dump(a);
	int ans = N;
	dp[0] = 1;
	rep(i, 1, 5010)flag[i] = ~flag[i];
	rep(i, 0, N) {
		if (a[i] >= K)break;
		rrep(j, 0, K - a[i]) {
			if (dp[j]) {
				dp[j + a[i]] = dp[j];
				bitset<5010> tmp;
				tmp[i] = 1;
				flag[j + a[i]] &= flag[j] | tmp;
			}
		}
	}
	rep(i, 0, N) {
		if (a[i] >= K) {
			ans--;
			continue;
		}
		rep(j, K - a[i], K) {
			if (dp[j]) {
				dump(flag[j]);
				if (flag[j][i])continue;
				dump(i, a[i], j);
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h, w,count;
  cin >> h >> w;
  vector<vector<char>> s(h+2,vector<char>(w+2));
  for (int i=0;i<h;i++){
    for (int j=0;j<w;j++){
      cin >> s[i+1][j+1];
    }
  }
  for(int i=1;i<h+1;i++){
    for (int j=1;j<w+1;j++){
      count=0;
      if(s[i][j]=='.'){
        if(s[i-1][j-1]=='#'){
          count++;
        }
        if(s[i-1][j]=='#'){
          count++;
        }
        if(s[i-1][j+1]=='#'){
          count++;
        }
        if(s[i][j-1]=='#'){
          count++;
        }
        if(s[i][j+1]=='#'){
          count++;
        }
        if(s[i+1][j-1]=='#'){
          count++;
        }
        if(s[i+1][j]=='#'){
          count++;
        }
        if(s[i+1][j+1]=='#'){
          count++;
        }
        s[i][j]=char(count+'0');
      }
    }
  }
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cout << s[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == (b + c) || b == (a + c) || c == (a + b)) {
        cout << "Yes" << endl; 
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int n,c,s[10][10],dx[6]={-1,-1,0,1,1,0},dy[6]={-1,0,1,1,0,-1};
bool visited[10][10],ad0[10][10];
bool inn(int x,int y) { return (0<=x&&0<=y&&x<n&&y<=x); }
void dfs(int x,int y,int id){
	visited[x][y]=true;
	ad0[x][y]=true;
	rep(i,6){
		int nx=x+dx[i],ny=y+dy[i];
		if(inn(nx,ny)&&!visited[nx][ny]&&s[x][y]==s[nx][ny]) dfs(nx,ny,id);
	}
}
int main(){
	while(true){
		cin>>n>>c;
		if(n==0) break;
		rep(i,n) rep(j,i+1) cin>>s[i][j];
		int ans=-100000;
		rep(i,n) rep(j,i+1) if(s[i][j]==0){
			s[i][j]=c;
			rep(k,n) rep(h,k+1) visited[k][h]=0,ad0[k][h]=0;
			rep(k,n) rep(h,k+1) if(s[k][h]==0){
				rep(d,6){
					int nx=k+dx[d],ny=h+dy[d];
					if(inn(nx,ny)&&s[nx][ny]!=0) dfs(nx,ny,s[nx][ny]);
				}
			}
			int now=0;
			rep(k,n) rep(h,k+1) if(!ad0[k][h]){
				if(s[k][h]==c) now--;
				else if(s[k][h]!=0) now++;
			}
/*			rep(k,n){
				rep(h,k+1) cout << s[k][h] << " ";
				cout << endl;
			}
			cout << endl;
			rep(k,n){
				rep(h,k+1) cout << ad0[k][h] << " ";
				cout << endl;
			}
			cout << endl<<endl;*/
			ans=max(ans,now);
			s[i][j]=0;
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

string s;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  int n = s.length();
  vector<vector<int>> dp(n, vector<int>(4, 1));
  range(i, 0, n) {
    range(j, max(1, i - 3), i + 1) {
      int c = i - j;
      range(x, max(0, j - 4), j) {
        int t = j - 1 - x;
        if(s.substr(x, t + 1) != s.substr(j, c + 1)) dp[i][c] = max(dp[i][c], dp[j - 1][t] + 1);
      }
    }
  }
  int res = 1;
  range(i, 0, 4) res = max(res, dp[n - 1][i]);
  cout << res;
  return 0;
}


Measured memory_bytes: 11412
//author: zekigurbuz (Zeki Gurbuz) 2019

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef queue<int> qi;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, vi> mvi;
typedef map<int, vpii> mvpii;
typedef priority_queue<int> pqi;
typedef set<int> si;

#define int ll
#define double ld
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rsz resize
#define forn(a,b) for(int a=0;a<b;++a)
#define rep(a,b,c) for(int a=b;a<c;++a)
#define all(x) begin(x), end(x)

const ld PI = 4*atan((ld)1);
const int MOD = 1000000007; //998244353
const ll INF = 1e18;
const int N = 200005;

ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a,ll b){return a / gcd(a, b) * b;}

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }



signed main() {ios_base::sync_with_stdio(0);cin.tie(0);
	
	int n; cin >> n;
	ld c = 0.0;
	rep(i, 1, n + 1) {
		if (i % 2 == 1) c++;
	}
	cout << c / n << endl;
	
return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	int l;
	cin >> l;
	if (l % 3 == 0) {
		cout << (l / 3) * (l / 3) * (l / 3) << endl;
	}
	else {
		double max =  -inf;
		for (double i = l/3; i < l/3+1; i += 0.0001) {
			for (double j = l/3; j < l/3+1; j += 0.0001) {
				double z = l - i - j;
				double ans = z * i * j;
				if (max < ans) {
					max = ans;
				}
			}
		}
		printf("%12f", max);
	}
	return 0;
}




Measured memory_bytes: 256
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class UnionFind:
    def __init__(self, n):
        self.state = [-1] * n
        #self.size_table = [1<<i for i in range(n)]
        # cntはグループ数
        # self.cnt = n

    def root(self, u):
        v = self.state[u]
        if v < 0: return u
        self.state[u] = res = self.root(v)
        return res

    def merge(self, u, v):
        ru = self.root(u)
        rv = self.root(v)
        if ru == rv: return
        du = self.state[ru]
        dv = self.state[rv]
        if du > dv: ru, rv = rv, ru
        if du == dv: self.state[ru] -= 1
        self.state[rv] = ru
        # self.cnt -= 1
        #self.size_table[ru] |= self.size_table[rv]
        #self.size_table[rv]=0
        return

def main():
    n,k,l=MI()
    road=UnionFind(n)
    train=UnionFind(n)
    for _ in range(k):
        u,v=MI1()
        road.merge(u,v)
    for _ in range(l):
        u,v=MI1()
        train.merge(u,v)
    cnt=defaultdict(int)
    for u in range(n):
        cnt[road.root(u),train.root(u)]+=1
    ans=[cnt[road.root(u),train.root(u)] for u in range(n)]
    print(*ans)

main()


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

const long long MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<long long>> dp(n+1, vector<long long>(13, 0));

    dp[0][0] = 1;
    // digは大きい方から何桁目か(dig=0のときは上から1桁目のチェック)
    for (int dig = 0; dig < n; ++dig) {
        // 13で割った余り
        for (int d = 0; d < 13; ++d) {
            if (s[dig] == '?') {
                for (int i = 0; i < 10; ++i) {
                    // 新しい余り
                    int nd = (10 * d + i) % 13;
                    dp[dig+1][nd] += dp[dig][d];
                    dp[dig+1][nd] %= MOD;
                }
            } else {
                int i = s[dig] - '0';
                int nd = (10 * d + i) % 13;
                dp[dig+1][nd] += dp[dig][d];
                dp[dig+1][nd] %= MOD;
            }
        }
    }
    cout << dp[n][5] << endl;
}


Measured memory_bytes: 13696
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  rep(i,ty-sy)cout<<'U';
  rep(i,tx-sx)cout<<'R';
  rep(i,ty-sy)cout<<'D';
  rep(i,tx-sx)cout<<'L';
  cout<<'L';
  rep(i,ty-sy+1)cout<<'U';
  rep(i,tx-sx+1)cout<<'R';
  cout<<"DR";
  rep(i,ty-sy+1)cout<<'D';
  rep(i,tx-sx+1)cout<<'L';
  cout<<'U'<<endl;
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<double> A(N);
	for (int i = 0; i < N; ++i) cin >> A.at(i);

	double S = 0;
	for (int i = 0; i < N; ++i) {
		S += 1 / A.at(i);
	}
	cout << 1/S << endl;

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
typedef long long ll;

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MAX_INT 100000
#define MOD 1000000007



void solve()
{
    ll n,m;cin>>n>>m;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ll sm=0;
    for(int i=0;i<n;i++) sm+=a[i];
    ll mx=ceil((double)sm/(4*m));
    ll cnt=0;
    for(int i=0;i<n;i++)
        if(a[i]>=mx)
            cnt++;
    
    
    if(cnt<m) cout<<"No";
    else cout<<"Yes";
    
}
    
int main()
{
    IOS;
    
    //ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

def comb(n, k, mod=10**9+7):
    ret = 1
    for i in range(1, k + 1):
        ret = ret * (n - i + 1) % mod
        ret = ret * pow(i, mod - 2, mod) % mod
    return ret

a = (2 * Y - X) / 3
b = (2 * X - Y) / 3
if a != int(a) or b != int(b) or a < 0 or b < 0:
    print(0)
else:
    print(comb(int(a + b), int(a)))


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

int main(){
  int N;cin>>N;
  int tmp=10000;
  int ans=0;
  for(int i=111;i<1000;i+=111){
    if(i>=N){
      if(i-N<tmp){
        tmp=i-N;
      }
      if(tmp==i-N){
        ans=i;
      }
    }
  }
  cout<<ans<<endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  map<ll,ll> v;
  rep(i,n){
    ll a;
    cin >> a;
    v[a]++;
  }
  ll ans = v.size(),cnt = 0;
  for (auto&& u : v) {
    if(u.se % 2 == 0){
      ++cnt;
    }
  }
  if(cnt % 2){
    ans -= 1;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int i,j,k;
  while(cin>>n,n){
    int mat[n][n];
    fill(mat[0],mat[n],-1);
    int x=n/2,y=n/2+1;
    for(i=1;i<=n*n;i++){
      //ut << x << y << endl;
      mat[y][x]=i;
      x++;y++;
      if(x>=n){
	x=0;
      }
      if(y>=n){
	y=0;
      }
      if(i==n*n) break;
      while(mat[y][x]!=-1){
	x--;
	y++;
	if(x<0){
	  x=n-1;
	}
	if(y>=n){
	  y=0;
	}
      }
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	printf("%4d" ,mat[i][j]); 
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long
int arr[60];
int n, p;

int main() {
	ll l, r;
	cin >> l >> r;
	if (r - l >= 2019)
		return cout << 0, 0;
	ll mini = 1e18;
	for (ll i = l; i <= r; i++) {
		for (ll j = i + 1; j <= r; j++) {
			mini = min(mini, (ll)(i * j) % 2019);
		}
	}
	cout << mini << endl;
}


Measured memory_bytes: 3612
input_lines = gets.chop.split.map(&:to_i)

setNumber = 0
answer = 0 
if input_lines[0] % 2 == 0 
    setNumber =  input_lines[0]/2
else
    setNumber =  input_lines[0]/2 + 1
end

puts  setNumber * 1.0 /input_lines[0] 

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=1e6+5;
int L;
int cnt;
int id[N];
int a[N],b[N],c[N],z;
void add(int u,int v,int w){
    z++;
    a[z]=id[u];
    b[z]=id[v];
    c[z]=w;
}
void Build(int x){
    if(id[x]){
        return ;
    }
    if(x==0){
        id[x]=++cnt;
        return ;
    }
    if(x&1){
        Build(x/2);
        if(!id[x])
            id[x]=++cnt;
        add(x/2,x,x/2+1);
        add(x/2,x,0);
    }
    else{
        Build(x/2-1);
        if(!id[x])
            id[x]=++cnt;
        add(x/2-1,x,x/2);
        add(x/2-1,x,0);
        add(0,x,x);
    }
}
int main()
{
    scanf("%d",&L);
    L--;
    Build(L);
    printf("%d %d\n",cnt,z);
    for(int i=1;i<=z;i++)
        printf("%d %d %d\n",a[i],b[i],c[i]);
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t x = n / 1.08;
    while ((int)(x * 1.08) < n) {
        ++x;
    }

    if ((int)(x * 1.08) == n) {
        cout << x << endl;
    } else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <iostream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	if ((b - a + 1) < 2 * k){
		FOR(i, a, b+1) cout << i << "\n";
	}else{
		FOR(i, a, a + k) cout << i << "\n";
		FOR(i, b - k + 1, b + 1) cout << i << "\n";
	}
}


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

using namespace std;
#define F first
#define S second
typedef long long lli;
const int MX = 10004 , infi =1000000 , mod = 1000000007;
typedef pair<int,int> pii;

int n , m , fat[MX] , x , y , z;

int fin(int x)
{
    if(x!=fat[x])
        return fat[x] = fin(fat[x]);
    return x;
}

void unio(int a , int b)
{
    int aa = fin(a);
    int bb = fin(b);
    if(aa==bb)return;
    fat[aa]=bb;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    for(int i=0;i<MX;i++)fat[i]=i;
    cin>>n>>m;
    while(m-- && cin>>x>>y>>z)
    {
        if(x)cout<<(fin(y)==fin(z))<<"\n";
        else unio(y,z);
    }
    return 0;
}



Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
#define fr(i,n) for (int i=0;i<n;i++)
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void pre() {
}
void solve() {
	int n;
	cin >> n;
	cout << 2 * PI*n << endl;
}
signed main()
{
	fastio;
	cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	//pre();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define mo 998244353
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define ms 16
#define endl '\n'

 
using namespace std ;
 
#define N 400005

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{
    
///////////////////////////////////////////
    fastio;


    string s;
    cin>>s;

    lli k=s.size();

    lli sum=0;
    loopl(i,0,k)
    {
        if(s[i] == 'o') sum++;
    }

    if(sum>=8 || (8-sum)<=(15-k))
        cout<<"YES";
    else cout<<"NO";

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(),x=sc.nextInt(),t=sc.nextInt();
//        System.out.println((n+x-1)/x*t);
        int ans=n/x;
        if (n%x!=0){
            ans++;
        }
        System.out.println(ans*t);



    }




    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortReverse(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
//        Collections.sort.(l);
        Collections.sort(l,Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }


}

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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> bmMap(H, vector<char>(W));

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> bmMap.at(i).at(j);
    }
  }

  vector<int> skipH(H);
  vector<int> skipW(W);

  // skipHを求める
  for (int i = 0; i < H; ++i) {
    bool isSkip = true;
    for (int j = 0; j < W; ++j) {
      if (bmMap.at(i).at(j) == '#') {
        isSkip = false;
        break;
      }
    }
    if (isSkip) {
      skipH.at(i) = 1;
    }
  }

  for (int i = 0; i < W; ++i) {
    bool isSkip = true;
    for (int j = 0; j < H; ++j) {
      if (bmMap.at(j).at(i) == '#') {
        isSkip = false;
        break;
      }
    }
    if (isSkip) {
      skipW.at(i) = 1;
    }
  }

  // 表示
  for (int i = 0; i < H; ++i) {
    if (skipH.at(i)) {
      continue;
    }
    for (int j = 0; j < W; ++j) {
      if (skipW.at(j)) {
        continue;
      }
      cout << bmMap.at(i).at(j);
    }
    cout << endl;
  }
}

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

int main() 
{
    // i+1 < y.size(): problem of last night -> compiilateur yefhem
    int n, sum=0, m=0;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int p;
        cin >> p;
        m = max(m,p);
        sum += p;
    }
    cout << sum - m/2;
    return 0;
}

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

typedef long long ll; 
#define sz(a) ((int)(a.size()))

const int mod=1e9+7; 
int mul(int a, int b){
  return (ll)a*b%mod; 
}
void add_self(int &a, int b){
  a+=b; 
  if(a>= mod) a-=mod; 
}
void mul_self(int &a, int b){
  a=(ll)a*b%mod; 
}
void sub_self(int &a, int b){
  a-=b; 
  if(a<0) a+=mod;
}
int exp(int a, int b){
  int ret=1; 
  while(b){
    if(b%2){
      mul_self(ret,a); 
    }
    mul_self(a,a); 
    b/=2; 
  }
  return ret; 
}
//--------------------------------------------------


void solve(){ 
  int n; cin>>n; 
  double ans=0; 
  double den=0; 
  for(int i=0;i<n;i++){
    int a; cin>>a; 
    den+=1.0/a; 
  }
  printf("%.10lf\n",1.0/den); 
}

int main(){
  clock_t beg=clock(); 
  solve(); 
  clock_t end=clock(); 
  fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
}

Measured memory_bytes: 256
def to_m2(n):
    if n == 0:
        return '0'

    digits = []
    base = 1
    while n != 0:
        if n % (base * 2) == 0:
            digits.append(0)
        else:
            digits.append(1)
            n -= base
        base *= -2
    return ''.join(map(str, reversed(digits)))


print(to_m2(int(input())))


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


ll rec(ll x) {
    if (x == 1)
        return 1;
    return 1 + rec(x / 2) * 2;
} 
int main() {
    ll h;
    cin >> h;
    cout << rec(h) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int a, b, c, d, cnt = 0;
int main(int argc[], char* argv[], char* envp[])
{
	cin >> a >> b >> c >> d;
	int cnt = 0;
	for(int i = 0; i <= a; i++)
		for (int j = 0; j <= b; j++)
			for (int k = 0; k <= c; k++)
				if (i * 500 + j * 100 + k * 50 == d)
					cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];

  ll pos = 0, sum = 0;
  rep(i, 0, n){
    sum += abs(pos - a[i]);
    pos = a[i];
  }
  sum += abs(a[n-1]);

  pos = 0;
  rep(i, 0, n){
    ll ans = sum;
    if(i == 0) ans -= abs(a[i]) + abs(a[i]-a[i+1]);
    else if(i == n-1) ans -= abs(a[i] - a[i-1]) + abs(a[i]);
    else ans -= abs(a[i]-a[i-1]) + abs(a[i]-a[i+1]);

    if(i == n-1) ans += abs(pos);
    else ans += abs(pos - a[i+1]);

    cout << ans << endl;
    pos = a[i];
  }
  return 0;
}

Measured memory_bytes: 2048
h=int(input())
w=int(input())
n=int(input())
t=0
if h>=w:
    if n%h==0:
        print(n//h)
    else:
        print((n//h)+1)
else:
    if n%w==0:
        print(n//w)
    else:
        print((n//w)+1)

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

using namespace std;
int n,k,i,v[100005],j,din[100005];
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>n>>k;
    for (i=1;i<=n;i++)
    {
        cin>>v[i];
        din[i]=1000000005;
    }
    din[1]=0;
    for (i=2;i<=n;i++)
    {
        for (j=i;j>=max(i-k,1);j--)
        {
            din[i]=min(din[i],din[j]+abs(v[j]-v[i]));
        }
    }
    cout<<din[n];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 int
 
#define mod  1000000007


int main()
{
	FAST;
	ll a, b;
	cin >> a >> b;
	if((a*b) % 2){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

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

int main() {
  int n, k;
  long ans = 0;
  cin >> n >> k;

  if (n <= k) {
    cout << 0;
    return 0;
  }
  vector<long> h(n);

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

  sort(h.begin(), h.end(), greater<long>());

  for (int i = k; i < n; i++) {
    ans += h[i];
  }

  cout << ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int gl(int x)
{
	using namespace std;
	int leng=0;
	while(x)
	{
		x/=10;
		leng++;
	}
	return leng;
}
int main()
{
	int n, k;
	cin>>n>>k;
	int no[10] = {0};
	for(int i = 1; i <= k; i++){
		int t;
		cin>>t;
		no[t] = 1;
	}
	int nown = n;
	while(1){
        int len = gl(nown);
        int cnt = 0;
		int flag = 0;
		int nownn;
		int nownt = nown;
		while(1){
            nownn = nownt % 10;
            nownt /= 10;
            cnt++;
            if(cnt > len)break;
			if(no[nownn] == 1){
				flag = 1;
				break;
			}
		}
		if(flag == 0){
			cout<<nown;
			break;
		}
		nown++;
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
template <class T>
struct fenwick_tree {
	vector<T> x;
	fenwick_tree(int n) : x(n, 0) { }
	T mx(int j) {
		T S = 0;
		for (j; j >= 0; j = (j & (j + 1)) - 1) S = max(S, x[j]);
		return S;

	}
	void add(int k, T a) {
		for (; k < x.size(); k |= k + 1) x[k] = max(x[k], a);
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<int,int> > A(N);
	vector<int> B(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	sort(A.begin(), A.end());
	fenwick_tree<int> ft(N);
	for (int i = 0; i < N; i++) {
		int j = A[i].second;
		int z = ft.mx(j - 1);
		//cerr << j << " " << z << endl;
		ft.add(j, B[j] + z);
	}
	cout << ft.mx(N-1) << endl;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
//const int mod=998244353;



struct node{
    ll s,w,v;
    bool inline operator < (const node &a) const{return this->s+this->w<a.s+a.w;}
};


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,y,l,r;
    cin >> n;
    vector<node> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i].w >> v[i].s >> v[i].v;
    }
    sort(all(v));
    m=30000;
    vll dp(m,0);
    for(int i=0; i<n; i++){
        for(int j=(int)v[i].s; j>=0; j--){
            dp[j+v[i].w]=max(dp[j+v[i].w],dp[j]+v[i].v);
        }
    }
    cout << *max_element(all(dp)) << el;
    return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)

	x3 := x2 - y2 + y1
	y3 := y2 + x2 - x1
	x4 := x3 - y3 + y2
	y4 := y3 + x3 - x2
	fmt.Printf("%d %d %d %d\n", x3, y3, x4, y4)
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int cnt[500050];
char s[500050];
int ans[500050];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++)if(s[i]=='0')cnt[i]=i;
		else cnt[i]=cnt[i-1];
	for(int i=1;i<=n;i++){
		ans[i]=ans[i-1];
		if(s[i]=='1'){
			if(s[i-1]=='0'&&s[i-2]=='1'){
				ans[i]=max(ans[i],ans[cnt[i-2]]+i-2-cnt[i-2]);
				ans[i]=max(ans[i],ans[cnt[i-2]+1]+i-2-cnt[i-2]-1);}
			if(s[cnt[i]-1]=='1'){
				ans[i]=max(ans[i],ans[cnt[i]-2]+i-cnt[i]);}}}
	cout<<ans[n];
//	system("pause");
	return 0;
 } 

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    int ans = h[0];
    for (int i = 1; i < n; i++)
        if (h[i-1] < h[i])
            ans += (h[i] - h[i-1]);
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

i64 cup(i64 xxx, i64 yyy) {//切り上げ
	return (xxx + yyy - 1) / yyy;
}

//メモリ置き場
int n;
vector<int> dat;
set<int> dat2;

//inputします
void input() {
	cin >> n;
	dat.resize(n);
	ff(i, 0, n) {
		int b;
		cin >> b;
		dat2.insert(b);
	}
}

//ライブラリ置き場

//main
int main() {
	input();
	if (dat2.size() == n)cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 10368