akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure 
typedef tree<int, null_type, 
			less_equal<int>, rb_tree_tag, 
			tree_order_statistics_node_update> 
	indexed_set;  
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 200009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll> 
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
class uSet{
public:
	vi siz,parent;
	ll n;
	uSet(ll n1){
		n=n1;
		parent.resize(n+1);
		siz.resize(n+1);
		rep(i,0,n+1){
			makeSet(i);
		}
	}
	void makeSet(ll v){
		parent[v]=v;
		siz[v]=1;
	}
	void unionSet(ll a,ll b){
		a=findSet(a);
		b=findSet(b);
		if(a!=b){
			if(siz[a]<siz[b])
				swap(a,b);
			parent[b]=a;
			siz[a]+=siz[b];
		}
	}
	ll findSet(ll v){
		if(v==parent[v])
			return v;
		return parent[v]=findSet(parent[v]);
	}
};


void solve(){
	ll n,m;
	cin>>n>>m;
	uSet s(n);
	rep(i,0,m){
		ll a,b;
		cin>>a>>b;
		s.unionSet(a,b);
	}
	ll ans=0;
	rep(i,1,n+1){
		ll st=s.findSet(i);
		ll loc=s.siz[st];
		ans=max(ans,loc);
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 6344
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M=get_i
boll=array(N,1)
info=array(N,false)
info[0]=true
M.times do
  x,y=get_i.map{|x| x-=1}
  if info[x]
      info[y]=true
  end
  boll[y]+=1
  if boll[x]==1
      info[x]=false
  end
  boll[x]-=1
end
puts info.count{|x| x}

Measured memory_bytes: 15736
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<random>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
int d;
int c[30]={};
int s[370][30];
int num=10000;
int calc(vector<int>const& t,vector<vector<int>>& last_list){
  int res=0;
  vector<int> last(30,0);
  rep1(i,d){
    res+=s[i][t[i]];
    last[t[i]]=i;
    last_list[i]=last;
    int buf=0;
    rep1(j,26){
      buf+=c[j]*(i-last[j]);
    }
    res-=buf;
    //cout<<res<<"\n";
  }
  return res;
}
int change(int nd,int nq,int& res,vector<int>& t,vector<vector<int>>& last_list){
  int flag_t=false;
  int flag_q=false;
  int x=t[nd];
  t[nd]=0;
  res+=s[nd][nq];res-=s[nd][x];
  for(int i=nd;i<=d;++i){
    if(flag_t&&flag_q)break;
    if(t[i]==x||flag_t)flag_t=true;
    else{
      res+=c[x]*(i-last_list[i][x]);
      last_list[i][x]=last_list[i-1][x];
      res-=c[x]*(i-last_list[i][x]);
    }
    if(t[i]==nq||flag_q)flag_q=true;
    else{
      res+=c[nq]*(i-last_list[i][nq]);
      last_list[i][nq]=nd;
      res-=c[nq]*(i-last_list[i][nq]);
    }
  }
  t[nd]=nq;
  return res;
}
vector<int> greedy(int d){
  vector<int> res(d+1,0);
  vector<int> last(30,0);
  rep1(i,d){
    int mx=-inf;
    int mx_ind=0;
    rep1(j,26){
      int tmp=s[i][j];
      rep1(k,26){
        if(k==j)continue;
        tmp-=c[k]*(i-last[k]);
      }
      if(mx<tmp){
        mx=tmp;
        mx_ind=j;
      }
    }
    last[mx_ind]=i;
    res[i]=mx_ind;
  }
  return res;
}
signed main(){
  cin>>d;
  rep1(i,26)cin>>c[i];
  rep1(i,d){
    rep1(j,26)cin>>s[i][j];
  }
  vector<int> t=greedy(d);
  vector<vector<int>> last_list(d+1,vector<int>(30,0));
  int res=calc(t,last_list);
  rep(xx,num){
    random_device rnd;
    mt19937 mt(rnd());
    int nd=mt()%d+1;
    int nq=mt()%26+1;
    int bq=t[nd];
    int bval=res;
    int hoge=change(nd,nq,res,t,last_list);
    if(hoge<res){
      change(nd,bq,res,t,last_list);
    }
  }
  rep1(i,d){
    cout<<t[i]<<"\n";
  }
  return 0;
}
/*
int m;cin>>m;
  vector<int> bres(m);
  rep(i,m){
    int d,q;cin>>d>>q;
    bres[i]=change(d,q,res,t,last_list);
  }
  rep(i,m){
    cout<<bres[i]<<"\n";
  }
  */

Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
#include <limits>

#define MAXNUM  ( 5000 )

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  while ( true )
  {
    int N;
    int maxiVal = numeric_limits < int >::min ( );
    int testVal = 0;

    cin >> N;
    if ( N == 0 ) break;

    for ( int i = 0; i < N; ++i )
    {
      int __tmp;

      cin      >> __tmp;
      testVal  += __tmp;
      maxiVal   = max ( maxiVal, testVal );

      if ( testVal < 0 ) testVal = 0;
    }

    cout << maxiVal << endl;
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    rep(i, k) ans += l[i];
    cout << ans << endl;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S; cin >> S;
  
  //main
  if(S == "A"){ cout << "T" << endl;}
  else if(S == "C"){ cout << "G" << endl;}
  else if(S == "G"){ cout << "C" << endl;}
  else{ cout << "A" << endl;}
  
  // output
  //cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a,b ;

int main(void){
    
    scanf ("%d%d",&a,&b) ;
    
    if ( a==1 ){
        a = 14 ;
    }
    if ( b==1 ){
        b = 14 ;
    }
    
    if ( a>b ){
        printf ("Alice\n") ;
        
    } else if ( a==b ){
        printf ("Draw\n") ;
        
    } else {
        printf ("Bob\n") ;
        
    }

    return 0 ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int h[100005];
  int dpt[100005] = {};

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

  dpt[0] = 0;
  dpt[1] = abs(h[0] - h[1]);
  for(int i = 2;i < n;i++){
    dpt[i] = min(abs(h[i - 1] - h[i]) + dpt[i - 1], abs(h[i - 2] - h[i]) + dpt[i - 2]);
  }

  cout << dpt[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	int n = scan.nextInt();
        	if(n == 0){
        		break;
        	}
        	int[][] sq = new int[n][n];
        	int a = 2;
        	int x = n/2 + 1;
        	int y = n/2;
        	sq[x][y] = 1;
        	while(a <= n*n){
        		while(true){
        			x = (x == n-1)?0:x+1;
        			y = (y == n-1)?0:y+1;
        			if(sq[x][y] == 0){
        				sq[x][y] = a;
        				break;
        			}else{
        				x = (x == n-1)?0:x+1;
        				y = (y == 0)?n-1:y-1;
        				sq[x][y] = a;
        				break;
        			}
        		}
        		a++;
        	}
        	for(int i = 0;i < n;i++){
        		for(int j = 0;j < n;j++){
        			System.out.printf("%4d",(j == n-1)?sq[i][j]:sq[i][j]);
        		}
        		System.out.println();
        	}
        }
    }
}

Measured memory_bytes: 20076
fn main() {
    // input
    let input = read_vec::<u32>();

    // M
    let m = input[0];
    // D
    let d = input[1];

    let ans = (1..m + 1)
        .map(|m| {
            (22..d + 1)
                .map(|d| {
                    (d % 10, d / 10)
                })
                .filter(|&(one,_)|
                    one >= 2
                )
                .filter(|&(_,ten)|
                    ten >= 2
                )
                .filter(|&(one,ten)|
                    m == one * ten
                )
                .count()
        })
        .sum::<usize>();
    println!("{}", ans);
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLn >>= main'
    where
        main' n = breads >>= print . solve n 

solve :: Int -> [Int] -> Int
solve n vs = check as bs
    where
        check [(vx, lx)] [(vy, ly)]
            | vx /= vy =  0
            | otherwise = min lx ly
        check ((vx, lx) : xs) ys@[(vy, ly)]
            | vx /= vy = n - lx - ly
            | otherwise = check xs ys
        check xs@[(vx, lx)] ((vy, ly) : ys)
            | vx /= vy = n - lx - ly
            | otherwise = check xs ys
        check (x@(vx, lx) : xs) (y@(vy, ly) : ys)
            | vx /= vy = n - lx - ly
            | otherwise = min (check (x : xs) ys) $ check xs (y : ys)

        (as, bs) = split vs

        split = edit . foldr ff (True, ([] ,[]))
            where
                ff x (b, (xs, ys))
                    | b = (not b, (x : xs, ys))
                    | otherwise = (not b, (xs, x : ys))

                edit (_, (xs, ys)) = (groupf xs, groupf ys)

                groupf = sortBy (flip cmpf) . map ((,) <$> head <*> length) . group . sort 
                    where
                        cmpf (lv, ll) (rv, rl) = compare ll rl `mappend` compare lv rv

        

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

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

const int MOD = 1000000007;
int main() {
    int N, M;
    long long a;
    a = 1ll;
    scanf("%d %d", &N, &M);
    if (abs(N - M) > 1) a = 0;
    else {
        for (int i = N; i > 0; i--) {
            a *= i;
            a %= MOD;
        }
        for (int i = M; i > 0; i--) {
            a *= i;
            a %= MOD;
        }
    } 
    if (N == M) {
        a *= 2;
        a %= MOD;
    }
    printf("%lld\n", a);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long h,ans=0;
    cin>>n;
	cin>>h;
	long long a[n],b[n];
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i];
	}
    sort(a,a+n);
    reverse(a,a+n);
    sort(b,b+n);
    reverse(b,b+n);
    long long i=0,j=0;
    while(i<n && h>0 && b[i]>a[0]) {
        h-=b[i];
        i++;
        ans++;
    }
    cout<<ans+ max(j,(h-1+a[0])/a[0]);
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

map<vector<int> , int> mp;

bool solve(){
	vector<int> p(8);
	for(int i=0; i<8; ++i){
		if(scanf(" %d", &p[i]) == EOF) return false;	
	}
	
	cout << mp[p] << endl;
	
	return true;
}

int main(){
	int dir[4]={1,-1,4,-4};
	queue< vector<int> > que;
	
	vector<int> start(8);
	for(int i=0; i<8; ++i) start[i]=i;
	
	que.push(start);
	mp[start]=0;
	
	while(!que.empty()){
		vector<int> v=que.front();
		que.pop();
		
		int z;
		for(int i=0; i<8; ++i){
			if(v[i]==0){
				z=i;
				break;	
			}	
		}
		
		for(int i=0; i<4; ++i){
			int nz=z+dir[i];
			if(nz>=0 && nz<=7 && !(z==3&&nz==4) && !(z==4&&nz==3)){
				vector<int> tmp=v;	
				swap(tmp[z], tmp[nz]);
				
				if(mp.find(tmp) == mp.end()){
					que.push(tmp);
					mp[tmp]=mp[v]+1;	
				}
				
			}		
		}
			
	}
	
	while(solve());
}

Measured memory_bytes: 3772
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var L=(Arr.shift())-0;
for(var i=0;i<L;i++){
var str=Arr[i];
console.log(str.replace(/Hoshino/g,"Hoshina"));
}

Measured memory_bytes: 7644
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N, M, K;
	cin >> N;


	cout << N * N;




}	


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <queue>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
struct Edge
{
    int next, to;
    Edge(int next = 0, int to = 0):next(next), to(to) {};
}edge[N];
int tot, head[N];
void add(int x, int y) { edge[++tot] = Edge(head[x], y); head[x] = tot; }
int n, m;
int ac[20][N], d[N], cov[N], ans, fa[N];
void dfs(int x)
{
    d[x] = d[fa[x]]+1; for(int i = 1; i < 20; ++i) ac[i][x] = ac[i-1][ac[i-1][x]];
    for(int i = head[x]; i; i = edge[i].next) dfs(edge[i].to);
}
void cover(int x)
{
    if(cov[x]) return; cov[x] = 1;
    for(int i = head[x]; i; i = edge[i].next) cover(edge[i].to);   
}
priority_queue<pair<int, int> > q;
int main()
{
    n = read(), m = read();
    for(int x = 1; x <= n; ++x) fa[x] = read();
    for(int x = 2; x <= n; ++x) add(ac[0][x] = fa[x], x);
    ans += fa[1] != 1; dfs(1);
    for(int x = 1; x <= n; ++x) q.push(make_pair(d[x], x));
    while(q.size())
    {
        int x = q.top().second, p = x; q.pop();
        if(cov[x]||d[x]-d[1] <= m) continue;
        for(int i = 19; ~i; --i) 
            if(d[x]-d[ac[i][p]] < m&&ac[i][p]) p = ac[i][p];
        cover(p); ++ans;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 12916
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N;
    cin >> N;
    cout << 2 * 3.14 * N << endl;
    return 0;
}


Measured memory_bytes: 3768
import sys
from collections import deque

n = int(input())
matches = [[a - 1 for a in map(int, line.split())] for line in sys.stdin]
q = deque(range(n))
depth = [0] * n
waiting = [-1] * n

while q:
    a = q.popleft()
    b = matches[a].pop()
    if waiting[b] == a:
        depth[a] = depth[b] = max(depth[a], depth[b]) + 1
        if matches[a]:
            q.appendleft(a)
        if matches[b]:
            q.appendleft(b)
    else:
        waiting[a] = b

if any(matches):
    print(-1)
else:
    print(max(depth))


Measured memory_bytes: 35848
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n=0;
  string s;
  cin >> s;
  rep(i,4){
    if (s[i]=='+') n++;
    else n--;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define mp make_pair

template <typename T>
bool uax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef list<int> li;
typedef vector<li> vli;
typedef vector<vpi> vvpi;
typedef long long i64;

const int inf = 1e9 + 500500;

void solve_e() {
  int n,k,q;
  cin >> n >> k >> q;
  vi a(n);
  forn(i, n) cin >> a[i];
  int ans = inf;
  vi b(a); sort(all(b)); b.erase(unique(all(b)), b.end());
  vi t, z;
  for (int L: b) {
    t.clear(); z.clear();
    for (int x: a) {
      if (x < L) {
        if (t.size() >= k) {
          nth_element(t.begin(), t.begin() + t.size() - k, t.end());
          z.insert(z.end(), t.begin(), t.begin() + t.size() - k + 1);
        }
        t.clear();
      } else t.pb(x);
    }
    if (t.size() >= k) {
      nth_element(t.begin(), t.begin() + t.size() - k, t.end());
      z.insert(z.end(), t.begin(), t.begin() + t.size() - k + 1);
    }
    if (z.size() >= q) {
      nth_element(z.begin(), z.begin() + q - 1, z.end());
      if (q > 1) {
        nth_element(z.begin(), z.begin() + 1, z.begin() + q - 1);
      }
      uin(ans, z[q - 1] - z[0]);
    } else break;
  }
  cout << ans << endl;
}

int main() {
#ifdef HOME
  freopen("../input.txt", "rt", stdin);
#endif
  solve_e();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef long long ll;
using namespace std;
const int MOD = 1e9+7;

int main() {
	int n;
	cin>>n;
	vector<int> g[200001];
	for (int i=2 ;i<=n; i++) {
		int x;
		cin>>x;
		g[x].push_back(i);
	}
	
	for (int i=1; i<=n; i++) {
		cout << g[i].size() << endl;
	}
	return 0;
}

Measured memory_bytes: 14568
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

vector<vector<P>> G(100010);
int n,a,b,w;
vi c(100010,-1);

void dfs(int s,int sum){
    c[s] = sum%2;
    for(auto x:G[s]){
        if(c[x.first]!=-1){continue;}
        else{
            c[x.first] = (sum+x.second)%2;
            dfs(x.first,sum+x.second);
        }
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,0,n-1){
        cin>>a>>b>>w;
        a--;b--;
        G[a].emplace_back(b,w);
        G[b].emplace_back(a,w);
    }
    c[0]=0;
    dfs(0,0);
    rep(i,0,n){
        cout<<c[i]<<endl;
    }
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll) 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 1000005;

int main() {
    FAST
    string s,t;
    cin>>s>>t;
    int ans=INT_MAX;
    for(int i=0;i<s.size()-t.size()+1;i++){
        int c=0;
        for(int j=0,k=i;j<t.size();k++,j++){
            if(s[k]!=t[j])
                c++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;


    return 0;
}


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

#define R (long long)(1e9 + 7)
#define INF (long long)(1e16L + 5)
#define ll long long
#define grid vector<vector<ll>>

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(ll& x  : a)
        cin >> x;
    long long ans = 0;
    vector<ll> b = a;
    for(int i = n - 2; i >= 0; i--)
        b[i] = (b[i] + b[i+1]) % R;

    // for(auto x : b)
    //     cout << x << ' ';
    // cout << '\n';

    for(int i = 0; i < n - 1; i++)
    {
        ans = (ans + a[i] * b[i+1]) % R;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    LL n;cin>>n;

    VVL p(n);
    VVL m(n);

    REP(i,n){
        p[i].resize(3);
        m[i].resize(3);
        LL x,y;cin>>x>>y;
        p[i][0] = x+y;
        p[i][1] = x;
        p[i][2] = y;
        m[i][0] = x-y;
        m[i][1] = x;
        m[i][2] = y;
        
        

    }

    SORT_ASC(p);
    SORT_ASC(m);

    LL result = max(abs(p[0][1]-p[n-1][1]) + abs(p[0][2]-p[n-1][2]), abs(m[0][1]-m[n-1][1]) + abs(m[0][2]-m[n-1][2]));
    cout<<result<<endl;


    

   
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 25112
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    }
    let mut d:usize=0;
    let mut e:usize=100;
    let mut ans:usize=0;
    while d!=c {
        if a%e==0&&b%e==0 {d+=1; ans=e}
        e-=1;
    }
    println!("{}",ans);
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    string s;
    cin >> s;

    int sum = 0;
    REP(i, s.size()) if(s[i] == '1') sum++;
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s;cin>> s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int n,k;cin>>n>>k;
	int a=1;
	rep(i,n){
		a=min(a*2,a+k);
	}
	cout<<a<<endl;
}


Measured memory_bytes: 256
n = int(input())
A = [[] for i in range(n+1)]
CHK = [False for i in range(n+1)]
COL = [0 for i in range(n+1)]
for i in range(n-1):
  u,v,w = map(int,input().split())
  w = w%2
  A[u].append((v,w))
  A[v].append((u,w))
#print(A)
cnt=0
Q = [1]
while cnt<n:
  p = Q.pop()
  childs = A[p]
  for c in childs:
    u1 = c[0]
    w1 = c[1]
    if not CHK[u1]:
      Q.append(u1)
      if w1==0:
        COL[u1] = COL[p]
      else:
        COL[u1] = 0 if COL[p]==1 else 1
  CHK[p] = True
  cnt+=1
  #print(cnt)

for i in range(n):
  print(COL[i+1])

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

int main(void)
{
    int n;
    scanf("%d", &n);

    int *v, *c, sum;
    v = (int *) calloc (n, sizeof(int));
    c = (int *) calloc (n, sizeof(int));
    for (int i=0; i<n; i++) {
        scanf("%d", &v[i]);
    }
    for (int i=0; i<n; i++) {
        scanf("%d", &c[i]);
    }
    sum = 0;
    for (int i=0; i<n; i++) {
        int f = v[i] - c[i];
        if (f > 0) {
            sum += f;
        }
    }
    printf("%d\n", sum);
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int tot = 0;
	if (m2 >= m1) {
		tot = (h2 - h1) * 60 + (m2 - m1);
	}
	else {
		tot = (h2 - h1 - 1) * 60 + (m2 + 60 - m1);
	}
	cout << tot - k << '\n';
	return 0;
}


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

using namespace std;

int main(){
	int value,money;
	while(cin>>value>>money&&!(value==0&&money==0)){
		int left=money-value;
		int sen=0;
		int gohyaku=0;
		int hyaku=0;

		sen=left/1000;
		left-=sen*1000;
		gohyaku=left/500;
		left-=gohyaku*500;
		hyaku=left/100;
		cout<<hyaku<<" "<<gohyaku<<" "<<sen<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    vector<int> a(n + 1);
    int all = 1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        all = all * 3ll % mod;
    }
    vector<int> dp(n * 300 + 1);
    vector<int> cdp(n * 300 + 1);
    dp[0] = 1;
    cdp[0] = 1;
    int s = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = s; j >= 0; j--) {
            dp[j + a[i]] += dp[j];
            cdp[j + a[i]] += cdp[j];
            dp[j] = dp[j] * 2ll % mod;
            if (dp[j + a[i]] >= mod) {
                dp[j + a[i]] -= mod;
            }
            if (cdp[j + a[i]] >= mod) {
                cdp[j + a[i]] -= mod;
            }
        }
        s += a[i];
    }

    int lim = s / 2 + s % 2;

    for (int i = lim; i <= s; i++) {
        all -= 3ll * dp[i] % mod;
        if (all < 0) {
            all += mod;
        }
        if (i * 2 == s) {
            all += 3ll * cdp[i] % mod;
            if (all >= mod) {
                all -= mod;
            }
        }
    }
    cout << all << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int m,f,r;
    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) {
            break;
        }
        if(m==-1||f==-1) {
            cout << 'F' << endl;
        }else if(m+f>=80){
            cout << 'A' << endl;
        }else if(m+f>=65) {
            cout << 'B' << endl;
        }else if(m+f>=50){
            cout << 'C' << endl;
        }else if(m+f>=30){
            if(r>=50) {
                cout << 'C' << endl;
            }else cout << 'D' << endl;
        }
        else cout << 'F' << endl;
    }
    return 0;
}


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

const int N = 2e5 + 10;
struct block {
	int x, l, r;
	
	block() {
		x = l = r = 0;
	}
	
	block(int a, int b, int c) {
		x = a;
		l = b;
		r = c;
	}
} job[N];

int n, q, ar[N];
vector <int> vec[N], vec2[N];
multiset <int> st;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		job[i] = block(x, l, r);
	}
	for (int i = 0; i < q; i++)
		cin >> ar[i];
	
	for (int i = 0; i < n; i++) {
		int l = job[i].l, r = job[i].r, x = job[i].x;
		int indxl = lower_bound(ar, ar + q, l - x) - ar, indxr = lower_bound(ar, ar + q, r - x) - ar;
		if (indxl >= 0 && indxl < q) 
			vec[indxl].push_back(i);
		if (indxr >= 0 && indxr < q)
			vec2[indxr].push_back(i);
	}
	
	
	for (int i = 0; i < q; i++) {
		for (int j : vec[i])	
			st.insert(job[j].x);
		for (int j : vec2[i])
			st.erase(st.find(job[j].x));
			
		if (!st.size())
			cout << "-1\n";
		else
			cout << *st.begin() << '\n';
	}
}

