akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, k, ans = INT_MAX, cnt;
vector<int> v[N];

void dfs(int x, int back, int dep, int lim) {
	if(dep == lim + 1)
		return;
	cnt++;
	for(auto i : v[x])
		if(i != back)
			dfs(i, x, dep + 1, lim);
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> n >> k;
	for(int i = 1; i <= n - 1; i++) {
		int a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	for(int i = 1; i <= n; i++){
		if(k % 2 == 0) {
			cnt = 0;
			dfs(i, 0, 0, k / 2);
			ans = min(ans, n - cnt);
		}
		else {
			for(auto j : v[i]) {
				cnt = 0;
				dfs(i, j, 0, (k - 1) / 2);
				dfs(j, i, 0, (k - 1) / 2);
				ans = min(ans, n - cnt);
			}
		}
	}
	cout << ans;
}

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


int N,K,X,Y,res;

int main(){
  cin>>N>>K>>X>>Y;
  for(int i=1; i<=N; ++i){
    if(i<=K)
      res+=X;
    else res+=Y;
  }
  cout<<res<<endl;
  return 0;
}

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

int main(){
    ll N;cin >> N;
    vector<ll> A(5);

    rep(i,5){
        cin >> A[i];
    }

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

    if(N % A[0] == 0){
        cout << (N/A[0]) + 4 << endl;
    }

    else{
        cout << (N/A[0]+1) + 4 << endl;
    }
}

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

int main() {
	int n, num;
	string s;
	int card[4][52];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			card[i][j] = 1;
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s >> num;
		if (s == "S") {
			card[0][num - 1] = 0;
		} else if (s == "H") {
			card[1][num - 1] = 0;
		} else if (s == "C") {
			card[2][num - 1] = 0;
		} else if (s == "D") {
			card[3][num - 1] = 0;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (i == 0 && card[i][j] == 1) {
			cout << "S " << j + 1 << endl;
			} else if (i == 1 && card[i][j] == 1) {
			cout << "H " << j + 1 << endl;
			} else if (i == 2 && card[i][j] == 1) {
			cout << "C " << j + 1 << endl;
			} else if (i == 3 && card[i][j] == 1) {
			cout << "D " << j + 1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1208
class Dice

  def initialize(surfaces)
    @surfaces = surfaces.dup 
  end

  def top
    @surfaces[0]
  end

  def front
    @surfaces[1]
  end

  def right
    @surfaces[2]
  end

  def N
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[1]
    @surfaces[1] = @surfaces[5]
    @surfaces[5] = @surfaces[4]
    @surfaces[4] = tmp
    self
  end

  def E
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[3]
    @surfaces[3] = @surfaces[5]
    @surfaces[5] = @surfaces[2]
    @surfaces[2] = tmp
    self
  end

  def S
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[4]
    @surfaces[4] = @surfaces[5]
    @surfaces[5] = @surfaces[1]
    @surfaces[1] = tmp
    self
  end

  def W
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[2]
    @surfaces[2] = @surfaces[5]
    @surfaces[5] = @surfaces[3]
    @surfaces[3] = tmp
    self
  end

  def adjust_front(front)
    return unless has_value?(front)

    4.times do
      self.N
      return if self.front == front
    end

    self.E
    adjust_front(front)
  end

  def equal_surfaces(other)
    (0..5).all?{|n| surface_val(n) == other.surface_val(n) }
  end

  def surface_val(num)
    @surfaces[num]
  end

  def has_value?(v)
    @surfaces.include?(v)
  end
end

def is_equal_dice(dice1, dice2)
  dice2.adjust_front(dice1.front)

  4.times do
    dice2.E
    return true if dice1.equal_surfaces(dice2)
  end

  false
end

n = gets.chomp.to_i
dices = []
n.times do |i|
  dices << Dice.new(gets.chomp.split.map(&:to_i))
end

dices.permutation(2) do |dice1, dice2|
  if is_equal_dice(dice1, dice2)
    puts 'No'
    exit
  end
end

puts 'Yes'

Measured memory_bytes: 8836
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int a[3],b[3],i,ans=0;
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  b[0] = abs(a[0]-a[1]);
  b[1] = abs(a[1]-a[2]);
  b[2] = abs(a[2]-a[0]);
  
  qsort(b,3,sizeof(int),cmp);
  
  for(i=0;i<2;i++){
    ans+=b[i];
  }
  
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,k,n) for(int i=k;i<n;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n and n>0){
		int dp[50]; rep(i,50) dp[i]=0;
		dp[0]=1;
		rep(i,n+1){
			if(i==1) dp[i]=dp[i-1];
			if(i==2) dp[i]=dp[i-1]+dp[i-2];
			if(i>2) dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
		}
		cout<<(dp[n]-1)/3650+1<<endl;;
	}
	return 0;
}



Measured memory_bytes: 3052
n, k = gets.split.map(&:to_i)
count = Hash.new(0)
n.times do
    p = gets.chomp
    count[p[0]] += 1
end
ret = 0
loop do
    b = false
    count = count.sort{|(k1, v1), (k2, v2)| v2 <=> v1 }
    break if count.size < k
    k.times do |i|
        if count[i][1] > 0
            count[i][1] -= 1
        else
            b = true
            break
        end
    end
    break if b
    ret += 1
end
p ret

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

int main(void){
	while(true){
		string s;
		getline(cin,s); // getline() is 便利 -> http://www.ci.seikei.ac.jp/matsumoto/opro/05.pdf
		if(s[0]=='.') break;
		stack<char> st; // push() -> top() -> pop()
		bool err = false;
		for(int i = 0; i < s.size(); ++i){
			if(s[i] == '(' || s[i] == '['){
				st.push(s[i]);
			}else if(s[i] == ')' || s[i] == ']'){
				if(st.empty() || s[i] != (st.top()=='('?')':']')){
					err = true;
					break;
				}else{
					st.pop();
				}
			}
		}
		if(!err && st.empty()){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3188
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

template <class T>
struct fenwick_tree {
  vector<T> x;
  fenwick_tree(int n) : x(n, 0) { }
  T sum(int i, int j) {
    if (i == 0) {
      T S = 0;
      for (; j >= 0; j = (j & (j + 1)) - 1) S += x[j];
      return S;
    } else return sum(0, j) - sum(0, i-1);
  }
  void add(int k, T a) {
    for (; k < x.size(); k |= k+1) x[k] += a;
  }
};

int main(){
	int n,q,c,x,y;
	scanf("%d%d",&n,&q);
	fenwick_tree<long long> f(n);
	for(;q--;){
		scanf("%d%d%d",&c,&x,&y);
		if(c)printf("%lld\n",f.sum(x-1,y-1));
		else f.add(x-1,y);
	}
}

Measured memory_bytes: 1796
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    long    N, kind=1;
    char    pool[200001][16] = {0};

    //全データ取得
    scanf("%ld", &N);
    for(int i=0; i<N; i++){ scanf("%s", pool[i]); }

    //ソート
    qsort( pool, N, 16, strcmp );

    //カウント
    for(int j=0; j<N-1; j++){
        if( strcmp(pool[j], pool[j+1]) != 0 ){ kind++; }
    }
    printf("%ld\n", kind);
    return 0;
}

Measured memory_bytes: 7592
#include<stdio.h>
#include<iostream>
using namespace std;
typedef long long LL;
const int maxn=1077;
const int INF=1E9+77;

int N,A[maxn];
bool flag=false;

bool X[maxn];
int Ne[maxn],out[maxn],co;
void finish(){
	co=0;
	Ne[0]=-1;
	for(int i=1;i<N;++i){
		if(X[i-1]) Ne[i]=i-1;
		else Ne[i]=Ne[i-1];
	}

	LL s=0;
	for(int i=0;i<N;++i) if(X[i]) s+=A[i];
	cout<<s<<endl;

	int i;
	for(i=N-1;!X[i];--i){
		out[co++]=i;
	}

	while(i && Ne[i]>=0){
		for(i-=2;!X[i];i-=2){
			out[co++]=i;
		}
		out[co++]=i+1;
	}

	for(int j=0;j<i;++j) out[co++]=0;

	printf("%d\n",co);
	for(int i=0;i<co;++i) printf("%d\n",out[i]+1);
}

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;++i){
		scanf("%d",A+i);
		if(A[i]>0) flag=true;
	}
	if(!flag){
		int ma=-INF,x;
		for(int i=0;i<N;++i) if(A[i]>ma){
			ma=A[i];
			x=i;
		}
		X[x]=true;
		finish();
		return 0;
	}
	int D;
	LL V=-INF;
	for(int d=0;d<2;++d){
		LL v=0;
		for(int i=d;i<N;i+=2){
			if(A[i]>0) v+=A[i];
		}
		//cerr<<"v:"<<v<<endl;
		//cerr<<"V:"<<V<<endl;
		if(v>V){
			V=v;
			D=d;
		}
	}

	//cerr<<"D:"<<D<<endl;
	for(int i=D;i<N;i+=2) if(A[i]>0) X[i]=true;
	finish();
	return 0;
}


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

using namespace std;

int dist(int x0, int y0, int x1, int y1){
    return abs(x0-x1)+abs(y0-y1);
}

int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);

    for (int i = 0; i<N; i++){
        cin >> x.at(i) >> y.at(i) >> h.at(i);
    }
/*
    int j=0;
    while(h.at(j)==0) j++; 
 //C_XとC_Yを動かす

    for (int C_X=0; C_X<=100; C_X++){
        for(int C_Y=0; C_Y<=100; C_Y++){
            int H = h.at(j) + abs (x.at(j)-C_X)+ abs (y.at(j)-C_Y);
            for(int i=0; i<N; i++){
                int HH = H - abs (x.at(i)-C_X) - abs (y.at(i)-C_Y);
                if(H != HH) break;
                if(i=N-1){
                    cout << x.at(i) << " " << y.at(i) << " " << H << endl;
                }
            }
        }
    }
*/
    for(int C_X =0; C_X <= 100; C_X++){
        for(int C_Y=0; C_Y <=100; C_Y++){
            int needH = -1; 
            //needH =-1なら未確定。0以上なら確定
            //needH =-2ならダメ

            for(int i=0; i<N; i++){
                if(h.at(i)>0){
                    int tmp = h.at(i)+dist(C_X, C_Y, x.at(i), y.at(i));
                    if(needH == -1) needH =tmp;
                    else{
                        if(needH != tmp){
                            needH=-2;
                            break;
                        }
                    } 
                }
            }
            if(needH==-2) continue;
            for(int i=0; i<N; i++){
                if(h.at(i)==0){
                    if(needH - dist(C_X, C_Y, x.at(i), y.at(i)) > 0 ) needH =-2;
                }
            }
            if(needH == -2) continue;
            cout << C_X << " " << C_Y << " " << needH << endl;
        }
    }

}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力


		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a >= 13){
			System.out.println(b);
		}else if(6 <= a && a <= 12){
			System.out.println(b/2);
		}else{
			System.out.println(0);
		}
	}


	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}





}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 21716
N = int(input())
ps = [int(i) for i in input().split(" ")]
probe = list(range(1,N+1))
checker = [1 if probe[i]!=ps[i] else 0 for i in range(N)]
if sum(checker)==0 or sum(checker)==2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
    if(a.fi==b.fi)return a.se>b.se;
    return a.fi>b.fi;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n,k; cin>>n>>k;
