akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Control.Applicative

main = do
    n <- readLn
    if n == 0 then return ()
              else showMatrixSum n >> main

showMatrixSum :: Int -> IO ()
showMatrixSum n = do
    sets <- replicateM n $ map read.words<$>getLine :: IO [[Int]]
    let result = calcColmnSum.calcRawSum $ sets
    showMatrix 5 result

showMatrix :: Show a => Int -> [[a]] -> IO ()
showMatrix i list = putStr res
    where res = unlines.map (concat.map (justifyr i.show)) $ list

justifyr :: Int -> String -> String
justifyr n str
  | length str < n  = replicate (n - length str) ' ' ++ str
  | otherwise       = str

calcRawSum :: Num a => [[a]] -> [[a]]
calcRawSum []       = []
calcRawSum (ns:nss) = (ns ++ [sum ns]) : calcRawSum nss

calcColmnSum :: Num a => [[a]] -> [[a]]
calcColmnSum list = list ++ [calc' list]
    where calc' = foldl (zipWith (+)) (replicate n 0) 
          n     = length.head $ list

Measured memory_bytes: 4056
#include <cstdio>
#include <cstring>
#include <bitset>
using namespace std;
bitset<16001> xpos, ypos;
char s[8001];
int main(){
	register int n, i, x, y, cnt, marken;
	scanf("%s", s);
	n = strlen(s);
	scanf("%d %d", &x, &y);
	xpos.set(8000), ypos.set(8000);
	cnt = 0;
	for (i = 0; s[i] == 'F' && i < n; ++i) ++cnt;
	xpos = xpos << cnt;
	for (marken = cnt = 0; i < n; ++i) {
		if (s[i] == 'T') {
			if (marken) ypos = (ypos << cnt) | (ypos >> cnt);
			else xpos = (xpos << cnt) | (xpos >> cnt);
			cnt = 0;
			marken ^= 1;
		}
		else ++cnt;
	}
	if (marken) ypos = (ypos << cnt) | (ypos >> cnt);
	else xpos = (xpos << cnt) | (xpos >> cnt);
	if (xpos[8000 + x] && ypos[8000 + y]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    map<int,int> mp,mp2;
    int n;
    cin >> n;
    rep(i,n){
        int tmp;
        cin >> tmp;
        if(i%2==0){
            mp[tmp]++;
        }else{
            mp2[tmp]++;
        }
    }
    vector<pair<int,int> > a,b;
    for(auto x:mp){
        a.push_back(MP(x.second,x.first));
    }
    for(auto x:mp2){
        b.push_back(MP(x.second,x.first));
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    if(a[0].second!=b[0].second){
        cout << n - a[0].first - b[0].first << endl;
    }else{
        if(a.size()==1){
            if(b.size()==1){
                cout << n/2 << endl;
            }else{
                cout << n/2 - b[1].first << endl;
            }
        }else if(b.size()==1){
            cout << n/2 -a[1].first << endl;
        }else{
            int mx = a[0].first + b[1].first;
            mx =max(mx,a[1].first + b[0].first);
            cout << n-mx << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6140
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::str::FromStr;

// binomial-coefficients.rs --- Binomial Coefficients
// author: Seong Yong-ju <sei40kr@gmail.com>

#[allow(unused_macros)]
macro_rules! get {
  ($t:ty) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.trim().parse::<$t>().unwrap()
    }
  };
  ($($t:ty),*) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      let mut iter = line.split_whitespace();
      (
        $(iter.next().unwrap().parse::<$t>().unwrap(),)*
      )
    }
  };
  ($t:ty; $n:expr) => {
    (0..$n).map(|_|
                get!($t)
    ).collect::<Vec<_>>()
  };
  ($($t:ty),*; $n:expr) => {
    (0..$n).map(|_|
                get!($($t),*)
    ).collect::<Vec<_>>()
  };
  ($t:ty ;;) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.split_whitespace()
        .map(|t| t.parse::<$t>().unwrap())
        .collect::<Vec<_>>()
    }
  };
  ($t:ty ;; $n:expr) => {
    (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
  };
}

#[allow(unused_macros)]
macro_rules! debug {
  ($($a:expr),*) => {
    println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
  }
}

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

#[allow(dead_code)]
fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer);
}

