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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W, n, sr, sc;
	cin >> H >> W >> n >> sr >> sc;
	string s, t;
	cin >> s >> t;
	bool ans = true;
	for(char c : "LRUD"){
		if(c == 'L'){
			int c1 = 0, c2 = 0;
			rep(i,n){
				c1 += (s[i] == c);
				if(sc + c2 - c1 <= 0){
					ans = false;
					break;
				}
				if(t[i] == 'R' && sc + c2 + 1 - c1 <= W) c2++;
			}
		}
		else if(c == 'R'){
			int c1 = 0, c2 = 0;
			rep(i,n){
				c1 += (s[i] == c);
				if(sc + c1 - c2 > W){
					ans = false;
					break;
				}
				if(t[i] == 'L' && sc + c1 - c2 - 1 > 0) c2++;
			}
		}
		else if(c == 'U'){
			int c1 = 0, c2 = 0;
			rep(i,n){
				c1 += (s[i] == c);
				if(sr + c2 - c1 <= 0){
					ans = false;
					break;
				}
				if(t[i] == 'D' && sr + c2 + 1 - c1 <= H) c2++;
			}
		}
		else{
			int c1 = 0, c2 = 0;
			rep(i,n){
				c1 += (s[i] == c);
				if(sr + c1 - c2 > H){
					ans = false;
					break;
				}
				if(t[i] == 'U' && sr + c1 - c2 - 1 > 0) c2++;
			}
		}
	}
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}

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

#define ll long long
#define ld double

using namespace std;


int main()
{
	ll n; cin >> n;
	vector<ll> a((ll)1e6 + 1, 0);
	for (int i = 0; i < n; i++) {
		ll num; cin >> num; a[num]++;
	}

	ll ans = 0;
	vector<ll> b((ll)1e6 + 1, 1);
	for (int i = 1; i <= 1e6; i++) {
		if (a[i]) {
			if (a[i] > 1 && b[i]) ans += a[i];
			for (int j = i * 2; j <= 1e6; j += i) {
				if (a[j] && b[j]) {
					ans += a[j];
					b[j] = 0;
				}
			}
		}
	}

    cout << n - ans << endl;

}

Measured memory_bytes: 18820
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;

int main() {
  long long n;
  cin>>n;
  int ans=10000;
  while(n>99){
    int temp=n%1000;
    ans=min(ans,abs(temp-753));
    n/=10;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
int nums[10005];
int i, j, temp, isSorted;
int n;
scanf("%d",&n);
for(i=0;i<n;i++)
    scanf("%d",&nums[i]);
for(i=0; i<n-1; i++){
isSorted = 1; //假设剩下的元素已经排序好了
for(j=0; j<n-1-i; j++){
if(nums[j] > nums[j+1]){
temp = nums[j];
nums[j] = nums[j+1];
nums[j+1] = temp;
isSorted = 0; //一旦需要交换数组元素，就说明剩下的元素没有排序好
}
}
if(isSorted) break; //如果没有发生交换，说明剩下的元素已经排序好了
}


int sum=0;
for(i=0; i<n-1; i++)
sum+=nums[i];



sum=sum+nums[n-1]/2;
printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<bool>A(55556,true);
  for(int i=2;i<55556;i++){
  if(!A.at(i))
    continue;
    else{
    for(int j=2;i*j<=55555;j++)
      A.at(i*j)=false;
    }
   }int a=0;
  vector<int>B;
  for(int i=2;i<55556;i++){
  if(A.at(i)){if(i%5==1){B.push_back(i);a++;}}
  if(a==N)break;
  }for(int i=0;i<N-1;i++)
    cout<<B.at(i)<<" ";
  cout<<B.at(N-1)<<endl;
  return 0;
}

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

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=2e5+25;
  const int M=31;

 
 void doit()
 { 
   int n; cin>>n; vi ct(n+1);

   rep(i,1,n){
     int x; cin>>x;
     ct[x]++;
   }

   rep(i,1,n+1) cout<<ct[i]<<nl;
 }

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

 
  
   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }
  


 return 0; 
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a;
    for (int i = 0; i < 2 * n; i++) {
        int in;
        std::cin >> in;
        a.push_back(in);
    }
    std::sort(a.begin(), a.end());
    int ret = 0;
    for (int i = 0; i < n; i++) {
        ret += a[i * 2];
    }
    std::cout << ret << std::endl;

    return 0;
}


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