vi arr(n);
rep(i,0,n)cin>>arr[i],arr[i]--;
vi vis(n,-1);
ll curr = 0,mv = 0;
while(1)
{
    if(vis[curr]==-1)vis[curr] = mv;
    else break;
    if(mv==k)
    {
        cout<<curr+1<<endl;
        return 0;
    }
    curr = arr[curr];
    mv++;
}
if(vis[curr]-mv==0)
{
    cout<<curr+1<<endl;
    return 0;
}
//cout<<mv<<" "<<vis[curr]<<endl;
k-=(vis[curr]);
k%=(mv-vis[curr]);
if(k==0)
{
    cout<<curr+1<<endl;
    return 0;
}
//cout<<k<<endl;
while(1)
{
    if(k==0)
    {
        cout<<curr+1<<endl;
        break;
    }
    curr = arr[curr];
    k--;
}
return 0;
}


Measured memory_bytes: 6368
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
#include <functional>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <set>
#include <queue>
#include <map>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	long long a=k;
	for(int i=1;i<n;i++){
		a=a*(k-1);
	}
	cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
  string s;
  string tmp;
  string bef,aft;
  int res=0;
 
  cin>>s;
 
  if(s.size()%2==0)
  {
    s.pop_back();
    s.pop_back();
  }
  else
  {
    s.pop_back();
  }
 
  for(int i=s.size();i>0;i-=2)
  {
    for(int j=0;j<i;j++)
    {
      tmp+=s[j];
    }
 
    bef = tmp.substr(0,tmp.size()/2);
    aft = tmp.substr(tmp.size()/2);
 
    if(bef==aft)
    {
      cout<<i<<endl;
      break;
    }
    tmp="";
    bef="";
    aft="";
  }
}

