akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<int> d(m);
  int i;
  for (i = 0; i < m; i++) {
    cin >> d[i];
    d[i] += n - p;
    d[i] %= n;
  }
  sort(d.begin(), d.end());
  int result = d[m - 1];
  for (i = m - 1; i > 0; i--) {
    result = min(result, d[i - 1] + (n - d[i]) * 2);
  }
  result = min(result, n - d[0]);
  for (i = 0; i < m - 1; i++) {
    result = min(result, d[i] * 2 + (n - d[i + 1]));
  }

  cout << result * 100 << endl;

  return 0;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=400;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch&15);ch=getchar();}
	return x*f;
}

int n,ans,l[N];

int main()
{
	n=read();
	for(int i=1;i<=2*n;i++) l[i]=read();
	std::sort(l+1,l+2*n+1);
	for(int i=1;i<=2*n;i+=2) ans+=l[i];
	printf("%d\n",ans);
}

Measured memory_bytes: 256
N=int(input(''))
a=1
k=0
F=int(N**(1/2))

while a<N:
  if N%a>0:
    b=N//a
    k=k+b
    b=0
  else:
    b=N//a
    k=k+b-1
    b=0
  a=a+1

print(k)

Measured memory_bytes: 9440
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using ll = long long int;
ll mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    vector<vector<ll>> dp(s.size(), vector<ll>(13, 0));
    vector<ll> base(s.size(), 0);
    ll b = 1;
    base[0] = 1;
    for(int i = 1; i < s.size(); i++)
    {
        base[i] = (base[i - 1] * 10) % 13;
    }
    //for(auto e : base) cout << e << " ";
    //cout << endl;
    if(s[0] == '?')
    {
        for(int i = 0; i < 10; i++)
        {
            ll rest = (i * base[s.size() - 1]) % 13;
            dp[0][rest]++;
        }
    }else{
        ll a = s[0] - '0';
        ll rest = (a * base[s.size() - 1]) % 13;
        dp[0][rest] = 1;
    }
    for(int i = 1; i < s.size(); i++)
    {
        ll temp = base[s.size() - i - 1];
        if(s[i] == '?')
        {
            for(int j = 0; j < 10; j++)
            {
                ll rest = (j * temp) % 13;
                //cout << rest << endl;
                for(int k = 0; k < 13; k++)
                {
                    if(dp[i - 1][k] != 0)
                    {
                        ll newrest = (rest + k) % 13;
                        dp[i][newrest] = (dp[i][newrest] + dp[i - 1][k]) % mod;
                    }
                }
            }
        }else{
            ll a = s[i] - '0';
            ll rest = (a * temp) % 13;
            for(int j = 0; j < 13; j++)
            {
                if(dp[i - 1][j] != 0)
                {
                    ll newrest = (rest + j) % 13;
                    dp[i][newrest] = dp[i - 1][j];
                }
            }
        }
    }
    /*for(int i = 0; i < s.size(); i++)
    {
        for(int j = 0; j < 13; j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << dp[s.size() - 1][5] << endl;
}

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

using namespace std;

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

  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> count(n, 0);
  for (int i = 1; i < n; ++i) {
    count[i] = count[i-1];
    if (s[i-1] == 'A' && s[i] == 'C') 
      count[i]++;
  }
  int l, r;
  while (q--) {
    cin >> l >> r;
    l--; 
    r--;
    cout << count[r]-count[l] << endl;
  }

  return 0;
}



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

long long gcd(long long a, long long b) {
  if (a > b) {
    return gcd(b, a);
  }
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}

int main()
{
  long long a, b;
  cin >> a >> b;
  long long g = gcd(a, b);
  long long origin = g;
  unordered_set<long long> s;
  for (long long i = 2; i*i <= origin; i++) {
    while (g % i == 0) {
      g = g / i;
      s.insert(i);
    }
  }
  if (2 < g) {
    s.insert(g);
  }
  cout << s.size() + 1 << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    A = list(map(int,input().split()))
    ans = 0
    for i in range(N):
        if i%2 == 0 and A[i]%2 == 1:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
// B.

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

using namespace std;

int main(int argc, char *argv[]) {
	long long a, b, k, c;
	cin >> a >> b >> k;
	c = min(a, k);
	a -= c;
	b = max(0LL, b - (k - c));
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, p; cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
    return 0;
}

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

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

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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


int main(){
    int a, b; cin >> a >> b;
    cout << max(2*a-1, max(2*b-1, a+b)) << endl;
    return 0;
}

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

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

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    cout << (N - 1 + K - 2) / (K - 1) << endl;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

long long solve(string str, long long m) {
    // cout << "str: " << str << endl;
    int n = str.size();
    vector<long long> A;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0 || str[i] != str[i-1]) {
            cnt = 1;
        } else {
            cnt++;
        }
        if (i == n - 1 || str[i] != str[i+1]) {
            A.push_back(cnt);
        }
    }
    // cout << "A: " << A << endl;
    long long ans = 0;
    if (A.size() == 1) {
        ans += A[0] * m / 2;
    } else if (str[0] == str[n-1]) {
        for (int i = 1; i < (int)A.size() - 1; i++)
            ans += A[i] / 2 * m;
        ans += A[0] / 2;
        ans += A.back() / 2;
        ans += (A[0] + A.back()) / 2 * (m - 1);
    } else {
        for (auto a: A)
            ans += a / 2 * m;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    string str;
    long long m;
    cin >> str >> m;

    long long ans = solve(str, m);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

string S;

int main() {
	cin >> S;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == S[i + 1]) {
			puts("Bad");
			return 0;
		}
	}
	puts("Good");
}

Measured memory_bytes: 764
N, K = map(int, input().split(" "))
# print(N, K)

people = []

for i in range(0, K):
  d = int(input())
  A = list(map(int, input().split(" ")))
  # print(d, A)
  for j in range(d):
    people.append(A[j])

# print(people)
print(N - len(set(people)))

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

int main(){
string s;
  cin >> s;
  vector<int> vec(125,0);
  rep(i,s.size())vec.at(s.at(i))++;
  for(int i=97; i<=122; i++){
    if(vec.at(i)==0){cout<<(char)(i)<< endl; return 0;}
  }
  cout << "None" << endl;

	return 0;
}


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

int v[100000][3];
int dp[100000][3];
int n;
int max_hap(int flag,int i)
{
    if(i == (n-1))
        return v[i][flag];
    if(dp[i][flag] != -1)
        return dp[i][flag];

    if(flag == 0)
        dp[i][flag] = v[i][flag] + max(max_hap(1,i+1),max_hap(2,i+1));
    else if(flag == 1)
        dp[i][flag] = v[i][flag] + max(max_hap(0,i+1),max_hap(2,i+1));
    else
        dp[i][flag] = v[i][flag] + max(max_hap(0,i+1),max_hap(1,i+1));

    return dp[i][flag];
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    memset(dp,-1,sizeof(dp));
    cout<<max(max_hap(0,0),max(max_hap(1,0),max_hap(2,0)));
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <functional>

using namespace std;

int main(){
    int N;
    cin >> N;
    long long dp[110][4][4][4];
    for(int b2=0; b2<4; b2++){
        for(int b1=0; b1<4; b1++){
            for(int now=0; now<4; now++){
                if( (now==3 && b1 == 1 && b2 == 0)
                   ||(now==3 && b1 == 0 && b2 == 1)
                   ||(now==1 && b1 == 3 && b2 == 0)
                   //||(now==3 && b1 == 1 && b3 == 0)
                   //||(now==3 && b2 == 1 && b3 == 0)
                   ){
                    dp[3][b2][b1][now] = 0;
                } 
                else dp[3][b2][b1][now] = 1;
            }
        }
    }
    for(int n=4; n<=N; n++){
        for(int b3=0; b3<4; b3++){
            for(int b2=0; b2<4; b2++){
                for(int b1=0; b1<4; b1++){
                    for(int now=0; now<4; now++){
                        if( (now==3 && b1 == 1 && b2 == 0)
                        ||(now==3 && b1 == 0 && b2 == 1)
                        ||(now==1 && b1 == 3 && b2 == 0)
                        ||(now==3 && b1 == 1 && b3 == 0)
                        ||(now==3 && b2 == 1 && b3 == 0)
                        ){      //不正
                            dp[n][b2][b1][now] = 0;
                        }
                        else{   //不正でない
                            dp[n][b2][b1][now] += dp[n-1][b3][b2][b1];
                            dp[n][b2][b1][now] %= 1000000007;
                        }
                    }
                }
            }
        } 
    }
    long long ans = 0;
    for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<4; k++){
                ans += dp[N][k][j][i];
                ans %= 1000000007;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '?') {
            s[i] = 'D';
        }
    }

    cout << s << "\n";

    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, k;
    cin >> n >> k;
    vector<double> l(n, 0), m(n, 0);
    for(int i = 0; i < n; i++){
        long a;
        cin >> a;
        l[i] = a*(a+1)/2/(double)a;
        if(i == 0) m[i] = l[i];
        else m[i] += l[i] + m[i-1];
    }
    double ans = -1;
    for(int i = 0; i < n-k+1; i++){
        if(i == 0) ans = max(ans, m[k-1]);
        else ans = max(ans, m[i+k-1] - m[i-1]);
    }
    printf("%.6f\n", ans);
    return 0;
}

Measured memory_bytes: 3456
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int a = cin.NextInt();
			int b = cin.NextInt();
            if (a >= 10 || b >= 10) Console.WriteLine(-1);
            else Console.WriteLine(a * b);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

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

#define F first
#define S second
#define pb push_back
#define mp make_pair

ll gcd(ll a, ll b){
	if (a == 0) return b;
	return gcd(b%a, a);
}

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

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

	ll s,d,t;

	cin  >> d >> t >> s;

	ll x = d/s;

	if(x < t)
		cout << "Yes\n";
	else if(x == t)
	{
		if(d%s == 0)
			cout << "Yes\n";
		else
			cout << "No\n";
	}	
	else
		cout << "No\n";
}

Measured memory_bytes: 3660
using System;

class _0103
{
    static bool[] bag = new bool[3];
    public static void Main()
    {
        string ev;
        int i, j, score, outc, inning = int.Parse(Console.ReadLine());
        for (i = 0; i < inning; i++)
        {
            score = 0; outc = 0;
            for (j = 0; j < bag.Length; j++) bag[j] = false;
            while (outc < 3)
            {
                ev = Console.ReadLine();
                switch (ev)
                {
                    case "HIT":
                        if (bag[2]) score++;
                        for (j = 2; j > 0; j--) bag[j] = bag[j - 1];
                        bag[0] = true;
                        break;
                    case "OUT":
                        outc++;
                        break;
                    case "HOMERUN":
                        for (j = 0; j < bag.Length; j++)
                        {
                            if (bag[j]) score++;
                            bag[j] = false;
                        }
                        score++;
                        break;
                }
            }
            Console.WriteLine(score.ToString());
        }
    }
}

Measured memory_bytes: 5644
use std::io::*;
use std::str::FromStr;

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")
}

fn main() {

    let mut a:i32 = read();
    let b:i32 = read();
    let mut c:i32 = read();
    let d:i32 = read();

    loop {
        c -= b;
        if c <= 0 {
            println!("Yes");
            break;
        }
        a -= d;
        if a <= 0 {
            println!("No");
            break;
        }
    }

}

Measured memory_bytes: 2068
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
  long long n,m,t1,t2,d_sum=0,m_sum=0;
  vector<pair<long long,long long>> a;
  cin >> n >>m;
  for(int i=0;i<n;i++){
    cin >> t1 >> t2;
    a.push_back(make_pair(t1,t2));
  }
  sort(a.begin(),a.end());
  int i=0;
  while(d_sum<m){
    if(a[i].second+d_sum<=m){
      d_sum+=a[i].second;
      m_sum+=a[i].first*a[i].second;
    }else{
      m_sum+=(m-d_sum)*a[i].first;
      d_sum=m;
    }
    i++;
  }
  cout << m_sum <<endl;
}



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

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


vector<bool> prime_num;



bool check(int x) {
    return (prime_num[x] && prime_num[(x+1)/2]);
}

int main(void) {
    int q; cin >> q;

    int max = 1e5+1;
    prime_num.resize(max, 1);
    prime_num[0] = false;
    prime_num[1] = false;

    for(int i = 2; i*i <= max; ++i) {
        if(prime_num[i]) {
            for(int j = 2; i * j <= max; ++j) {
                prime_num[i*j] = false;
            }
        }
    }

    vector<int> s(max+1, 0);
    for(int i = 0; i < max; ++i) {
        int a = 0;
        if(check(i)) {
            a++;
        }
        s[i+1] = s[i] + a;
    }

    REP(i,q) {
        int l, r;
        cin >> l >>  r;

        int ans = s[r+1] - s[l];

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

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

string str;

int main() {
    cin >> str;

    if (str[0] == '7' || str[1] == '7' || str[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

import static java.lang.Math.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner= new Scanner(System.in);
        int A,B,C,X,Y;
        A=scanner.nextInt();
        B=scanner.nextInt();
        C=scanner.nextInt();
        X=scanner.nextInt();
        Y=scanner.nextInt();
        int ans=(int)1e9;//1e9=10^9
        for(int i=0;i<2*(X+Y)+1;i++){
            int ABpizza=i;
            int Apizza=max(0,X-i/2);
            int Bpizza=max(0,Y-i/2);
                    ans=Math.min(ans,Apizza*A+Bpizza*B+ABpizza*C);
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 21972
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String S;
        S = sc.next();

        final Solver solver = new Solver();
        solver.solve(S);
    }
}

class Solver {
    public void solve(String S) {
        for (int i = 0; i < S.length(); i++) {
            System.out.print("x");
        }
        System.out.println();
    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,k,ans=0;
  
  cin >> n >> k;
  
  while (n>0){
    n/=k;
    ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        for(;;)
        {
            int[] data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if(data[0] == 0 && data[1] == 0)break;
            
            Array.Sort(data);
            Console.WriteLine(data[0] + " " + data[1]);
        }
    }
}


Measured memory_bytes: 14396
(function (input) {
    var inputs = input.replace(/\r/g, '').split("\n"), str, n, prev;
    while(true) {
        n = parseInt(inputs.shift());
        if(n === 0) {
            break;
        }
        str = inputs.shift();
        for(var i = 0; i < n; i++) {
            var tmp = '';
            prev = {
                char: str.charAt(0),
                repeat: 0
            };
            for(var j = 0, len = str.length; j < len; j++) {
                if(prev.char === str.charAt(j)) {
                    prev.repeat++;
                } else {
                    tmp += prev.repeat.toString() + prev.char;
                    prev = {
                        char: str.charAt(j),
                        repeat: 1
                    };
                }
            }
            tmp += prev.repeat.toString() + prev.char;
            str = tmp;
        }
        console.log(str);
    }
})(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 13688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i += 2)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i += 2)
int main() {
  string A;
  cin >> A;
  int LOL = 0;
  rep(i, A.size()) {
    if(A.at(i) == 'L') {
      LOL++;
    }
  }
  rep2(i, 1, A.size()) {
    if(A.at(i) == 'R') {
      LOL++;
    }
  }
  if(LOL > 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}
    


Measured memory_bytes: 3608
#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>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int s;cin>>s;
    int i=0;
    set<int> hoz;
    while(1){
        i++;
        if(hoz.count(s)){
            cout<<i<<endl;
            return 0;
            break;
        }else{
            hoz.insert(s);
        if(s%2){
                s=s*3+1;
            }else{
                s=s/2;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

int n;
vector<ll> a;

void solve(istream& cin, ostream& cout) {
  cin >> n;
  a.resize(n + 1);
  REP(i, n + 1) cin >> a[i];
  vector<ll> tree(n + 1, 0);
  tree[n] = a[n];
  RFOR(i, n - 1, 0) tree[i] = a[i] + tree[i + 1];

  ll ans = 1;
  tree[0] = 1;
  if (a[0] > 1) {
    cout << -1 << endl;
    return;
  }
  FOR(i, 1, n) {
    tree[i] = min(tree[i], (tree[i - 1] - a[i - 1]) * 2);
    if (tree[i] <= 0 || tree[i] < a[i]) {
      cout << -1 << endl;
      return;
    }
    ans += tree[i];
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 4784
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	A[0] %= M;
	for (int i = 0; i < N - 1; i++) {
		A[i + 1] += A[i];
		A[i + 1] %= M;
	}

	map<int, lint> mod;
	for (int i = 0; i < N; i++) mod[A[i] % M]++;

	lint ans = mod[0];
	for (const auto &elem : mod) ans += elem.second * (elem.second - 1) / 2;

	cout << ans << "\n";

	return 0;
}


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

typedef long long SEGNODE_TYPE;   // セグ木のノードの型の定義
class Segtree
{
    public:

    SEGNODE_TYPE monoid;
    int segsize;    // セグ木の大きさ
    vector<SEGNODE_TYPE> value;

    // [引数]
    //          int n                   : 大きさ
    //          SEGNODE_TYPE start      : 初期値
    //          SEGNODE_TYPE mnd        : 単位元（モノイド）
    // [動作]
    //          セグ木を作る
    // ※SEGNODE_TYPE の定義を忘れずに
    Segtree() {}
    Segtree(int n, SEGNODE_TYPE start, SEGNODE_TYPE mnd) {    
        segsize = 1;
        while(segsize < n){
            segsize = segsize * 2;
        }
  
        value = vector<SEGNODE_TYPE>(2 * segsize - 1, start);
        monoid = mnd;
    }      

    // [引数]
    //          int i           : 変更箇所
    //          SEGNODE_TYPE x  : 変更値
    // [動作]
    //          場所iをxに変更
    void UpDate(int i, SEGNODE_TYPE x) {
        i += segsize - 1;
        value[i] = x;
  
        while(i > 0){
            i = (i-1) / 2;
            value[i] = Requirement(value[i * 2 + 1], value[i * 2 + 2]);
        }

        return;
    }

    // [引数]
    //          int a   : 区間の左端
    //          int b   : 区間の右端
    //          int n   : 全区間の幅
    // [動作]
    //          区間[a, b)のクエリを処理する（SegQueryへ橋渡し）
    // ※呼び出す際にはSEGNODE_TYPE Requirement(SEGNODE_TYPE x, SEGNODE_TYPE y)の中身を確認
    SEGNODE_TYPE Query(int a, int b, int n) {
        return ( SegQuery(a, b+1, 0, 0, segsize) );
    }

    // [引数]
    //          int a    : クエリの範囲の左端
    //          int b    : クエリの範囲の右端
    //          int k    : 今いるノードの場所
    //          int l    : 今いるノードの参照範囲の左端
    //          int r    : 今いるノードの参照範囲の右端
    // [動作]
    //          区間[a, b)のクエリを求める
    SEGNODE_TYPE SegQuery(int a, int b, int k, int l, int r) {
        // [a, b)の区間に対するクエリについて、ノードk(区間[l, r)担当)が答える
        if(r <= a || b <= l) {
            return (monoid);
        }
        if(a <= l && r <= b){
            // ノードkの担当クエリ区間[a ,b)に完全に含まれる
            return (value[k]);
        }
        else {
            // 左右の子に尋ねる
            SEGNODE_TYPE c1 = SegQuery(a, b, 2*k+1, l, (l+r)/2);    // 左の子（状況に合わせて型を変える）
            SEGNODE_TYPE c2 = SegQuery(a, b, 2*k+2, (l+r)/2, r);    // 右の子（状況に合わせて型を変える）
    
            return ( Requirement(c1, c2) ); // 左右の子から求めたいものを返す
        }        
    }

    // 求めたいもの
    // ※ここのreturn文は用途に合わせて書き換える必要がある
    SEGNODE_TYPE Requirement(SEGNODE_TYPE x, SEGNODE_TYPE y) {
        return ( x + y );
    }

    // [引数]
    //          int i   : 場所
    // [動作]
    //          左からi番目の値を変えす
    SEGNODE_TYPE GetReaf(int i) {
        return( value[i + segsize - 1] );
    }
};

int main() {
    int n, q, a, x, y, z;
    long long node;

    cin >> n >> q;
    Segtree fen = Segtree(n, 0, 0);

    for ( int i = 0; i < n; i++ ) {
        cin >> a;
        fen.UpDate(i, a);
    }

    for ( int i = 0; i < q ; i++ ) {
        cin >> x >> y >> z;

        if ( x == 0 ) {
            node = fen.GetReaf(y);
            node = node + z;

            fen.UpDate( y, node );
        } else {
            cout << fen.Query(y, z-1, n) << endl;
        }
    }

    return (0);
}

Measured memory_bytes: 12520
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,j,len,al[26],flg,cnt;
	char alf[27],w[101];
	strcpy(alf,"abcdefghijklmnopqrstuvwxyz");
//	for(i=0;i<26;i++)al[i]=0;
	scanf("%s",w);
	len=strlen(w);
	for(i=0;i<26;i++){
		cnt=0;
		for(j=0;j<len;j++){
			if(w[j]==alf[i]) cnt++;
		}
		al[i]=cnt;
	}
	flg=1;
	for(i=0;i<26;i++){
		if(al[i]%2!=0){
			flg=0;
			break;
		}
	}
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

const int maxn = 2e5+9;
int A[maxn];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) scanf("%d",&A[i]);
    while(k--)
    {
        int B[maxn];
        memset(B,0,sizeof(B));
        for(int i=1;i<=n;i++)
        {
            int l = max(1,i-A[i]);
            int r = min(n,i+A[i]);
            //差分
            B[l]++;
            B[r+1]--;
        }
        //差分应用
        int flag = 1;
        for(int i=1;i<=n;i++)
        {
            A[i] = A[i-1] + B[i];
            if(A[i]!=n) flag = 0;
        }
        //if(A[n]==n) break;//不是很懂
        if(flag) break;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",A[i]);
    }
    return 0;
}


Measured memory_bytes: 5372
import numpy as np
huga = list(map(int, input().split()))
a=huga[0]
b=huga[1]
c=huga[2]
if a>b:
  x=a
  a=b
  b=x
        
      
if a<c and b>c:
  print("Yes")
else:
  print("No")

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
#define INF 1e9
//constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

ll dp[104][4][4][4];
bool isOk[4][4][4][4];
bool isAGC(int a, int b, int c, int d){
  return (a==1&&b==2&&c==3) || (b==1&&c==2&&d==3);
}

void calcOk(){
  REP(i, 4){
    REP(j, 4){
      REP(k, 4){
        REP(l, 4){
          bool ans = true;
          int s[] = {i, j, k, l};
          ans &= !isAGC(s[0], s[1], s[2], s[3]);
          REP(m, 3){
            swap(s[m], s[m+1]);
            ans &= !isAGC(s[0], s[1], s[2], s[3]);
            swap(s[m],s[m+1]);
          }
          isOk[i][j][k][l] = ans;
        }
      }
    }
  }
}
int main(){
  int N;
  cin >> N;
  dp[0][0][0][0] = 1;
  calcOk();
  REP(i, N){
    REP(j, 4){
      REP(k, 4){
        REP(l, 4){
          REP(m, 4){
            if(isOk[j][k][l][m]){
              dp[i+1][k][l][m] += dp[i][j][k][l];
              dp[i+1][k][l][m] %= mod;
            }
          }
        }
      }
    }
  }
  ll ans = 0;
  REP(i, 4){
    REP(j, 4){
      REP(k, 4){
        ans += dp[N][i][j][k];
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import itertools

w, h, n = map(int,input().split())
now = [[1]*w]*h
li = [list(map(int,input().split())) for i in range(n)]

for x in li:
    if x[2]==1: #x以下を塗りつぶす
        for i in range(h):
            for j in range(x[0]):
                now[i][j] = 0
    if x[2]==2: #x以上を塗りつぶす
        for i in range(h):
            for j in range(w-x[0]):
                now[i][x[0]+j] = 0
    if x[2]==3: #y以下を塗りつぶす
        for i in range(x[1]):
            now[i] = [0]*w
    if x[2]==4: #y以上を塗りつぶす
        for i in range(x[1],h):
            now[i] = [0]*w

print(sum(list(itertools.chain.from_iterable(now))))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int n, m, x, t;

int main() {
    std::cin >> n >> m >> x;
    std::vector<int> vec(n+1, 0);
    for (int i = 0; i < m; i++) {
        std::cin >> t;
        vec[t] = 1;
    }
    int sum1 = 0;
    int sum2 = 0;
    for (int i = x; i >= 0; i--) {
        sum1 += vec[i];
    }
    for (int i = x; i <= n; i++) {
        sum2 += vec[i];
    }
    std::cout << std::min(sum1, sum2) << std::endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long ans = 0;
        int N = sc.nextInt();
        int[] grad = new int[N];
        for(int i=2;i<=N;i++){
            int in = sc.nextInt();
            grad[in-1]++;
        }
        for(int i=0;i<N;i++)
        pw.println(grad[i]);
        pw.flush();
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 59924
#include <bits/stdc++.h>
using namespace std;
#define S 1000000007

long long myPow(long long x, long long n)
{
    long long ans = 1;
    while (n > 0)
    {
        if ((n & 1))
        {
            ans *= x;
        }
        x *= x;
        n >>= 1;
    }
    return ans;
}

long long myPowWithMod(long long x, long long n, long long m)
{
    if (x == 1)
    {
        return 1;
    }
    long long ans = 1;
    while (n > 0)
    {
        if ((n & 1))
        {
            ans *= (x %= m);
            ans %= m;
        }
        x *= (x %= m);
        n >>= 1;
    }
    return ans;
}

long long nCa(long long n, long long a)
{
    long long s = 1;
    for (long long i = n; i >= n - (a + 1); i--)
    {
        s *= i;
    }
    long long t = 1;
    for (long long i = 2; i <= a; i++)
    {
        t *= i;
    }
    return (s / t);
}

long long nCaWithMod(long long n, long long a, long long m)
{
    long long s = 1;
    for (long long i = n; i >= n - a + 1; i--)
    {
        s *= (i %= m);
        s %= m;
    }
    long long t = 1;
    for (long long i = 2; i <= a; i++)
    {
        t *= (i %= m);
        t %= m;
    }
    return (s * myPowWithMod(t, m - 2, m)) % S;
}

int main(int argc, char const *argv[])
{
    long n, a, b;
    cin >> n >> a >> b;
    long long zenbu = myPowWithMod(2, n, S) - 1;
    // cout << "zenbu " << zenbu << endl;

    long long s = nCaWithMod(n, a, S);
    // cout << "s " << s << endl;

    long long t = nCaWithMod(n, b, S);
    // cout << "t " << t << endl;

    long long u = (s + t) % S;
    // cout << "u " << u << endl;

    zenbu -= u;
    zenbu %= S;
    if (zenbu < 0)
    {
        zenbu += S;
    }
    cout << zenbu << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
D eps=1e-7;
bool eq(D a,D b){return abs(a-b)<eps;}
bool eq(P a,P b){return abs(a-b)<eps;}
int sig(D a){return eq(a,0)?0:(a>0?1:-1);}
D cro(P a,P b){return imag(conj(a)*b);}
D dot(P a,P b){return real(conj(a)*b);}
P perp(L l,P p){
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
P nor(P p){
	if(abs(p)<eps) return P(0,0);
	return p/abs(p);
}
bool ispal(L a,L b){
	return sig(cro(nor(a.fs-a.sc),nor(b.fs-b.sc)))==0;
}
bool on(L l,P p){
	return sig(cro(nor(l.fs-l.sc),nor(p-l.sc)))==0;
}
P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+t*(b.sc-b.fs);
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		vector<L> ls;
		rep(i,N){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			ls.pb(L(P(a,b),P(c,d)));
		}
		if(N<=2){
			puts("Many");
			continue;
		}
		vector<L> vl;
		vector<P> vp;
		rep(i,N) rep(j,i){
			vector<L> nvl;
			vector<P> nvp;
			L a=ls[i],b=ls[j];
			if(ispal(a,b)){
				P p=(perp(b,a.fs)+a.fs)/2.0,q=p+a.sc-a.fs;
				L l=L(p,q);
				if(i==1){
					vl.pb(l);
					continue;
				}
				for(L x:vl){
					if(ispal(l,x)){
						if(on(l,x.fs)) nvl.pb(x);
					}else{
						nvp.pb(intLL(x,l));
					}
				}
				for(P x:vp){
					if(on(l,x)) nvp.pb(x);
				}
			}else{
				P p=intLL(a,b);
				if(eq(p,a.fs)) swap(a.fs,a.sc);
				if(eq(p,b.fs)) swap(b.fs,b.sc);
				P e=a.fs-p,f=b.fs-p;
				e/=abs(e),f/=abs(f);//
				L l[2]={L(p,p+e+f),L(p,p-e+f)};
//				cout<<"l[0]="<<l[0].fs<<" "<<l[0].sc<<endl;
//				cout<<"l[1]="<<l[1].fs<<" "<<l[1].sc<<endl;
				if(i==1){
					vl.pb(l[0]),vl.pb(l[1]);
					continue;
				}
				rep(k,2){
					for(L x:vl){
						if(ispal(l[k],x)){
							if(on(l[k],x.fs)) nvl.pb(x);
						}else{
							nvp.pb(intLL(x,l[k]));
						}
					}
					for(P x:vp){
						if(on(l[k],x)) nvp.pb(x);
					}
				}
			}
			vl=nvl,vp=nvp;
/*			printf("i=%d,j=%d\n",i,j);
			cout<<"vl";
			for(L l:vl) cout<<"("<<l.fs<<","<<l.sc<<")  ";
			puts("");
			cout<<"vp";
			for(P p:vp) cout<<p<<"  ";
			puts("");*/
		}
		vector<P> nvp;
		for(P p:vp){
			bool ok=1;
			for(P np:nvp){
				if(eq(p,np)) ok=0;
			}
			if(ok) nvp.pb(p);
		}
		vp=nvp;
		if(!vl.empty()||vp.size()>1){
			puts("Many");
		}else if(vp.size()==0){
			puts("None");
		}else{
			printf("%.12f %.12f\n",vp[0].real(),vp[0].imag());
		}
	}
}