int main() {
  int N,M,C;
  cin>>N>>M>>C;
  
  vector<int> b(M);
  for(int i=0;i<M;++i){
    cin>>b[i];
  }
  
  int ans=0;
  for(int i=0;i<N;++i){
    int x=0;
    for(int j=0;j<M;++j){
      int A;
      cin>>A;
      x+=A*b[j];
    } 
    
    x+=C;
    if(x>0)
      ++ans;
  }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		
		int result = 1;
		for (int i = 0; i < N; i++) {
			if (result * 2 < result + K) {
				result *= 2;
			} else {
				result += K;
			}
		}
		
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

// ----------------------------------------------------------------

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	ans := 0.0
	for i := 1; i <= n; i++ {
		score := i
		prob := 1.0 / float64(n)
		for k > score {
			score *= 2
			prob /= 2.0
		}
		ans += prob
	}

	fmt.Println(ans)

}

// ----------------------------------------------------------------

var dx = []int{0, 1, 0, -1, 0}
var dy = []int{1, 0, -1, 0, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

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

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}

func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}

func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


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

int N, M, Q;
vector<int> A, B, C, D;
long long answer = 0;

void dfs(vector<int> seq) {
    if (seq.size() == N + 1) {
        long long now = 0;
        for (int i = 0; i < Q; i++) {
            if (seq[B[i]] - seq[A[i]] == C[i]) now += D[i];
        }
        answer = max(answer, now);
        return;
    }
    seq.push_back(seq.back());
    for (int i = seq.back(); i <= M; i++) {
        dfs(seq);
        seq.back()++;
    }
}

int main() {
    cin >> N >> M >> Q;
    A = B = C = D = vector<int>(Q);
    for (int i = 0; i < Q; i++) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
    }
    dfs({1});
    cout << answer << endl;
    return 0;
}

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

public class Main {