fn main() {
    let n = get!(i32);
    assert!(2 <= n);
    let mut xs = (0..n).map(|_x| read::<i32>()).collect::<BinaryHeap<_>>();

    let (xi, xj) = {
        let xi = xs.pop().unwrap();
        let xj = xs.into_iter().min_by_key(|x| (xi - x * 2).abs()).unwrap();
        (xi, xj)
    };

    with_bufwriter(|mut out| writeln!(out, "{} {}", xi, xj).unwrap());
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        System.out.println(dfs("", n));
    }

    private static long dfs(String s, long n) {
        long res = 0;
        if (!s.isEmpty()) {
            if (check(s, n)) {
                res++;
            } else if (Long.parseLong(s) > n) {
                return 0;
            }
        }
        for (String next : Arrays.asList("7", "5", "3")) {
            res += dfs(s + next, n);
        }
        return res;
    }

    private static boolean check(String s, long n) {
        long sl = Long.parseLong(s);
        if (sl > n) {
            return false;
        }
        if (!s.contains("3") || !s.contains("5") || !s.contains("7")) {
            return false;
        }
        return true;
    }
}


Measured memory_bytes: 39336
import java.io.*;

public class Main {
	static public void main(String[] argv) {
		try{
//			FileReader file_in = new FileReader("test.txt");
//			BufferedReader d = new BufferedReader( file_in );
			BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
	
			int[] res = new int[3];
			res[0] = 0;
			res[1] = 0;
			res[2] = 0;
			
			while(true) {
				String str = d.readLine();
				if( str == null ) break;
				res = compare(Integer.valueOf(str), res);
			}
			
			printResult(res);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	static int[] compare(int input, int[] array) {
		if( input > array[0] ) {
			array[2] = array[1];
			array[1] = array[0];
			array[0] = input;
		} else if( input > array[1] ) {
			array[2] = array[1];
			array[1] = input;
		} else if( input > array[2] ) {
			array[2] = input;
		}
		return array;
	}
	
	static void printResult(int[] res) {
		System.out.println(res[0]);
		System.out.println(res[1]);
		System.out.println(res[2]);
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> m(n), km;
  for (int i = 0; i < n; i++) {
    cin >> m.at(i);
  }
  for (int i = 0; i < n; i++) {
    int j = 0;
    for (; j < km.size(); j++) {
      if (m.at(i) == km.at(j)) {
        break;
      }
    }
    if (j == km.size()) {
      km.push_back(m.at(i));
    }
  }
  cout << km.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  int a,b,al,bl;
  cin>>a>>b;
  al=(a*25 +1)/2;
  bl=b*10;
  al=max(al,bl);
  if(floor(al*0.08)==a && floor(al*0.1)==b) cout<<al;
  else cout<<"-1\n";
  //if(al>bl+9 || bl>al+12) cout<<"-1\n";
  //else cout<<max(al,bl);
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int K = Integer.parseInt(s.nextLine().split(" ")[1]);
        String Ps = s.nextLine();
        List<Double> p = Arrays.asList(Ps.split(" ")).stream().map(Double::parseDouble).collect(Collectors.toList());
        int ret = 0;
        int tmp = 0;
        for (int i = 0; i < p.size(); i++) {
            double n = p.get(i);
            tmp += n;
            if (i < K) {
                ret += n;
                continue;
            }
            tmp -= p.get(i - K);
            if (ret < tmp) {
                ret = tmp;
            }
        }
        System.out.print((ret + K) / 2.0);
    }
}

Measured memory_bytes: 61228
import itertools
n=int(input())
a=[]
for i in range(n):
    a.append(i+1)
b=[]
for per in itertools.permutations(a):
    b.append(list(per))
c=b.index(list(map(int,input().split())))
d=b.index(list(map(int,input().split())))
print(abs(c-d))

Measured memory_bytes: 14484
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k);
    }
};

