akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  rep(i,n){
    ll a; cin>>a;
  }
  cout<<(n-1+k-2)/(k-1)<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	int N;
	cin >> N;
	map<string, int> mp;
	int mx=0;
	for(int i=0; i<N; ++i){
		string S;
		cin >> S;
		++mp[S];
		mx=max(mx, mp[S]);
	}
	for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
		if(itr->second==mx){
			cout << itr->first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<vector>

using namespace std;

int main() {
  int N,max,temp;
  vector<int> a;

  cin >> N;
  a.resize(N);
  
  temp = 0;
  max = 0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(i > 0 && (a[i-1] >= a[i] )){
         temp++;
    }else{
         if(temp > max ) max = temp;
         temp = 0;
    }
  }
  if(temp > max ) max = temp;
  cout << max;
  return 0;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int arr[N];
vector<int> g[N];
bool vis[N];
map<int, int> mp;
vector<int> pos, node;
void dfs(int curr, int par)
{
  vis[curr] = 1;
  pos.pb(curr);
  node.pb(arr[curr]);
  for(auto x: g[curr])
    if(!vis[x])
      dfs(x, curr);
}
int main()
{
	int n, m;
	cin>>n>>m;
	repn(i, 1 , n) {
		cin>>arr[i];
		mp[arr[i]] = i;
	}
	rep(i,0 , m)
	{
		int x, y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	int ans = 0;
	rep(i, 1, n+1)
		if(vis[i] == 0)
		{
			pos.clear(); node.clear();
			dfs(i, -1);
			sort(all(pos));
			for(int x: node)
			{
				auto itr = lower_bound(all(pos), x);
				if(itr == pos.end()) continue; 
				if(*itr == x)
				{ 
					ans++;
					// cout<<x<<" "<<(*itr)<<endl;
				}
			}
		}
	cout<<ans<<endl;
	// cout<<arr[418]<<" "<<arr[922]<<endl;
	// cout<<arr[21]<<endl;
	// cout<<arr[890]<<endl;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll EXA = 1000000000000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int check(int n, int k, string s, const vector<pair<char, char>> &p) {
  for(int i=0;i<(int)(p.size());++i) {
    int next = (p[i].second == 'L' ? -1 : 1);
    if(s[k] == p[i].first) {
      k += next;
    }
    if(k == 0 || k == n+1) break;
  }
  return k;
}



int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  
  int n, q; cin >> n >> q;
  string s; cin >> s;
  s.push_back('*');
  reverse(s.begin(), s.end());
  s.push_back('*');
  reverse(s.begin(), s.end());
  vector<pair<char, char>> p(q);
  for(int i=0;i<q;++i) {
    cin >> p[i].first >> p[i].second;
  }

  int ansl = 0, ansr = 0;

  int l = 0, r = n+2;
  while(r - l > 1) {
    int mid = (l + r) / 2;
    if(check(n, mid, s, p) == 0) {
      l = mid;
    } else {
      r = mid;
    }
  }
  ansl = l;

  l = -1; r = n+1;
  while(r - l > 1) {
    int mid = (l + r + 1) / 2;
    if(check(n, mid, s, p) == n+1) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ansr = r;
  // cout << ansl << ":" << ansr << endl;

  if(ansr > ansl) cout << ansr - ansl - 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Abc166E
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var dic = new Dictionary<long, long>();

            for (int i = 0; i < n; i++)
            {
                if (!dic.ContainsKey(a[i] + i))
                    dic.Add(a[i] + i, 1);
                else
                    dic[a[i] + i]++;
            }

            long count = 0;
            for (int i = 0; i < n; i++)
            {
                if (i < a[i])
                    continue;
                long m = 0;
                if (dic.TryGetValue(i - a[i], out m))
                    count += m;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 57176
#include <bits/stdc++.h>
using namespace std;
int a;int b[200009];
int main(){
  int n,k,ans=0;cin>>n>>k;
  
  for(int i=0;i<n;++i){
    cin>>a;
    b[a]++;
  }
  int m=n-k;
  sort(b,b+n+1);
  for(int i=0;i<=m;++i){
    ans+=b[i];
  }
  cout<<ans<<endl;
}

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

int main(void){
  double a;
  while(cin >> a){
    double sum = a;
    for(int i = 2; i <= 10; i++){
      if(i % 2 == 0){
        a = 2 * a;
        sum += a;
      }else{
        a = a / 3;
        sum += a;
      }
    }
    printf("%.8f\n", sum);
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<map<int, int>> v(2);
    for (auto i = 0; i < n; i++) {
        int a; cin >> a;
        if (i % 2 == 0) v[0][a]++;
        else v[1][a]++;
    }

    vector<int> max_count(4, 0), max_index(4, 0);
    int ans, index = 0;
    for (auto & vec : v) {
        for (auto i = 0; i < 2; i++) {
            for (auto & elm : vec) {
                if (max_count[index] < elm.second) {
                    max_count[index] = elm.second;
                    max_index[index] = elm.first;
                }
            }
            vec.erase(max_index[index]);
//            cout << max_count[index] << " " << max_index[index] << endl;
            index++;
        }
    }

    if(max_index[0] == max_index[2]) {
        if(max_count[0] + max_count[3] < max_count[1] + max_count[2]) {
            ans = n - (max_count[2] + max_count[1]);
        } else {
            ans = n - (max_count[3] + max_count[0]);
        }
    } else {
        ans = n - (max_count[0] + max_count[2]);
    }

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

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    string s;
    cin >> s;
    string last = "", now = "";
    int ans = 0;
    for(auto c : s) {
        now += c;
        if(now==last)
            continue;
        last = now;
        now = "";
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define ff              first1
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 int temp=0,temp1=0;
 int myfun(int a,int b)
 {
     return a>b;
 }
int32_t main()
{
	FIO;


	string s;
	int a,b,c;cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,n,c=0;
  scanf("%d %d %d",&n,&a,&b);
  while(c==0){
    if(1<=n&&n<=20&&1<=a&&a<=50&&1<=b&&b<=50){
      c++;
    }
    scanf("%d %d %d",&n,&a,&b);
  }
  if(a*n>b){
    printf("%d",b);
  } else {
    printf("%d",a*n);
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(){
  string str;
  cin>>str;
  int cnt=0, maxcnt=0;
  for(auto c:str){
    if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
      cnt++;
      maxcnt = max(maxcnt, cnt);
    } else {
      cnt = 0;
    }
  }
  cout<<maxcnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/
 
const int maxn=(int)(1e5)+5;
int cnt[maxn],now[2];
 
int main() {
    int n;
    read(n);
    REP(i,1,n) {
        int x;
        read(x);
        cnt[x]++;
    }
    int mx=(int)(1e5);
    REP(i,1,mx) if(cnt[i]) {
        if(cnt[i]&1) now[1]++;
        else now[0]++;
    }
    if(now[0]&1) now[1]--;
    printf("%d\n",now[1]+now[0]);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n, k; cin >> n >> k;
  V p(n); cin >> p;
  sort(all(p));

  ll ans = 0;
  rep(i, k) ans += p[i]; 

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int ans[2005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, x, y;
	cin >> n >> x >> y;
	for(int i = 1; i <= n; ++i){
		for(int j = i+1; j <= n; ++j){
			int dist = j - i;
			chmin(dist, abs(i-x) + 1 + abs(y-j));
			chmin(dist, abs(i-y) + 1 + abs(x-j));
			ans[dist]++;
		}
	}
	for(int k = 1; k <= n-1; ++k){
		cout << ans[k] << endl;
	}
	return 0;
}

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

int main() {
  int N, K;
  vector <int> inputs;
  cin >> N >> K;

  int i;
  int a;
  long long int inputSum = 0;
  for (i = 0; i < N; i++) {
    cin >> a;
    inputSum += (a > 0) ? a : 0;
    inputs.push_back(a);
  }

  long long int whiteloss = 0;
  long long int blackloss = 0;
  for (i = 0; i < K; i++) {
    whiteloss += (inputs[i] > 0) ? inputs[i] : 0;
    blackloss += (inputs[i] < 0) ? -inputs[i] : 0;
  }

  long long int minloss = (whiteloss > blackloss) ? blackloss : whiteloss;
  for (i = 0; i + K < N; i++) {
    whiteloss -= (inputs[i] > 0) ? inputs[i] : 0;
    blackloss -= (inputs[i] < 0) ? -inputs[i] : 0;
    whiteloss += (inputs[i + K] > 0) ? inputs[i + K] : 0;
    blackloss += (inputs[i + K] < 0) ? -inputs[i + K] : 0;
    if (minloss > whiteloss) minloss = whiteloss;
    if (minloss > blackloss) minloss = blackloss;
  }

  cout << inputSum - minloss << endl;

  return 0;
}


Measured memory_bytes: 892
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


int main(void)
{
	int n;
	ll k;
	while(scanf("%d%lld", &n, &k)==2)
	{
		vi a(n+1);
		vll m(n+1, -1);

		for(int i=1;i<=n;i++) scanf("%d", &a[i]);

		int p=1;
		bool is_first=true;
		for(;k>0;k--)
		{
			if(m[p]>0)
			{
				if(is_first)
				{
					is_first=false;
					ll l=k/(m[p]-k);
//					printf("k=%lld  (m[p]-k)=%d  ", k, m[p]-k);
					k-=(m[p]-k)*l;
//					printf("l=%lld k=%lld\n", l, k);
					if(k==0) break;
				}
			}
			m[p]=k;
			p=a[p];
		}
		printf("%d\n", p);
	}
	return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

int cal(vector<int> &a, int n) {
  vector<int> b(n);
  for (int i = 0; i < n; i++) b[i] = i + 1;
  int cnt = 1;
  while (a != b) {
    cnt++;
    next_permutation(all(b));
  }
  return cnt;
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto &i : a) cin >> i;
  for (auto &i : b) cin >> i;
  cout << abs(cal(a, n) - cal(b, n)) << '\n';
}


Measured memory_bytes: 3588
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	vector<int>c(3);
	rep(i,3)cin>>c[i];
	sort(c.begin(),c.end());
	int n;
	cin>>n;
	int i=0,j=0,cnt=0;
	while (c[2]*i<=n){
		j=0;
		while(c[2]*i+c[1]*j<=n){
			if((n-c[2]*i-c[1]*j)%c[0]==0) cnt++;
			j++;
		}
		i++;
	}
	cout<<cnt<<endl;

	return 0;
}

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

using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define PB(c) push_back(c)
#define SS size()
#define ST first
#define ND second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

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

int main() {
    int n; cin >> n;
    cout << (n/3) << endl;
}

Measured memory_bytes: 256
import java.util.*;

 class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] a = new long[n];
		for(int i=0;i<n;i++)
		{
			a[i] = sc.nextInt();
		}
		if(k>=n)
		{
			System.out.println(0);
		}
		else
		{
			int temp = n-k;
			long sum = 0;
            Arrays.sort(a);
			for(int i=0;i<temp;i++)
			{
               sum = sum + a[i];
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 85812
#!/usr/bin/env python3.4

# abc126_b

def isMM(n):
    return 1 <= n <= 12

def main():
    # input
    s = input()
    s1 = int(s[:2])
    s2 = int(s[2:])
    # get ans
    if isMM(s1) and isMM(s2):
        ans = 'AMBIGUOUS'
    elif isMM(s1):
        ans = 'MMYY'
    elif isMM(s2):
        ans = 'YYMM'
    else:
        ans = 'NA'
    # output
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <iostream>

using namespace std;

#define MOD 1000000007
#define MAX 1000001

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool normarize(int& x, int& y) {
	int xx = -x + 2 * y, yy = 2 * x - y;
	if (xx < 0 || yy < 0 || xx % 3 != 0 || yy % 3 != 0) return false;
	x = xx / 3, y = yy / 3;
	return true;
}

int main() {
	int x, y; cin >> x >> y;
	if (!normarize(x, y)) {
		cout << 0 << endl;
		return 0;
	}
	COMinit();
	cout << COM(x + y, x) << endl;
	
	return 0;
}

Measured memory_bytes: 23808
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void yesno(bool c) { OUT(c ? "yes" : "no"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N, M;
	cin >> N >> M;
	vll Xs(N), Ys(N), Xc(M), Yc(M);
	REP(i, N) {
		cin >> Xs[i] >> Ys[i];
	}
	REP(i, M) {
		cin >> Xc[i] >> Yc[i];
	}

	vi ans;
	REP(i, N) {
		vll D(M);
		REP(j, M) {
			D[j] = abs(Xs[i] - Xc[j]) + abs(Ys[i] - Yc[j]);
		}
		ll Dmin = *min_element(ALL(D));
		REP(j, M) {
			if (D[j] == Dmin) {
				ans.push_back(j);
				break;
			}
		}
	}
	REP(i, N) {
		OUT(ans[i] + 1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
typedef long long ll;
//
int main(){
    int n;cin>>n;
    ll d;cin>>d;
    vector<pair<ll,ll>> v;
    rep(i,n){
        int a,b;cin>>a>>b;
        v.push_back(pair<ll,ll> (a,b));
    }
    int ans=0;
    rep(i,n){
        if(sqrt(v[i].F*v[i].F+v[i].S*v[i].S)<=d)ans++;
    }
    cout<<ans<<endl;
    
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if (c-a-b>=0 && 4*a*b<(c-a-b)*(c-a-b)) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

long long int dp[55][3000][55];

int N, A, x[55];

int main(void) {

	cin >> N >> A;

	for (int i = 1; i <= N; i++) { cin >> x[i]; }

	/*for (int i = 0; i <= N; i++) {
		dp[i][0][0] = 1;
	}*/

	for (int i = 1; i <=N ; i++) {
		dp[i][x[i]][1] += 1;
		for (int k = 0; k <= 2500; k++) {
			for (int m = 0; m <= N - 1; m++) {
				dp[i][k + x[i]][m + 1] += dp[i-1][k][m];
				dp[i][k][m] += dp[i - 1][k][m];
			}
		}
	}

	long long int ans = 0;

	for (int m = 1; m <= N; m++) {
		ans += dp[N][m*A][m];
	}

	/*for (int k = 0; k <= 20; k++) {
		cout << "dp["<<3<<"][" << k << "][" << 2 << "]= " << dp[3][k][2] << endl;
	}*/
	cout << ans << endl;

	//system("pause");
	return 0;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  long long Q,H,S,D;

  cin>>Q>>H>>S>>D;

  double N;

  cin>>N;

  long long ans=0;

  long long cnt2=min(min(min(Q*8,H*4),S*2),D);

  long long cnt1=min(min(Q*4,H*2),S);

  long long cnt5=min(Q*2,H);

  long long cnt25=Q;
  
  int i=4;

  while(1){

    if(N==0){
      break;
    }

    if(i==4){
      if(N>=2){
	ans+=int(N/2)*cnt2;
	N-=(int(N/2)*2);
	
      }else{
	i-=1;
      }
    }
    else if(i==3){
      
      if(N>=1){
	
	ans+=int(N/1)*cnt1;
	N-=(int(N/1)*1);
	
      }else{
	i-=1;
      }
      
    }else if(i==2){
      
      if(N>=0.5){
	ans+=int(N/0.5)*cnt5;
	N-=(int(N/0.5)*0.5);

	
      }else{
	i-=1;
      }
    }else if(i==1){

      if(N>=0.25){
	ans+=int(N/0.25)*cnt25;
	N-=(int(N/0.25)*0.25);
      }else{
	i-=1;
      }
    }
  
  }
  cout<<ans<<endl;
  
  

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

#define N	300000
#define MD	1000000007

int min(int a, int b) { return a < b ? a : b; }

int vv[N * 3 + 1], ff[N * 3 + 1], gg[N * 3 + 1], p3[N * 2 + 1];

void init() {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N * 3; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
	p3[0] = 1;
	for (i = 1; i <= N * 2; i++)
		p3[i] = p3[i - 1] * 3LL % MD;
}

long long choose(int n, int k) {
	return k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	int n, m, k, i, ans, sum;

	init();
	scanf("%d%d%d", &n, &m, &k);
	ans = 0, sum = 1;
	for (i = 0; i <= m + k; i++) {
		ans = (ans + sum * choose(n - 1 + i, n - 1) % MD * p3[m + k - i]) % MD;
		sum = (sum * 2 - choose(i, i - k) - choose(i, m)) % MD;
	}
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


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


#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int w,ans;
string s;

main() {
    cin >> s;
    rep(i,s.size()) if(s[i] == 'W') ans += max((int)0,i-w++);
    ct(ans)
}




Measured memory_bytes: 640
n = int(input())
A = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
    arr = list(map(int, input().split(' ')))
    u, k, v = arr[0], arr[1], arr[2:]
    for j in range(k):
        A[u-1][v[j]-1] = 1

for li in A:
    print(' '.join(list(map(str, li))))


Measured memory_bytes: 5676
#include <bits/stdc++.h>
#define LL long long
#define N 400005
using namespace std;
const int mo=1e9+7;
vector <int> H,M,D;
int S,cnt,a[N],b[N],g[N],nex[N],E[N],d[N],l,r,n,x,y,w[N],R[N],v[N],s[N],e[N]; LL ans,tmp,P[N],Q[N],f[N];
void fly(int x){
	H.push_back(x); v[x]=1;
	for (int i=g[x];i;i=nex[i])
	if (!v[b[i]]) fly(b[i]);
}
void dfs(int x){
	for (int i=g[x];i;i=nex[i])
	if (!E[i]) E[i]=1,E[i>n?i-n:i+n]=-1,dfs(b[i]);
}
LL po(LL x,int y){
	LL z=1;
	for (;y;y>>=1,x=x*x%mo)
	if (y&1) z=z*x%mo;
	return z;
}
LL C(int n,int m){
	return P[n]*Q[m]%mo*Q[n-m]%mo;
}
int go(){
	for (int i=0;i<H.size();++i) f[H[i]]=1,s[H[i]]=R[H[i]]=0;
	l=r=f[0]=1; s[0]=0;
	for (int i=0;i<M.size();++i)
		if (E[M[i]]==1) e[a[M[i]]]=b[M[i]];
	for (int i=0;i<H.size();++i)
		if (H[i]<e[e[H[i]]]) ++R[e[H[i]]];
	for (int i=0;i<H.size();++i)
		if (!R[H[i]]) d[r++]=H[i];
	while (l<r){
		int x=d[l]; ++s[x];
		if (x<e[e[x]]){
			--R[e[x]]; if (!R[e[x]]) d[r++]=e[x];
			(f[e[x]]*=f[x]*C(s[e[x]]+=s[x],s[x])%mo)%=mo;
		}else (f[0]*=f[x]*C(s[0]+=s[x],s[x])%mo)%=mo;
		++l;
	}
	return f[0];
}
int main(){
	scanf("%d",&n); ans=1;
	for (int i=1;i<=n+n;++i){
		scanf("%d%d",&x,&y); y+=n;
		++w[x]; ++w[y];
		a[i]=x; b[i]=y; nex[i]=g[x]; g[x]=i;
		a[i+n+n]=y; b[i+n+n]=x;
		nex[i+n+n]=g[y]; g[y]=i+n+n;
	}
	n+=n;
	P[0]=1; for (int i=1;i<=n;++i) P[i]=P[i-1]*i%mo;
	Q[n]=po(P[n],mo-2); for (int i=n-1;~i;--i) Q[i]=Q[i+1]*(i+1)%mo;
	for (int i=1;i<=n;++i)
		if (!w[x]) return puts("0"),0;
	for (int I=1;I<=n;++I)
	if (!v[I]){
		H.clear(); M.clear(); fly(I); l=r=1;
		for (int i=0;i<H.size();++i)
		for (int j=g[H[i]];j;j=nex[j])
			M.push_back(j);
		for (int i=0;i<H.size();++i)
			if (w[H[i]]==1) d[r++]=H[i];
		while (l<r){
			for (int i=g[d[l]];i;i=nex[i])
			if (!E[i]){
				E[i]=1; E[i>n?i-n:i+n]=-1;
				--w[a[i]]; --w[b[i]];
				if (w[b[i]]==1) d[r++]=b[i];
			}
			++l;
		}
		D.clear();
		for (int i=0;i<H.size();++i)
			if (w[H[i]]&&w[H[i]]!=2) return puts("0"),0;
		for (int i=0;i<M.size();++i)
			if (!E[M[i]]) D.push_back(M[i]);
		dfs(a[D[0]]);
		tmp=go();
		for (int i=0;i<D.size();++i) E[D[i]]*=-1;
		(tmp+=go())%=mo;
		ans=ans*tmp%mo*C(S+=H.size(),H.size())%mo;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 30832
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i,j,l=s.size();
    for(i=0;s[i]!='A';i++);
    for(j=l-1;s[j]!='Z';j--);
    cout<<j-i+1<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cstring>
#define F first;
#define S second;
#define PB(x) push_back(x);
#define MP make_pair;
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
template <typename T>
T max(T x, T y)
{
    return (x > y) ? x : y;
}
template <typename T>
T min(T x, T y)
{
    return (x < y) ? x : y;
}
const int M = 1e9 + 7;
void solve()
{
    char s[200010];
    cin >> s;
    int len = strlen(s);
    int sum = 0;
    FOR(i, 0, len - 1) sum += s[i]-'0';
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3768
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ; 
    vector<int> v(n) ; 
    vector<int> cnt(N);
    for(int i = 0; i < n; i++){
        cin >> v[i] ; 
        cnt[v[i]]++;
    }
    int ans = 0 ;
    for(int i = 1; i < N; i++){
        ans += cnt[i] * (cnt[i] - 1) / 2 ;
    }
    for(int i = 0; i < n; i++){
        int val = v[i] ; 
        int cur = cnt[val] * (cnt[val] - 1) / 2 ;
        ans -= cur ;
        int m = cnt[val] - 1; 
        m = m * (m - 1) / 2;
        ans += m ;
        cout << ans << endl;
        ans -= m ; 
        ans += cur ;
    }
    return 0; 
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int K;
  string s;
  cin>>K>>s;
  if(int(s.size()) <= K){
    cout << s << endl;
  }else{
    for(int i(0);i<K;i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
  return 0;
}



Measured memory_bytes: 3620
import math
a,b,x = list(map(int, input().split()))
l=a*a*b
if a<=b:
    if x/l>0.5:
        print(math.degrees(math.atan(2*(l-x)/a/a/a)))    
    else:
        print(90-math.degrees(math.atan(2*x/a/b/b)))
else:
    if x/l<0.5:
        print(90-math.degrees(math.atan(2*x/a/b/b)))    
    else:
        print(math.degrees(math.atan(2*(l-x)/a/a/a)))

Measured memory_bytes: 3064
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, W, *WV = map(int, read().split())
    weight = WV[::2]
    value = WV[1::2]

    w_min = min(weight)
    items = [[] for _ in range(4)]
    for w, v in zip(weight, value):
        items[w - w_min].append(v)

    for i in range(4):
        items[i].sort(reverse=True)

    csums = [0] * 4
    for i in range(4):
        csums[i] = [0]
        csums[i].extend(accumulate(items[i]))

    def rec(i, w, v):
        if i == 4:
            if w <= W:
                return v
            else:
                return -1
        ans = 0
        for j in range(len(csums[i])):
            w_next = w + (w_min + i) * j
            if w_next > W:
                break
            ans = max(ans, rec(i + 1, w_next, v + csums[i][j]))

        return ans

    print(rec(0, 0, 0))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 73740
#include<iostream> 
#include <string.h>
#include <stdio.h>

using namespace std; 

int main() { 	
	
	long long int a,b,k;
	cin>>a>>b>>k;
	if(a>=k) a=a-k;
	else if(a+b>=k){
		b=b-(k-a);
		a=0;
	}else{
		a=b=0;
	}
	cout<<a<<" "<<b<<endl;
	
		return 0; }


Measured memory_bytes: 256
h, w = map(int, input().split())
campus = [["."] * (w + 2)]

for _ in range(h):
    c = ["."] + list(input()) + ["."]
    campus.append(c)

campus.append(["."] * (w + 2))

draw = True

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if campus[i][j] == "#":

            if campus[i - 1][j] == "." and\
               campus[i][j - 1] == "." and\
               campus[i + 1][j] == "." and\
               campus[i][j + 1] == ".":
               draw = False

print("Yes" if draw else "No")

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	vector<pair<int,int>>v;
	int b=0,s=1;
	for(int i=1;i<n;++i){
		if(a.at(i)>=a.at(b))s=i;
		if(b<s&&a.at(b)<a.at(s)){
			v.push_back({a.at(b),a.at(s)});
			b=i,s=i;
		}
		if(a.at(i)<a.at(b))b=i;
	}
	int64_t money=1000;
	for(auto&&i:v){
		int64_t stock=money/i.first;
		money-=1L*stock*i.first;
		money+=1L*stock*i.second;
	}
	cout<<money<<"\n"s;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dp[2019];
ll temp[2019];

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    ll N = S.length();
    
    Fill(dp, 0);
    Fill(temp, 0);

    ll ans = 0;
    REP(i, N){
        // 一つ前の値を保存
        for(ll j=0; j<2019; j++){
            temp[j] = dp[j];
            dp[j] = 0; 
        }

        ll a = S[i]-'0';
        dp[a]++;
        // if(i == 0) continue;
        for(ll j=0; j<2019; j++){
            dp[(j*10+a)%2019] += temp[j];
        }
        ans += dp[0];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
def calc(n, dp):
	if dp[n]:
		return dp[n]
	if n <= 1:
		return dp[n]
	dp[n] = calc(n-1, dp) + calc(n-2, dp)
	return dp[n]

def resolve():
	n = int(input())
	dp = [None] * 87
	dp[0], dp[1] = 2, 1
	print(calc(n, dp))
resolve()

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;

  int64_t c = 0;
  for (int64_t i = 1; i < s.size(); i++) {
    if (s[i] != s[i - 1]) {
      c++;
    }
  }
  std::cout << c << std::endl;
  return 0;
}

Measured memory_bytes: 512
// ALDS1_5_C.cpp
// Divide and Conquer - Koch Curve

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
double const PI = 3.14159265;
struct Point
{
	double x;
	double y;
};

double dist(Point p1, Point p2) {
	double dx = p1.x - p2.x;
	double dy = p1.y - p2.y;
	return sqrt(dx * dx + dy * dy);
}

vector<Point> divide(Point p1, Point p2)
{
	vector<Point> res;

	Point p_new1;
	p_new1.x = p1.x + (p2.x - p1.x) / 3;
	p_new1.y = p1.y + (p2.y - p1.y) / 3;

	Point p_new2;
	p_new2.x = p2.x - (p2.x - p1.x) / 3;
	p_new2.y = p2.y - (p2.y - p1.y) / 3;

	Point p_new3;
	double side = dist(p_new1, p_new2);
	double theta = atan2(p_new2.y - p_new1.y, p_new2.x - p_new1.x);
	p_new3.x = p_new1.x + side * cos(PI / 3 + theta);
	p_new3.y = p_new1.y + side * sin(PI / 3 + theta);

	res.push_back(p1);
	res.push_back(p_new1);
	res.push_back(p_new3);
	res.push_back(p_new2);
	res.push_back(p2);
	return res;
}

void show(vector<Point>& ps)
{
	for (int i = 0; i < ps.size(); i++) {
		cout << ps[i].x << " " << ps[i].y << endl;
	}
}

void KochCurve(vector<Point>& ps, int n)
{
	vector<Point> res;
	if (n == 0) {
		show(ps);
		return;
	}
	else {
		res.push_back(ps[0]);
		for (int i = 0; i + 1 < ps.size(); i++) {
			vector<Point> tmp = divide(ps[i], ps[i + 1]);
			for (int j = 1; j < tmp.size(); j++) {
				res.push_back(tmp[j]);
			}
		}
		KochCurve(res, n - 1);
	}

}

int main()
{
	Point p;
	vector<Point> ps;
	ps.push_back({ 0.0, 0.0 });
	ps.push_back({ 100.0, 0.0 });
	int n;
	cin >> n;
	KochCurve(ps, n);
	return 0;
}

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

int main() {
  char c;
  string ans;
  cin >> c;
  if(c == 'a' ||
     c == 'e' || 
     c == 'i' ||
     c == 'o' ||
     c == 'u' )
    ans = "vowel";
  else
    ans = "consonant";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

ll gcd(ll a, ll b){
	while(b){
		a %= b;
		swap(a, b);
	}
	return a;
}
//b is not 0
ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll ans = lcm(n, m);
    ll a = ans / n, b = ans / m;
    size_t i1 = 0, i2 = 0;
    int p1 = 0, p2 = 0;
    while(i1 < s.size() && i2 < t.size()){
        if(p1 == p2){
            if(s[i1] != t[i2]){
                printde(i1, i2, p1, p2);
                cout << -1 << '\n';
                return 0;
            }
            i1++;
            i2++;
            p1 += a;
            p2 += b;
        }else if(p1 < p2){
            i1++;
            p1 += a;
        }else{
            i2++;
            p2 += b;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  int sum = 0;
  vector<int> d (N);
  for(int i = 0; i < N; i++) cin >> d[i];
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double t,pi=M_PI;
bool ck(double r) {return pi-t<=r&&r<=pi+t;}

int calc(double m) {
  ll l=0,r=m*4;
  while(l+1<r) {
    ll m2=(l+r)/2;
    if((double)m2/m<=pi) l=m2;
    else r=m2;
  }
  return l;
}

int main() {
  while(cin >> t && t) {
    for(double r=1; r<(1<<29); r++) {
      ll y=calc(r),x;
      double M=1<<29;
      for(int i=-1; i<2; i++) {
        if(!ck((y+i)/r)) continue;
        double d=fabs((double)(y+i)/r-pi);
        if(d<M) {
          M=d;
          x=y+i;
        }
      }
      if(M!=1<<29) {
        cout << x << "/" << r << endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3180
#include<iostream>
#include<string>

using namespace std;


int main(){

	int D;
	int x;
	string a;
	int p;
	int y;
	string bc;
	int q;
	int dp[14]={0};
	int max;

	cin>>D;
	for(int i=1;i<=D;i++) dp[i]=0;

	cin>>x;

	for(int i=0;i<x;i++){
		cin>>a>>p;
		if(a=="D"){
			for(int j=D-1;j>=0;j--){
				if((dp[j]!=0||j==0)&&dp[j]+p>dp[j+1]){
					dp[j+1]=dp[j]+p;
				}
			}
		}
	}

	cin>>y;

	for(int i=0;i<y;i++){
		cin>>bc>>q;
		if(bc=="DD"){
			for(int j=D-2;j>=0;j--){
				if((dp[j]!=0||j==0)&&dp[j]+q>dp[j+2]){
					dp[j+2]=dp[j]+q;
				}
			}
		}
	}

	max=dp[0];
	for(int i=1;i<=D;i++){
		if(max<dp[i]) max=dp[i];
	}

	cout<<max<<endl;

}

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

int main(){
	bool a = true;
	string s,t;
	cin >> s >> t;

	for(int i = 0; i < s.size(); i++){
		if(s.at(i) != t.at(i)){
			a = false;
		}
	}

	if(a == true){
		cout << "Yes" << endl;
	}

	if(a == false){
		cout << "No" << endl;
	}

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    ll diff = 0, sgn = 0, ans = 0, prevsgn = 0;
    for (int i = 0; i < N - 1; i++)
    {
        diff = A[i + 1] - A[i];
        if (diff == 0)
        {
            sgn = prevsgn;
        }
        else
        {
            sgn = diff / abs(diff);
        }
        if (sgn != 0 and prevsgn != 0 and sgn != prevsgn)
        {
            ans++;
            sgn = prevsgn = 0;
        }
        prevsgn = sgn;
    }
    cout << ans + 1;
    return 0;
}

Measured memory_bytes: 1024
from collections import deque
sx, sy, tx, ty = [int(x) for x in input().split()]
ret = 'R' * (tx - sx) + 'U' * (ty - sy)
ret += 'L' * (tx - sx) + 'D' * (ty - sy)
ret += 'D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L'
ret += 'U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R'
print(ret)

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

int main() {

	int h, w; cin >> h >> w;

	vector<vector<char>> a(h + 2, vector<char>(w + 2, 'e'));

	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cin >> a[i][j];
	
	int ans = 0;
	for (int sy = 1; sy <= h; sy++) {
	for (int sx = 1; sx <= w; sx++) {
		if (a[sy][sx] == '#') continue;

			// BFS のためのデータ構造
			vector<vector<int>> dist(h + 2, vector<int>(w + 2, -1)); // 全頂点を「未訪問」に初期化
			queue<pair<int, int>> que;

			// 初期条件
			dist[sy][sx] = 0;
			que.push({ sy,sx });

			const int dy[4] = { 1, 0, -1, 0 };
			const int dx[4] = { 0, 1, 0, -1 };

			// BFS 開始 (キューが空になるまで探索を行う)
			while (!que.empty()) {

				pair<int, int> p = que.front(); // キューから先頭頂点を取り出す
				que.pop();

				// p から辿れるマスをすべて調べる
				for (int i = 0; i < 4; i++) {

					int y_next = p.first + dy[i];
					int x_next = p.second + dx[i];

					if (dist[y_next][x_next] != -1) continue;
					if (a[y_next][x_next] == 'e' || a[y_next][x_next] == '#') continue;

					// 新たなマス { y_next, x_next } について距離情報を更新してキューに追加する
					dist[y_next][x_next] = dist[p.first][p.second] + 1;
					que.push({ y_next, x_next });

				}

			}

			int tmp_dist = 0;
			for (int gy = 1; gy <= h; gy++) {
				for (int gx = 1; gx <= w; gx++) {
					if (a[gy][gx] == '#') continue;
					tmp_dist = max(tmp_dist, dist[gy][gx]);
				}
			}
		
			ans = max(ans, tmp_dist);
	}
	}

	cout << ans << endl;
	return 0;

}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    int cnt = 0;
    for (int i = 0; i < n; ) {
        int r = distance(a.begin(), upper_bound(a.begin(), a.end(), a[i]));
        if ((r - i) % 2 == 1) ++cnt;
        i = r;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe

main = do
  (n:m:_) <- (map read) . words <$> getLine
  stud <- replicateM n ((map read) . words <$> getLine)
  check <- replicateM m ((map read) . words <$> getLine)

  mapM_ print $ mapMaybe (\(a:b:_) -> f (map (\(c:d:_) -> abs(a-c)+abs(b-d)) check)) stud

  where
    f :: [Int] -> Maybe Int
    f xs = fmap (+1) (elemIndex min xs)
      where
        min = minimum xs


Measured memory_bytes: 1020