Measured memory_bytes: 30196
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;
int K;
int N;
int A[110];

int dp[110][2][110];

signed main(){
	cin>>S>>K;
	N=S.size();
	REP(i,N){
		A[i]=S[i]-'0';
	}
	dp[0][0][0]=1;
	for(int i=0;i<N;i++){
		int num=S[i]-'0';
		for(int j=0;j<2;j++){
			for(int k=0;k<100;k++){
				for(int l=0;l<(j?10:num+1);l++){
					dp[i+1][j||l<num][k+(l!=0)]+=dp[i][j][k];
				}
			}
		}
	}
	cout<<dp[N][0][K]+dp[N][1][K]<<endl;
	return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int N;
	char[] S;

	public void solve() {
		N = nextInt();
		S = next().toCharArray();

		StringBuilder start = new StringBuilder();
		StringBuilder end = new StringBuilder();

		int count = 0;

		for(int i = 0;i < N;i++){
			if(S[i] == '('){
				count++;
			}else{
				count--;

				if(count < 0){
					start.append("(");
					count++;
				}
			}
		}

		for(int i = 0;i < count;i++){
			end.append(")");
		}

		out.println(start.toString() + String.valueOf(S) + end.toString());
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

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

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

Measured memory_bytes: 23380
#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>;

struct UnionFind {
	// それ自身の場合はsize の-1 掛けたもの
	// それ以外は自分の親のid
	vector<int> r;

	UnionFind(int N) {
		r = vector<int>(N, -1);
	}

	int root(int x) {
		if (r[x] < 0) return x;
		return r[x] = root(r[x]);
	}

	bool unite(int x, int y){
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (r[x] > r[y]) swap(x,y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}

	int size(int x){
		return -r[root(x)];
	}
};
int main() {
	int n,m;
	cin >> n >> m;
	UnionFind UF(n);
	rep(i,m) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		UF.unite(a,b);
	}
	int ans=0;
	rep(i,n) {
		ans = max(ans, UF.size(i));
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N,L ;
  cin >> N >> L;
  int sa=10000,num,sum=0 ;
  for(int i=1;i<=N;i++){
    if(sa > abs(L+i-1)){
      sa = abs(L+i-1) ;
      num = i ;
    }
  }
  for(int i=1;i<=N;i++){
    if(i != num) sum += L+i-1;
  }
  cout << sum ;
}


Measured memory_bytes: 256
def r(): return list(map(int,input().split()))
M=9e9
_=r();a=r()
m=M;D=0
for x in a:
    m=min(m,x)
    D=max(D,x-m)
m=M;y=0
for x in a:
    m=min(m,x)
    y+=(x-m==D)
print(y)

Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
    if(a>=b){
      if(b == 0) return a;
      return gcd(b, a % b);
    }
    else{
      if(a==0)return b;
      return gcd(a, b%a);
    }
}

vector<int> divisors(int n) {
    vector<int> res;
    for(int i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue; 
        res.push_back(n/i);
    }
    return res;
}
int main(){
  int a,b,k,g;cin>>a>>b>>k;vector<int> v;
  g=gcd(a,b);
  v=divisors(g);
  sort(v.rbegin(),v.rend());
  cout<<v[k-1]<<endl;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))

print(dp[N - 1])


Measured memory_bytes: 20480
#include<stdio.h>
int main()
{
  int i,j,u=0,m,temp=0,A[100],minj;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<=m-2;i++){
    minj=i;
    for(j=i;j<=m-1;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;
    if(i!=minj) u++;
  }
  for(i=0;i<m-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d",A[m-1]);
  printf("\n");
  printf("%d\n",u);
  return 0;
}

Measured memory_bytes: 604
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 998244353;

int main()
{
    ll N, X, sum = 0;
    cin >> N >> X;
    vector<ll> m(N);
    rep(0, i, N)
    {
        cin >> m.at(i);
        sum += m.at(i);
    }
    sort(all(m));

    ll ans = N + (X - sum) / m.at(0);
    cout << ans << endl;
}

Measured memory_bytes: 3592
a, b, c, k = map(int, input().split())

if k % 2 == 0:
    if a - b > pow(10,18):
        print("Unfair")
    else:
        print(a - b)
else:
    if b - a > pow(10,18):
        print("Unfair")
    else:
        print(b - a)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

int main()
{
    ll X;
    ll ans = 0;
    cin >> X;
    
    if(400 <= X && X < 600)ans = 8;
    else if(600 <= X && X < 800)ans = 7;
    else if(800 <= X && X < 1000)ans = 6;
    else if(1000 <= X && X < 1200)ans = 5;
    else if(1200 <= X && X < 1400)ans = 4;
    else if(1400 <= X && X < 1600)ans = 3;
    else if(1600 <= X && X < 1800)ans = 2;
    else if(1800 <= X && X < 2000)ans = 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#define N 45

int Fibonacci(int );
int F[N];

int main(){

  int n;
  
  F[0]=1;
  F[1]=1;
  
  scanf("%d",&n);

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

  return 0;
}

int Fibonacci(int n){

  if(n==0 || n==1) return 1;

  else if(F[n] > 1) return F[n];

  else return F[n]=Fibonacci(n-2)+Fibonacci(n-1);

}

Measured memory_bytes: 596
#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 <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 <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int solve(int n) {
  for(int x = 1; x <= 100000; x++) {
    if((int)(1.08 * x) == n) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  solve(n);
 }

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int Q;
	long long a, b, c, d;
	long long ttt = 1;
	scanf("%d", &Q);
	for (int i = 0; i < 30; ++i) ttt *= 3;
	for (int i = 0; i < Q; ++i) {
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		--a, --b, --c, --d;
		long long x = ttt;
		for (int i = 29; i >= 0; --i) {
			x /= 3;
			long long pa = a / x, pb = b / x, pc = c / x, pd = d / x;
			if (pa == pc && pa % 3 == 1 && pc % 3 == 1 && llabs(pd - pb) > 1) {
				long long flex = pa * x - 1, tape = pc * x + x, bad = min(c + a - 2 * flex, 2 * tape - c - a);
				printf("%lld\n", bad + llabs(d - b));
				goto solve;
			} else if (pb == pd && pb % 3 == 1 && pd % 3 == 1 && llabs(pc - pa) > 1) {
				long long flex = pb * x - 1, tape = pd * x + x, bad = min(d + b - 2 * flex, 2 * tape - d - b);
				printf("%lld\n", bad + llabs(c - a));
				goto solve;
			}
		}
		printf("%lld\n", llabs(c - a) + llabs(d - b));
		solve:;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int min = 0;
        for (int i = 0; i < s.length() - 2; i++) {
            String tmp = s.substring(i, i + 3);
            int kk = Integer.parseInt(tmp);
            int ck = Math.abs(kk - 753);
            if (i == 0) {
                min = ck;
            } else {
                min = Math.min(min, ck);
            }
        }
        System.out.println(min);

    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=998244353;

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

vi pr;

int fun(int n){
	int ret=0;
	for(int i=1;i*i<=n;++i){
		if(n%i==0){
			int ano=n/i;
			ret+=1+(ano!=i);
		}
	}
	return ret;
}

void solve(){
	int n; cin>>n;
	int k; cin>>k;
	int l[k],r[k];
	f(i,0,k) cin>>l[i]>>r[i];
	int dp[n+1]={0}; dp[1]=1; dp[0]=0;
	int pre[n+1]={0}; pre[0]=0; pre[1]=1;
	for(int i=2;i<=n;++i){
		for(int j=0;j<k;++j){
			int left=i-r[j];
			int right=i-l[j];
			if(right<1) continue;
			if(left<1) left=1;
			dp[i]+=pre[right]-pre[left-1];
			dp[i]%=mod;
		}
		pre[i]=pre[i-1]+dp[i];
		pre[i]%=mod;
	}
	if(dp[n]<0)
	dp[n]+=mod;
	cout<<dp[n]<<"\n";
}


int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
  	int t=1;   //cin>>t;
  	while(t--) solve();
 	return 0;
}

Measured memory_bytes: 6732
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
        String str = sc.next();
        if (str.equals("-")) {
        break;
        }
        int m = sc.nextInt();
        for(int i=1;i<=m;i++){

            int h = sc.nextInt();
            String firstStr = str.substring(0,h);
            String endStr = str.substring(h);

            str = endStr + firstStr;
        }

        System.out.println(str);    

        
        }

    }
}