	static int ans[];
	static int count = 0;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int ans = 0;
		for (int i = 1; i <= n; i += 2) {
			int count = 0;
			for (int j = 1; j <= n; j++) {
				if (i % j == 0) {
					count++;
				}
			}
			if (count == 8) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
//       THIS IS MY NINJA WAY
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ctime>
#include<vector>
#include<algorithm>

#define str string
#define dbl double
#define ll long long int
#define ull unsigned long long int
#define vl vector<ll> 
#define vs vector<str>
#define pll pair<ll,ll> 
#define vll vector<pll>
#define sl set<ll>
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define fr(i,a,b) for(long long i=a; i<b; i++)
#define nfr(i,a,b) for(long long i=a; i<=b; i++)
#define psl pair<str,ll>
#define pls pair<ll,str>
#define pss pair<str,str>
#define lcm(a,b) (a*b)/__gcd(a,b)
#define ALL(a) a.begin(),a.end()
#define stl stack<ll>
#define coml complex<ll>
#define INF 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define read(v,n) fr(i,0,n)cin>>v[i];
#define print(x) fr(i,0,x.size())cout<<x[i]<<" ";cout<<"\n";
const ll MOD = 1e9+7;
const ll N = 2e5 + 5;
using namespace std;
using namespace __gnu_pbds;
void solve(){
	ll n,k;
	cin>>n>>k;
	vl v(n);
	read(v,n);
	vl dp(n,INF);
	dp[0]=0,dp[1]=abs(v[0]-v[1]);
	fr(i,2,k){
		fr(j,1,k+1){
			if(i-j>=0)dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
		}
	}
	fr(i,k,n){
		fr(j,1,k+1){
			if(i-j>=0)dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
		}
	}
	//print(dp);
	cout<<dp[n-1];
}
int main()
{
	fast
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r" , stdin);
	//	freopen("output.txt", "w" , stdout);
	//#endif

	ll t;
	t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    long long ans=0;
    ans=n/(a+b)*a;
    if(n%(a+b)-a>=0)
        ans+=a;
    else
        ans+=n%(a+b);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    string s;
    cin >> s;
    int ans = 0, t = 0;
    for (char c : s) {
        if (c == 'R') {
            ++t;
        }
        else {
            ans = max(ans, t);
            t = 0;
        }
    }
    cout << max(ans, t);
}

/*
*/


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

int main()
{
    int n, k;
    cin >> n >> k;
    rep(i, n) {
        int a;
        cin >> a;
    }
    cout << ceil((double) (n - 1) / (k - 1)) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(n==1&&a==b)cout<<1<<endl;
    else if(n==1)cout<<0<<endl;
    else if(a>b)cout<<0<<endl;
    else cout<<(b-a)*(n-2)+1<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <array>
#include <unordered_map>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int n = 0, c = gcu();
	// bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
//template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

struct board {
	enum {size = 4};
	struct pos {int r, c;};
	typedef array<array<int, size>, size> arr;
	typedef unordered_map<int, int> mp;

	int h;
	arr b;
	pos p;

	void read() {
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				b[i][j] = in();
				if (!b[i][j])
					p.r = i, p.c = j;
			}
		h = hn(b);
	}

	void print() {
		for (auto &r: b) {
			for (int &c: r)
				out(&c == &r[0]?"":" ", c);
			out('\n');
		}
		out('\n');
	}

	static int hn(const arr &a) {
		int l = 0;
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				if (!a[i][j])
					continue;
				int k = a[i][j] - 1;
				l += abs(i - k / size) + abs(j - k % size);
			}
		return l;
	}

	static int key(const arr &a) {
		int k = 0;
		for (auto &r: a)
			for (int c: r)
				k = (k * 10) + c;
		return k;
	}

	static bool dfs(board &a, mp &m, int depth, int limit) {
		static const pos to[] = {-1, 0, 0, -1, 1, 0, 0, 1};
		if (!a.h)
			return true;

		if (depth + a.h > limit)
			return false;

		int k = key(a.b);
		auto res = m.find(k);
		if (res != m.end() && (*res).second <= depth)
			return false;

		pos tp = a.p;
		int th = a.h;
		for (pos o: to) {
			o.r += tp.r, o.c += tp.c;
			if (0 <= o.r && o.r < size && 0 <= o.c && o.c < size) {
				swap(a.b[tp.r][tp.c], a.b[o.r][o.c]);
				int f = a.b[tp.r][tp.c] - 1;
				a.h = th
					+ abs(tp.r - f / size) + abs(tp.c - f % size)
					- abs(o.r - f / size) - abs(o.c - f % size);
				a.p = o;
				if (dfs(a, m, depth + 1, limit))
					return true;
				swap(a.b[o.r][o.c], a.b[tp.r][tp.c]);
			}
		}
		a.p = tp;
		a.h = th;
		if (res == m.end() || (*res).second > depth)
			m[k] = depth;
		return false;
	}

	int solver() {
		int limit = h;
		for (;;limit += 2) {
			mp m = {};
			if(dfs(*this, m, 0, limit))
				return limit;
		}
	}
};

int main() {
	board b;
	b.read();
	out(b.solver(), '\n');
}


Measured memory_bytes: 33760
n, m = tuple(map(int, input().split(' ')))
h = list(map(int, input().split(' ')))
adj = [[] for i in range(n)]
for i in range(m):
  a, b = tuple(map(int, input().split(' ')))
  a -= 1
  b -= 1
  adj[a].append(b)
  adj[b].append(a)
ans = 0
for i in range(n):
  if len(adj[i]) == 0:
    ans += 1
  else:
    ok = True
    for j in adj[i]:
      if h[i] <= h[j]:
        ok = False
    if ok:
      ans += 1
print(ans)

Measured memory_bytes: 29404
/**
 *      ABC 112 B
 *      author  : kyomukyomupurin
 *      created : 2018-10-06 21:03:19
**/

#include <bits/stdc++.h>
#define int32 int_fast32_t
#define int64 int_fast64_t
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int32 N, T; cin >> N >> T;
    int32 c[N] = {}; int32 t[N] = {};
    for (auto i = 0; i < N; ++i) {
        cin >> c[i] >> t[i];
    }

    bool flag = false;
    int32 ans = 1001;

   for (auto i = 0; i < N; ++i) {
       if (t[i] <= T){
           flag = true;
           if (c[i] < ans){
               ans = c[i];
           }
       }
   } 
    if (!flag){
        cout << "TLE" << '\n';
    }
    else {
        cout << ans << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())

bitts = ''
ans = ''

dic = 'abcdefghijklmnopqrstuvwxyz'

while (N > 0):
    N -= 1
    
    b = N // 26
    mod = N - 26 * b
    bitts += str(mod)
    
    ans += dic[mod]
    
