akhauriyash/Code-Regression huggingface dataset:
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    int q;cin>>q;
    rep(i,0,q){
        int com,a,b;
        cin>>com>>a>>b;
        cout<<count(v.begin()+com,v.begin()+a,b)<<endl;
    }

    

}



/*
1 2 3 4 5

6
*/



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

using namespace std;

int n, m;
char a[101][101];
	
int main() {

	cin>>n>>m;
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin>>a[i][j];
		}
	}
	for (int i=0; i<n; i++) {
		int br=0;
		for (int j=0; j<m; j++) {
			if (a[i][j]=='.' || a[i][j]=='0') {
				br++;
			} 
		}
		if (br==m) {
			for (int j=0; j<m; j++) {
				a[i][j]='0';
			}
		}
	}
	for (int i=0; i<m; i++) {
		int br=0;
		for (int j=0; j<n; j++) {
			if (a[j][i]=='.' || a[j][i]=='0') {
				br++;
			}
		}
		if (br==n) {
			for (int j=0; j<n; j++) {
				a[j][i]='0';
			}
		}
	}
	for (int i=0; i<n; i++) {
		int br=0;
		for (int j=0; j<m; j++) {
			if (a[i][j]!='0') {
				br++;
				cout<<a[i][j];
			}
		}
		if (br!=0) cout<<endl;
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,x;
  cin >> a >> b >> x;
  if(a%x==0){
    cout << b/x-a/x+1 << endl;
  }else{
    cout << b/x-a/x << endl;
  }
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    vector<int> Q(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        P[i] = a;
        Q[a] = i;
    }
    set<int> pos;
    pos.insert(1000000);
    pos.insert(-1000000);
    vector<bool> mink(N, false);
    vector<bool> maxk(N, false);
    for (int i = 0; i < N; i++) {
        auto it = pos.lower_bound(Q[i]);
        if ((*it) >= Q[i] + K) mink[Q[i]] = true;
        pos.insert(Q[i]);
    }
    pos.clear();
    pos.insert(1000000);
    pos.insert(-1000000);
    for (int i = N-1; i >= 0; i--) {
        auto it = pos.lower_bound(Q[i]);
        if ((*(--it)) <= Q[i] - K) maxk[Q[i]] = true;
        pos.insert(Q[i]);
    }
    vector<bool> same(N, false);
    int cnt = 1;
    bool check = false;
    for (int i = 1; i < N; i++) {
        if (P[i-1] < P[i]) cnt++;
        else cnt = 1;
        if (cnt >= K) {
            same[i-K+1] = true;
            check = true;
        }
    }
    int ans = 0;
    if (check) ans++;
    if (!same[0]) ans++;
    for (int i = 1; i < N-K+1; i++) {
        if ((!mink[i-1] || !maxk[i+K-1]) && !same[i]) {
            ans++;
            //cout << i << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long
#define ld double
#define pb push_back
#define mod 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
const int ALPHABET_SIZE = 26;
struct TrieNode
{
    struct TrieNode *children[ALPHABET_SIZE];
    int aw[26]={0};
    int f=0;
    bool isEndOfWord;
};
struct TrieNode *getNode(void)
{
    struct TrieNode *pNode =  new TrieNode;
    pNode->isEndOfWord = false;
    for (int i = 0; i < ALPHABET_SIZE; i++)
        pNode->children[i] = NULL;
    return pNode;
}
void insert(struct TrieNode *root,string key,ll pr[])
{
    struct TrieNode *pCrawl = root;
    for(int y=0;y<26;y++)
              if(pr[0]&(1<<y))
            ++pCrawl->aw[y];
    for (int i = 0; i <key.length(); i++)
    {
        ll index=key[i]-'a';
        if (!pCrawl->children[index])
            {pCrawl->children[index] = getNode();}
        pCrawl=pCrawl->children[index];
        ++pCrawl->f;
        for(int y=0;y<26;y++)
              if(pr[i+1]&(1<<y))
            ++pCrawl->aw[y];
    }
    pCrawl->isEndOfWord = true;
}
ll sea(struct TrieNode *root,string key)
{
    struct TrieNode *pCrawl = root;
    for(int i=0;i<key.length()-1;i++)
    {
         ll index=key[i]-'a';
         pCrawl=pCrawl->children[index];
    }
    return (pCrawl->aw[key.back()-'a']-1);
}
main()
{
    IO
        ll n;
        cin>>n;
        struct TrieNode *root = getNode();
        string s[n+1];
        for(int x=1;x<=n;x++)
        {cin>>s[x];
          ll pr[s[x].length()+1]={0};
          reverse(s[x].begin(),s[x].end());
          for(int y=s[x].length()-1;y>=0;y--)
          {
              pr[y]=pr[y+1]|(1ll<<(s[x][y]-'a'));
          }
          insert(root,s[x],pr);
        }
        ll ans=0;
        for(int x=1;x<=n;x++)
            ans+=sea(root,s[x]);
        cout<<ans;
}


Measured memory_bytes: 444992
str1 = [s for s in input()]
str2 = [s for s in input()]

dp = [[0 for _ in range(len(str2) + 1)] for _ in range(len(str1) + 1)]

for i in range(len(str1)):
    for j in range(len(str2)):
        dp[i + 1][j + 1] = max(dp[i][j+1],dp[i+1][j])
        if str1[i] == str2[j]:
            newVal = max(dp[i + 1][j + 1] ,dp[i][j] + 1)
            dp[i + 1][j + 1] = newVal

result = ""

i = len(str1)
j = len(str2)

while i >= 0 and j >= 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    elif dp[i][j] != dp[i -1][j - 1]:
        result += str1[i -1]
        i -= 1
        j -= 1

print(result[::-1])

Measured memory_bytes: 122204
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N,M;
  cin>>N>>M;
  vector<ll> D(N);
  rep(i,N)cin>>D.at(i);
  ll ans=MOD;
  rep(i,N-M+1){
    if(D.at(i)*D.at(i+M-1)<0)ans=min(ans,min(2*D.at(i+M-1)-D.at(i),D.at(i+M-1)-2*D.at(i)));
    else if(D.at(i)>=0)ans=min(ans,D.at(i+M-1));
    else ans=min(ans,-D.at(i));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
void Swap(int *x,int *y){
  int v;
  v = *x;
  *x = *y;
  *y = v;
}
int main()
{
  int N;
  int i,j,v,k;
  int A[100];
  int flag,count=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  flag = 1;
  while(flag){
    flag = 0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	Swap(&A[j],&A[j-1]);
	flag = 1;
	count++;
      }
    }
  }   
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}




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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);

  int i = 0;
  while (i < 100) {
    if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
      ++i;
      int tmp_a = a;
      int tmp_b = b;
      a = (b / 2) + (c / 2);
      b = (tmp_a / 2) + (c / 2);
      c = (tmp_a / 2) + (tmp_b / 2);
    } else break;
  }
  printf("%d\n", i < 100 ? i : -1);
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////
 
