akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c[b+1];
	for(int i=1;i<=b;i++)
	{
		cin>>c[i];
		a-=c[i];
	}
	if(a<0)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	else
	{
		cout<<a<<endl;
		return 0;
	}
	
}

Measured memory_bytes: 3644
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        
        int s;
        
        int dp[2005];
        int solve(int p)
        {
        	if(p==s)
        	{
        		return 1;
			}
			if(dp[p]!=-1)
			{
				return dp[p];
			}
			int ans=0;
			for(int i=3;i<=s;i++)
			{
				if(p+i<=s)
				{
					ans+=solve(p+i);
					ans%=MOD;
				}
			}
			return dp[p]=ans;
		}
        signed main()
        {
        	
        	cin>>s;
        	
        	int ans=0;
        	
        	mem(dp,-1);
        	for(int i=3;i<=s;i++)
        	{
        		ans+=solve(i);
        		ans%=MOD;
			}
			cout<<ans<<endl;
		}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main()
{
	long long sum=100,x;
	cin>>x;
	int tot=0;
	for(long long i=1;i<=x;i++)
	{
		sum*=1.01;
		tot++;
		if(sum>=x)
		{
			cout<<tot;
			break;
		}
	}
}

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

int main(){

  int N=0;
  cin>>N;
	
	
  string S;
  cin>>S;
  
  int max=0;
  for(int i=1;i<N-1;i++){

    string F=S.substr(0,i);
    string B=S.substr(i,N-i);
    
    map<char,int> mpf;
    map<char,int> mpb;
    
    rep(k,i){
      mpf[F.at(k)]=1;
    }
    rep(k,N-i){
      mpb[B.at(k)]=1;
    }
    
    int count=0;
    rep(i,26){
	
      if(mpf['a'+i]==1 && mpb['a'+i]==1){
		count++;
      }
      
    }
    
    if(count>max)max=count;

  }
  

  cout<<max<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {

            int h = sc.nextInt();
            int w = sc.nextInt();

            if (h == 0 && w == 0) break;

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {

                    if (i % 2 == 0) {
                        if (j % 2 == 0) System.out.print("#");
                        else System.out.print(".");
                    } else {
                        if (j % 2 == 0) System.out.print(".");
                        else System.out.print("#");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 35680
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int K;

    private class P implements Comparable<P> {
        int m;
        long c;

        public P(int m,long c) {
            this.m = m;
            this.c = c;
        }

        public int compareTo(P p) {
            return Long.compare(this.c,p.c);
        }
    }

    private void solve() {
        K = nextInt();

        ArrayDeque<P> pq = new ArrayDeque<>();
        pq.add(new P(1,1));

        long[] min = new long[K];
        Arrays.fill(min,Long.MAX_VALUE / 2);

        while(pq.size() > 0) {

            P p = pq.poll();

            if (min[p.m] <= p.c) {
                continue;
            }

            min[p.m] = p.c;

            pq.addLast(new P((p.m + 1) % K,p.c + 1));
            pq.addFirst(new P((p.m * 10) % K,p.c));
        }

        out.println(min[0]);
    }

    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: 30036
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define P_B push_back
#define E_B emplace_back
#define fi first
#define se second

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

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

int main(){
  string S;
  ll N, n, A, B, ans = 0;

  cin >> N;

  Sieve s(1000005);

  auto fs = s.factor(N);

  rep(i, fs.size()){
    int count = 1;
    while(fs[i].se >= count){
      fs[i].se -= count;
      count++;
    }
    ans += count - 1;
  }


  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 7840
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn num2bit(mut n: u64) -> Vec<bool> {
    let mut ret = vec![];
    while n > 0 {
        ret.push((n % 2) == 1);
        n /= 2;
    }
    ret
}

fn solve(mut m: u64, bits: Vec<bool>) -> u64 {
    let mut ret: u64 = 1;
    for b in bits {
        if b {
            ret = (ret * m) % 1000000007;
        }
        m = (m * m) % 1000000007;
    }
    ret
}

fn main() {
    let v: Vec<u64> = read_vec();
    let m = v[0];
    let n = v[1];

    let bits = num2bit(n);

    println!("{}", solve(m, bits));
}



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

using namespace std;

#define ll long long


int main()
{

   string s;
   getline(cin,s);

   string s1;
   getline(cin,s1);
   string s2;
   int c=0;
   for(int i=0;i<s.size();i++){
        if(s[i]==s1[i])c++;
   }
   int x,y;
   x=s.size();
   y=s1.size();

   if(c!=x || y!=x+1){
    cout<<"No";
   }
   else cout<<"Yes"<<endl;




}




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

using namespace std;

int mod = 1e9+7;

long long int solve(int s, vector<int>& dp) {

	if(dp[s] != -1) return dp[s];

	if(s < 3) return 0;

	dp[s] = 1;

	for(int i=3; i<s; i++) {

		dp[s] += solve(s-i, dp);
		dp[s] %= mod;
	}

	return dp[s];
}

int main() {

	int s;
	cin>>s;

	vector<int> dp(s+1, -1);
	
	int ans = solve(s, dp);

	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        b[i]=0;
    }
    b[1]=abs(a[1]-a[0]);
    for (int i = 2; i < n; i++)
    {
        b[i]=min(abs(a[i]-a[i-1])+b[i-1],abs(a[i]-a[i-2])+b[i-2]);
    }
        cout<<b[n-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>vec;
  for(int i=0;i<3;i++){
    int a;
    cin>>a;
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  cout<<vec.size()<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  if(N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  i64 two = 0;
  {
    two += N / 2;
    i64 n = N / 2;
    while(n > 0) {
      i64 x = n / 2;
      two += x;
      n = x;
    }
  }

  i64 five = 0;
  {
    i64 n = N / 2;
    while(n > 0) {
      i64 x = n / 5;
      five += x;
      n = x;
    }
  }

  cout << std::min(five, two) << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 998244353
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, min=1e18;

	cin>>n;

	vll a(n), a2;

	rep(i, n){
		cin>>a[i];
		a[i]-=(i+1);
	}
	a2=a;
	sort(all(a2));

	if(n>100){
		repr(i, n/2-5, n/2+5){
			ll b=a2[i], cost=0;
			rep(j, n){
				cost+=abs(a[j]-b);
			}
			if(min>cost) min=cost;
		}
		cout<<min<<endl;
	}else{
		rep(i, n){
			ll b=a2[i], cost=0;
			rep(j, n){
				cost+=abs(a[j]-b);
			}
			if(min>cost) min=cost;
		}
		cout<<min<<endl;
	}
}


Measured memory_bytes: 3456
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;
use std::collections::BTreeMap;

fn main() {
    input!{
        n: usize,
        ss: [chars; n]
    }
    let mut cmap: BTreeMap<char,usize> = BTreeMap::new();
    for c in ss[0].clone() {
        let count = cmap.entry(c).or_insert(0);
        *count += 1;
    }
    for i in 1..n {
        let mut cmap2: BTreeMap<char,usize> = BTreeMap::new();
        for c in ss[i].clone() {
            let count = cmap2.entry(c).or_insert(0);
            *count += 1;
        }
        for (c,v) in cmap.iter_mut() {
            if let Some(v2) = cmap2.get(&c) {
                *v = cmp::min(*v,*v2);
            } else {
                *v = 0;
            }
        }
    }
    for (k,v) in cmap.iter() {
        let cs = vec![*k;*v];
        print!("{}", cs.into_iter().collect::<String>());
    }
    print!("\n");
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B;
		A = sc.nextInt();
		B = sc.nextInt();
		
		if(B % A == 0) 
			System.out.println(A + B);
		else
			System.out.println(B - A);
		

	}


}


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

ll n;
string s;

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

    cin>>s;
    n=s.size();

    if(s[0]!=s[n-1])
    {
        if(n%2==1)
            cout<<"First"<<endl;
        else
            cout<<"Second"<<endl;
    }
    else
    {
        if(n%2==0)
            cout<<"First"<<endl;
        else
            cout<<"Second"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3772
q,h,s,d=map(int,input().split())
n=int(input())
h=min(2*q,h)
s=min(2*h,s)
if 2*s<d:
    print(n*s)
else:
    cnt=n%2
    cnt_2=n//2
    print(cnt_2*d+cnt*s)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  printf("%d %d %d %d",b+c-d,c+d-a,a+b-d,b+c-a);
  return 0;
}


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

int main(){
  string s;cin >> s;
  int k; cin >> k;
  for(int i=0; i<s.size()-1; i++){
    //cout << k << endl;
    if(((int)s.at(i) - 96)==1||k==0){
      continue;
    }else if((27-((int)s.at(i) - 96))<=k){
      
      //cout << (int)s.at(i) << endl;
      k -= 27-((int)s.at(i)-96);
      s.at(i) = 'a';
    }
  }
  //cout << k << endl;
  k = k%26;
  if(k!=0){
    if(122<s.at(s.size()-1)+k){
      s.at(s.size()-1) = (char)96+(s.at(s.size()-1)+k-122);
    }else{
      s.at(s.size()-1) = (char)s.at(s.size()-1)+k;
    }
  }
  cout << s << endl;
}
      

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, t;
  cin >> n >> t;
  if (n <= t) {
    cout << 0 << endl;
  } else {
    cout << n - t << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;
	vector<pair<int, int> > s;
	vector<pair<int, int> > c;

	cin >> N >> M;
	
	s.resize(N);
	c.resize(M);

	for (int i = 0; i < N; i++)
		cin >> s[i].first >> s[i].second;
	for (int j = 0; j < M; j++)
		cin >> c[j].first >> c[j].second;

	for (int i = 0; i < N; i++){
		// f:diff, s:number
		vector<pair<int, int> > d;
		d.resize(M);
		int x1 = s[i].first;
		int y1 = s[i].second;
		for (int j = 0; j < M;j++){
			int x2 = c[j].first;
			int y2 = c[j].second;
			d[j].first = abs(x1 - x2) + abs(y1 - y2);
			d[j].second = j;
		}
		sort(d.begin(), d.end());
		cout << d[0].second + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){

    char a,b,c,d;
    char S[4];
    scanf("%s",&S);
    a=S[0],b=S[1],c=S[2],d=S[3];
    if((a==b)&&(c==d)&&(b!=c)){
        printf("Yes\n");
    }
    else if((a==d)&&(b==c)&&(a!=b)){
        printf("Yes\n");
    }
    else if((a==c)&&(b==d)&&(a!=b)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int k;
    cin >> k;
    queue<ll> Q;
    rrep(i, 9) Q.push(i);
    ll ans;
    rep(i, k) {
        ans = Q.front();
        Q.pop();
        ll b = 10 * ans + (ans % 10);
        if(ans % 10 != 0) Q.push(b - 1);
        Q.push(b);
        if(ans % 10 != 9) Q.push(b + 1);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
while(1):
    H,W=map(int,input().split(" "))
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print("")
    print("")


Measured memory_bytes: 7012
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k; cin >> k;
    ll a[50];
    rep(i, 50) a[i] = 49;
    cout << 50 << endl;
    ll cnt = k / 50;
    k -= cnt * 50;
    rep(i, 50)  a[i] += cnt;
    rep(i, 50) {
        if(k <= 0) break;
        k--;
        a[i] += 51;
        rep(j, 50) {
            a[j]--;
        }
    }
    rep(i, 50) {
        if(i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector<ll> X, Y;

map< pair<ll, ll>, ll> cnt;

signed main()
{
    cin >> N;
    X.resize(N);
    Y.resize(N);
    REP(i, N) {
        cin >> X[i] >> Y[i];
    }

    REP(i, N) {
        REP(j, N) {
            if(i == j) { continue; }
            ll dx = X[i] - X[j];
            ll dy = Y[i] - Y[j];
            cnt[make_pair(dx, dy)]++;
        }
    }

    ll ans = N;
    for(auto& cand : cnt) {
        ans = min(ans, N - cand.second);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 384
import itertools

foods = [int(input()) for _ in range(5)]
all_route = list(itertools.permutations(foods))
ans = []
for route in all_route:
    total = 0

    for i in range(len(route) - 1):
        total += route[i]
        if route[i] % 10 != 0:
            total += 10 - route[i] % 10
    total += route[-1]
    ans.append(total)
print(min(ans))


Measured memory_bytes: 8940
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n, m;
string s;
signed main(){
	cin >> n >> s >> m;
	if(s[0]=='+'){
		cout << n+m << endl;
	}else{
		cout << n-m << endl;
	}
 
	
 
return 0;
}

Measured memory_bytes: 256
import numpy as np
from numpy.fft import rfft, irfft

mod = 10 ** 9 + 7
S = input()

mat = []
for i in range(6):
    w = np.zeros(13)
    for j in range(10):
        w[(10 ** i * j) % 13] += 1
    mat.append(rfft(w))

ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]


state = np.zeros(13)
state[0] = 1
state = rfft(state)

keta = 0
res = 5
for s in reversed(S):
    if s == "?":
        state = state * mat[keta % 6]
    else:
        res -= ress[keta % 6][int(s)]

    if state[0] >= 2 ** 50:
        state = np.round(irfft(state, 13))
        state = rfft(np.remainder(state, mod))

    keta += 1

state = irfft(state, 13)
print(int(np.round(np.real(state[res % 13]))) % mod)


Measured memory_bytes: 12664
from itertools import combinations
n = int(input())
lst = [(i+1) for i in range(n)]
ans = []
for x,y in combinations(lst, 2):
    if n%2==0:
        if x+y==n+1:
            continue
    if n%2!=0:
        if x+y==n:
            continue
    ans.append((x,y))
print(len(ans))
for x,y in ans:
    print(x,y)

Measured memory_bytes: 3996
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    string s[3];
    REP(i, 3) cin >> s[i];

    int i = 0;
    while (s[i].size() > 0) {
        int j = s[i][0] - 'a';
        s[i].erase(0, 1);
        i = j;
    }

    cout << (char)('A' + i) << '\n';
    return 0;
}


Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
c=gs
puts c.next

Measured memory_bytes: 1788
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner ipt = new Scanner(System.in);
		int a = ipt.nextInt(), b = ipt.nextInt(), add, sub, mul;
		add = a + b;
		sub = a - b;
		mul = a * b;
		if (add >= sub)
			if (mul >= add)
				System.out.println(mul);
			else
				System.out.println(add);
		if (sub > add)
			if (mul >= sub)
				System.out.println(mul);
			else
				System.out.println(sub);
	}
}

Measured memory_bytes: 21844
def merge(A,B):
    C = []
    i = 0
    j = 0
    while i < len(A) and j < len(B):
        if A[i]>B[j]:
            C.append(A[i])
            i += 1
        else:
            C.append(B[j])
            j += 1

    if len(A)-i>len(B)-j:
        C.extend(A[i:])
    else:
        C.extend(B[j:])

    return C

X,Y,A,B,C = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))

# P = [3,63,12,5,6]
# Q = [3,5,6,7,8]
# R = [13,5,6,8,23,5]
# X = 3
# Y = 2

# P = [63,12,6]
# Q = [8,7]

# i = 2
# j = 2
# C = [63,12,8,7]


P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

S = merge(P[:X],Q[:Y])
S = merge(S,R)

score = 0
for i in range(X+Y):
    score += S[i]
print(score)



Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
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);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

void solve(ll K){
    ll N = 50;
    vector<ll> A(N);
    rep(i,N) A[i] = 49 + K/50;
    
    rep(i,K%50){
        sort(ALL(A));
        A[0] += N;
        rep(j,50) if(j != 0) A[j] --;
    }
    
    print(50);
    rep(i,N) cout << A[i] << " ";
    return;
}

int main(){
    ll K; cin >> K;
    solve(K);
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    while (1)
    {
        int H, W;
        cin >> H >> W;
        if(H==0&&W==0) break;

        for (size_t i = 0; i < H; i++)
        {

            for (size_t j = 0; j < W; j++)
            {
                if ((j + i) % 2 == 0)
                {
                    cout << "#";
                }
                else
                {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088
/* 
 Author:N_o_o_B 
 Created:November 09 2019 17:30:52
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n;
    cin >> n;
    int ans = (n-1)/2;
    cout << ans << endl;




    time_taken();
    return 0;
}

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

#define ll long long
using namespace std;

int main(){
    ll N,ans=0;
    int a,b;
    cin >> N;
    cin >> a;
    ans = a;
    if(N == 2) ans += a;
    for(int i = 0; i < N-2; i++){
        cin >> b;
        ans += min(a,b);
        a = b;
    }
    ans += b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


char c[2] = { 'S','W' };

int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int y = 0;y < 2;y++) {
		for (int z = 0;z < 2;z++) {
			string t;
			t += c[y];
			t += c[z];
			for (int i = 1;i < n-1;i++) {
				if (t[i] == 'S'&&t[i - 1] == 'S') {
					if (s[i] == 'o')t+='S';
					else t+= 'W';
				}
				else if (t[i] == 'S'&&t[i - 1] == 'W') {
					if (s[i] == 'o')t+='W';
					else t+='S';
				}
				else if (t[i] == 'W'&&t[i - 1] == 'S') {
					if (s[i] == 'o')t+='W';
					else t+= 'S';
				}
				else {
					if (s[i] == 'o')t += 'S';
					else t+= 'W';
				}
			}
			bool fl = 0;
			if (t[n - 1] == 'S') {
				if (s[n - 1] == 'o') {
					if (t[n - 2] == t[0])fl = 1;
				}
				else {
					if (t[n - 2] != t[0])fl = 1;
				}
			}
			else {
				if (s[n - 1] == 'o') {
					if (t[n - 2] != t[0])fl = 1;
				}
				else {
					if (t[n - 2] == t[0])fl = 1;
				}
			}

			if (fl) {
				if (t[0] == 'S') {
					if (s[0] == 'o') {
						if (t[n - 1] == t[1]) {
							cout << t << endl;
							return 0;
						}
					}
					else {
						if (t[n - 1] != t[1]) {
							cout << t << endl;
							return 0;
						}
					}
				}
				else {
					if (s[0] == 'o') {
						if (t[n - 1] != t[1]) {
							cout << t << endl;
							return 0;
						}
					}
					else {
						if (t[n - 1] == t[1]) {
							cout << t << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){"use strict";var n=e(1);e(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,e){"use strict";var n=e(3),i=e(5);t.exports=function(t){var r=new n(t);i(r)}},function(t,r,e){"use strict";var n=e(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,e){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,e){"use strict";var n=e(6);t.exports=function(t){for(var r=t.in(),e=t.in(),i=new Array(r),o=99999999999999,s=0;s<r;s++)i[s]=new Array(r).fill(o);for(var u=0;u<e;u++){var c=t.in(),f=t.in(),a=t.in();i[c][f]=a}for(var l=n(i,o),p=[],v=0;v<r;v++){var d=[];if(l[v][v]<0)return void console.log("NEGATIVE CYCLE");for(var h=0;h<r;h++)l[v][h]==o?d.push("INF"):d.push(l[v][h].toString());p.push(d.join(" "))}console.log(p.join("\n"))}},function(t,r,e){"use strict";t.exports=function(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:99999999999999,e=t.length,n=new Array(e),i=0;i<e;i++)n[i]=t[i].concat(),n[i][i]=0;for(var o=0;o<e;o++)for(var s=0;s<e;s++)for(var u=0;u<e;u++)if(n[s][o]!=r&&n[o][u]!=r){var c=n[s][o]+n[o][u];n[s][u]>c&&(n[s][u]=c)}return n}}]);


Measured memory_bytes: 25428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin>>n;
  vec a(n);
  vec b(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  ll ans=0;
  for(ll i=n-1;i>-1;i--) {
    ans+=(a[i]+ans+b[i]-1)/b[i]*b[i]-(a[i]+ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
---+/
/+---test
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;

  struct Item { long i; string n; long s; }
  auto I = new Item[](N);
  foreach (i, ref item; I) {
    item.i = i+1;
    readf(" %s %d ", &item.n, &item.s);
  }

  I.multiSort!("a.n < b.n", "a.s > b.s");
  foreach (x; I) x.i.writeln;
}


Measured memory_bytes: 256
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readUint() = readString() |> uint64
let readIntArray() = readStringArray() |> Array.map(fun x -> int x)
let char2String(value) = List.ofSeq value |> List.toArray |> System.String

let n, q = readIntArray() |> fun x -> (x.[0], x.[1])
let s = readString().ToCharArray()
let queries = [for _ in [1..q] -> readIntArray()]
let ary : int array = Array.zeroCreate n
for i in [0..n-2] do 
    Array.set ary (i+1) (if s.[i] = 'A' && s.[i+1] = 'C' then 1 else 0)
for i in [1..n-1] do 
    Array.set ary i (ary.[i-1] + ary.[i])

queries
|> List.iter (fun x -> printfn "%d" (ary.[x.[1]-1] -  ary.[x.[0]-1]))

Measured memory_bytes: 38428
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> num_like(m);
  rep(i, n) {
    int k;
    cin >> k;
    rep(j, k) {
      int a;
      cin >> a;
      a--;
      num_like[a]++;
    }
  }
  int ans = 0;
  rep(i, m) if(n == num_like[i]) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1 for _ in range(n)]
        #マイナスが根を表す
        #数字はグループのノード数（サイズ）を表す
        #初期状態では、全てのノードが根で、サイズは1
 
    def same(self, x, y):
        return self.root(x)==self.root(y)
 
    def root(self, x):
        if self.par[x]<0:
            return x
        self.par[x] = self.root(self.par[x])
        #再帰的に根を求め、根に直接繋いで高速化（辺の縮約）
        return self.par[x]
 
    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
 
        if self.par[x] > self.par[y]:
            x,y = y,x
            #木のバランスに偏りが生じると計算量が増えるので、
            #サイズが小さいグループを大きいグループの下に繋げる
 
        self.par[x] += self.par[y]
        #下に繋ぐグループのサイズを上のグループに加算
        self.par[y] = x
        #親を更新
 
    def size(self,x):
        return -self.par[self.root(x)]

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ab.reverse()
uf = UnionFind(n)

res = []
tmp = n * (n - 1) // 2
#全く繋がっていない状態からスタート（逆算していく方が簡単）
for a,b in ab:
    res.append(tmp)
    a -= 1
    b -= 1
    if uf.same(a,b):
        continue
 
    sa = uf.size(a)
    sb = uf.size(b)
    tmp -= sa * sb
    #aとbを繋げることで、aグループのサイズ * bグループのサイズの島の組が新たに行き来可能となる
    uf.unite(a,b)

res.reverse()
#本来の順番に戻す
for r in res:
    print(r)

Measured memory_bytes: 34608
N = int(input())
A = list(map(int,input().split()))

minus = 0
plus_min = 1000000000
minus_max = -1000000000
total = 0

for j in range(N):
    if A[j] >= 0:
        plus_min = min(A[j],plus_min)
    else:
        minus_max = max(A[j],minus_max)
        minus += 1

    total += abs(A[j])

if minus % 2 == 0:
    print(total)
else:
    print(total-2*min(abs(minus_max),plus_min))



Measured memory_bytes: 14284
#include<iostream>
#include<cstdlib>
#include<stack>
#include<string>

const int N = 4;
const char *oprs = "+-*";
int operands[N];
int bExist = false;

using namespace std;

int generateExpression(int *oprpos, int *opr, int *operand, int n, int *e){
	int t = 0;
	int eIndex = 0;
	int nextOperand = 0;

	e[eIndex++] = operands[operand[nextOperand++]];
	e[eIndex++] = operands[operand[nextOperand++]];
	for(int i = 0; i < n - 1; i++){
		for(int j = t; j < oprpos[i] + t; j++){
			e[eIndex++] = oprs[opr[j]];
		}
		if( i < n - 2 ){
			e[eIndex++] = operands[operand[nextOperand++]];
		}
		t += oprpos[i];
	}
	return eIndex;
}

int calculateExpression( int *e, int esize, string &answer ){
	int i = 0;
	stack< int > st;
	stack< string > sst;
	int ret = 0;

	for(int i = 0; i < esize; i++){
		int t, t1, t2;
		string exp, exp1, exp2;
		char opr;
		opr = e[i];

		if( opr == '+' || opr == '-' || opr == '*' ){
			exp1 = sst.top();	sst.pop();
			exp2 = sst.top();	sst.pop();
			switch( opr ){
				case '+':
					t1 = st.top();	st.pop();
					t2 = st.top();	st.pop();
					t = t1 + t2;
					st.push( t );
					break;
				case '-':
					t2 = st.top();	st.pop();
					t1 = st.top();	st.pop();
					swap( exp1, exp2 );
					t = t1 - t2;
					st.push( t );
					break;
				case '*':
					t1 = st.top();	st.pop();
					t2 = st.top();	st.pop();
					t = t1 * t2;
					st.push( t );
					break;
			}
			exp = '(';exp+=exp1;exp+=' ';exp+=opr;exp+=' ';exp+=exp2;exp+=')';
			sst.push( exp );
		}else{
			char stroperand[32];
			sprintf( stroperand, "%d", opr);
			st.push( opr );
			sst.push( stroperand );
		}
	}
	ret = st.top();
	answer = sst.top();
	return ret;
}

void permit_operand(int *flag, int *p, int rest, int n, int *opr, int *oprpos){
	int t = 0;
	for(int i = 0; i < n; i++ ){
		if( flag[i] ){
			t++;
		}
	}
	if( t == n ){
		// TODO
		int e[N*2], esize;
		string expr;

		esize = generateExpression( oprpos, opr, p, n, e);
		if( calculateExpression( e, esize, expr ) == 10 ){
			if( !bExist ){
				bExist = true;
				cout << expr << '\n';
			}
		}
		return ;
	}

	for(int i = 0; i < n; i++ ){
		if( flag[i] ){
			continue;
		}else{
			flag[i] = 1;
			p[n - rest] = i;
			permit_operand(flag, p, rest - 1, n, opr, oprpos);
			flag[i] = 0;
		}
	}
}

void rawcomb_opr(int *p, int rest, int n, int *oprpos){
	if( rest == 0 ){
		// TODO
		int flag[N] = {0,};
		int operand[N];
		permit_operand( flag, operand, N, N, p, oprpos );
		return ;
	}
	for(int i = 0; i < n; i++){
		p[n - rest] = i;
		rawcomb_opr(p, rest - 1, n, oprpos);
	}
}

void rawcomb_oprpos(int *p, int rest, int n){
	if( rest == 0 ){
		// TODO
		int t = 0;
		for(int m = 0; m < n - 1; m++){
			t += p[m];
			if( t > m + 1 ){
				return ;
			}
		}
		if( t == n - 1 ){
			int opr[N];
			rawcomb_opr( opr, 3, 3, p );
		}
		return ;
	}
	for(int i = 0; i < n + 1 - rest; i++){
		p[(n - 1) - rest] = i;
		rawcomb_oprpos(p, rest - 1, n);
	}
}

int main(void){
	while(true){
		int end = 0;
		int p[N];

		for(int i = 0; i < N; i++){
			cin>>operands[i];
			end |= operands[i];
		}
		if( end == 0 ){
			break;
		}
		bExist = false;
		rawcomb_oprpos(p, N - 1, N);
		if( !bExist ){
			cout << "0\n";
		}
	}
	return 0;
}

Measured memory_bytes: 960
function bomb(x){
   var str="";
   for(var i=0;i<x.length;i++){
      str+=x[i];
   }
   var L=0;
   while(L!=str.length){
      L=str.length;
      str=str.replace(/1111+|2222+|3333+/,"");
   }
   min=Math.min(min,str.length);
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var N=Arr.shift()-0;
   if(N==0)break;
   var arr=[];
   for(var i=0;i<N;i++){
      var v=Arr.shift()-0;
      arr.push(v);
   }
   var min=Infinity;
   for(var i=0;i<N;i++){
      var memo=arr[i];
      if(i<N-1){
         arr[i]=arr[i+1];
         bomb(arr);
      }
      if(i>0){
         arr[i]=arr[i-1];
         bomb(arr);
      }
      arr[i]=memo;
   }
   console.log(min);
}

Measured memory_bytes: 44304
#include <iostream>
using namespace std;
int main(void)
{
	int n;
	int date[8] = {0,10,20,30,40,50,60,1000};
	while(cin>>n){
		int freq[7]={0};
		if(!n) break;
		while(n--){
			int year;
			cin >> year;
			for(int i=0;i<7;i++){
				if(date[i]<=year&&year<date[i+1]){
					freq[i]++;
					break;
				}
			}
		}
		for(int i = 0; i < 7; i++){
			cout << freq[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 864
#include <iostream>
#include <utility>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define llint long long
#define eps 1e-8

using namespace std;

struct vec2d{
	double x, y;
	vec2d(){}
	vec2d(double x, double y){
		this->x = x, this->y = y;
	}
	double add(double a, double b){
		if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;
		return a+b;
	}
	vec2d operator+(vec2d ope){
		return vec2d(add(x, ope.x), add(y, ope.y));
	}
	vec2d operator-(vec2d ope){
		return vec2d(add(x, -ope.x), add(y, -ope.y));
	}
	vec2d operator*(double t){
		return vec2d(x*t, y*t);
	}
	vec2d operator/(double t){
		return vec2d(x/t, y/t);
	}
	double dot(vec2d ope){
		return add(x*ope.x, y*ope.y);
	}
	double cross(vec2d ope){
		return add(x*ope.y, -y*ope.x);
	}
	double norm(){
		double d2 = dot(*this);
		if(d2 > 0) return sqrt(d2);
		return 0.0;
	}
};

llint n;
vec2d p[10];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 0; i < 10; i++) p[i].x = p[i].y = 0;
	for(int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y;
	
	int perm[10];
	for(int i = 0; i < 10; i++) perm[i] = 0;
	for(int i = 1; i <= n; i++) perm[i] = i;
	
	double ans = 1e9;
	do{
		vec2d a = p[perm[1]], b = vec2d(1, 0);
		double tmp = fabs(acos(a.dot(b) / (a.norm()*b.norm())));;
		for(int i = 1; i <= n; i++){
			vec2d a = p[perm[i]]-p[perm[i-1]], b = p[perm[i+1]]-p[perm[i]];
			tmp += fabs(acos(a.dot(b) / (a.norm()*b.norm())));
			//cout<< a.x << " " << a.y << " " << b.x << " " << b.y << " " << a.dot(b) << endl;
			//cout << a.dot(b) / (a.norm()*b.norm()) << endl;
		}
		ans = min(ans, tmp);
	}while(next_permutation(perm+1, perm+n+1));
	
	printf("%.11f\n", ans * 180 / 3.14159265358979);
	
	return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,k,q,i,j;
    cin>>n>>k>>q;
    ll a[q];
    for(i=0;i<q;i++){
        cin>>a[i];
    }
    ll s[n];
    std::fill_n(s,n,k-q);
    for(i=0;i<q;i++){
        ++s[a[i]-1];
    }
    for(i=0;i<n;i++){
        if(s[i]<=0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 2176