    N = N // 26
    

print(ans[::-1])



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

ll fun(vector<ll> &arr, int n)
{
    ll max_sum = arr[0], min_sum = arr[0];
    for (int i = 0; i < n; i++)
    { // Finding max and min sum value
        max_sum = max(max_sum, arr[i]);
        min_sum = min(min_sum, arr[i]);
    }
    return (max_sum - min_sum);
}

ll maxAbsValExpr(vector<int> &arr1, vector<int> &arr2)
{
    int n = arr1.size();
    vector<ll> sum1(n, 0), diff1(n, 0), sum2(n, 0), diff2(n, 0);
    for (int i = 0; i < n; i++)
    {
        sum1[i] = arr1[i] + arr2[i] ;
        diff1[i] = arr1[i] - arr2[i] ;
        sum2[i] = arr1[i] + arr2[i] ;
        diff2[i] = arr1[i] - arr2[i];
    }
    return max(max(fun(sum1, n), fun(diff1, n)), max(fun(sum2, n), fun(diff2, n)));
}
int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n;++i)
        cin >> x[i] >> y[i];

    cout << maxAbsValExpr(x, y);
    return 0;
}

Measured memory_bytes: 11112
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,x=0,y=0;
	cin>>n;
	for(int i=0;i<n;i++){
		string a,b;
		cin>>a>>b;
		int r=a.compare(b);
		if(!r)++x,++y;
		else if(r>0)x+=3;
		else y+=3;
	}
	cout<<x<<" "<<y<<endl;
	return 0;
}

Measured memory_bytes: 1212
#define _CRT_SECURE_NO_WARNINGS
#define TASK "insider"
#pragma comment(linker, "/STACK:671088640")
#include <stdio.h>
#include <iostream>
#include <iomanip> 
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <assert.h>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <complex>
using namespace std;

const int MOD = 1000000007;
const int INF = 20000000;
const long double EPS = 1e-7;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(1);

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

void my_return(int code)
{
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int n, k, w[5010];
bool pref[5010][5010], suff[5010][5010];
int cnt[5010];

int main()
{
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
	/*freopen("pie_progress.txt", "r", stdin);
	freopen("pie_progress_output.txt", "w", stdout);*/
#endif

	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &w[i]);
	}

	pref[0][0] = true;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <= k; ++j)
		{
			pref[i][j] = pref[i - 1][j];
			if (w[i] <= j)
				pref[i][j] |= pref[i - 1][j - w[i]];
		}
	}
	suff[n + 1][0] = true;
	for (int i = n; i >= 1; --i)
	{
		for (int j = 0; j <= k; ++j)
		{
			suff[i][j] = suff[i + 1][j];
			if (w[i] <= j)
				suff[i][j] |= suff[i + 1][j - w[i]];
		}
	}

	int ans = 0;
	for (int x = 1; x <= n; ++x)
	{
		for (int j = 0; j <= k; ++j)
			cnt[j] = suff[x + 1][j] ? 1 : 0;
		for (int j = 1; j <= k; ++j)
			cnt[j] += cnt[j - 1];
		bool good = true;
		for (int val = 0; val <= k; ++val)
		{
			if (pref[x - 1][val])
			{
				int ll = k - w[x] - val, rr = k - 1 - val;
				ll = max(0, ll);
				rr = min(rr, k - 1);
				if (ll <= rr)
				{
					if (ll == 0 && cnt[rr] > 0)
						good = false;
					else if (ll > 0 && cnt[rr] - cnt[ll - 1] > 0)
						good = false;
				}
			}
		}
		if (good)
			++ans;
	}
	printf("%d\n", ans);

	my_return(0);
}

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

int main (){
  
 int a,b,k,i,j,count,ans;
  scanf("%d",&a);
  
  for(i = 1;i < a + 1;i++){
    //奇数だけにしている
  	if(i % 2 != 0){
      for(j = 1;j < i + 1;j++){
        if(i % j == 0){
        count++;
      	}
      }
      if(count == 8){
        ans++;
      }else{
        count = 0;
      }
   	 
 	}
  }
  
  printf("%d",ans);
    
  
      return 0;
  
}



Measured memory_bytes: 128
#bin/usr/env python3

n,m = map(int, input().split())
mod = 10**9+7

br = [0 for i in range(n+2)]
for i in range(m):
    a = int(input())
    br[a] = 1

can = [0 for i in range(n+2)]

can[1] = 1
can[2] = 2

if br[1] == 1:
    can[1] = 0
    can[2] = 1