Measured memory_bytes: 256
//                                                   ¯\_(ツ)_/¯
  //#pragma GCC optimize("Ofast")
 //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pi pair<int,int>
const int N=1e6+5,MOD=1e9+7;

using namespace std;

int n;
ll dp[3005][3005];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	
	scanf("%d",&n);

	std::vector<int> a(n+1);

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

	for(int l=n;l>=1;l--){

		for(int r=l;r<=n;r++){
			if((l-1+n-r)%2==0)
				dp[l][r]=max(a[l]+dp[l+1][r],a[r]+dp[l][r-1]);
			else
				dp[l][r]=min(-a[l]+dp[l+1][r],-a[r]+dp[l][r-1]);
		}
	}

	printf("%lld\n",dp[1][n] );

}

Measured memory_bytes: 70016
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < 5; i++) {
			list.add(sc.nextInt());
		}
		System.out.println(list.indexOf(0) + 1);
	}
}


Measured memory_bytes: 35812
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;string s;int cnt=0;
	cin>>n>>s;
	for(int i=0;i+2<s.size();i++) {
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
			cnt++;
		}
	} 
	cout<<cnt;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>

int H,W;
char S[410][410];
int visited[410][410];
long long ans=0;
long long black,white;
int vx[4]={0,1,0,-1};
int vy[4]={1,0,-1,0};