Measured memory_bytes: 26344
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll x[111] = {};
    ll ans = INF;
    ll N;
    cin >> N;
    rep(i, N){
        ll p;
        cin >> p;
        x[p] += 1;
    }
    rep1(i, 100){
        ll tmp = 0;
        rep1(j, 100){
            tmp += x[j] * (i - j) * (i - j);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long h,w,d;
    scanf("%ld %ld %ld", &h, &w, &d);

    long n=h*w;
    vector<long> hh(n);
    vector<long> ww(n);
    long i,j;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            long tmp;
            scanf("%ld", &tmp);
            hh[tmp-1]=i;
            ww[tmp-1]=j;
        }
    }

    vector<ll> cc(n);
    for(i=0; i<n; i++) {
        if(i<d) {
            cc[i]=0;
        }
        else {
            cc[i]=cc[i-d]+abs(hh[i]-hh[i-d])+abs(ww[i]-ww[i-d]);
        }
    }

    long qq;
    scanf("%ld", &qq);
    vector<long> ll(qq);
    vector<long> rr(qq);
    for(i=0; i<qq; i++) {
        scanf("%ld %ld", &ll[i], &rr[i]);
    }   
    for(i=0; i<qq; i++) {
        printf("%lld\n", cc[rr[i]-1]-cc[ll[i]-1]);
    }

    return 0;
}


Measured memory_bytes: 4736