if br[2] == 1:
    can[1] = 1
    can[2] = 0
if br[1] == 1 and br[2] == 1:
    can[1] = 0
    can[2] = 0

for i in range(3, n+1):
    if br[i]!=1 :
        can[i] = (can[i-1] + can[i-2])%mod
    
    else:
        can[i] = 0

print(can[n])




Measured memory_bytes: 7836
#include <bits/stdc++.h>
using namespace std;
#define int int long long
#define MdataX 200005
#define FdataST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
int n;
void GO()
{
    cin>>n;
    if(n)
        cout<<(0)<<endl;
    else
        cout<<1<<endl;
}

int32_t main()
{
    FdataST
    #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    int testCase;
    // cin>>testCase;
    testCase=1;
    std::vector<int> tc;
    for (int i = 0; i < testCase; ++i)
    {
        tc.push_back(i);
    }
    for(auto test : tc)
    {
        GO(); // let's solve this case :)
    }
    
    return 0;
}

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

int main() {
    int n;
    int k;
    string s;
    string s1, s2;
    cin >> n;
    cin >> s;
    k = n/2;

    if (n%2 == 0)
    {
        s1 = s.substr(0,k);
        s2 = s.substr(k,k);
        if (s1 == s2)
        {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val a = new Array[Int](n)
  for(i <- 0 until n)
    a(i) = sc.nextInt()

  var cnt = 0L
  var ans = 0L
  for(i <- 0 until n){
    val now = a(i)
    cnt += now

    if(i % 2 == 0){
      if(cnt < 1){
        ans += 1 - cnt
        cnt = 1
      }
    }
    else{
      if(cnt > -1){
        ans += cnt - (-1)
        cnt = -1
      }
    }
  }

  cnt = 0L
  var ans2 = 0L
  for(i <- 0 until n){
    val now = a(i)
    cnt += now

    if(i % 2 != 0){
      if(cnt < 1){
        ans2 += 1 - cnt
        cnt = 1
      }
    }
    else{
      if(cnt > -1){
        ans2 += cnt - (-1)
        cnt = -1
      }
    }
  }

  println(Math.min(ans, ans2))
}


Measured memory_bytes: 52628
N = int(input())
A = [int(i) for i in input().split()] 
A.insert(0, 0)
B = [0]*N
mydict={}
for i in range(1,N+1):
    mydict[A[i]]=i
sorted(mydict.items(), key=lambda x: x[1])
for i in range(1,N+1):
    B[i-1]=mydict[i]
print(' '.join(map(str, B)))

Measured memory_bytes: 30168
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m, q) = parse!(it, 3);
    let mut counts = vec![vec![0; n]; n];
    for _ in 0..m {
        let (l, r): (usize, usize) = parse!(it, 2);
        counts[l - 1][r - 1] += 1;
    }
    let mut accum = counts.clone();
    for w in 0..n {
        if w >= 2 {
            for l in 0..(n - w) {
                accum[l][l + w] -= accum[l + 1][l + w - 1];
            }
        }
        for l in 0..(n - w) {
            let r = l + w;
            if l > 0 {
                accum[l - 1][r] += accum[l][r];
            }
            if r < n - 1 {
                accum[l][r + 1] += accum[l][r];
            }
        }
    }
    for _ in 0..q {
        let (p, q): (usize, usize) = parse!(it, 2);
        println!("{}", accum[p - 1][q - 1]);
    }
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        2 3 1
1 1
1 2
2 2
1 2
        ";
        solve(s);
    }
}


Measured memory_bytes: 11000
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  set<ll> primes;
  FOR(i, 2, N+1){
    if(is_prime(i)){
      primes.insert(i);
    }
  }

  ll ans = 1;
  for(auto ip: primes){
    ll cnt = 1;
    ll tmp=0;
    while(pow(ip, cnt)<=N){
      tmp += N/pow(ip, cnt);
      cnt++;
    }
    ans =mod(ans * (tmp+1), MOD);
  }

  cout << ans;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N;ll X; cin >> N >> X;
	using P = pair<ll,double>;
	deque<P> xfs;
	double S = 0;
	rep(ph,N){
		ll t,v; cin >> t >> v;
		ll dec = (ph?v:0);
		while(dec){
			auto& p = xfs.back();
			if(dec < p.fs){
				p.fs -= dec; S -= dec*p.sc;
				dec = 0;
			}else{
				xfs.pop_back(); S -= p.fs*p.sc;
				dec -= p.fs;
			}
		}
		xfs.push_front(P(v,t)); S += v*t;
		while(si(xfs) >= 2 && xfs[0].sc < xfs[1].sc){
			auto a = xfs[0], b = xfs[1];
			double nt = (a.fs*a.sc+b.fs*b.sc)/(a.fs+b.fs);
			rep(_,2) xfs.pop_front();
			xfs.push_front(P(a.fs+b.fs,nt));
		}
		cout << S/X << '\n';
	}
}