void solve(int x,int y){
	if(visited[x][y]==1)return;
	
	char t;
	if(S[x][y]=='#'){
		t='.';
		black++;
	}else {
		t='#';
		white++;
	}
	visited[x][y]=1;
	
	for(int k=0;k<4;k++){
		int X=x+vx[k];
		int Y=y+vy[k];
		if(0<=X && X<H && 0<=Y && Y<W && S[X][Y]==t)solve(X,Y);
	}
	return;
}

int main(){
	scanf("%d%d",&H,&W);
	for(int i=0;i<H;i++)scanf("%s",S[i]);
	
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		black=white=0;
		solve(i,j);
		ans+=black*white;
	}
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)



void solve(){
  long double l;
  cin >> l;
  long double v = (l*l*l)/27;
  std::cout << std::fixed << std::setprecision(20);
  cout << v << endl;
}

int main(void){
  solve();
  return 0;
}

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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  int n1 = a1.size();
  int n2 = a2.size();
  if (n1 != n2) {
    return n1 - n2;
  }
  for (int i=0; i<n1; i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

vector<vector<int>> all_comb(int n, int k) {
  vector<vector<int>> combs(nCr(n, k), vector<int>(k));
  for(int i=0; i<k; i++) {
    combs[0][i] = i;
    combs[1][i] = i;
  }
  
  for(long i=1; i<nCr(n, k); i++) {
    int p = 1;
    while(combs[i][k - p] == n - p) {
      p++;
      if(p > k) {
        break;
      }
    }
    combs[i][k - p]++;
    int q = combs[i][k - p];
    for(int j=1; j<p; j++) {
      combs[i][k - p + j] = q + j;
    }

    if(i < nCr(n, k) - 1) {
      for(int j=0; j<k; j++) {
        combs[i + 1][j] = combs[i][j];
      }
    }
  }

  return combs;
}

template <typename TYPE> void co(TYPE a) {
  cout << a << endl;
}

template <typename TYPE> void co_2(TYPE a, TYPE b) {
  cout << a << ' ' << b << endl;
}

template <typename TYPE> void co_l(vector<TYPE> as) {
  int n = as.size();
  for(int i=0; i<n; i++) {
    cout << as[i] << endl;
  }
}

template <typename TYPE> void co_s(vector<TYPE> as) {
  int n = as.size();
  for(int i=0; i<n; i++) {
    if(i > 0) {
      cout << ' ';
    }
    cout << as[i];
  }
  cout << endl;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;
  vector<long> a(n + 1, 0);
  vector<long> p(n);

  long ans = 0;
  for(int i=0; i<n; i++) {
    cin >> p[i];
    ans += a[p[i]];
    a[p[i]]++;
  }

  for(int i=0; i<n; i++) {
    cout << ans - a[p[i]] + 1 << endl;
  }
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<bool> vb;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200007, M = N;
int i,j,idx,cnt,par;


void solve() {
    string s;
    cin>>s;

    int n = s.length();
    vi vec(n+1 , 0);

    int cnt[2],idx = -1;
    cnt[0] = 0;
    cnt[1] = 0;
    char c = 'R';

    fo(i,0,n) {
        if(s[i] == c) cnt[i%2]++;
        else {
            if(s[i] == 'L') {
                idx = i - 1;
                vec[idx] += cnt[idx%2];
                vec[idx+1] += cnt[(idx+1)%2];
            }
            else {
                vec[idx]+=cnt[idx%2];
                vec[idx+1]+=cnt[(idx+1)%2];
            }
            cnt[0] = 0;
            cnt[1] = 0;
            cnt[i%2]++;
            c = s[i];
        }
    }
    vec[idx]+=cnt[idx%2];
    vec[(idx+1)]+=cnt[(idx+1)%2];

    for(int i=0;i<n;i++) cout<<vec[i]<<" ";

    cout<<"\n";

}

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

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




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

int main() {
  
  int n;
  char str[9] = "";
  cin >> str;
  n = atoi(str);
  int x = 0;
  for(int i = 0; i < 9; i++) {
    char c = str[i];
    if(c == '\0') 
      break;
    char tmp[2] = {c, '\0'};
    x += atoi(tmp);
  }
  if((n % x) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;

double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

bool compare(pair <int, int> x, pair <int, int> y) {
  return x.second < y.second;
}

int main() {
  int n, k, s; cin >> n >> k >> s;
  for(int i = 0; i < k; i++) {
    cout << s << ' ';
  }
  int nxt = s == 1000000000 ? s - 1 : s + 1;
  for(int i = k; i < n; i++) {
    cout << nxt << ' ';
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL X;cin>>X;
    int K;cin>>K;
    LL r[K+1];REP(i,K)cin>>r[i+1];
    r[0]=0;

    LL sum[K+1];
    sum[0]=0;
    REP(i,K)sum[i+1]=sum[i]+(r[i+1]-r[i])*(i%2==0 ? 1:-1);
    pair<LL,LL> range[K+1];
    range[0]={0LL,X};

    REP(i,K){
        range[i+1].first=range[i].first;range[i+1].second=range[i].second;
        if(i%2==0)range[i+1].first=max(range[i+1].first,sum[i+1]);
        else range[i+1].second =min(range[i+1].second,X+sum[i+1]);
    }

    LL a0[K+1];a0[0]=0;
    LL ax[K+1];ax[0]=X;

    REP(i,K){
        a0[i+1]=a0[i]+(r[i+1]-r[i])*(i%2==0 ? -1:1);
        a0[i+1]=max(0LL,a0[i+1]);
        a0[i+1]=min(X,a0[i+1]);

    }

    REP(i,K){
        ax[i+1]=ax[i]+(r[i+1]-r[i])*(i%2==0 ? -1:+1);
        ax[i+1]=max(0LL,ax[i+1]);
        ax[i+1]=min(X,ax[i+1]);
    }

    int q;cin>>q;
    REP(i,q){
        LL t,a;cin>>t>>a;
        LL ans=0;
        int k = upper_bound(r,r+K+1,t)-r -1;
        if(a>range[k].first&&a<range[k].second)ans = a - sum[k];
        else if(a<=range[k].first)ans = a0[k];
        else ans = ax[k];

        ans += (t-r[k])*(k%2 ==0 ? -1:1);
        ans = max(0LL,ans);
        ans = min(X,ans);

        cout<<ans<<endl;

    }

    return 0;
}

Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		String st = s + t;
		int count = 0;
		if (s.length() != t.length() - 1) {
			count++;

		}
		char[] s1 = s.toCharArray();
		char[] t1 = t.toCharArray();
		for (int i = 0; i < s1.length; i++) {
			if (s1[i] != t1[i]) {
				count++;
			}
		}

		if (count == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 27008
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  if(n % 2 == 0) cout << n;
  else cout << n * 2 << endl;
}






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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    using P = pair<i64, i64>;
    vector<P> A(N);
    set<i64> le;
    REP(i, N) {
        cin >> A[i].first;
        A[i].second = i;
        le.insert(i);
    }
    sort(A.rbegin(), A.rend());

    i64 s = 0;
    set<i64> g;
    REP(i, N) {
        P p = A[i];
        i64 n = p.first;
        i64 idx = p.second;

        auto calc_r = [&]() {
            auto gr1 = g.upper_bound(idx);
            if (gr1 == g.end()) return;
            auto gr2 = next(gr1, 1);
            i64 r1 = *gr1;
            i64 r2;
            if (gr2 == g.end()) r2 = N;
            else r2 = *gr2;

            i64 l;
            if (gr1 == g.begin()) l = 0;
            else l = *prev(gr1, 1) + 1;

            s += n * (r2 - r1) * (idx - l + 1);
        };
        calc_r();
        auto calc_l = [&]() {
            auto gr1 = g.upper_bound(idx);
            if (gr1 == g.begin()) return;
            auto gl1 = prev(gr1, 1);
            i64 l1 = *gl1;
            i64 l2;
            if (gl1 == g.begin()) l2 = 0;
            else l2 = *prev(gl1, 1) + 1;

            i64 r;
            if (gr1 == g.end()) r = N - 1;
            else r = *gr1 - 1;

            s += n * (l1 - l2 + 1) * (r - idx + 1);
        };
        calc_l();

        g.insert(idx);
    }
    cout << s << endl;

    return 0;
}

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

int f(int n) {
    if (n % 2 == 0) {
        return n / 2;
    }
    else {
        return 3 * n + 1;
    }
}

int main() {
    vector <int> a;
    set <int> st;
    int s;
    cin >> s;
    a.push_back(s);
    st.insert(s);
    int pre = s;
    rep (i, 1000001) {
        int res = f(pre);
        if (st.count(res)) {
            cout << i + 2 << endl;
            break;
        }
        st.insert(res);
        pre = res;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        if (N%2==1) {
            System.out.println("No");
            return;
        }
        for (int i=0;i<N/2;i++) {
            if (S.charAt(i)!=S.charAt(i+N/2)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

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

int main() {
    uint N, K;
    cin >> N >> K;

    vector<int> l(N, 0);
    for (auto &x: l) cin >> x;
    sort(l.begin(), l.end(), greater<int>());

    int sum = 0;
    for (size_t i=0; i<K; ++i) sum += l[i];
    cout << sum << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    string s;
    cin >> s;
    bool miss = false;
    
    reverse(s.begin(),s.end());
    
    string chunks[4] = {"dream","dreamer","erase","eraser"};
    
    for(int i = 0 ; i < 4 ; i++ )
        reverse(chunks[i].begin(),chunks[i].end());
    
    while(s.size() != 0){
        int old = s.size();
        if( s.size() < 5 ){
            miss = true;
            break;
        }
        
        for(int i = 0 ; i < 4 ; i++ ){
            if( s.size() >= chunks[i].size() ){
                string temp = s.substr(0,chunks[i].size());
                //cout << temp << endl;
                if( temp == chunks[i] ){
                    s = s.substr(chunks[i].size(),s.size() - chunks[i].size());
                }
            }
        }

        //cout << "now:" << s << endl;
        if( old == s.size() ){
            miss = true;
            break;
        }
        
    }
    
    if( miss ){
        cout << "NO"<<endl;
    }else{
        cout << "YES"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 512
package main 

import "fmt"

func main(){
	var S string
	var e, s, n, w int
	fmt.Scan(&S)

	for i := 0 ; i < len(S) ; i++ {
		if S[i] == 'N'{
			n++
		}else if S[i] == 'S'{
			s++
		}else if S[i] == 'W' {
			w++
		}else if S[i] == 'E' {
			e++
		}
	}
	if (n > 0 && s > 0) && (w == 0 && e == 0) {
		fmt.Println("Yes")
	} else if (n > 0 && s > 0) && (w > 0 && e > 0){
		fmt.Println("Yes")
	} else if (n == 0 && s == 0) && (w > 0 && e > 0){
		fmt.Println("Yes")
	} else{
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
import sys
stdin = sys.stdin

ni = lambda: int(ns)
ns = lambda: stdin.readline().rstrip()
na = lambda: map(int, stdin.readline().split())

from itertools import groupby

def f(x):
  groups = []
  for _, g in groupby(x):
    groups += [list(g)]
 
  ans = 0
  flag = False
  for group in groups:
    n = len(group)
    if flag:
      n -= 1
      flag = False
    if n == 0:
      print(group, file=sys.stderr)
      continue
    c = (n-1)//3 * 2
    o = n%3
    if o == 0:
      d = 2
    elif o == 1:
      d = 1
    elif o == 2:
      d = 2
      flag = True
    print(group, c, d, file=sys.stderr)
    ans += c + d
  if flag:
    ans -= 1
  print(ans, file=sys.stderr)
  return ans

def solve():
  s = ns()
  print(max(f(s), f(s[::-1])))


if __name__ == '__main__':
  solve()

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

int main(){
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(a+b<c+c){
		printf("%d\n",x*a+y*b);
	}else{
		int together=min(x,y);
		x-=together,y-=together;
		printf("%d\n",min((c+c)*together+a*x+b*y,(c+c)*(together+x+y)));
	}
	return 0;
}

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

int main(void){
    long long x,ans;
    scanf ("%lld",&x);
    if (x%11==0){
        printf ("%lld",(x/11)*2);
    } else if (x%11<=6){
        printf ("%lld",ans=(x/11)*2+1);
    } else {
        printf ("%lld",(x/11)*2+2);
    }
	return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

//ユークリッドの互除法 O(log a)
int gcd(int a, int b){
	if(b > a) swap(a, b);
	int tmp;
	while(b != 0){
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	int now;
	cin >> now;
	for(int i=1; i<N; i++){
		int tmp;
		cin >> tmp;
		now = gcd(now, tmp);
	}
	cout << now << endl;

	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <tuple>
#include <utility>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int64;
typedef pair<int, int> pii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  if (n >= 3200) {
    cout << s << '\n';
  } else {
    cout << "red" << '\n';
  }
  return 0;
}



Measured memory_bytes: 256
/*
* @Author: Samson
* @Date:   2018-04-11 16:28:56
* @Last Modified by:   Samson
* @Last Modified time: 2018-05-02 20:34:31
*/
//   @URL : 
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1E4+10;

int s[MAXN],T[505],ans,n;

void fun(int x)
{
    for(int i = 1; i <= n; ++i)
    {
        if(s[i] == x)
            {++ans; break;}
    }
}
int main(void)
{
    int q,tmp;
    scanf("%d",&n);
    for(int i = 1; i <= n; ++i)
        scanf("%d",&s[i]);
    scanf("%d",&q);
    for(int i = 1; i <= q; ++i)
    {
        scanf("%d",&tmp);
        fun(tmp);
    }
    printf("%d\n",ans );
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;


int N;
ve<ve<char>> A;
bool check(int x, int y){
    
    ve<ve<char>> SS(N,ve<char>(N,'a'));
    rep(i,N) rep(j,N){
        SS[i][j] = A[i+x][j+y];
    }
    
    rep(i,N) reps(j,i,N){
        if(SS[i][j] != SS[j][i]){
            return false;
        }
    }
    return true;
}


int main()
{
    cin >> N;
    ve<ve<char>> S(N,ve<char>(N,'a'));
    rep(j,N) in(N,S[j]);
    A.resize(2*N,ve<char>(2*N,'a'));
    rep(i,N) rep(j,N){
        A[i][j] = S[i][j];
        A[i+N][j] = S[i][j];
        A[i][j+N] = S[i][j];
        A[i+N][j+N] = S[i][j];
    }
    int ans = 0;
    rep(i,N) if(check(0,i)) ans+=(N-i);
    reps(i,1,N) if(check(i,0)) ans+=(N-i);
    
    out(ans);

    return 0;
}


Measured memory_bytes: 768
N,M = map(int,input().split())

if N==M:
  ans = 1
  for i in range(1,N+1):
    ans *= i
    ans %= 10**9 + 7
  ans *= ans
  ans %= 10**9 + 7
  ans *= 2
  ans %= 10**9 + 7
elif N==M+1 or N+1==M:
  ans = 1
  for i in range(1,N+1):
    ans *= i
    ans %= 10**9 + 7
  for i in range(1,M+1):
    ans *= i
    ans %= 10**9 + 7
else:
  ans = 0
print(ans)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}

const ll INF = 1e18L+5;

int main()
{
	int n,w;
	cin>>n>>w;
	vl wi(n),v(n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>wi[i]>>v[i];
		sum+=v[i];
	}
	vl dp(sum+1,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int ve=sum-v[i];ve>=0;ve--)
		{
			dp[ve+v[i]]=min(dp[ve+v[i]],dp[ve]+wi[i]);
		}
	}
	ll ans=0;
	for(int i=sum;i>=0;i--)
	{
		if(dp[i]<=w) {ans=i;break;}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, m, x, a[100], cnt[101] = {};
	cin >> n >> m >> x;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	int ans1 = 0, ans2 = 0;
	for (int i = 0; i < x; i++) {
		if (cnt[i] == 1) {
			ans1++;
		}
	}
	for (int i = x + 1; i < n + 1; i++) {
		if (cnt[i] == 1) {
			ans2++;
		}
	}
	cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
int main() {
	int num;
	scanf("%d", &num);
	int color[9] = { 0 };
	int colorNum = 0;
	int rate;
	for (int i = 0; i < num; i++) {
		scanf("%d", &rate);
		if(rate < 3200)color[rate / 400]++;
		else color[8]++;
	}
	for (int i = 0; i < 8; i++) {
		if (color[i])colorNum++;
	}
	if (!colorNum)std::cout << 1;
	else std::cout << colorNum;
	std::cout << " " << colorNum + color[8];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
typedef pair<double,int> P;

int main(void){
	priority_queue<P, vector<P>, greater<P> > atime;
	queue<P> ktime;
	for(int i=0;i<3;i++){
		priority_queue<P, vector<P>, greater<P> > time;
		for(int j=0;j<8;j++){
			int a;
			double b;
			scanf("%d%lf",&a,&b);
			time.push(P(b,a));
		}
		for(int j=0;j<2;j++){
			P p=time.top();time.pop();
			ktime.push(P(p.first,p.second));
		}
		for(int j=0;j<2;j++){
			P p=time.top();time.pop();
			atime.push(P(p.first,p.second));
		}
	}
	for(int j=0;j<6;j++){
		P p=ktime.front();ktime.pop();
		printf("%d %0.2f\n",p.second,p.first);
	}
	for(int j=0;j<2;j++){
		P p=atime.top();atime.pop();
		printf("%d %0.2f\n",p.second,p.first);
	}
    return 0;
}

Measured memory_bytes: 0
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(min((double)1.0, max((double)-1.0, cosine)));
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		double now_length = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa - now_min >= eps || (abs(goa - now_min) <= eps && (abs(a[i] - a[starter]) - now_length) >= eps)) {
					now_min = goa;
					now_go = i;
					now_length = abs(a[i] - a[starter]);
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;

}

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

int main() {
  int x,y;
  cin >> x >> y;
  if(y % 2 == 1) cout << "No" << endl;
  else {
    int a = x * 2;
    int b = x * 4;
    if(a <= y && y <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
def main():
    import sys
    # readline = sys.stdin.readline
    readlines = sys.stdin.readlines
    H, W, N = map(int, input().split())
    grid = {}
    P = set()
    for s in readlines():
        a, b = map(int, s.split())
        a -= 1; b -= 1
        if a in grid:
            grid[a].add(b)
        else:
            grid[a] = set([b])
        P.add((a, b))

    ans = [0] * 10
    done = set()
    for a, b in P:
        for oa in range(a - 2, a + 1):
            for ob in range(b - 2, b + 1):
                if 0 <= oa <= H - 3 and 0 <= ob <= W - 3 and (oa, ob) not in done:
                    tmp = 0
                    for i in range(3):
                        for j in range(3):
                            na = oa + i
                            nb = ob + j
                            if (na, nb) in P:
                                tmp += 1
                    ans[tmp] += 1
                    done.add((oa, ob))
    
    ans[0] = (H - 2) * (W - 2) - sum(ans[1:])

    print(*ans, sep='\n')


if __name__ == "__main__":
    main()


Measured memory_bytes: 155896