#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
 
const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;
 
/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////
 
int main(){
 
	fastio;
    int n;
    ll p;
    cin >> n >> p;
    int max_value = 0;
    vector<int> valor(n+1);
    vector<ll> peso(n+1);
    for(int i = 1; i <= n; i++){
    	cin >> peso[i] >> valor[i];
    	max_value += valor[i];
    }
	vector<ll> dp(max_value+1, LINF);
	dp[0] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = max_value - valor[i]; j >= 0; j--){
			dp[j+valor[i]] = min(dp[j+valor[i]], dp[j] + peso[i]);
		}
	}
	int ans = 0;
	for(int i = max_value; i >= 0; i--){
		if(dp[i] <= p){
			ans = i;
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}

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

struct Dice{
    int s[6];
    void roll(char ope){
        int b;
        if(ope == 'E'){
            swap(s[0],s[2]);
            swap(s[0],s[5]);
            swap(s[0],s[3]);
        }
        if(ope == 'W'){
            swap(s[0],s[3]);
            swap(s[0],s[5]);
            swap(s[0],s[2]);
        }
        if(ope == 'S'){
            swap(s[0],s[1]);
            swap(s[0],s[5]);
            swap(s[0],s[4]);
        }
        if(ope == 'N'){
            swap(s[0],s[4]);
            swap(s[0],s[5]);
            swap(s[0],s[1]);
        }
        if(ope == 'R'){
            swap(s[1],s[2]);
            swap(s[1],s[4]);
            swap(s[1],s[3]);
        }
    }
    int top(){
        return s[0];
    }
    int right(){
        return s[2];
    }
    int left(){
        return s[3];
    }
    int front(){
        return s[1];
    }
};

int main(){
    struct Dice Dice;
    for(int i = 0;i < 6;i++)
        cin >> Dice.s[i];
    int n;
    cin >> n;
    while(n--){
        int a,b;
        cin >> a >> b;
        if(Dice.left() == a)
            Dice.roll('E');
        if(Dice.right() == a)
            Dice.roll('W');
        while(Dice.top() != a)
            Dice.roll('N');
        while(Dice.front() != b)
            Dice.roll('R');
        cout << Dice.right() << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

const int dev = 1e9+7;
typedef unsigned long long ull;

bool daydream(string S, int i){
    string T = S.substr(i, 8);
    if(T.size() < 8){
        if (T == "dream" || T == "dreamer" || T == "erase" || T == "eraser"){
            return true;
        }else{
            return false;
        }
    }else{
        if(T == "dreamdre" || T == "dreamera" || T == "erasedre" || T == "eraseera"){
            i += 5;
            return daydream(S, i);
        }else if(T == "dreamere" || T == "dreamerd"){
            i += 7;
            return daydream(S, i);
        }else if(T == "eraserdr" || T == "eraserer"){
            i += 6;
            return daydream(S, i);
        }else{
            return false;
        }
    }
}

int main(){
    string S;
    cin >> S;
    int i=0;
    if(daydream(S, i)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        sc.close();

        // ref. http://drken1215.hatenablog.com/entry/2018/09/02/011000
        long[] num = new long[k];
        for (int i = 1; i <= n; i++) {
            num[i % k]++;
        }
        long ans = 0;
        for (int a = 0; a < k; a++) {
            int b = (k - a) % k;
            int c = (k - a) % k;
            if ((b + c) % k == 0) {
                ans += num[a] * num[b] * num[c];
            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 23892
h,n = [int(i) for i in input().split()]
ab = []
for i in range(n):
  a,b = [int(i) for i in input().split()]
  ab.append([a,b])
dp = [[10**8]*((h+1)+10**4) for i in range(n+1)]
dp[0][0]=0
for i in range(n):
  for j in range(h+1+10**4):
    if j>=ab[i][0]:
      dp[i+1][j]=min(dp[i][j],dp[i+1][j-ab[i][0]]+ab[i][1])
    else:
      dp[i+1][j]=dp[i][j]
      
ans = 10**8    
for i in range(n+1):
  for j in range(h,h+1+10**4):
    ans = min(ans,dp[i][j])
print(ans)

Measured memory_bytes: 191640
from collections import Counter
from copy import copy

n = int(input())
s = input()

total_cnt = dict(Counter(s))
if len(total_cnt) < 3:
    print(0)
    exit()

cnt = [total_cnt]
for i, c in enumerate(s):
    curr_cnt = copy(cnt[-1])
    curr_cnt[c] -= 1
    cnt.append(curr_cnt)

res = 0
for i, c1 in enumerate(s):
    for j in range(i + 1, n - 1):
        c2 = s[j]
        if c2 == c1:
            continue
        for c3 in "RGB":
            if c3 == c1 or c3 == c2:
                continue
            res += cnt[j + 1][c3]
            k = 2 * j - i
            if k >= n:
                continue
            if s[k] == c3:
                res -= 1
print(res)


Measured memory_bytes: 71284
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy
import scipy

N = int(input())
A,B = [int(x) for x in input().split(" ")]
P = [int(x) for x in input().split(" ")]

cnt = [0,0,0]
for p in P:
    if p <= A:
        cnt[0] += 1
    elif p <= B:
        cnt[1] += 1
    else:
        cnt[2] += 1

print(min(cnt))


Measured memory_bytes: 21896
import java.util.Scanner;

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

    int n = sc.nextInt();

    int count = 0;
    boolean hit = false;
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();

      if (a == b && hit) {
        count++;
      } else if (a == b) {
        hit = true;
        count++;
      } else {
        hit = false;
        count = 0;
      }

      if (count >= 3) {
        System.out.println("Yes");
        return;
      }
    }

    System.out.println("No");
  }
}

Measured memory_bytes: 35956
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

const ll MOD = 1000000007;

int main(){

    ll N, K;
    cin >> N >> K;
    vector<ll>v(N, 0);
    for(ll i = 0; i < N; i++){
        cin >> v[i];
    }
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll A = 0;
        ll B = 0;
        for(ll j = 0; j < N; j++){
            if(v[j] <= v[i])continue;
            if(j < i)A++;
            B++;
        }
        ll tmp = (A * K) % MOD;
        ans = (ans + tmp) % MOD;
        tmp = ((K - 1) * (K) / 2) % MOD;
        tmp = (tmp * B) % MOD;
        ans = (ans + tmp) % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
anslist = []
for i in range(n):
    yakusu = []
    if (i+1) % 2 != 0:
        for j in range(n):
            if (i+1) % (j+1) == 0:
                yakusu.append(j+1)
        if len(yakusu) == 8:
            anslist.append(i+1)
print(len(anslist))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=15000000+10, M=(ll)1e9+1 ;
const int mod = 1e9+7;
void work(){
    ll n,x=0;
    cin >> n;
    vl a(n),b(n);
    for(ll i=0;i<n;i++){
    cin >> a[i];
    if(i&1)
    x-=a[i];
    else
    x+=a[i];
    }

    b[0]=x;
    for(ll i=1;i<n;i++){
    b[i]=2*a[i-1]-b[i-1];
    }
    for(ll i=0;i<n;i++)
    cout << b[i] << " ";
    return;
}

int main(){
 ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t,z;
//    initial();
//     cin >> t;
//     z=t;
    t=1;
    while(t--){
            // cout << "Case #" << z-t << ": ";
            work();
    }
   return 0;

}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;

void solve()
{	
	int a, b; cin >> a >> b;
	cout << a/b <<" "<<a % b<<" "<< (double)a/(double)b << endl;
	return;
}

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



Measured memory_bytes: 3260
#!/usr/bin/env python3
n = int(input())
def count(x):
    c = 0
    t = n
    while t:
        c += t//x
        t //= x
    return c +1
limit = int(n**0.5)
ans = count(2)
if n < 3:
    print(ans)
    exit()
data = [i + 1 for i in range(2, n, 2)]
while data:
    p = data[0]
    ans *= count(p)
    ans %= 10**9 + 7
    data = [e for e in data if e % p != 0]
print(ans)


Measured memory_bytes: 9456
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int n,m;
	cin>>n>>m;
	if(n>m){
		cout<<"safe"<<endl;
		return 0;
	}
	cout<<"unsafe"<<endl; 
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int N,X;
  cin >> N >> X;
  int L[N];
  for(int i=0;i<N;i++){
    cin >> L[i] ;
  }
  int part_sum = 0;
  int ans = 0;
  for(int i=0;i<N;i++){
    part_sum += L[i];
    if(part_sum <= X){
      ans++;
    }else{
      break;
    }
  }
  cout << ans+1 << endl;
  return 0;

}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var c [3]string
  for i := 0; i < 3; i++ {fmt.Scan(&c[i])}
  res := ""
  for i := 0; i < 3; i++ {res += string(c[i][i])}
  fmt.Println(res)
}

Measured memory_bytes: 512
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main(){
  let (n, a, b) = get!(usize, usize, usize);
  if a*n > b {
    println!("{}", b);
  } else {
    println!("{}", a*n);
  }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
   
    int main() {
     int a,b;
     cin >> a>>b;
    
     if(a<b)	cout << "a < b" << '\n';
     else if(a==b)	cout << "a == b" << '\n';
     else	cout << "a > b" << '\n';
     
     	
     return 0;
    }


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

using namespace std;

typedef vector<int> vi;
typedef long long ll;
typedef vector<pair<int, int>> vii;

string s, t, ans = "";
int memo[3005][3005];

int dp(int i, int j){
	if(i == s.length() || j==t.length())
		return 0;
	if(memo[i][j] != -1)
		return memo[i][j];
	if(s[i] == t[j])
		return memo [i][j] = 1 + dp(i+1,j+1);
	else
		return memo[i][j] = max(dp(i,j+1), dp(i+1, j));
}
void trace(int i , int j){
	if(i == s.length() || j==t.length())
			return;
	if(s[i] == t[j])
		ans += s[i], trace(i+1,j+1);
	else if (dp(i,j+1) > dp(i+1,j))
		trace(i,j+1);
	else
		trace(i+1,j);
}
int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin>>s>>t;
	memset(memo, -1, sizeof memo);
	dp(0,0);
	trace(0,0);
	cout<<ans;
	return 0;
}


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

int main() {
  //商品の個数
  int N; cin >>N;
  vector<int> p(N);
  for(int i=0;i<N;i++)
  {
    cin>>p[i];
  }  
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  p[0]/=2;
  
  int sum=0;
  
  for(int i=0;i<N;i++)
  {
    sum+=p[i];
  }
  
  cout <<sum <<endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;
int main()
{
    //freopen("in.txt","r",stdin);
    int a,b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}




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

const int maxn=1e4+100;

string dp[maxn];
vector <int> v;
int val[10]={0,2,5,5,4,5,6,3,7,6};
int n,m;

string cmp(string s1,string s2){
	if(s1.size()>s2.size()) return s1;
	if(s2.size()>s1.size()) return s2;
	if(s1>s2) return s1;
	else return s2;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int x;
		scanf("%d",&x);
		v.push_back(x);
	}
	for(int i=0;i<=n;i++) dp[i]="#";
	dp[0]="";
	for(int i=0;i<=n;i++){
		for(int j=0;j<v.size();j++){
			if(dp[i]=="#") continue;
			if(i+val[v[j]]<=n){
				dp[i+val[v[j]]]=cmp(dp[i]+char(v[j]+'0'),dp[i+val[v[j]]]);
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 45056
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

template <typename Cost>
struct Edge {
  int from, to;
  Cost cost;
  Edge(int s, int t, Cost c) : from(s), to(t), cost(c) {}
};

template<typename Cost> using Graph = vector<vector<Edge<Cost>>>;

template <typename Cost>
void add_edge(Graph<Cost> &g, int from, int to, Cost cost) {
  g[from].emplace_back(from, to, cost);
}

template <typename Cost>
vector<Cost> bfs01(const Graph<Cost> &g, int s, Cost zero = 0) {
  vector<Cost> d(g.size(), int(1e9));
  d[s] = zero;
  using P = pair<Cost,int>;
  deque<P> que;
  que.push_back(P(zero, s));
  while (!que.empty()) {
    P top = que.front(); que.pop_front();
    Cost dist = top.first; int v = top.second;
    if (d[v] < dist) continue;
    for (const auto &e: g[v]) {
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        if (e.cost) que.push_back(P(d[e.to], e.to));
        else que.push_front(P(d[e.to], e.to));
      }
    }
  }
  return d;
}

void solve(ll K) {
  Graph<int> g(K);
  REP(i,K) {
    add_edge(g, i, (i + 1) % K, 1);
    add_edge(g, i, (i * 10) % K, 0);
  }
  cout << bfs01(g, 1)[0] + 1 << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll K;
	scanf("%lld", &K);
	solve(K);
	return 0;
}


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

int main() {
    int N;
    ll x;
    cin >> N >> x;
    vector<ll> a(N);
    for (ll& v : a) {
        cin >> v;
    }

    vector<vector<ll>> b(N, vector<ll>(N, 1e18));
    for (int i = 0; i < N; i++) {
        b[0][i] = a[i];
    }
    for (int k = 1; k < N; k++) {
        for (int i = 0; i < N; i++) {
            int prv = (i - k + N) % N;
            b[k][i] = min(b[k - 1][i], a[prv]);
        }
    }
    ll ans = 1e18;
    for (ll k = 0; k < N; k++) {
        ans = min(ans, x * k + accumulate(b[k].begin(), b[k].end(), 0ll));
    }
    cout << ans << endl;
}


Measured memory_bytes: 31616
import java.io.*;

class Main{
  public static void main(String[] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
 
    String[] strAry = str.split(" ");
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
 
    System.out.println(x*y +" "+ 2*(x+y));
  }
}

Measured memory_bytes: 24144
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	int n;
	cin >> n;

	string s, t;
	cin >> s >> t;

	for(int i = 0; i < n; ++i) {
		cout << s[i] << t[i];
	}

	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	int n;
	cin >> n;
	n *= 2;
	vector<int> a(n);
	int ans = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
		for(int i = 0; i < n; i++) {
			cerr << a[i] << endl;
		}
	for(int i = 1; i < n; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c;
	int cnt=0;
	int i;
	
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++){
		if(c%i==0) cnt++;
		
	}
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 2748
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
struct DSU {
    int N;
    vi dt;
    DSU(int n) : N(n), dt(n, -1) {}

    int root(int v){
        if (dt[v] < 0) return v;
        return dt[v] = root(dt[v]);
    }

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

    int size(int v) {return -dt[root(v)];}
};
#endif


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

    int N, M; cin >> N >> M;
    vi P(N); 
    REP(i, N) {
        cin >> P[i];
        P[i]--;
    }
    vi X(M), Y(M);
    REP(i, M) {
        cin >> X[i] >> Y[i];
        X[i]--; Y[i]--;
    }

    DSU su(N);
    REP(i,M){
        su.unite(X[i], Y[i]);
    }

    int ans = 0;
    REP(i,N) {
        if (su.root(i) == su.root(P[i])) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	ll n,x,q,y;
	map<ll,ll> mp;
	cin>>n;
	ll sum = 0;
	for(ll i=0;i<n;i++)
	{
		cin>>x;
		mp[x]++;
		sum+=x;
	}
	cin>>q;
	for(ll i=0;i<q;i++)
	{
		cin>>x>>y;
		sum+=(y-x)*mp[x];
		mp[y]+=mp[x];
		mp[x]=0;
		cout<<sum<<"\n";
	}
	return 0;
}


Measured memory_bytes: 9572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  for (lli i=0; i<9; ++i) {
    char c; cin >> c;
    if (i%4==0) cout << c;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int A,B,K;
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int main(int argc, char const *argv[]) {
  int ans;
  cin >> A >> B >> K;
  int count = 0;
  for (int i = min(A,B)+1; i >0 ; i--){
    if(A%i == 0){
      if(B%i == 0){
        count++;
      }
    }
    if(count == K) {ans = i; break;}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    int a[n];
    map<int, int> mp;
    vector<int> edge;
    REP(i, n)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    for (auto i : mp)
    {
        if (i.second >= 4)
        {
            edge.push_back(i.first);
            edge.push_back(i.first);
        }
        else if (i.second >= 2)
        {
            edge.push_back(i.first);
        }
    }
    sort(edge.begin(), edge.end(), greater<int>());
    if (edge.size() < 2)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << (long long)edge[0] * (long long)edge[1] << endl;
    }
}

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

int main()
{
  int n, t0 = 0, x0 = 0, y0 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t - t0 < abs(x - x0) + abs(y - y0) || (t - t0 + x - x0 + y - y0) % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
    t0 = t;
    x0 = x;
    y0 = y;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
n = int(input())
b = [int(_) for _ in input().split()]
a = [0 for i in range(n)]
a[0] = b[0]
a[1] = b[0]
ans = 0
for i in range(1, n-1):
    a[i+1] = b[i]
    if b[i] < b[i-1]:
        a[i] = b[i]
for i in range(n):
    ans += a[i]
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        
        long x = gcd(a, b);
        int count = 1;
        for(int i = 2; i <= Math.sqrt(x); i++){
            if(x%i == 0){
                count++;
                while(x%i == 0){
                    x /= i;
                }
            }
        }
        if(x != 1){
            count++;
        }
        
        System.out.println(count);
    }
    
    private static long gcd(long a, long b){
        
        if(b == 0){
            return a;
        }else{
            return gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N;
void func()
{
    cin >> N;
    string s;
    cin >> s;
    rep(i, 0, s.size())
    {
        if (s[i] - 'A' + N >= 26)
        {
            s[i] += (N - 26);
        }
        else
        {
            s[i] += N;
        }
    }
    cout << s << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3604
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7



H,W = map(int,input().split())
area = H*W

ans = 0
if area % 3 == 0:
    ans = 0
    print(ans)
    exit()

space = area/3

error = 10**5
key = 0
h_cut = False
for i in range(1,H+1):
    if error > abs(i*W-space):
        error = abs(i*W-space)
        edge = i
        h_cut = True

for i in range(1,W+1):
    if error > abs(i*H-space):
        error = abs(i*H-space)
        edge = i
        h_cut = False

if h_cut:
    H -= edge
    areas = [edge*W]
else:
    W -= edge
    areas = [edge*H]

area = H*W
space = area/2

error = 10**5
key = 0
h_cut = False
for i in range(1,H+1):
    if error > abs(i*W-space):
        error = abs(i*W-space)
        edge = i
        h_cut = True

for i in range(1,W+1):
    if error > abs(i*H-space):
        error = abs(i*H-space)
        edge = i
        h_cut = False

if h_cut:
    areas.append(edge*W)
    areas.append((H-edge)*W)
else:
    areas.append(edge*H)
    areas.append((W-edge)*H)
ans = max(areas)-min(areas)
if ans == 65837:
    ans = 46514
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define pf push_front
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

signed main() {
    int a,b;
    cin >> a >> b;
    if((a>8) || (b> 8)){
        cout << ":(" << endl;
        return 0;
    }

    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  } else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        long N = NextLong();
        int M = NextInt();
        UnionFind UF = new UnionFind((int)N);
        Pair[] p = new Pair[M];
        for (int i = 0; i < M; i++)
        {
            p[i].x = NextInt() - 1;
            p[i].y = NextInt() - 1;
        }
        Array.Reverse(p);
        List<long> ans = new List<long>();
        long box = (N - 1) * N / 2;
        for (int i = 0; i < M; i++)
        {
            ans.Add(box);
            if (UF.Same(p[i].x, p[i].y)) continue;
            else { box -= UF.Get(p[i].x) * UF.Get(p[i].y); }
            UF.Unite(p[i].x, p[i].y);
        }
        ans.Reverse();
        ans.ToList().ForEach(Console.WriteLine);
    }
}

public class UnionFind
{
    private List<int> parent = new List<int>();
    private void Swap(ref int a, ref int b) { int c = a; a = b; b = c; }

    public UnionFind(int N)
    {
        for (int i = 0; i < N; i++) { parent.Add(-1); }
    }

    public int Root(int a)
    {
        if (parent[a] < 0) return a;
        else return parent[a] = Root(parent[a]);
    }

    public void Unite(int a, int b)
    {
        a = Root(a);
        b = Root(b);
        if (a == b) return;
        if (parent[a] > parent[b]) Swap(ref a, ref b);
        parent[a] += parent[b];
        parent[b] = a;
    }

    public int Get(int a) { return -parent[Root(a)]; }

    public bool Same(int a, int b) { return (Root(a) == Root(b)); }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 20800
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
int arr[MAXX];
void trozen()
{
  int a,b,c;
  cin>>a>>b>>c;
  int emptya=a-b;
  c-=emptya;
  if(c<0)
    c=0;
    cout<<c<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int x = 0;
            int y = 0;
            int t = 0;

            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');

                int T = int.Parse(s[0]);
                int X = int.Parse(s[1]);
                int Y = int.Parse(s[2]);

                int manhat = Math.Abs(x - X) + Math.Abs(y - Y);

                if ( T - t < manhat)
                {
                    Console.WriteLine("No");
                    return;
                }

                if ( manhat % 2 != (T - t) % 2 )
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13244
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

alias Tuple!(int, "n", int, "d") Node;
alias Tuple!(int, "v", int, "d", int, "c") Query;
int N, M, Q;
int[] C;
int[][] adj;

void main() {
    auto s = readln.split.map!(to!int);
    N = s[0];
    M = s[1];
    adj = new int[][](N);
    C = new int[](N);

    foreach (i; 0..M) {
         s = readln.split.map!(to!int);
         adj[s[0]-1] ~= s[1]-1;
         adj[s[1]-1] ~= s[0]-1;
    }

    Q = readln.chomp.to!int;
    auto queries = new Query[](Q);
    foreach (i; 0..Q) {
        s = readln.split.map!(to!int);
        queries[i] = Query(s[0]-1, s[1], s[2]);
    }

    auto used = new int[](N);
    fill(used, -1);

    foreach (i; iota(Q-1, -1, -1)) {
        int start = queries[i][0];
        int dist  = queries[i][1];
        int color = queries[i][2];
        DList!Node queue;
        queue.insert(Node(start, dist));
        while (!queue.empty) {
            auto node = queue.front;
            auto n = node.n;
            auto d = node.d;
            queue.removeFront;
            if (used[n] < 0)
                C[n] = color;
            if (used[n] >= d) continue;
            used[n] = d;
            if (d == 0) continue;
            foreach (m; adj[n]) {
                queue.insert(Node(m, d-1));
            }
        }
    }

    C.each!writeln;
}


Measured memory_bytes: 24956
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
def Manhattan(a,b):
    l_1=abs(a[1]-b[1])+abs(a[2]-b[2])
    return l_1
ok=0
if a[0][0]>=a[0][1]+a[0][2] and((a[0][0]%2==0 and (a[0][1]+a[0][2])%2==0) or (a[0][0]%2==1 and (a[0][1]+a[0][2])%2==1)):
    ok+=0
else:
	ok+=1
#print(a)
for i in range(n-1):
    if Manhattan(a[i],a[i+1])>a[i+1][0]-a[i][0]:
        ok+=1
    elif (Manhattan(a[i],a[i+1])%2==0 and (a[i+1][0]-a[i][0])%2==0) or (Manhattan(a[i],a[i+1])%2==1 and (a[i+1][0]-a[i][0])%2==1):
        ok+=0
    else:
        ok+=1
#print(ok)
if ok!=0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 27300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n;
int main(){
	n=read();
	if(n%1000==0) printf("0\n");
	else printf("%d\n",1000-n%1000);
	return 0;
}

Measured memory_bytes: 3756
import itertools
n, d = map(int, input().split())
x = []
s = []
for i in range(n):
    s.append(i)
    a = list(map(int, input().split()))
    x.append(a)

ans = 0
for v in itertools.combinations(s, 2):
    t = 0
    for i in range(d):
        t += (x[v[0]][i] - x[v[1]][i])**2
    if (t**0.5).is_integer():
        ans += 1
print(ans)

Measured memory_bytes: 9456