Measured memory_bytes: 23572
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

int main(){
    
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    ll H = ty - sy, W = tx - sx;
    cout << string(H, 'U');
    cout << string(W + 1, 'R');
    cout << string(H + 1, 'D');
    cout << string(W + 1, 'L');
    cout << "UL";
    cout << string(H + 1, 'U');
    cout << string(W + 1, 'R');
    cout << string(H + 1, 'D');
    cout << string(W, 'L');
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef int I;
I main() { 
	I n, c = 0,l[100]; cin >> n; 
	bool f = false;
	for (I i = 0; i < n; i++) { 
		I m;
		cin >> m; 
		l[i] = m;
		i > 0 ? ((l[i - 1] == l[i] && f==false) ? (c++, f=true): f=false) : 0 ; 
	} 
	cout << c << endl;
}

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

using namespace std;

int main (void){
    int a, b, x;
    cin >> a >> b >> x;
    if(a > x){
         cout << "NO" << endl;
    }else if(a + b < x){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}


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

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

    string s;
    cin >> s;
    int n = s.size();

    int end = n;
    for(int i = n-1; i >= 0; --i){
        if(s[i] == 'B') --end;
        if(s[i] == 'W') break;
    }
    n = end;

    ll res = 0;
    rep(i, n){
        if(s[i] == 'B') {
            res += end - i - 1;
            --end;
        }
    }

    cout << res << endl;

    return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

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

int main(){
    int n, m, k; cin >> n >> m >> k;
    REP(i, 0, n+1){
        REP(l, 0, m+1){
            if(i*(m-l)+l*(n-i) == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

struct node {
	int sum;
	char delta;
	node *son[2];
} *root, pool[0x80000 + 10];

const int mod = 998244353;
int n, q, idx;
int sum[200010], pw[200010];
void build(node*, const int&, const int&);
void modify(node*, const int&, const int&, const char&, const int&, const int&);

int main() {
	scanf("%d%d", &n, &q);
	pw[0] = 1;
	for (int i = 1; i <= n; ++i)
		sum[i] = (1ll * 10 * sum[i - 1] + 1) % mod,
			pw[i] = 1ll * 10 * pw[i - 1] % mod;
	const int N = 1 << 32 - __builtin_clz(n - 1);
	build(root = &pool[idx++], 0, N);
	modify(root, 0, n, 1, 0, N);
	while (q--) {
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		modify(root, n - r, n - l + 1, char(d), 0, N);
		printf("%d\n", root->sum);
	}
	return 0;
}

void build(node *p, const int &l, const int &r) {
	if (l + 1 != r) {
		const int mid = l + r >> 1;
		build(p->son[0] = &pool[idx++], l, mid);
		build(p->son[1] = &pool[idx++], mid, r);
	}
}

void modify(node *p, const int &l, const int &r, const char &x, const int &L, const int &R) {
	if (l == L && r == R) {
		p->delta = x;
		p->sum = 1ll * sum[R - L] * x % mod;
	}
	else {
		if (p->delta && R - L > 1)
			p->son[0]->delta = p->son[1]->delta = p->delta,
			p->son[0]->sum = p->son[1]->sum = 1ll * sum[R - L >> 1] * p->delta % mod,
			p->delta = 0;
		const int mid = L + R >> 1;
		if (r <= mid)
			modify(p->son[0], l, r, x, L, mid);
		else if (l >= mid)
			modify(p->son[1], l, r, x, mid, R);
		else {
			modify(p->son[0], l, mid, x, L, mid);
			modify(p->son[1], mid, r, x, mid, R);
		}
		p->sum = (p->son[0]->sum + 1ull * p->son[1]->sum * pw[R - L >> 1]) % mod;
	}
}



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

int main(){
    int n; cin >> n;
    vector<int> ans(n + 1, 0);

    for (auto i = 1; i <= 100; i++) {
        for (auto j = 1; j <= 100; j++) {
            for (auto k = 1; k <= 100; k++) {
                int tmp = i * i + j * j + k * k + i * j + j * k + k * i;
                if(tmp <= n) ans[tmp]++;
            }
        }
    }

    for (auto i = 1; i <= n; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3520
N = int(input())
A = [0]*N
check = 1
A =  [int(N) for N in input().split()]
for i in range (N):
    if (A[i]%2)==0:
        if (A[i]%3)==0 or (A[i]%5)==0:
            check += 1
        else:
            check = 0
            break
if check >=1:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    long long int N;

    scanf("%lld", &N);
    
    if(N % 2 == 1){
        printf("0\n");

        return 0;
    }
    N /= 2;

    long long int ans = 0;

    for(long long int five = 5; five <= N; five *= 5){
        ans += N / five;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int n, ri = 0, rem, oi;
    scanf("%d", &n);
    oi= n;
    while( n!=0 )
    {
        rem= n%10;
        ri= ri*10 + rem;
        n /= 10;
    }
    if (oi == ri)
        printf("Yes");
    else
        printf("No");

    return 0;
}


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

int main()
{    
    int n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    int sum = 0;
    rep(i,k)
    {
        char prev = 'n';
        for(int j=i;j<n;j+=k)
        {
            char cur = t[j];
            if(cur == prev)
            {
                prev = 'n';
                continue;
            }
            if(cur == 'r') sum += p;
            else if(cur == 's') sum += r;
            else sum += s;
            prev = cur;
        }
    }

    cout << sum << endl;
    return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
int K, X;
ll ret = 0;

void input() {
  IN(K);
  IN(X);
}

void solve() {
  ll first = max(-1000000, X-K+1);
  ll end = min(1000000, X+K-1);
  FOR(i, first, end+1) {
    cout << i << " ";
  }
}

int main(void){
  input();
  solve();
}


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(){
  int N;
  cin >> N;
  vector<vector<int>> v(N);
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    v[b].push_back(a);
    v[a].push_back(b);
  }
  int c[N];
  rep(i,N) cin >> c[i];
  sort(c,c+N);
  queue<int> q;
  stack<int> s;
  q.push(0);
  s.push(0);
  bool u[N];
  rep(i,N) u[i]=false;
  u[0]=true;
  while(!q.empty()){
    int x=q.front();
    q.pop();
    for(auto y:v[x]) if(u[y]==false){
      u[y]=true;
      q.push(y);
      s.push(y);
    }
  }
  int cnt=0;
  int ans=0;
  int d[N];
  rep(i,N) d[i]=-17;
  while(!s.empty()){
    int x=s.top();
    s.pop();
    d[x]=c[cnt];
    ans+=c[cnt];
    cnt++;
  }
  cout << ans-c[N-1] << endl;
  rep(i,N) cout << d[i] << (i==N?"\n":" ");
  return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint c(int n, int k) {
  mint a = 1, b = 1;
  rep(i,k) {
    a *= n-i;
    b *= i+1;
  }
  return a/b;
}

void solve() {
  int n;
  cin >> n;
  n -= 5;
  mint ans;
  for (int o = 0; o <= 11; o++) {
    int m = n-o;
    if (m < 0 || m%2 != 0) continue;
    ans += c(m/2+15,15)*c(11,o);
  }
  cout << ans << endl;
}

int main() {
  int ts;
  cin >> ts;
  rep(ti,ts) solve();
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

struct KOUZOUTAI0505
{
	int num;
	int request;
};
typedef struct KOUZOUTAI0505 kouzoutai0505;

void display(kouzoutai0505 data[], int m);
void sort00(kouzoutai0505 data[], int m);					//配列の中身を.requestで降順に並べ替える関数。mは要素数。
void sort01(kouzoutai0505 data[], int m);					//配列の中身の.requestが同じものを、.numで昇順に整頓する関数。mは要素数。
int maxidx00(kouzoutai0505 data[], int from, int to);

int main()
{
	int n,m;
	int i,k;
	int x;
	kouzoutai0505 data[100];
	while(1){
		scanf("%d %d", &n, &m);
		if(n==0&&m==0){
			break;
		}
		for(i=0; i<n; i++){
			for(k=0; k<m; k++){
				if(i==0){									//初回(i==0)時は.numを割り振る。
					data[k].num=k;
					data[k].request=0;
				}
				scanf("%d", &x);
				if(x){
					data[k].request++;
				}
			}
		}
		sort00(data, m);
		sort01(data, m);
		display(data, m);
	}
	return 0;
}



void display(kouzoutai0505 data[], int m){
	int i;
	for(i=0; i<m; i++){
		if(i>0){
			printf(" ");
		}
		printf("%d", data[i].num+1);
	}
	printf("\n");
	return;
}

void sort00(kouzoutai0505 data[], int m){					//配列の中身を.requestで降順に並べ替える関数。mは要素数。
	kouzoutai0505 work;
	int i;
	int idx;
	for(i=0; i<m; i++){
		idx = maxidx00(data, i, m);
		work = data[i];
		data[i] = data[idx];
		data[idx] = work;
	}
	return;
}

void sort01(kouzoutai0505 data[], int m){
	kouzoutai0505 work;
	int i;
	int count=1;
	while(1){
		if(count==0){
			break;
		}
		count=0;
		for(i=0; i<m; i++){
			if(data[i].request==data[i+1].request){
				if(data[i].num>data[i+1].num){
					work = data[i];
					data[i] = data[i+1];
					data[i+1] = work;
					count++;
				}
			}
		}
	}
	return;
}

int maxidx00(kouzoutai0505 data[], int from, int to){
	int i;
	int idx=from;
	for(i=from; i<to; i++){
		if(data[idx].request<data[i].request){
			idx=i;
		}
	}
	return idx;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
long long n;
long long cnt[100];
long long ans;
int main(){
	cin>>n;
	for(long long i=1;i<=n;i++){
		long long x;
		cin>>x;
		for(long long j=0;j<61;j++){
			cnt[j]+=x&1;
			x>>=1;
		}
	}
	long long t=1;
	for(long long i=0;i<61;i++){
		ans+=((cnt[i]*(n-cnt[i])%1000000007)*t)%1000000007;
		ans%=1000000007;
		t<<=1;
		t%=1000000007;
	}
	cout<<ans;
	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
#define print(x)        cout << (x) << endl
#define printa(x)       REP(i, x.size()) cout << x[i] << endl
typedef pair<ll, ll>    P;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<ll> a(s.size() + 1, 0);

    REP(i, n) {
        if(s[i] == '<') a[i+1] = a[i] + 1;
    }

    REP_REV(i, n) {
        if(s[i] == '>') a[i] = max(a[i], a[i+1] + 1);
    }

    ll ans = 0;
    REP(i, n+1) ans += a[i];
    print(ans);

    return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=1;i<=n;i+=2){
    int tmp = 0;
    for(int j=1;j<=i;j++){
      if(i % j == 0) tmp++;
    }
    if(tmp == 8) ans++;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
s = input()
cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

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

struct Node {
  int num = 0,
      deg = 0;
  vi v;
  Node(int num = 0): num(num) {}
};

int main() {
  int n;
  cin >> n;
  
  vector<Node> g(n);
  rep(i, n) {
    int num;
    cin >> num;
    auto nd = new Node(num);
    cin >> nd->deg;
    rep(j, nd->deg) {
      int v;
      cin >> v;
      nd->v.push_back(v);
    } 

    g[i] = *nd;
  }
  
  rep(i, n) {
    auto nd = g[i];
    int r = 0;
    rep(j, n) {
      int p;
      if (nd.v.size() && r < nd.v.size() && j + 1 == nd.v[r]) {
        p = 1;
        r++;
      } else p = 0;
      printf(j == n - 1 ? "%d\n" : "%d ", p);
    }
  }
}



Measured memory_bytes: 3236
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.unionSet(a, b);
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (uf.findSet(i, A[i])) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
n_loop = n - 1

a = gets.chomp.split(" ").map!{|i|i.to_i}

diff_total = 0
n_loop.times do |i|
  next_a = a[i+1]
  diff = a[i+1] - a[i]
  if diff < 0
  	a[i+1] = a[i]
    diff_total += diff.abs
  end
  
end

p diff_total

Measured memory_bytes: 28680
use std::io;

fn main() {
    let k: usize = parse_line();
    let vs =  parse_values(2);
    let a: usize = vs[0];
    let b: usize = vs[1];
    for i in a..=b {
        if i % k == 0 {
            print!("OK");
            return
        }
    }
    print!("NG");
}

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

#[allow(dead_code)]
fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}



Measured memory_bytes: 2152