akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i], --a[i];
  int x = a[0], cta = 0;
  set<int> st;
  while (x != 1 && st.find(x) == st.end()) st.insert(x), x = a[x], ++cta;
  if (x == 1)
    out(++cta);
  else
    out(-1);
}
int main(void) { solve(); }


Measured memory_bytes: 8156
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int n;
string s;
int main() {
	cin >> n >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] + n > 90) s[i] = s[i] - (26 - n);
		else s[i] += n;
	}
	cout << s << endl;
	return 0;
}

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

int main(){
    std::ios::sync_with_stdio(false);
    int n,i,j,number,total=0,count;
    cin>>n;
    long long a[n],b[n][2]={};
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    i=0;
    while(i<n){
        number=a[i];
        count=0;
        while(i<n && a[i]==number){
            count++;
            i++;
        }
        total+=count%2;
    }

    cout<<total;


    return 0;
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#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 DEBUG(x) cerr << #x << ": " << x << '\n'



int a, b, x;

signed main(){
    cin >> a >> b >> x;
    if (a <= x && x <= a+b){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h;
  string s[1000];
  set<string> st;  
  char c;
  cin>>w>>h;
  for(int i=0;i<h;st.insert(s[i++]))
    for(int j=0;j<w;j++)cin>>c,s[i]+=c;  
  sort(s,s+h);
  bool ans=1;
  int cnt=0;
  for(int i=0;i<w;i++){
    if(s[0][i]=='1')cnt++;
    if(s[h/2-1][i]==s[(h+1)/2][i])ans=0;
  }
  if((cnt!=w/2&&cnt!=(w+1)/2)||st.size()!=2)ans=0;
  cout<<(ans?"yes":"no")<<endl;
  return 0;
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> data(N);
  int count = 0;
  for(int i = 0; i < N - 1; i++) {
    if(S.at(i) == 'A') {
      if(S.at(i + 1) == 'C') count++;
    }
    data.at(i + 1) = count;
  }
  int ans, l, r;
  for(int i = 0; i < Q; i++) {
    ans = 0;
    cin >> l >> r;
    ans = data.at(r - 1);
    if(l - 2 >= 0) ans -= data.at(l - 1); 
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include<stdlib.h>
using namespace std;

int main()
{
    long n, i,k;
    cin >> n;
    long long a[n+1],b[n+1];
    b[0]=999999999999999999;
    for (int i=1;i<=n;i++)
        cin >> a[i];
    b[1]=0;
    for (i=2;i<=n;i++)
    {
        b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<b[n];
    return 0;
}



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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}

void mul_self(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a *= b;
        a %= mod;
}

void add_self(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a += b;
        a %= mod;
}

void sub_self(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a -= b;
        if(a < 0) {
                a += mod;
        }
        a %= mod;
}

ll pow1(ll a, ll n) {
        ll res = 1LL;
        
        while(n) {
                if(n % 2) {
                        mul_self(res, a); 
                }
                mul_self(a, a);
                n /= 2;
        }
        return res;
}

void solve() {
        
       ll N;
       cin >> N;
       ll tot = pow1(10, N);
       sub_self(tot, pow1(9, N));
       sub_self(tot, pow1(9, N));
       add_self(tot, pow1(8, N));
       
       cout << tot << endl;
       
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
int n, c, a[100009], sa[100009], bit[200009];
void add(int pos, int x) {
	pos += n;
	for (int i = pos + 1; i <= 2 * n; i += i & (-i)) {
		bit[i] += x;
	}
}
int sum(int pos) {
	pos += n;
	int ans = 0;
	for (int i = pos; i >= 1; i -= i & (-i)) {
		ans += bit[i];
	}
	return ans;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i], sa[i] = a[i];
	sort(sa, sa + n);
	c = unique(sa, sa + n) - sa;
	for (int i = 0; i < n; ++i) a[i] = lower_bound(sa, sa + c, a[i]) - sa;
	long long all = 1LL * n * (n + 1) / 2;
	int l = -1, r = c;
	while (r - l > 1) {
		int m = (l + r) >> 1;
		for (int i = 0; i <= 2 * n; ++i) bit[i] = 0;
		long long cnt = 0; int cur = 0;
		add(0, 1);
		for (int i = 0; i < n; ++i) {
			cur += (a[i] <= m ? 1 : -1);
			cnt += sum(cur);
			add(cur, 1);
		}
		if (cnt * 2 > all) r = m;
		else l = m;
	}
	cout << sa[r] << '\n';
	return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str=bfr.readLine();
		int a=Integer.parseInt(str);

		if(a/1000==0) {
			System.out.println("ABC");
		}

		else if(a/1000==1) {
			System.out.println("ABD");
		}
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>

#undef max
#undef min

using namespace std;

void SolveA()
{
	size_t N;
	cin >> N;
	size_t cnt1 = 0;
	size_t cnt2 = 0;
	size_t cnt4 = 0;
	for (size_t i = 0; i < N; ++i)
	{
		size_t tmp;
		cin >> tmp;
		if (!(tmp % 4))
			++cnt4;
		else if (!(tmp % 2))
			++cnt2;
		else
			++cnt1;
	}

	size_t lastType = 4;
	for (size_t i = 0; i < N; ++i)
	{
		if (lastType == 4 && cnt1 > 0)
		{
			--cnt1;
			lastType = 1;
		}
		else if (lastType >= 2 && cnt2 > 0)
		{
			--cnt2;
			lastType = 2;
		}
		else if (cnt4 > 0)
		{
			--cnt4;
			lastType = 4;
		}
		else
		{
			cout << "No";
			return;
		}
	}

	cout << "Yes";
}

void SolveB()
{
	int X[100][100];
	size_t H, W;
	cin >> H >> W;
	size_t N;
	cin >> N;
	int iCur = 0;
	int jCur = 0;
	int dir = 1;
	for (size_t i = 0; i < N; ++i)
	{
		size_t a;
		cin >> a;
		for (size_t j = 0; j < a; ++j)
		{
			X[iCur][jCur] = i + 1;
			jCur += dir;
			if (jCur == W)
			{
				jCur = W - 1;
				dir = -1;
				++iCur;
			}
			else if (jCur == -1)
			{
				jCur = 0;
				dir = 1;
				++iCur;
			}
		}
	}

	for (size_t i = 0; i < H; ++i)
	{
		for (size_t j = 0; j < W; ++j)
			cout << X[i][j] << " ";
		cout << "\n";
	}
}

int main()
{
	SolveB();
	return 0;
}


Measured memory_bytes: 384
import math


def koch(n, p1, p2):
    if n == 0:
        return
    s = [(2 * p1[0] + p2[0]) / 3, (2 * p1[1] + p2[1]) / 3]
    t = [(p1[0] + 2 * p2[0]) / 3, (p1[1] + 2 * p2[1]) / 3]
    u = [(t[0] - s[0]) * math.cos(math.radians(60))
         - (t[1] - s[1]) * math.sin(math.radians(60)) + s[0],
         (t[0] - s[0]) * math.sin(math.radians(60))
         + (t[1] - s[1]) * math.cos(math.radians(60)) + s[1]]

    koch(n - 1, p1, s)
    print(s[0], s[1])
    koch(n - 1, s, u)
    print(u[0], u[1])
    koch(n - 1, u, t)
    print(t[0], t[1])
    koch(n - 1, t, p2)

n = int(input())
p1 = (0, 0)
p2 = (100, 0)
print(p1[0], p1[1])
koch(n, p1, p2)
print(p2[0], p2[1])

Measured memory_bytes: 6900
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#ifdef __BORLANDC__
	typedef __int64 ll;
#else
	typedef long long ll;
#endif




class Prim{
	public:
	static const int PN = 1000;
	typedef pair<int,int> pii;
	
	
	vector<pii> edge[PN];
	Prim(){
		rep(i,PN)edge[i].clear();
	}
	
	void add_edge(int a,int b, int c){
		edge[a].push_back(pii(b,c));
	}
	
	class Q{
		public:
		int pos;
		int val;
		Q(int pos,int val):pos(pos),val(val){};
		bool operator<(const Q& a)const{
			if(val!=a.val)return val>a.val;
			return pos>a.pos;
		}
	};
	
	int visit[PN];
	int solve(int st){
		rep(i,PN)visit[i]=0;
		priority_queue<Q> que;
		que.push(Q(st,0));
		
		int ret = 0;
		while(!que.empty()){
			Q u = que.top();
			que.pop();
			
			if(visit[u.pos]==1)continue;
			visit[u.pos]=1;
			
			ret += u.val;
			
			rep(i,edge[u.pos].size()){
				pii e = edge[u.pos][i];
				que.push(Q(e.first, e.second));
			}
		}
		return ret;
	}
	
};

int main(){
	int n,m;
	while(cin>>n,n){
		cin>>m;
		
		Prim prim;
		rep(i,m){
			int a,b,c;
			scanf("%d,%d,%d",&a,&b,&c);
			int d = (c+99)/100-1;
			prim.add_edge(a,b,d);
			prim.add_edge(b,a,d);
			
		}
		
		cout<<prim.solve(0)<<endl;
		
	}
}

Measured memory_bytes: 1564
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;

const int MAX_N = 112345;

const ll INF = LONG_LONG_MAX;


int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N,H;
    cin >> N >> H;
    vint sords_b;
    int max_sord_a=0;
    repeat(i, N){
        int a,b;
        cin >> a >> b;
        max_sord_a = max(max_sord_a,a);
        sords_b.push_back(-b);
    }
    sort(sords_b.begin(),sords_b.end());
    int ans = 0;
    for(auto sord:sords_b){
        if(H <= 0 || -sord < max_sord_a){
            break;
        }
        H += sord;
        ans++;
    }
    while(H>0){
        H -= max_sord_a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 892
import math

N, D = map(int, input().split())

X = []

def distance(a, b):
    x = 0
    for i in range(len(a)):
        x += (a[i] - b[i]) * (a[i] - b[i])
    y = math.sqrt(x)
    return y.is_integer()

for i in range(N):
    x = list(map(int, input().split()))
    X.append(x)

ans = 0

for i in range(N):
    for j in range(i+1, N):
        if distance(X[i], X[j]):
            ans += 1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int isLeap(int y){
	if(y%400==0)return 1;
	if(y%100==0)return 0;
	if(y%4==0)return 1;
	return 0;
}
int main(){
	const int D[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	const int LEAPD[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int y1,m1,d1,y2,m2,d2;
	while(cin>>y1>>m1>>d1>>y2>>m2>>d2){
		if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0)break;
		int days=0,tmp1=d1,tmp2=d2;
		for(int i=0;i<m1-1;++i) tmp1+=((isLeap(y1))?LEAPD[i]:D[i]);
		for(int i=0;i<m2-1;++i) tmp2+=((isLeap(y2))?LEAPD[i]:D[i]);
		for(int i=y1;i<y2;++i) days+=((isLeap(i))?366:365);
		cout<<(days-tmp1+tmp2)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <string>
#include <stdlib.h>
#include <utility>
 
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i = a;i<=b;i++)
#define ll long long int
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define iii pair<ii,int >
#define ff first
#define ss second
#define vi vector<int>
 
using namespace std;


int main(){
	int n,k;
	cin >> n >> k;
	int arr[n];
	FOR(i,n)cin >> arr[i];
	int dp[n];
	dp[0] = 0;
	FORE(i,1,n-1){
		dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
		FORE(j,max(0,i-k),i-1){
			dp[i] = min(dp[i],dp[j] + abs(arr[i] - arr[j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    string s,t,ans;
    cin >> s >> t;
    rep(i,0,n-1){
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    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 mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
int main(){
    ll n,m;cin>>n>>m;
    vector<ll>V(m);rep(i,m)cin>>V[i];sort(V.begin(),V.end());
    vector<ll>v(m-1);rep(i,m-1)v[i]=V[i+1]-V[i];sort(v.begin(),v.end());
    ll ans=0;
    rep(i,m-n)ans+=v[i];
    cout<<ans;
}

Measured memory_bytes: 1792
#include <iostream>
 
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    int res = (b-1)/(a-1);
    if ((b-1)%(a-1) != 0) ++res;
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  int ans=1;
  int s=0;
  rep(i,n-1){
    if(s==0){
      if(a[i]<a[i+1])s=1;
      if(a[i]>a[i+1])s=-1;
    }else if(s==1){
      if(a[i]>a[i+1]){
	s=0;
	ans++;
      }
    }else if(s==-1){
      if(a[i]<a[i+1]){
	s=0;
	ans++;
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define llmax LLONG_MAX   //ranges are defined in climits
#define llmin LLONG_MIN
#define imax INT_MAX
#define imin INT_MIN
#define pb push_back
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
  int n,m;cin>>n>>m;
  char a[n][n],b[m][m];
  int i,j;
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      cin>>a[i][j];
  for(i=0;i<m;i++)
    for(j=0;j<m;j++)
      cin>>b[i][j];
  bool ans=true;
  for(i=0;i+m<=n;i++)
  {
    for(j=0;j+m<=n;j++)
    {
      bool found=true;
      for(int x=0;x<m && found;x++)
      {
        for(int y=0;y<m;y++)
        {
          if(a[i+x][j+y]!=b[x][y])
          {
            found=false;
            break;
          }
        }
      }
      if(found)
      {
        cout<<"Yes";return 0;
      }
    }
  }
  cout<<"No";
	return 0;
}


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

#define endl "\n"
#define ll long long int

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	ll p=s.size();
	if((s[p-1]==s[p-2]) && (s[p-3]==s[p-4])){
        cout<<"Yes"<<endl;
	}else{cout<<"No"<<endl;}
	return 0;
}


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

int main(){

    int n,m;
    cin>> n >> m;

    vector<pair<ll,ll> > a(n);

    rep(i,n)cin >> a[i].first >> a[i].second;

    sort(a.begin(),a.end());

    ll t=0;
    ll ans=0;

    for(int i=0;i<n;i++){
        if(t+a[i].second>m){
            ans+=(ll)a[i].first*(m-t);
            break;
        }
        t+=a[i].second;
        ans+=(ll)a[i].second*a[i].first;
    }

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

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

int main()
{
  int X;
  int N;
  int *p;
  int tmp;
  bool flag;
  cin>>X>>N;
  p=new int[N];
  for(int i=0;i<N;i++)
  	cin>>p[i];
  
  for(int i=0;i<101;i++)
  {
    flag=true;
    tmp=X-i;
    for(int j=0;j<N;j++)
    {
     	if(tmp==p[j])
          flag=false;
    }
    if(flag)
    {
      	cout<<tmp;
    	break;
    }
    
    flag=true;
    tmp=X+i;
    for(int j=0;j<N;j++)
    {
     	if(tmp==p[j])
          flag=false;
    }
    if(flag)
    {
      	cout<<tmp;
    	break;
    }
  }
  
  delete[] p;
  return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m,a,b;
   cin>>n>>m;
   vector<int>v[300];
   for(int i=1;i<=m;i++)
   {
       cin>>a>>b;
       v[a].push_back(b);
       v[b].push_back(a);
   }
   for(int i=1;i<=n;i++)
   {
       cout<<v[i].size()<<endl;
   }
}


Measured memory_bytes: 3616
fn main() {
    let _ = read::<usize>();
    let a = read_vec::<usize>();
    let b = read_vec::<usize>();
    let c = read_vec::<usize>();

    let mut pre = usize::max_value() - 1;
    let mut ret = 0;
    for i in a.iter() {
        ret += b[i-1];
        if pre + 1 == i - 1 {
            ret += c[pre];
        }
        pre = i - 1;
    }

    println!("{}", ret);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k>=a+b+c)
    {
        cout<<a-c;
    }
    else if(k<=a)
    {
        cout<<k;
    }
    else if(k>a && k<=a+b)
    {
        cout<<a;
    }
    else if(k>a+b && k<a+b+c)
    {
        cout<<a-(k-(a+b));
    }
	// your code goes here
	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;

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

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

	int k[10];
	int s[10][10];
	rep(i,M){
		cin >> k[i];
		rep(j,k[i]){
			cin >> s[i][j];
		}
	}

	int p[10];
	rep(i,M) cin >> p[i];

	int ans = 0;
	bool flag = true;


	rep(i,pow(2, N)){
		flag = true;
		rep(j,M){
			int num=0;
			rep(l,k[j]){
				if(i & (1 << (s[j][l]-1))) num += 1;
				//cout << i << j << l << num << endl;
			}

			if(p[j] != num%2){
				flag = false;
				break;
			}
		}

		if(flag) {
			ans ++;
			//cout << "fa" << endl;
		}
	}

	cout << ans << endl;


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	char a;
	cin >> a;
	if ('a' <= a && a <= 'z')
	{
		cout << 'a' << endl;
	}
	else
	{
		cout << 'A' << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i,n) for(int i(0);i<n;++i)
 
int main(){
	int n;
	cin >> n;
	cout << n*n*n; 
}



Measured memory_bytes: 256
(defn create-data [s]
  (map #(Long/parseLong %) (.split s " ")))

(defn pizza [[a b c x y] z]
  (->>
   (+ (* a (max 0 (- x z)))
      (* b (max 0(- y z)))
      (* 2 c z))))

(defn halfAndHalf [[a b c x y]]
  (->>
   (for [i (range (max (inc x) (inc y)))
         :let [onedan ((partial pizza [a b c x y]) i)]]
     onedan)
   (apply min)
   ))

(println (halfAndHalf (create-data (read-line))))


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

const int MAX_MAP = 12;
const int x2[4] = {0,1,0,-1}, y2[4] = {1,0,-1,0};
char island[MAX_MAP+1][MAX_MAP+1];


void island_clear(int x, int y){
	island[x][y] = '0';
	for(int i=0; i<4; i++){
		int next_x = x+x2[i], next_y = y+y2[i];
		if(next_x >= 0 && next_x < MAX_MAP && next_y >= 0 && next_y < MAX_MAP && island[next_x][next_y] == '1'){
			island_clear(next_x,next_y);
		}
	}
}

void count(){
	int count=0;
	
	for(int i=0; i<MAX_MAP; i++){
		for(int j=0; j<MAX_MAP; j++){
			if(island[i][j] == '1'){
				island_clear(i,j);
				count++;
			}
		}
	}
	cout << count << endl;
}

int main(){
	string s;
	while(scanf("%s", island[0]) != EOF){
		for(int i=1; i<MAX_MAP; i++){
			scanf("%s", island[i]);
		}
		count();
	}
}

Measured memory_bytes: 0
import itertools
n,*s=open(0).read().split()
d={'M':0,'A':0,'R':0,'C':0,'H':0}
for i in s:
    k=i[0]
    if k in d:
        d[k]+=1
p=0
for i,j,k in itertools.combinations(d.values(),3):
    p+=i*j*k
print(p)

Measured memory_bytes: 10864
divisor = 10**9 + 7

def frac(n):
  sum = 1
  for i in range(1,n+1):
    sum = sum * i % divisor
  return sum

import sys,fractions
N,M=map(int,input().split(' '))
# abs(N-M) > 1なら無理
if (abs(N-M) > 1):
  print(0)
  sys.exit()

# それぞれの階乗を求める
frac_n = frac(N)
frac_m = frac(M)

if N == M:
  ans = frac_m * frac_n * 2
else:
  ans = frac_n * frac_m

print(ans % (10**9 + 7))

Measured memory_bytes: 5304
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s;
    cin >> s;
    if( s == "Sunny" ) cout << "Cloudy";
    if( s == "Cloudy" ) cout << "Rainy";
    if( s == "Rainy" ) cout << "Sunny";
    cout << endl;
    return 0;
}



Measured memory_bytes: 764
#include<stdio.h>
#include<string.h>


int main()
{
    char a[1000];
    scanf("%s",a);
    if(strcmp(a,"Sunny")==0){
        printf("Cloudy\n");
    }
    else if(strcmp(a,"Cloudy")==0){
        printf("Rainy\n");
    }
   else if(strcmp(a,"Rainy")==0){
        printf("Sunny\n");
    }
}





Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool S1[100001];
bool S2[100001];

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

	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') S1[i] = S2[i] = true;
	}

	int ans1 = 0, ans2 = 0;

	// 0番目を0にする場合
	if (S1[0] != false) {
		S1[0] = false;
		ans1++;
	}
	for (int i = 1; i < S.size(); i++) {
		if (S1[i] == S1[i - 1]) {
			S1[i] = !S1[i - 1];
			ans1++;
		}
	}

	// 0番目を1にする
	// 0番目を0にする場合
	if (S2[0] != true) {
		S2[0] = true;
		ans2++;
	}
	for (int i = 1; i < S.size(); i++) {
		if (S2[i] == S2[i - 1]) {
			S2[i] = !S2[i - 1];
			ans2++;
		}
	}

	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 720
#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; }

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<char, int>> cnt;
    cnt.emplace_back('1', 0);
    rep(i, n) {
        if (s[i] != cnt.back().first) cnt.emplace_back(s[i], 0);
        cnt.back().second++;
    }
    if (cnt.back().first == '0') cnt.emplace_back('1', 0);
    int l = 0, r = 0, ans = 0, len = 0, sum = 0;
    while (l<sz(cnt) && r<sz(cnt)) {
        while (len<k || (len==k&&cnt[r-1].first=='0')) {
            ++r;
            sum += cnt[r-1].second;
            if (r >= sz(cnt)) break;
            if (cnt[r-1].first == '0') ++len;
        }
        ans = max(ans, sum);
        if (l >= sz(cnt)) break;
        ++l; sum -= cnt[l-1].second;
        ++l; sum -= cnt[l-1].second;
        --len;
    }
    cout << ans << endl;
    return 0;
}


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



int main() {
  ll MX = 1e18;
  int n;
  cin >> n;
  ll ans = 1;
  bool flag = false;
  rep(i,n) {
    ll a;
    cin >> a;
    if(a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (flag || MX/ans < a) {
      flag = true;
    }
    ans *= a;
  }
  if (flag) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToList();
            var b = a.OrderBy(x => x).ToList();
            int low = b[n / 2 - 1];
            int high = b[n / 2];
            for(int i = 0; i < n; i++)
            {
                if (a[i] < high) Console.WriteLine(high);
                else Console.WriteLine(low);
            }
        }
    }
}

Measured memory_bytes: 39300
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int m = readint;
    writeln(48 - m);
}


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

int main() {
  int a[5];
  int k;
  int flag=0;
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  cin>>k;
  for(int i=0;i<5;i++){
  for(int j=i+1;j<5;j++){
  if((a[j]-a[i])>k){
    flag++;
  }
  }
  }
 if(flag){
  cout<<":(";
 }
  else{
  cout<<"Yay!";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    ll l,r;
    cin >> l >> r;
    int ret = 0;
    if ((l/2019 == r/2019)&&(l%2019 != 0)) {
        ret = 2018;
        ll s = l % 2019;
        ll f = r % 2019;
        for (ll i = s; i <= f; i++) {
            for (ll j = i + 1; j <= f; j++) {
                if (i * j % 2019 < ret) {
                    ret = i * j % 2019; 
                }
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 1;
int n, a[MAX] = {0}, b[MAX] = {0};
string s;
int main () {
    
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> s;
    
    for (int i = 0; i < n; i++) {
        a[i+1] = a[i] + (s[i] == '#');
        b[i+1] = b[i] + (s[i] == '.');
    }
    
    int ans = n;
    
    for (int i = 0; i <= n; i++) {
        int result = a[i] + (b[n] - b[i]);
        if (ans > result)   ans = result;
    }
    
    cout << ans;
    
    return 0;
}

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

int main(){
  int n;
  double t, a;
  cin >> n;
  cin >> t >> a;
  double h[n];
  for (int i = 0; i<n ;i++){
    cin >> h[i];
  }

  double top = h[0];
  double topi = 0;
  for (int i = 0; i<n; i++){
    double toptemp;
    double comptemp;
    toptemp = abs(t - (top*0.006) -a);
    comptemp = abs(t - (h[i]*0.006) -a);
    if (comptemp < toptemp){
      top = h[i];
      topi = i;
    }
  }
  cout << topi+1;
}


Measured memory_bytes: 256
import sys
import math
import heapq
from collections import defaultdict, deque
from decimal import *
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

ac=0;wa=0;tle=0;re=0
for _ in range(r()):
    s=input()
    if s=="AC":
        ac+=1
    elif s=="WA":
        wa+=1
    elif s=="TLE":
        tle+=1
    else:
        re+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x", re)

Measured memory_bytes: 74580
S = input().strip()
C = {}
for i in range(4):
    a = S[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
C = list(C.items())
if len(C)==2 and C[0][1]==2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007

#define int long long

void solve()
{
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  vector<int> DC;
  DC.push_back(0);
  for (int i = 1; i < S.size(); i++)
  {
    if(S[i] != S[i-1]) DC.push_back(i);
  }
  DC.push_back(N);

  // for (int i = 0; i < N; i++)
  // {
  //   cout<<DC[i]<<endl;
  // }

  vector<int> MAX(DC.size(),0);
  int MAX_Suf = DC.size() -1 ;

  for (int i = 0; i < DC.size() -1 ; i++)
  {
    int suf_b = DC[i];

    if(S[suf_b] == '1')
    {
      MAX[i] = -1 * DC[i] + DC[min(MAX_Suf,i + 2*K+1)];
    } 
    else
    {
      MAX[i] = -1 * DC[i] + DC[min(MAX_Suf,i + 2*K)];      
    }
  }

  std::vector<int>::iterator iter = std::max_element(MAX.begin(), MAX.end());
  size_t index = distance(MAX.begin(), iter);

  cout<<MAX[index]<<endl;

  
  
  
  

}
 
int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long A[int(2e5)+5];
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>A[i];
	}
	long long alsum=0,sum=0;
	for(int i=1;i<=n;++i){
		alsum+=A[i];
	}
	long long less=0; 
	for(int i=1;i<=n-1;++i){
		less+=A[i];
		sum+=A[i]%mod*((alsum-less)%mod);
		sum%=mod;
	} 
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i * i < n; i++)
	{
		if(n % i == 0 && i < (n / i - 1))
		{
			ans += (n / i - 1);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int lcm(int a,int b){return a%b==0?(b):lcm(b,a%b);}
int main(void){
	int N;
		cin >> N;
	int lcme;
		cin >> lcme;
	for(int i=1;i<N;i++){
		int a;
			cin >> a;
		lcme=lcm(max(lcme,a),min(a,lcme));
	}
	cout << lcme << endl;
	return 0;
}

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

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


  int cnt=0;
  for(int x =a; x <=b; x++){
  if(c % x == 0) cnt++;
}

  cout<<cnt<<endl;


  return 0;
}


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

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  if( (B/K - A/K) > 0 || B%K == 0 || A%K == 0) cout << "OK";
  else cout << "NG";
  return 0;
}

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

int main()
{
    int n,m;
    cin>>n>>m;
    if(n==1)
    {
        n=14;
    }
    if(m==1)
    {
        m=14;
    }
    if(n==m)
    {
        cout<<"Draw"<<endl;

    }
    else if(n<m)
    {
        cout<<"Bob";
    }
    else
    {
        cout<<"Alice"<<endl;


    }
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,n,t,p=0,ara[2000];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>ara[i];
    }
    for(i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            p+=ara[i]*ara[j];
        }
    }
    cout<<p<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 
	public static void main(String[] args) {  
		Scanner input = new Scanner(System.in);
		int R = input.nextInt();
		int C = input.nextInt();
		int N = input.nextInt();
		int[] arr = new int[N+1];
		int[][] ans = new int[R][C];
		for (int i = 1; i <= N; i++) {
			arr[i] = input.nextInt();
		}
		int index = 1;
		for (int r = 0; r < R; r++) {
			if (r%2==0) {
				for (int c = 0; c< C; c++){
					ans[r][c]=index;
					arr[index]--;
					if (arr[index]==0) index++;
				}
			}else {
				for (int c = C-1; c>=0; c--) {
					ans[r][c]=index;
					arr[index]--;
					if (arr[index]==0) index++;
				}
			}
		}
		for (int i = 0; i < R; i++) {
			for (int j = 0; j < C; j++) {
				System.out.print(ans[i][j]+" ");
			}
			System.out.print("\n");
		}
	}
}


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

#include <cstdio>
#include <cstdlib>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

class mint{
public:
  ll x;
  mint(ll x=0) : x(x%mod){}
  mint& operator+=(const mint rhs){
    x += rhs.x;
    while(x >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint rhs){
    x -= rhs.x;
    while(x < 0) x += mod;
    return *this;
  }
  mint & operator*=(const mint rhs){
    (x *= rhs.x) %= mod;
    return *this;
  }
  mint operator+(const mint rhs) const {
    mint res(*this);
    return res += rhs;
  }
  mint operator-(const mint rhs) const {
    mint res(*this);
    return res -= rhs;
  }
  mint operator*(const mint rhs) const {
    mint res(*this);
    return res *= rhs;
  }
  friend ostream& operator<<(ostream& os,const mint rhs){
    os << rhs.x;
    return os;
  }
};

#define rep(index,num) for(int index=0;index<num;++index)

int main(){
  string  S;
  std::cin >> S;
  sort(S.begin(),S.end());
  if(S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
# G[i][j]: 頂点v_iから頂点v_jへ到達するための辺コストの和
# クラスにしてしまったけど、これ遅いのでクラスじゃ無い方が良い
class Warshall_Floyd:
    def __init__(self, V):
        self.V = V
        self.G = [[float('inf')] * self.V for i in range(self.V)]

    def add_edge(self, fr, to, cost):
        self.G[fr][to] = cost

    def add_multi_edge(self, v1, v2, cost):
        self.G[v1][v2] = cost
        self.G[v2][v1] = cost

    def solve(self):
        for i in range(self.V):
            self.G[i][i] = 0
        for k in range(self.V):
            for i in range(self.V):
                for j in range(self.V):
                    if self.G[i][k] != float("inf") and self.G[k][j] != float('inf'):
                        self.G[i][j] = min(self.G[i][j], self.G[i][k] + self.G[k][j])

    def if_negative(self):
        for i in range(self.V):
            if self.G[i][i] < 0:
                return True
        return False

    def dist(self, fr, to):
        return self.G[fr][to]


G = Warshall_Floyd(10)

H, W = map(int, input().split())
for i in range(10):
    for j, c in enumerate(input().split()):
        G.add_edge(i, j, int(c))
G.solve()


ans = 0
for i in range(H):
    for j, a in enumerate(input().split()):
        if a != "-1":
            ans += G.dist(int(a), 1)

print(ans)

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(S == U){
    A--;
  }
  if(T == U){
    B--;
  }  
  cout << A << " " << B << endl;
}

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

int main(){
	int n,m,i,j,num = 0,add;
	cin >> n;
	cin >> m;
	int s[m],c[m],ans[n];
	for(i = 0; i < m; i++){
		cin >> s[i];
		cin >> c[i];
	}
	for(i = 0; i < n; i++){
		ans[i] = 10;
	}
	for(i = 0; i < m; i++){
		if(ans[s[i] - 1] > 9){
			ans[s[i] - 1] = c[i];
		}
		else if(ans[s[i] - 1] != c[i]){
			num = -1;
			break;
		}
	}

	if(n == 1){
		if(ans[0] > 9){
			ans[0] = 0;
		}
	}
	else{
		if(ans[0] > 9){
			ans[0] = 1;
		}
		for(i = 1; i < n; i++){
			if(ans[i] > 9){
				ans[i] = 0;
			}
		}
	}
	if(n > 1){
		if(ans[0] == 0){
			num = -1;
		}
	}

	if(num != -1){
		for(i = 0; i < n; i++){
			add = ans[i];
			for(j = 0; j < n - i -1; j++){
				add = add*10;
			}
			num = num + add;
		}
		cout << num;
	}
	else{
		cout << num;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
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 isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
   q.empty();
*/
//座標　corrdinateト深さヲ保持スルタメノ構造体
struct Coor{
  ll y;
  ll x;
  ll depth;
};
 ll N,M;  
 ll sy,sx,gy,gx;
 ll y,x,depth;//キューから取り出した座標
vector<string> vec;
queue<Coor> q;
vector<ll> y_vec={0,0,-1,+1};//technique
vector<ll> x_vec={-1,+1,0,0};

int BFS(){
  while(!q.empty()){
    Coor now=q.front();q.pop();//キューの先頭を取り出す
    y=now.y,x=now.x,depth=now.depth;
    
    //停止条件
    if(y==gy&&x==gx){return depth;}
    
    //上下左右４方向を探索、進むことができればキューに格納
    for(int i=0;i<4;i++){
      Coor next={y+y_vec[i],x+x_vec[i],depth+1};
      if(0<=next.y&&next.y<=N-1&&0<=next.x&&next.x<=M-1&&vec[next.y][next.x]=='.'){
        vec[next.y][next.x]='x';//同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}
                   
  


int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);


  int x,a,b;cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b)){cout<<'A'<<endl;
                       }else{cout<<'B'<<endl;}
  
  
  
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int ai,bi;
  ai = 0;
  bi = 0;
  char a[11],b[11],c[11];
  scanf("%s %s %s",a,b,c );
  while(a[ai] != '\0'){
    ai += 1;
  }
  ai -= 1;
  while(b[bi] != '\0'){
    bi += 1;
  }
  bi -= 1;
  if(a[ai] == b[0] && b[bi] == c[0]){
    printf("%s\n","YES" );
  }
  else{
    printf("%s\n", "NO");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		char[][] moji = new char[n][10];
		
		for(int i = 0; i < n; i++) {
			moji[i] = stdIn.next().toCharArray();
			Arrays.sort(moji[i]);
		}
		
		
		String[] tmp = new String[n];
		
		for(int i = 0; i < n; i++) {
			tmp[i] = String.valueOf(moji[i]);
		}
		
		Arrays.sort(tmp);
		

		
		long ans = 0;
		
		long cnt = 1;
		for(int i = 0; i < n-1; i++) {
			if(tmp[i].equals(tmp[i+1])) {
				cnt++;
			}else {
				ans += cnt*(cnt-1)/2;
				cnt = 1;
			}
			
			
			
		}
		if(cnt != 1) {
			ans += cnt * (cnt-1)/2;
		}
		
		System.out.println(ans);
		
		
	}

}

Measured memory_bytes: 55272
let is_prime n = match n with
    2|3|5 -> true
    | n when n mod 2 = 0 -> false
    | n when n mod 3 = 0 -> false
    | n ->
       let rec loop i =
         if i*i > n then (if n <= 25 && (n mod 5 = 0) then false else true)
         else if n mod i = 0 then false
         else if n mod (i+2) = 0 then false
         else loop (i+6);
       in loop 5

let () =
  let n = read_int () in
  let rec read ct = function
      0 -> ct
    | i ->
       let m = read_int () in
       read (if is_prime m then ct+1 else ct) (i-1)
  in
  Printf.printf "%d\n" (read 0 n)

Measured memory_bytes: 3024