akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](long a, long b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<long>;
using vvi = vector<vi>;
using vs = vector<string>;
#define co(x) cout << x << endl;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int n;
  cin >> n;
  switch (n%10) {
    case 3:
      co("bon");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      co("pon");
      break;
    default:
      co("hon");
  }
  return 0;
}


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

using namespace std;

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

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

int main() {
    string myWord;
    cin >> myWord;
    myWord = toUpper(myWord);

    int counter = 0;
    while (1) {
        string myText;
        cin >> myText;
        if (myText == "END_OF_TEXT") break;
        myText = toUpper(myText);
        if (myWord == myText) counter++;
    }

    cout << counter << endl;
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#define ll long long

#define sl(n) scanf("%lld", &n)
#define ss(n) scanf("%s", n)
#define sf(n) scanf("%lf", &n)

#define PI 2*acos(0.0)
#define INF (1LL<<62)

#define pll pair<ll,ll>

#define pb push_back
#define fr first
#define sc second
#define srt(v) sort(v.begin(), v.end())
using namespace std;

ll A[300010];

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

    ll n, i, j, k, x, y, z, cs = 0, ts, l, r;

    sl(n);

    for (i = 0; i < n; i++) sl(A[i]);

    sort(A, A + n);

    ll ans = 0;

    x = 0;
    z = n-1;

    for (i = 0; i < n; i++)
    {
        if (i == 0) continue;

        if (x == 0)
        {
            ans += A[z];
            if (z == n-1)
                z--;
            else x = 1;
        }
        else
        {
            ans += A[z--];
            x = 0;
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 5324
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
void solve()
{
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            for(ll k=1;k<=n;k++)
                ans+=__gcd(__gcd(i,j),k);
        }
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
struct ps
{
	ll o , idx , x ;
};
int main(){
	//mahakal(),fast;
	ll int a,b;
	cin>>a>>b;
	if ((a+b)%2==0)
	cout<< (a+b)/2<<endl;
	else cout<<"IMPOSSIBLE"<<endl;


	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  vector<vector<int>> dp(n+1,vector<int>(3,0));
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
    dp[i+1][0]=a[i]+max(dp[i][1],dp[i][2]);
    dp[i+1][1]=b[i]+max(dp[i][0],dp[i][2]);
    dp[i+1][2]=c[i]+max(dp[i][0],dp[i][1]);
  }
  cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
  return 0;
}


Measured memory_bytes: 6912
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <regex>

/*
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;



using ll = long long;
using ull = unsigned long long;
constexpr ll N = 2e5;

constexpr ull max_num = 1e18;
ull a[N];
*/

using ull = unsigned long long;
using ll = long long;

using namespace std;



int main() {
   
	string s, t;
	cin >> s;
	cin >> t;

	int c = 0;
	for (ull i = 0; i < s.length(); i++)
	{
		if (s[i] != t[i])
			c++;
	}
	cout << c;
	
	return 0;
	
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  string S;
  cin >> S;
  int res = 0;
  char c = S[0];
  REP(i,S.length()) {
    if(S[i] != c) {
      ++res;
      c = S[i];
    }
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 1020
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const long long inf = 1LL << 22;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX_N 210000
#define MUL 2

/*エラトステネスの篩*/
void Eratosthenes(int *pri) {
  for(int i = 2; i < MAX_N; i++)
    pri[i] = 1;

  for(int i = 2; (i * i) < MAX_N; i++) {
    if(pri[i] == 1) {
      for(int j = (i * 2); j < MAX_N; j+=i)
        pri[j] = 0;
    }
  }
}

int matsuzaki(int N, int P, int *pri) {
  vector<int> sum;
  vector<int> prime;
  int count = 0;

  for(int i = N + 1;; i++) {
    if(pri[i] == 1) {
      prime.push_back(i);
      count++;
    }
    if(count > P)
      break;
  }

  count = 0;

  for(int i = 0; i < P; i++) {
    for(int j = i; j < P; j++) {
      sum.push_back(prime[i] + prime[j]);
      count++;
    }
  }

  sort(sum.begin(), sum.end());
  prime.clear();

  return sum[P-1];
}

int main() {
  int N;
  int P;
  int pri[MAX_N];
  pri[0] = 0;
  pri[1] = 0;

  Eratosthenes(pri);

  while(1) {
    cin >> N >> P;
    if(N == -1 && P == -1)
      break;

    cout << matsuzaki(N, P, pri) << endl;
  }
  return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

long long gcd(long long A,long long B){
    return B?gcd(B,A%B):A;
}

long long max(long long A,long long B){
    return A>B?A:B;
}

int main(void){
    long long n,ans;
    scanf("%lld",&n);
    long long a[n],l[n],r[n];
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
        if (i==0){
            ans=a[i];
        } else {
            ans=gcd(a[i],ans);
        }
    }
    l[0]=a[0];
    for (int i=1; i<n; i++){
        l[i]=gcd(l[i-1],a[i]);
    }
    r[n-1]=a[n-1];
    for (int i=n-2; i>=0; i--){
        r[i]=gcd(r[i+1],a[i]);
    }
    ans=max(ans,r[1]);
    ans=max(ans,l[n-2]);
    for (int i=1; i<n-1; i++){
        ans=max(ans,gcd(l[i-1],r[i+1]));
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2560
def main():
    m,n = map(int,input().split())
    if abs(m-n) > 1:
        print(0)
        return
        
    c = 1
    w = 10**9+7
    for i in range(2, min(m, n)+1):
        c = (c * i) % w
    
    if m == n:
        nc = (c * 2) % w
    else:
        nc = (c * max(m, n)) % w
    
    print(c*nc%w)
    
if __name__ == "__main__":
    main()

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

int main() {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && x + r <= W&&y - r >= 0 && y + r <= H) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
 
using ll = long long;
 
using namespace std;
 
int main() {
  int A[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      int num;
      cin >> num;
      A[i][j] = num;
    }
  }

  int N;
  cin >> N;

  // int b[N];
  int b;
  bool marked[3][3] = {false};

  for (int i = 0; i < N; i++) {
    // cin >> b[i];
    cin >> b;

    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (A[j][k] == b) marked[j][k] = true;
      }
    }
  }

  for (int i = 0; i < 3; i++) {
    // row
    if (marked[i][0] && marked[i][1] && marked[i][2]) {
      cout << "Yes";
      return 0;
    }
    // column
    else if (marked[0][i] && marked[1][i] && marked[2][i]) {
      cout << "Yes";
      return 0;
    }
  }

  // cross
  if((marked[0][0] && marked[1][1] && marked[2][2]) || (marked[0][2] && marked[1][1] && marked[2][0])){
      cout << "Yes";
      return 0;
  }

  cout << "No";

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()

	ans := 0
	for i := 1; i < N; i++ {
		ans += (N - 1) / i
	}

	out(ans)
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000007

signed main(){
    gok
   string s,t1="";
   cin>>s;
   int q;
   cin>>q;
   int f1=0;
   while(q--)
   {
       int x;
       cin>>x;
       if(x==1)
       {
           f1 = (f1^1);
       }
       else
       {
           int y;
           char ch;
           cin>>y>>ch;
           if(y==1)
           {
               if(f1==0)
               {
                   //string tt="";
                   t1.push_back(ch);
                  // s = tt + s;
               }
               else
               {
                  s.push_back(ch);
               }
           }
           else
           {
              if(f1==1)
               {
                   //string tt="";
                   t1.push_back(ch);
                   //s = tt + s;
               }
               else
               {
                  s.push_back(ch);
               }
           }
       }
   }
   reverse(t1.begin(),t1.end());
   s = t1 + s;
   if(f1==1)
    reverse(s.begin(),s.end());

   cout<<s;
    return 0;
}


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

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


vector<vector<char>> ans(1010,vector<char>(1010));

void threexthree(int k) {
    for (int i=0;i<3;i++) {
        for (int j=0;j<3;j++) {
            if (i%3==0 && j%3<2) ans[i+k][j+k]='d';
            else if (i%3>0 && j%3==2) ans[i+k][j+k]='d';
        }
    }
}

void fourxfour(int k) {
    for (int i=0;i<4;i++) {
        for (int j=0;j<4;j++) {
            if ((i%4==0 && j%4<2) || (i%4==2 && j%4>1)) ans[i+k][j+k]='a';
            else if ((i%4==1 && j%4<2) || (i%4==3 && j%4>1)) ans[i+k][j+k]='b';
            else if ((i%4>1 && j%4==0) || (i%4<2 && j%4==2)) ans[i+k][j+k]='c';
            else ans[i+k][j+k]='d'; 
        }
    }
}

void fivexfive(int k) {
    for (int i=0;i<5;i++) {
        for (int j=0;j<5;j++) {
            if ((i==0 && j<2) || (i<2 && j==4) ||
                (i==4 && j>2) || (i>2 && j==0)) {
                    ans[k+i][k+j]='a';
            } else if ((i==0 && j>1) || (i>1 && j==4) ||
                       (i==4 && j<3) || (i<3 && j==0)) {
                ans[k+i][k+j]='b';
            }
        }
    }
    threexthree(k+1);
}

void sevenxseven(int k) {
    for (int i=2;i<5;i++) {
        for (int j=0;j<2;j++) ans[k+i][k+j]='a'+i-2;
        for (int j=5;j<7;j++) ans[k+i][k+j]='a'+i-2;
    }
    for (int j=2;j<5;j++) {
        for (int i=0;i<2;i++) ans[k+i][k+j]='a'+j-2;
        for (int i=5;i<7;i++) ans[k+i][k+j]='a'+j-2;
    }
    threexthree(k+2);
}

int main() {
    int n;
    cin >> n;
    for (int i=0;i<n;i++) {
        for (int j=0;j<n;j++) ans[i][j]='.';
    }
    if (n==2) {
        cout << -1 << endl;
        return 0;
    } else if (n==3 || n==6) {
        for (int i=0;i<n/3;i++) {
            threexthree(3*i);
        }
    } else {
        int k;
        switch (n%4) {
            case 0:
                for (int i=0;i<n/4;i++) {
                    fourxfour(i*4);
                }
                break;
            case 1:
                k=int(n/4)-1;
                for (int i=0;i<k;i++) {
                    fourxfour(i*4);
                }
                fivexfive(4*k);
                break;
            case 2:
                k=int(n/4)-2;
                for (int i=0;i<k;i++) {
                    fourxfour(i*4);
                }
                fivexfive(4*k);
                fivexfive(4*k+5);
                break;
            case 3:
                k=int(n/4)-1;
                for (int i=0;i<k;i++) {
                    fourxfour(i*4);
                }
                sevenxseven(4*k);
                break;
        }
    }
    for (int i=0;i<n;i++) {
        for (int j=0;j<n;j++) cout << ans[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main()
{
	int A, B, K;
	cin >> A >> B >> K;

	int C[200];
	int n = 0;

	for (int i = 100; i >= 1; i--)
	{
		if (A % i == 0 && B % i == 0)
		{
			C[n] = i;
//			cout << C[n] << endl;
			n++;
		}
	}

	cout << C[K - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")

using namespace std;

#define inp "TestCode.inp"
#define out "TestCode.out"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileInOut freopen(inp,"r",stdin);freopen(out,"w",stdout);
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define pi acos(-1)
#define pii pair<int,int>
#define ppiii pair< pair <int,int> ,int>
#define INF 1000000
#define endl '\n'
#define ll long long
#define pq priority_queue
const int mod=1e9+7;
int test=1;
/*-----------------------------------------------*/
void nathan_on_osu()
{

    FAST
    #ifndef ONLINE_JUDGE
    //FileInOut
    #endif // ONLINE_JUDGE
}
/*-----------------------------------------------*/

int n,l;
int a[110];
int sum=0;
int minDif=100000;
int ans;

int main()
{
    nathan_on_osu();
    cin>>n>>l;
    for(int i=1;i<=n;i++)
    {
        a[i]=l+i-1;
        sum+=a[i];
    }
    //cout<<sum<<endl;
    for(int i=1;i<=n;i++)
    {
        if(abs(a[i])<minDif)
        {
            minDif=abs(a[i]);
            ans=sum-a[i];
        }
        //cout<<a[i]<<" "<<minDif<<endl;
    }
    cout<<ans;
}



Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll mod_pow(ll x, ll n, ll mod = MOD) {
  ll res = 1;

  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }

    x = x * x % mod;
    n >>= 1;
  }

  return res;
}

class Rational {
public:
  ll a;
  ll b;

  Rational(ll a, ll b) {
    ll g = gcd(a, b);

    if (g != 0) {
      this->a = a / g;
      this->b = b / g;
    } else {
      this->a = a;
      this->b = b;
    }
  }

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

int main() {
  int N;
  cin >> N;

  map<ll, map<ll, ll>> counter;
  vector<Rational> R;
  ll A, B;
  ll Z = 0;
  for (int i = 0; i < N; ++i) {
    cin >> A >> B;
    Rational r(A, B);

    if (A == 0 && B == 0) {
      Z++;
      R.push_back(r);
      continue;
    }

    if (r.b < 0) {
      r.a *= -1;
      r.b *= -1;
    } else if (r.b == 0) {
      r.a = 1;
    } else if (r.a == 0) {
      r.b = 1;
    }

    counter[r.a][r.b]++;
    R.push_back(r);
  }

  map<ll, map<ll, bool>> checked;
  ll ans = 1;

  for (int i = 0; i < N; ++i) {
    Rational r = R[i];

    if (r.a == 0 && r.b == 0) continue;
    if (checked[r.a][r.b]) continue;
    checked[r.a][r.b] = true;

    ll s = counter[r.a][r.b];
    ll t = 0;

    if (r.b == 0) {
      t = counter[0][1];
      checked[0][1] = true;
    } else if (r.a == 0) {
      t = counter[1][0];
      checked[1][0] = true;
    } else if (r.a < 0) {
      t = counter[r.b][-r.a];
      checked[r.b][-r.a] = true;
    } else {
      t = counter[-r.b][r.a];
      checked[-r.b][r.a] = true;
    }

    ll v = (mod_pow(2, s) + mod_pow(2, t) - 1);
    ans *= v;
    ans %= MOD;

    fprintf(stderr, "[%lld/%lld], %d: s: %lld, t: %lld, ans: %lld\n",
        r.a, r.b, i, s, t, ans);
  }

  fprintf(stderr, "Z = %lld\n", Z);
  ans += (Z - 1);
  if (ans < 0) ans += MOD;
  cout << ans << endl;

  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll N;
    cin >> N;

    vector<ll> A(100001,0);

    ll ans = 0;
    rep(i,N) {
        ll a;
        cin >> a;
        A[a]++;
        ans += a; 
    }
    int Q;
    cin >> Q;
    rep(i,Q) {
        ll b,c;
        cin >> b >> c;
        ans += c*A[b];
        ans -= b*A[b];
        A[c]+=A[b];
        A[b]=0;
        cout << ans << endl;
    }  
} 


Measured memory_bytes: 4048
n=gets.chomp.to_i
h=gets.chomp.split(" ").map{|s| s.to_i}.reverse
f=true
for i in 0..n-2
  if h[i]==h[i+1]-1
    h[i+1]-=1
  elsif h[i]<h[i+1]-1
    f=false
    break
  end
end
if f
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 10500
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().answer();
        }
    }

    class Solution
    {
        string N, M;
        string T = "0";
        public Solution()
        {
            N = Console.ReadLine();

            int j = N.Length;
            string[] M_split = new string[j];

            int i;
            for (i = 0; i < j; i++)
            {
                M_split[i] = N.Substring(i, 1);
            }

            var qry = from a in M_split
                      select a;

            List<string> lst = new List<string>();
            lst = qry.ToList();
            lst = lst.Distinct().ToList();
            lst.Sort();

            string[] D = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };


            for (i = 0; i < 26; i++)
            {
                if (i < lst.Count())
                {
                    if (D[i] != lst[i])
                    {
                        T = D[i];
                        i = 27;
                    }
                }
                else
                {
                    T = D[i];
                    i = 27;
                }
            }

            if (T == "0")
            { T = "None"; }
        }

        public void answer()
        {
            Console.WriteLine(T);
        }
    }
}

Measured memory_bytes: 16608
import java.util.*;

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

      int n = Integer.parseInt(sc.next());
      int[] x = new int[n];
      int[] y = new int[n];
      for(int i=0;i<n;i++){
        x[i] = Integer.parseInt(sc.next());
        y[i] = Integer.parseInt(sc.next());
      }

      String s = "";
      for(int i=0;i<n;i++){
        s += String.valueOf(i);
      }
      //int cnt = 0;
      double ans = 0;
      while(true){
         int lng = s.length();
         //char[] c = new char[lng];
         int[] c = new int[lng];
         for(int i=0;i<lng;i++){
           c[i] = s.charAt(i);
           c[i] -= 48;
         }
         for(int i=1;i<lng;i++){
           int dx = x[c[i]] - x[c[i-1]];
           int dy = y[c[i]] - y[c[i-1]];
           double kyori = Math.sqrt((dx*dx)+(dy*dy));
           ans += kyori;
         }
         //cnt++;
	       s = nextPermutation(s);
         if (s.equals("Final")) break;
      }
      for(int i=1;i<=n;i++){
        ans /= i;
      }
       System.out.println(ans);
    }

    public static String nextPermutation (String s) {

	     ArrayList<Character> list = new ArrayList<>();
	     for(int i=0;i<s.length();i++){
         list.add(s.charAt(i));
       }

       int pivotPos = -1;
       char pivot = 0;
       for(int i=list.size()-2;i>=0;i--){
         if(list.get(i)<list.get(i+1)){
           pivotPos = i;
           pivot = list.get(i);
           break;
		     }
	     }

        if(pivotPos==-1 && pivot==0){
          return "Final";
        }

        int L = pivotPos+1, R = list.size()-1;
        int minPos = -1;
        char min = Character.MAX_VALUE;
        for(int i=R;i>=L;i--){
          if(pivot<list.get(i)){
            if(list.get(i)<min){
              min = list.get(i);
              minPos = i;
			       }
		       }
	      }

	       Collections.swap(list, pivotPos, minPos);
	       Collections.sort(list.subList(L, R+1));

	       StringBuilder sb = new StringBuilder();
         for(int i=0;i<list.size();i++){
           sb.append(list.get(i));
         }

         return sb.toString();
    }

}


Measured memory_bytes: 47888
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false


#define ATOZ 26
int main() {
	int N;
	cin >> N;
	int mina = 1000, maxa = 0;
	REP(i, N) {
		int a;
		cin >> a;
		mina = min(mina, a);
		maxa = max(maxa, a);
	}
	cout << maxa - mina << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>a>>b;
    ans=a+b-n;
    if(ans<0)ans=0;
    cout<<min(a,b)<<" "<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 764
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N=int(input())
if N==1:
	print(0)
	exit()


arr=prime_factorize(N)
kaisu=0
####################

#print(arr)

while(len(arr)>0):
	#print(arr)

	minval = min(arr)
	c=arr.count(minval)
	lp=c
	
	for i in range(1,lp+1):
		#print(i)
		if c >= i:
			c-=i
			kaisu+=1
			#print(kaisu)
		arr.remove(minval)

print(kaisu)

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

int main()
{
  int a, sum, mod;
  
  cin >> sum;
  cin >> a;
  
  mod = sum % 500;
  if (a >= mod ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

typedef long long int ll;

int main()
{
    ll A, B, m, mina, minb;
    cin >> A >> B >> m;
    mina = minb = 100020;
    vector<ll> a(A), b(B);
    for(ll i = 0;i < A;i++){
        cin >> a[i];
        mina = min(mina, a[i]);
    }
    for(ll i = 0;i < B;i++){
        cin >> b[i];
        minb = min(minb, b[i]);
    }
    vector<tuple<ll,ll,ll>> xyz(m);
    for(ll i = 0;i < m;i++){
        cin >> get<0>(xyz[i]) >> get<1>(xyz[i]) >> get<2>(xyz[i]);
    }

    ll ans = mina + minb;
    for(ll i = 0;i < m;i++){
        ans = min(ans,a[get<0>(xyz[i]) - 1] + b[get<1>(xyz[i]) - 1] - get<2>(xyz[i]));
    }

    if(ans < 0){
        ans = 0;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;

long long int N,M,A[200200],res=0,cou=0;
bool num[200202]={};
string S;
int main()
{
    cout << fixed << setprecision(18);
	
    cin>>S;
	N=S.size();
	for(long long int i = 0; i < N; i++){
		if(S[i]=='g'&&cou==0){cou++;}
		else if(S[i]=='g'){res++;cou--;}
		else if(S[i]=='p'&&cou==0){res--;cou++;}
		else{cou--;}
		//cout<<i<<" "<<res<<endl;
	}
	cout<<res<<endl;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int64_t n, x = 0, index = 0;
  vector<int64_t> a(5);

  cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  for (int i = 0; i < 5; i++)
  {
    a[i] = (n - 1) / a[i] + 1;
    if (x < a[i])
    {
      x = a[i];
      index = i;
    }
  }
  cout << x + 4 << endl;
}


Measured memory_bytes: 3736
/*
      author : nishi5451
      created: 12.08.2020 00:33:35
*/

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


int main(){
    string s;
    cin >> s;
    string init = s.substr(0,4);
    if(init=="YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
    ll n;
    cin >> n;
    if(n == 25){
    cout << "Christmas"; 
    } else if(n == 24){
    cout <<  "Christmas Eve";
    } else if(n == 23){
    cout << "Christmas Eve Eve";
    } else if(n == 22){
    cout << "Christmas Eve Eve Eve";
    }
    cout << endl;
}



Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		P[] ps = new P[] {
				new P("black", get("000000")),
				new P("blue", get("0000ff")),
				new P("lime", get("00ff00")),
				new P("aqua", get("00ffff")),
				new P("red", get("ff0000")),
				new P("fuchsia", get("ff00ff")),
				new P("yellow", get("ffff00")),
				new P("white", get("ffffff")),
		};
		for (;sc.hasNext();) {
			String s = sc.next();
			if (s.equals("0")) break;
			s = s.substring(1);
			int[] rgb = get(s);
			int best = Integer.MAX_VALUE;
			P ans = null;
			for (P p : ps) {
				int d = d2(rgb, p.rgb);
				if (best > d) {
					best = d;
					ans = p;
				}
			}
			System.out.println(ans.name);
		}
	}
	
	int sq(int x) { return x * x; }
	int d2(int[] a, int[] b) {
		return sq(a[0] - b[0]) + sq(a[1] - b[1]) + sq(a[2] - b[2]);
	}
	
	int[] get(String s) {
		int x = Integer.parseInt(s, 16);
		int b = x % 256; x /= 256;
		int g = x % 256; x /= 256;
		int r = x % 256; x /= 256;
		return new int[]{r, g, b};
	}

	static class P {
		String name;
		int[] rgb;
		private P(String name, int[] is) {
			this.name = name;
			this.rgb = is; 
		}
	}
}

Measured memory_bytes: 21820
//https://atcoder.jp/contests/abc048/tasks/arc064_a
//2020-04-27
#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()
{
    long long num;
    cin >> num;
    long long maximum;
    cin >> maximum;
    vector<long long> v;
    long long tmp;
    for(int i=0;i<num;i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    long long ans =0;
    if(v[0]>maximum){
        ans += v[0]-maximum;
        v[0]=maximum;
    }
    for(int i=1;i<num;i++){
        if(v[i-1]+v[i]>maximum){
            ans += (v[i-1]+v[i])-maximum;
            v[i]=maximum-v[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;

  if (S.substr(0, 4) == "YAKI")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <queue>
#include <cstdint>
#include <algorithm>

int main()
{
    using namespace std;
    using Int = std::uint64_t;
    Int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    std::priority_queue<Int, vector<Int>, greater<Int>> RA3000;
    for (Int a = 0; a < X; ++a) {
        Int A_i;
        cin >> A_i;
        RA3000.push(A_i);
    }
    std::vector<Int> SA3000;
    while (RA3000.size()) {
        SA3000.push_back(RA3000.top());
        RA3000.pop();
    }

    // for (auto const& x: SA3000) cout << x << ", ";
    cout << endl << endl;

    std::priority_queue<Int, vector<Int>, greater<Int>> RB3000;
    for (Int i = 0; i < Y; ++i) {
        Int B_i;
        cin >> B_i;
        for (auto const A_i: SA3000) {
            Int updated = A_i + B_i;
            if (RB3000.size() >= 3000) {
                if (updated < RB3000.top()) continue;
                RB3000.pop();
                RB3000.push(updated);
            } else {
                RB3000.push(updated);
            }
        }
    }
    std::vector<Int> SB3000;
    while (RB3000.size()) {
        SB3000.push_back(RB3000.top());
        RB3000.pop();
    }

    // for (auto const& x: SB3000) cout << x << ", ";
    // cout << endl << endl;

    std::priority_queue<Int, vector<Int>, greater<Int>> RC3000;
    for (Int i = 0; i < Z; ++i) {
        Int C_i;
        cin >> C_i;
        for (auto const B_i: SB3000) {
            Int updated = B_i + C_i;
            if (RC3000.size() >= 3000) {
                if (updated < RC3000.top()) continue;
                RC3000.pop();
                RC3000.push(updated);
            } else {
                RC3000.push(updated);
            }
        }
    }
    std::vector<Int> SC3000;
    while (RC3000.size()) {
        SC3000.push_back(RC3000.top());
        RC3000.pop();
    }
    Int counter = 0;
    for (auto iter = SC3000.rbegin(); iter != SC3000.rend(); ++iter) {
        cout << *iter << endl;
        ++counter;
        if (counter == K) break;
    }

    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

#木の根を求める
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x != y:
        #xとyの属している集合が異なる時
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x]==rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

########################################
#初期化
n,m = map(int,input().split())

par = [0]*n #親
for i in range(n):
    par[i] = i
rank = [1]*n #深さ
size = [1]*n #size[i]:iを根とするグループのサイズ
edge2 = [[0] for i in range(m)]
for i in range(m):
    edge2[i] = list(map(int,input().split()))

edge = [[0] for i in range(m)]
for i in range(m):
    edge[i] = [edge2[m-1-i][0]-1,edge2[m-1-i][1]-1]
res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        res.append(size[fi]*size[se])
        unite(fi,se)
ass = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)


Measured memory_bytes: 48392
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 2019;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  string s; cin >> s; ll n = s.size();
  
  reverse(all(s));
  
  vl per(2019,0LL);
  
  ll now = 0; ll pow10 = 1;
  per[0]++;
  
  rep(i,n){
    now += (s[i] - '0')*pow10;
    pow10 *= 10;
    pow10 = mod(pow10);
    now = mod(now);
    
    per[now]++;
  }
  
  ll ans = 0;
  
  rep(i,2019){
    ans += per[i]*(per[i]-1)/2;
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3732
N = int(input())
p = [0,0]
for i in range(N):
    s = input().split()
    if s[0]>s[1]:
        p[0] += 3
    elif s[0] == s[1]:
        p[1] += 1
        p[0] += 1
    else:
        p[1] += 3
print(*p)


Measured memory_bytes: 5596
#include<stdio.h>

#define MAX 1000
 
int main(){
  int n, i, j, k, l, min, sum = 0;
  int g[MAX][MAX], a[MAX], b[MAX];
 
  scanf("%d", &n);
 
  for( i = 0; i < n; i++){
    a[i] = 0;
    b[i] = MAX;
    for( j = 0; j < n; j++){
      scanf("%d", &g[i][j]);   
    }
  }
  b[0] = 0;
 
  for( i = 1; i < n; i++){
    min = MAX;
    for( j = 0; j < n; j++){
      if( b[j] < min && a[j] == 0){
    min = b[j];
    k = j;
      }
    }
 
    a[k] = 1;
   
    for( l = 0; l < n; l++){
 
      if(g[k][l] < b[l] && g[k][l] != -1 && a[l] == 0){
    b[l] = g[k][l];
      }
    }
  }
 
  for( i = 0; i < n; i++){
    sum += b[i];
  }
 
  printf("%d\n", sum);
 
  return 0;
}

Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int A, B, K;
  ci(A, B, K);
  map<int, int> a;
  repi(i, A, A + K){
    a[i]++;
  }
  repi(i, B - K, B){
    a[i + 1]++;
  }
  each(i, a){
    if(A <= i.ft && i.ft <= B){
      co(i.ft);
    }
  }
}


Measured memory_bytes: 256
import CoreFoundation
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let n=arr[0]
let y=arr[1]
for i in 0...n {
	for j in 0...n-i {
		let k=n-i-j
		if i*1000+j*5000+k*10000==y {
			print(k,terminator:" ")
			print(j,terminator:" ")
			print(i)
			exit(0)
		}
	}
}
print("-1 -1 -1")

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

ll inf=1e18;

int main() {
  string s;
  cin >> s;
  vector<ll> n(s.size()+1);
  vector<vector<ll>> ans(2,vector<ll> (n.size()+1,inf));
  for(ll i=0;i<s.size();i++) {
    n[i]=int(s[s.size()-1-i]-'0');
  }
  ans[0][0]=0;
  for(ll i=0;i<n.size();i++) {
    ans[0][i+1]=min(ans[0][i+1],ans[0][i]+n[i]);
    ans[0][i+1]=min(ans[0][i+1],ans[1][i]+n[i]+1);
    ans[1][i+1]=min(ans[1][i+1],ans[0][i]+10-n[i]);
    ans[1][i+1]=min(ans[1][i+1],ans[1][i]+10-(n[i]+1));
  }
  ll res=min(ans[0][n.size()],ans[1][n.size()]);
  cout << res << endl;
}

Measured memory_bytes: 32644
#include <iostream>
#include <cmath>
#include <iomanip>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif

#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;


int main() {
    double a, b, x;
    cin >> a >> b >> x;
    
    double bb;
    bb = (2*x)/(a*a)-b;
    
    double tx, ty;
    if(bb<=0) {
        tx=b;
        ty=(1+bb/b)*a;
    } else {
        tx=b-bb;
        ty=a;
    }
    
    cout << setprecision(10) << (double)90-rad_to_deg(atan2(ty, tx)) << endl;

    return 0;
    
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
cnt = 0
for i in range(n) :
  res = 0
  a = list(map(int, input().split()))
  for j in range(m) :
    res += a[j]*b[j]
  if(res + c > 0 ) : cnt += 1
print(cnt)
  

Measured memory_bytes: 3060