Measured memory_bytes: 1252
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a+b>=a-b&&a+b>=a*b){
    printf("%d",a+b);
  }
  else if(a-b>=a+b&&a-b>=a*b){
    printf("%d",a-b);
  }
  else{
    printf("%d",a*b);
  }
  return 0;
}

Measured memory_bytes: 128
W,C;char m[484];R(i){m[i]>45?m[i]=0,C++,R(i-1),R(i+1),R(i-W),R(i+W):0;}main(p){for(;scanf("%d%*d",&W)*W;C=!printf("%d\n",C))memset(p=m,W++,484),scanf("%[^0-9]",m+W),R(strchr(m,64)-p);}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	int n, a[100], x=1001, y=-1;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		x=min(x, a[i]);
		y=max(y, a[i]);
	}
	cout << y-x << endl;

	return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc101/tasks/abc101_b
//2020-03-13
//18:50:48

#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    char str[10];
    cin >> str;
    int A=0,B=0;
    for(int i=0;i<strlen(str);i++){
        A = A*10 + (int)str[i] - 48;
        B += (int)str[i]-48; 
    }
    if(A%B==0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[][] edges = new int[M][2];
    for (int i = 0; i < M; i++) {
      edges[i][0] = scanner.nextInt() - 1;
      edges[i][1] = scanner.nextInt() - 1;
    }
    UnionFind uf = new UnionFind(N);
    long[] count = new long[M + 1];
    count[M] = (long) N * (N - 1) / 2;
    for (int i = M - 1; i >= 0; i--) {
      int a = edges[i][0];
      int b = edges[i][1];
      count[i] = count[i + 1];
      if (uf.find(a) != uf.find(b)) {
        count[i] -= (long) uf.size(uf.find(a)) * uf.size(uf.find(b));
        uf.union(a, b);
      }
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 1; i <= M; i++) sb.append(count[i]).append('\n');
    System.out.print(sb.toString());
  }

  static class UnionFind {
    private final int[] table;
    private final int[] ranks;
    private final int[] sizes;

    public UnionFind(int size) {
      this.table = new int[size];
      this.ranks = new int[size];
      this.sizes = new int[size];
      for (int i = 0; i < size; i++) {
        table[i] = i;
        sizes[i] = 1;
      }
    }

    public int find(int x) {
      if (table[x] != x) {
        table[x] = find(table[x]);
      }
      return table[x];
    }

    public int size(int x) {
      return sizes[x];
    }

    public void union(int x, int y) {
      int xRoot = find(x);
      int yRoot = find(y);
      if (xRoot == yRoot) return;

      if (ranks[xRoot] < ranks[yRoot]) {
        int tmp = xRoot;
        xRoot = yRoot;
        yRoot = tmp;
      }

      table[yRoot] = xRoot;
      sizes[xRoot] += sizes[yRoot];
      if (ranks[xRoot] == ranks[yRoot]) ranks[xRoot]++;
    }
  }
}