int main(){
    ll n, k;
    cin >> n >> k;

    ModComb mc(1001);
    if(n > k)   cout << 0 << endl;
    else        cout << mc.nPk(k, n) << endl;

    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> data(n);
	int a,b;
	ff(i, 0, n) {
		cin >> a >> b;
		data.at(i).first = b;
		data.at(i).second = a;
	}
	sort(data.begin(), data.end());
	int t = 0;
	ff(i, 0, n) {
		t += data.at(i).second;
		if (t > data.at(i).first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1792
#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 n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    bool flg = true;
    while (true)
    {
        rep(i, n)
        {
            if (a[i] % 2 == 1)
                flg = false;
        }
        if (flg)
        {
            ans++;
            rep(i,n){
                a[i]/=2;
            }
        }
        else
        {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1),EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll w;
int bubble_sort(vector<int> &vec){
  int res = 0;
  for(int i=0;i<(int)vec.size();++i){
    for(int j=0;j<(int)vec.size()-i-1;++j){
      if(vec.at(j)>vec.at(j+1))  swap(vec.at(j),vec.at(j+1)),++res;
    }
  }  
  return res;
}
int main(){
  int n;
  while(cin >> n,n){
    vector<int> vec(n);
    REP(i,n){
      cin >> vec.at(i);
    }
    //REP(i,n){
    //  cout << vec.at(i) << endl;
    //}
    cout << bubble_sort(vec) << endl;
  }
}


Measured memory_bytes: 3012
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>


using namespace std;

string check(int a,int b,int c){
	int A=a*a,B=b*b,C=c*c;
	if(A+B==C || C+A==B || B+C==A)return "YES";
	else return "NO";
}


int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		string ans=check(a,b,c);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>   
using namespace std;
#define PI 3.14159265
#define INF 2e18
#define intinf 999999999
#define EPS 1e-16
#define fst first
#define scd second 
#define pb push_back
#define mp make_pair
#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
#define FORR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
#define closest_perf_sq static_cast<int>(sqrt(static_cast<float>(number)) + .5f);
#define npow2(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}
typedef long long int ll; 
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
vector<pair<ll,ii> > ed;
vector<vii> adj;
priority_queue<ii , vector<ii> , greater<ii> > pq;

int main()
{
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    ll a,b;
    cin>>a>>b;
    if((a*b)%2==1) cout<<"Odd"<<endl;
    else cout<<"Even"<<endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 2e9, mod = 998244353;


int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n; cin >> n;
    vi a(n), b(n);
    set<ii> st;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++){
        cin >> b[i];
        if(a[i] != b[i])st.insert({b[i],i});
    }
    int sum = 0;
    for(;st.size();){
        auto it = st.rbegin();
        int cur = it->second;
        st.erase(*it);
        int times = (b[cur] - a[cur])/(b[(cur+1)%n] + b[(cur-1+n)%n]);
        if(times == 0) return cout << -1 << endl, 0;
        sum += times;
        b[cur] -= times * (b[(cur+1)%n] + b[(cur-1+n)%n]);
        if(b[cur] < a[cur]) return cout << -1 << endl, 0;
        if(b[cur] > a[cur]) st.insert({b[cur], cur});
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 15872
import itertools
def main6():
    n = int(input())
    p=[str(i) for i in input().split()]
    q=[str(i) for i in input().split()]
    l = [str(i) for i in range(1,n+1)]
    k = ''.join(p)
    k1 = ''.join(q)
    p_l = list(itertools.permutations(l))
    for v in range(len(p_l)):
        u = (''.join(p_l[v]))
        if(u == k):
            a = v
        if(u == k1):
            b = v

    print(abs(a-b))

if __name__ == '__main__':
    main6()

Measured memory_bytes: 13848
object Main extends App {
  val o, e = io.StdIn.readLine
  val ans = {
    val sb = StringBuilder.newBuilder
    val ito = o.iterator
    val ite = e.iterator
    for(i <- 0 until e.length) {
      sb.append(ito.next).append(ite.next)
    }
    if(ito.hasNext) sb.append(ito.next)
    sb
  }
  println(ans)
}

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

using namespace std;
int N,M;
vector<int> C,X;

void input(){
  C.resize(M);
  X.resize(N);
  for(int i = 0; i < M; i++) cin >> C[i];
  for(int i = 0; i < N; i++) cin >> X[i];
}

void solve(){
  const int Row = 2;
  const int Col = 256;
  const long long INF = (1LL<<50);
  
  long long dp[Row][Col];
  fill(dp[0],dp[0]+Row*Col,INF);

  dp[0][128] = 0;

  for(int i = 0; i < N; i++){
    for(int pos = 0; pos < Col; pos++) dp[(i+1)%2][pos] = INF;

    for(int j = 0; j < Col; j++){
      if(dp[i%2][j] == INF) continue;
      for(int k = 0; k < M; k++){
	int nex = j+C[k];
	nex = min(255,nex);
	nex = max(0,nex);
	dp[(i+1)%2][nex] = min(dp[(i+1)%2][nex],dp[i%2][j]+(X[i]-nex)*(X[i]-nex));
      }
    }
  }

  long long ans = INF;

  for(int i = 0; i < Col; i++) ans = min(ans,dp[N%2][i]);;
  cout << ans << endl;
}

int main(){
  while(cin >> N >> M && N+M){
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
 	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 a[55],K;
void Solve() {
    read(K);
    N = 50;
    a[1] = K / N;
    for(int i = 2 ; i <= N ; ++i) {
	a[i] = a[i - 1] + 1;
    }
    int t = K % N;
    for(int i = 1 ; i <= t ; ++i) {
	a[i] += N;
	for(int j = 1 ; j <= N ; ++j) {
	    if(i != j) a[j]--;
	}
    }
    out(N);enter;
    for(int i = 1 ; i <= N ; ++i) {
	out(a[i]);space;
    }
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,num[110],sum;
namespace MaxFlow{
	const int N=1000,M=2000000;
	int head[N],cur[N],dep[N],cnt,S,T,res;
	struct node{
		int to,next,val;
	}edge[M];
	void ae(int u,int v,int w){
		edge[cnt].next=head[u],edge[cnt].to=v,edge[cnt].val=w,head[u]=cnt++;
		edge[cnt].next=head[v],edge[cnt].to=u,edge[cnt].val=0,head[v]=cnt++;
	}
	queue<int>q;
	inline bool bfs(){
		memset(dep,0,sizeof(dep)),q.push(S),dep[S]=1;
		while(!q.empty()){
			register int x=q.front();q.pop();
			for(register int i=cur[x]=head[x];i!=-1;i=edge[i].next)if(edge[i].val&&!dep[edge[i].to])dep[edge[i].to]=dep[x]+1,q.push(edge[i].to);
		}
		return dep[T]>0;
	}
	bool reach;
	inline int dfs(int x,int flow){
		if(x==T){
			res+=flow;
			reach=true;
			return flow;
		}
		int used=0;
		for(register int &i=cur[x];i!=-1;i=edge[i].next){
			if(!edge[i].val||dep[edge[i].to]!=dep[x]+1)continue;
			register int ff=dfs(edge[i].to,min(edge[i].val,flow-used));
			if(ff){
				edge[i].val-=ff;
				edge[i^1].val+=ff;
				used+=ff;
				if(used==flow)break;
			}
		}
		return used;
	}
	inline void Dinic(){
		while(bfs()){
			reach=true;
			while(reach)reach=false,dfs(S,0x3f3f3f3f);
		}
	}
}
using namespace MaxFlow;
signed main(){
	scanf("%lld",&n),S=n+1,T=n+2,memset(head,-1,sizeof(head));
	for(int i=1;i<=n;i++){
		scanf("%lld",&num[i]);
		if(num[i]>0)ae(i,T,num[i]),sum+=num[i];
		else ae(S,i,-num[i]);
	}
	for(int i=1;i<=n;i++)for(int j=i+i;j<=n;j+=i)ae(i,j,0x3f3f3f3f);
	Dinic();
	printf("%lld\n",sum-res);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    cout << (ll)pow(K-1, (double) N-1) * K << endl;
    return 0;
}


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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 998244353;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1) ans = mul(ans, x);
        return ans;
    }
};  // namespace modular
using namespace modular;

namespace Base {
    template <typename Tp>
    inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp>
    inline void read(Tp &x) {
        x = input<Tp>();
    }
    template <typename Tp>
    inline void chmax(Tp &x, Tp y) {
        x < y ? x = y : 0;
    }
    template <typename Tp>
    inline void chmin(Tp &x, Tp y) {
        x > y ? x = y : 0;
    }
};  // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 1000007

int N, K;
int fac[MAX_N], ifac[MAX_N];

void init() {
    int MX = 1000000;
    fac[0] = ifac[0] = 1;
    Rep(i, MX) fac[i] = mul(fac[i - 1], i);
    ifac[MX] = qpow(fac[MX], MOD - 2);
    irep(i, MX, 2) ifac[i - 1] = mul(ifac[i], i);
}

int C(int x, int y) {
    if (y < 0 || x < y) return 0;
    return mul(fac[x], mul(ifac[y], ifac[x - y]));
}
int cal(int x, int y) { return C(x + y, x); }

int get(int x, int y, int t) {  // (0,0)->(x,y) y<x+t
    if (t <= 0) return 0;
    if (y >= x + t) return 0;
    return add(cal(x, y), MOD - cal(y - t, x + t));
}

void solve() {
    int res = 0, R, B;
    if (!(K & 1) && K / 2 - N + 1 > 0) {
        R = B = K / 2;
        inc(res, get(R, B - 1, B - N + 1));
    }
    R = (K - 1) / 2 + 1;
    while (R <= K) {
        B = K - R;
        if (B >= R) {
            R++;
            continue;
        }
        // printf("%d %d %d\n", R, B, get(R, B, R - N + 1));
        inc(res, get(R, B, R - N + 1));
        R++;
    }
    printf("%d\n", res);
}

int main() {
#ifdef LOCAL
    FIN("in");
#endif
    read(N), read(K);
    init();
    solve();
    return 0;
}


Measured memory_bytes: 8064
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// 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>

#if __cplusplus >= 201103L
#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 <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  ll num = 0;

  for (ll i = 0; i < s.length() - 1; i++)
  {
    if (s[i] == s[i + 1])
    {
      if (s[i + 1] == '0')
      {
        s[i + 1] = '1';
      }
      else
      {
        s[i + 1] = '0';
      }
      num++;
    }
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 512
//20181208
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {

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

    vector<long> h;
    long hi;

    for(int i=0;i<n;i++){
        cin >> hi;
        h.push_back(hi);
    }

    sort(h.begin(),h.end());

    long min_d = 1000000000;
    for(int i=0;i<n-(k-1);i++){
        if(abs(h[i]-h[i+k-1])<min_d){
            min_d = abs(h[i]-h[i+k-1]);
        }
    }

    cout << min_d << endl;


    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
using namespace std;

int main() 
{
    int x, n;
    cin >> x >> n;
 
    if(n == 0) 
    {
        cout << x;
        return 0;
    }
 
    int p[n];
    for(int i = 0; i < n; i++) 
    {
        cin >> p[i];
    }
 
    int t = 0;
    int mi;
    int pl;
    for(int i = 0; i < 200; i++) 
    {
        mi = x - t;
        pl = x + t;
        bool found = false;
        for(int j = 0; j < n; j++) 
        {
            if(mi == p[j]) 
            {
                found = true;
                break;
            }
        }
        if(!found) 
        {
            cout << mi;
            return 0;
        }
        found = false;
        for(int j = 0; j < n; j++) 
        {
            if(pl == p[j]) 
            {
                found = true;
                break;
            }
        }
        if(!found) 
        {
            cout << pl;
            return 0;
        }
        t++;
    }
}



Measured memory_bytes: 3592
in_1 = [int(x) for x in input().split(' ')]
x = in_1[0]
n = in_1[1]
result = 0

# n=0の場合、resultにxを設定する
if n == 0:
  result = x
# 絶対値が小さい順にin_dataに含まれるか検索し、含まれなければresultにx-i,もしくはx+1を設定する
else:
  in_data = [int(x) for x in input().split(' ')]
  for i in range(100):
    tmp_m = x-i
    tmp_p = x+i
#    print('tmp_m:{}'.format(tmp_m))
#    print('tmp_p:{}'.format(tmp_p))
    if tmp_m not in in_data:
      result = tmp_m
      break
    if tmp_p not in in_data:
      result = tmp_p
      break

print(result)

Measured memory_bytes: 9208
#include <stdio.h>
 
int main(void)
{
    int N, K, X, Y;
    int sum = 0;

    scanf("%d %d %d %d", &N, &K, &X, &Y);
    if(N > K){
        for(int i = 0; i < K; i++)
            sum += X;
        for(int j = K; j < N; j++)
            sum += Y;
    }
    else{
        for(int i = 0; i < N; i++)
            sum += X;
    }
    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC";
	else cout << "ABC";
}   

Measured memory_bytes: 3668
use proconio::input;
//use proconio::fastout;
//use proconio::marker::{Bytes, Chars};

//#[fastout]
fn main() {
    input!{
        d: f32,
        t: f32,
        s: f32,
    }

    println!("{}", if d / s <= t {"Yes"} else {"No"})
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

template <typename T>
T powint(T a, ll n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= a; 
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <ll mod>
class ModInt {
private:
    ll num;
public:
    ModInt() {};
    ModInt(ll n) { num = n % mod; }
    ModInt inv() const { return powint(*this, mod-2); }
    explicit operator ll() const { return num; }

    ModInt& operator+=(const ModInt& a) {
        num += a.num; 
        if (num >= mod) num -= mod; 
        return *this;
    }
    ModInt& operator-=(const ModInt& a) {
        if (num < a.num) num += mod;
        num -= a.num;
        return *this;
    }
    ModInt& operator*=(const ModInt& a) {
        num = num * a.num % mod;
        return *this;
    }
    ModInt& operator/=(const ModInt& a) { return *this *= a.inv(); }
    friend ModInt operator+(const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
    friend ModInt operator-(const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
    friend ModInt operator*(const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
    friend ModInt operator/(const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }

    friend ostream& operator<<(ostream& os, const ModInt& a) { return os << a.num; }
    friend istream& operator>>(istream& is, ModInt& a) {
        ll tmp;
        is >> tmp;
        a.num = tmp % mod;
        return is;
    }
};
using mint = ModInt<1000000007>;
//using mint = ModInt<998244353>;

vector<mint> fact, factinv;
static void fact_reserve(int n)
{
    fact.resize(n + 1);
    factinv.resize(n + 1);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) {
        fact[i] = (ll)fact[i - 1] * i;
    }
    factinv[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) {
        factinv[i - 1] = (ll)factinv[i] * i;
    }
}

mint P(int n, int k) {
    return fact[n] * factinv[n-k];
}
mint C(int n, int k) {
    return fact[n] * factinv[n-k] * factinv[k];
}
mint H(int n, int k) {
    return C(n+k-1, k);
}

mint calc(int n, int m, int k) {
    mint ret = 0;
    for (int d = 1; d < n; ++d) {
        ret += C(n*m-2, k-2) * (n-d) * m * m * d;
    }
    return ret;
}

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

    fact_reserve(n*m);

    mint ans = 0;
    ans += calc(n, m, k);
    ans += calc(m, n, k);

    cout << ans << endl;

    return 0;
}


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

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int x,n;cin>>x>>n;
  set<int> p;
  for(int i=0;i<n;i++){
    int v;cin>>v;
    p.insert(v);
  }
  int ans=0;
  int minans=10000;
  for(int i=-100;i<120;i++){
    int val=abs(x-i);
    if(p.find(i)!=p.end()){
      continue;
    }
    if(val<minans){
      ans=i;
      minans=val;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

const int N = 1005;

int n, m;
set <int> g[N];
vector <int> ans;
bool instack[N], visited[N];
vector <vector <int> > res;
bool ok = false;
int dem = 0;

void dfs (int u, int s) {
    dem++;
    if (dem >= 10000) return;
    if (ok) return;
    instack[u] = true;
    ans.push_back(u);
    
    for (auto v: g[u]) {
        if (ok) return;
        if (g[v].find(s) != g[v].end()) {
            ans.push_back(v);
            res.push_back(ans);
            ok = true;
            return;
        }
    }
    
    for (auto v: g[u]) if (!instack[v]) dfs(v, s);
    
    instack[u] = false;
    ans.pop_back();
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].insert(v);
    }
    
    for (int i = 1; i <= n; i++) {
        memset(instack, 0, sizeof(instack));
        ok = false;
        ans.clear();
        dem = 0;
        dfs(i, i);
    }
    
    if (res.size() == 0) cout << -1;
    else {
        int Min = 1e9;
        for (auto i: res) Min = min(Min, (int)i.size());
        
        for (auto i: res) {
            if (i.size() == Min) {
                cout << Min << "\n";
                for (auto j: i) cout << j << "\n";
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

struct edge{
  int u;
  int v;
  int cost;
};

class UnionFind{
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;

    //作る時はParentの値を全て-1にする
    //こうするとずべてバラバラになる
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているのか調べる
    int root(int A){
      if(Parent[A]<0) return A;
      return Parent[A] = root(Parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
      return -Parent[root(A)];//親を取ってきたい
    }

    //AとBをくっつける
    bool connect(int A,int B){
      //AとBを直すつつなぐのではなく、root(A)にroot(B)をくっつける)
      A = root(A);
      B = root(B);
      if(A==B){
        //すでにくっついているからくっつけない
        return false;
      }
      //大きい方(A)に小さい方(B)をくっつけたい
      //大小が逆だったらひっくり返しちゃう
      if(size(A)<size(B)) swap(A,B);

      //Aのサイズを更新する
      Parent[A] += Parent[B];
      //Bの親をAに変更する
      Parent[B] = A;

      return true;
    }
  };


bool comp(const edge& e1,const edge& e2){
  return e1.cost < e2.cost;
}

edge es[MAX];
int V,E;                  //頂点数と辺数

int kruskal(){
  sort(es, es + E, comp); //edge.costが小さい順にソートする
  UnionFind Uni(V);
  int res = 0;
  for (int i = 0; i < E; i++){
    edge e = es[i];
    if(Uni.root(e.u) != Uni.root(e.v)) {
      Uni.connect(e.u , e.v);
      res += e.cost;
    }
  }
  return res;
}

int main(){
  cin>>V>>E;
  rep(i,E){
    cin>>es[i].u>>es[i].v>>es[i].cost;
  }
  ll ans = kruskal();
  cout<<ans<<endl;
}



Measured memory_bytes: 4376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef long long  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 2E5+7;
const ll INF = 1e8;
ll n,res = 0;
void F(ll i){
    ll x = n;
    while(x%i==0)x/=i;
    if (x%i==1)res++;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


    cin>>n;
    ll sq = sqrt(n);
    for(ll i = 1;i<=sq;++i){
        if (n%i==0){
            if (i!=1)
            F(i);
            if (n/i!=1 && i!=n/i)
            F(n/i);
        }
    }
    ll bn = n-1;
    sq = sqrt(bn);
    for(ll i = 1;i<=sq;++i){
        if (bn%i==0){
            if (n%i==1)res++;
            if (n%(bn/i)==1 && i!=bn/i )res++;
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

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

    ll ans = 0;
    int right = 0;
    int sum = 0;
    for (int left = 0; left < n; ++left) {
        while (right < n  &&  (sum ^ a[right]) == (sum + a[right])){
            sum += a[right];
            ++right;
        }
        ans += right - left;
        if (left == right) ++right;
        else sum -= a[left]; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =  sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int max = Math.max(c,Math.max(a, b));
		int sum=a+b+c;
		int ans=max*3-sum;
		if(ans%2==1) {
			ans=(max+1)*3-sum;
		}
		System.out.println(ans/2);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=1e5+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,m,k,fa[maxn],d[maxn];
vector<int> g[maxn],rg[maxn];

int find(int x)
{
    if(fa[x]==x)
        return x;
    return fa[x]=find(fa[x]);
}

void merge(int x,int y)
{
    x=find(x),y=find(y);
    if(x!=y)
    {
        fa[y]=x;
        d[x]+=d[y];
    }    
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    int x,y;
    scanf("%d%d%d",&n,&m,&k);
    _rep(i,1,n) 
        fa[i]=i,d[i]=1;
    _rep(i,1,m)
    {
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
        merge(x,y);
    }
    _rep(i,1,k)
    {
        scanf("%d%d",&x,&y);
        rg[x].push_back(y);
        rg[y].push_back(x);
    }
    _rep(i,1,n) find(i);
    _rep(i,1,n)
    {
        int ans=d[find(i)]-1-g[i].size();
        for(unsigned int j=0;j<rg[i].size();j++)
            if(fa[i]==fa[rg[i][j]])
                ans--;
        if(i!=1)
            cout<<" ";
        cout<<ans;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 13176
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	int N;
	cin >> N;
	vi A(N);
	for (auto& x : A)
		cin >> x;
	ll x = 1000;
	ll y = 0;
	for (int i = 0; i < N - 1; ++i)
	{
		if (A[i] < A[i + 1])
		{
			ll z = x / A[i];
			x -= z * A[i];
			y += z;
		}
		else
		{
			x += y * A[i];
			y = 0;
		}
	}
	x += y * A[N - 1];
	cout << x << endl;


	return 0;
}

Measured memory_bytes: 3624
s = input()
l = len(s)
small = 999
for i in range(l - 2):
    num = int(s[i]) * 100 + int(s[i + 1]) * 10 + int(s[i + 2])
    if (abs(num - 753) < small):
        small = abs(num - 753)
print(small)


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

int main(){
    long long n,d;
    cin >> n >> d;
    long long count = 0;
    for(int i = 0;i < n;i++){
        long long x,y;
        cin >> x >> y;
        if(d*d >= x*x + y*y) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N;

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

	cin >> N;

	vector<int> A(N);


	for(auto &x: A){
		cin >> x;
	}

	sort(A.begin(),A.end());

	while(1){
		REP(i,N - 1){
			if(A[i] == 0 || A[i + 1] == 0) continue;
			int tb = A[i + 1];
			A[i + 1] = A[i + 1] % A[i];
			if(tb == A[i + 1]){
				if(A[i] > A[i + 1]){
					A[i + 1] = 0;
				}else{
					A[i] = 0;
				}
			}


		}

		sort(A.begin(),A.end());
		if(A[N - 2] == 0) break;
	}
	cout << A[N - 1] << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		int cnt = 0;
		int sum = 0;
		for(int i=1; i<=x; i++) {
			sum += i;
			cnt++;
			if(sum >= x) {
				System.out.println(cnt);
				return;
			}
		}
	}
}


Measured memory_bytes: 23764
n = int(input())
A = [int(i) for i in input().split()]
B = [0] * n
k = max(A)
C = [0] * (k + 1)
for i in range(0, n):
    C[A[i]] += 1
for i in range(1, k + 1):
    C[i] += C[i - 1]
for i in range(n - 1, -1, -1):
    C[A[i]] -= 1
    B[C[A[i]]] = A[i]
print(*B)

Measured memory_bytes: 234252
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

pll rng[200005];

ll solve(ll n)
{
	vector < ll > vec;

	for(ll i = 1; i <= n; i++) vec.push_back(rng[i].first);

	ll mn = 0;
	bool frac = 0;

	sort(vec.begin(),vec.end());

	if(n & 1) mn = vec[n / 2];
	else
	{
		ll x = vec[n / 2] + vec[(n - 1) / 2];

		mn = x / 2;
		if(x & 1) frac = 1;
	}

	vec.clear();

	for(ll i = 1; i <= n; i++) vec.push_back(rng[i].second);

	ll mx = 0;
	bool frac1 = 0;

	sort(vec.begin(),vec.end());

	if(n & 1) mx = vec[n / 2];
	else
	{
		ll x = vec[n / 2] + vec[(n - 1) / 2];

		mx = x / 2;
		if(x & 1) frac1 = 1;
	}

	ll ret = (mx - mn + 1);

	if(n % 2 == 0) ret = (ret * 2) - 1;

	if(frac1) ret++;
	if(frac) ret--;

	return ret;


}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n)
    {
		for(i = 1; i <= n; i++) slld(rng[i].first), slld(rng[i].second);

		ans = solve(n);

		cout << ans << '\n';
    }


}





Measured memory_bytes: 8556
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
int main(){
 string a,b;
 map<string ,int> mp;
 cin>>a;
 cin>>b;
 int aa,bb;
 cin>>aa>>bb;
 string t;
 cin>>t;

 mp[a] = aa;
 mp[b] = bb;
 mp[t]--;
 
 
  cout<<mp[a]<<" "<<mp[b];
  cout<<"\n";
return 0;
}


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

 
int main()
{
	FAST;
	ll x , k , d;
    cin >> x >> k >> d;
    x = abs(x);
    ll p = x / d;
    if(p >= k){
        x -= (k * d);
       k = 0;
    }
    else{
        x %= d;
        k -= p;
    }
    if(!k){
        cout << x << endl;
        return 0;
    }
    if(k % 2){
        cout << abs(x - d) << endl;
        return 0;
    }
    cout << x << endl;
    return 0;
	return 0;
}

Measured memory_bytes: 3644