Measured memory_bytes: 93780
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			int num = Integer.MAX_VALUE;
			int num2 = (1 << 8) - 1;
			long s = Long.parseLong(scanner.next(), 16);
			int x = (int) (s & num) >> 7;
			double y = (double) ((s & num2) * 0.0078125);
			String a = String.valueOf(y).substring(2);
			if (s >> 31 > 0)
				System.out.print("-");
			System.out.printf("%d.%s\n", x, a);
		}
	}
}

Measured memory_bytes: 49700
#include <iostream>
using namespace std;
#define MAX 101

int main(){
    int n,A[MAX];
    
    cin >> n;
    for(int i = 1 ; i <= n ; i++){
        cin >> A[i];
    }
    
    for(int i = 1 ; i <= n ; i++){
        if(i==1) cout << A[i];
        else cout << ' ' << A[i];
    }
    cout << endl;
    
    for(int j = 2 ; j <= n ; j++){
        int key = A[j] ,i = j-1;

        while(i > 0 && A[i] > key){
            A[i+1] = A[i];
            i--;
        }
        A[i+1] = key;
        
        for(int i = 1 ; i <= n ; i++){
            if(i==1) cout << A[i];
            else cout << ' ' << A[i];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
main()
{
  char s[101], t[101];
  int n;
  scanf("%d", &n);
  scanf("%s %s", &s, &t);
  for(int i=0; i<n; i++){
    putchar(s[i]);
  	putchar(t[i]);
  }
  return 0;
}

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

int main(){
    int n, c;
    while(cin >> n){
        //f(n+1) = f(n) + n + 1
        //f(n) = 2 + 2 + 3 + 4 ... n = 1 + n(n+1)/2
        c = n * (n+1) / 2 + 1;
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-6;
const long INF = 1e10;


int main(){
	int T;cin>>T;
	REP(t,T){
		string str,ans;cin>>str>>ans;
		reverse(ALL(str));
		REP(i,SZ(str)){
			if(str[i]=='A')reverse(ALL(ans));
			else if(str[i]=='C'){
				string tmp=ans.substr(1);
				tmp+=ans[0];
				ans=tmp;
			}else if(str[i]=='J'){
				string tmp="";
				tmp+=ans[SZ(ans)-1];
				tmp+=ans.substr(0,SZ(ans)-1);
				ans=tmp;
			}else if(str[i]=='E'){
				int sz=SZ(ans);
				string tmp=ans.substr(sz/2+(sz%2));
				if(sz%2==1)tmp+=ans[sz/2];
				tmp+=ans.substr(0,(sz/2));
				ans=tmp;
			}else if(str[i]=='P'){
				REP(j,SZ(ans)){
					if(ans[j]=='0'){
						ans[j]='9';
					}else if(ans[j]>='1'&&ans[j]<='9'){
						ans[j]=ans[j]-1;
					}
				}
			}else if(str[i]=='M'){
				REP(j,SZ(ans)){
					if(ans[j]=='9'){
						ans[j]='0';
					}else if(ans[j]>='0'&&ans[j]<='8'){
						ans[j]=ans[j]+1;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
n, k, c = map(int, input().split())
s = input()
l = []
tmp = 0
cnt = 0
while (tmp < n):
  if s[tmp] == "o":
    l.append(tmp)
    tmp += c + 1
    cnt += 1
  else:
    tmp += 1
if cnt > k:
  exit()
l2 = []
tmp2 = n - 1
cnt2 = 0
while (tmp2 >= 0):
  if s[tmp2] == "o":
    l2.append(tmp2)
    tmp2 -= c + 1
    cnt2 += 1
  else:
    tmp2 -= 1
if cnt2 > k:
  exit()
for i in range(k):
  if l[i] == l2[k - 1 - i]:
    print(l[i]+1)

Measured memory_bytes: 20724
#include <iostream>
#include <vector>
using namespace std;
class Human{
	public:
	Human();
	void sum(int);
	int getTotal();
	private:
	int total;
};

Human Alice = Human();
Human Bob = Human();
	
int main(void){
	int N;
	cin >> N;
	vector<int>a(N);
	for(int i=0; i<N; i++){
		cin >> a.at(i);
	}
	int max=0;
	int tmp;
	for(int i=0;i<N;i++){
		for(int j = i+1; j<N;j++){
			if(a.at(i) < a.at(j)){
				tmp=a.at(i);
				a.at(i)=a.at(j);
				a.at(j)=tmp;
			}
		}
	}
	for(int i=0; i<N; i++){
		if(i%2==0)Alice.sum(a.at(i));
		else Bob.sum(a.at(i));
	}
	cout << Alice.getTotal()-Bob.getTotal() << endl;
	return 0;
}


Human::Human(){
	total=0;
}
void Human::sum(int data){
	total+=data;
}
int Human::getTotal(){
	return total;
}



Measured memory_bytes: 256