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

const int MOD = 1000000007;
const int INF = 1e9;

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

  int ans = 0;
  for(int i = 0; i < n-1; i++){
    if(s[i] == s[i+1]) ans ++;
  }
  ans += 2 * k;
  cout << min(ans, n - 1) << endl;

  return 0;
}

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

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

  vector<int> a(N);
  rep(i, N) cin >> a[i];

  int now = 1;
  int cnt = 0;
  rep(i, N) {
    if (a[i] == now)
      ++now;
    else
      ++cnt;
  }

  if (cnt == N)
    cout << -1 << endl;
  else
    cout << cnt << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int K = sc.nextInt();
      int N = sc.nextInt();
      int[] A = new int[N];
      for(int i = 0; i < N; i++){
        A[i] = sc.nextInt();
      }
      
      // 家間の距離の総和と最も離れた距離を算出
      int total = 0;
      int max = 0;
      for(int i = 0; i < N; i++){
        int distance = 0;
        if(i < N-1){
          distance = A[i+1] - A[i];
        }else{
          distance = A[0] + K - A[i];
        }
        
        if(max < distance){
          max = distance;
        }
        
        total += distance;
      }
      
      int result = total - max;
      
      // 出力
      System.out.println(result);
    }
    
}

Measured memory_bytes: 74696
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  for(int i=0; i<5; i++){
    int temp;
    cin >> temp;
    if(temp == 0){
      cout << i+1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3540
def main():
    N, K = (int(i) for i in input().split())
    if (N-2)*(N-1)//2 < K:
        return print(-1)
    need_reduce = (N-2)*(N-1)//2 - K
    M = (N-1) + need_reduce
    ans = [(1, j) for j in range(2, N+1)]
    i = 2
    while need_reduce > 0:
        j = i+1
        while j <= N and need_reduce > 0:
            ans.append((i, j))
            j += 1
            need_reduce -= 1
        i += 1
    print(M)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    ll ans = 0;
    for(int i=1; i<=n; i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
#cd ~/Desktop/python_lesson
import math
a,b,h,m=map(int,input().split())
x=abs(30*h+0.5*m-6*m)
#math.cos(x*3.141592/180)
y=a**2+b**2-2*a*b*math.cos(x*3.14159265358979323846264/180)
print(math.sqrt(y))


Measured memory_bytes: 9432
import java.util.*;
import java.text.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        Pair[] pairs = new Pair[m];
        for (int i=0; i<m; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            pairs[i] = new Pair(l, r);
        }

        Arrays.sort(pairs);

        int cnt = 1;

        int point = pairs[0].r;

        for (int i=1; i<m; i++) {
            if (pairs[i].l < point && point <= pairs[i].r) {

            } else {
                point = pairs[i].r;
                cnt++;
            }
        }

        System.out.println(cnt);

    }

    class Pair implements Comparable<Pair>{
        int l;
        int r;
        public Pair(int l, int r) {
            this.l = l;
            this.r = r;
        }

        public int compareTo(Pair pair) {
            if (this.r < pair.r) return -1;
            if (pair.r < this.r) return 1;
            return 0;
        }
    }


}


Measured memory_bytes: 62476
n, k = map(int, input().split())
s = input()
segment = 0
now = '#'
ans = 0
for i in s:
    if i!=now:
        segment+=1
        now = i
    else:
        ans+=1
for i in range(k):
    t = 0
    if segment > 2:
        t = 2
    elif segment == 2:
        t = 1
    segment, ans = segment-t, ans+t
print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
char Num[1001];
int num[1001];

int main(void) {
    while(1){
        int sum=0;
        scanf( "%s", Num );
        for( int i = 0; Num[i] != '\0'; i++ ) {
            num[i] = Num[i] - '0';
            sum += num[i];
        }
        if( sum == 0 ) break;
        printf( "%d\n", sum );
    }
    return 0;
}


Measured memory_bytes: 2692
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	ls := strings.Split(s, "")

	result := []string{}
	for i, x := range ls {
		if x != "B" {
			result = append(result, x)
		} else if i != 0 && x == "B" {
			length := len(result)
			if (length != 0) {
				result = result[:length-1]
			}
		}
	}
	r := strings.Join(result, "")
	fmt.Println(r)
}


Measured memory_bytes: 1836
# -*- coding: utf-8 -*-

chars = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

def get_str(seq_list):
    result = []
    for seq in seq_list:
        used_char_num = len(set(seq))
        for i in range(used_char_num + 1):
            result.append(seq + chars[i])
    return result

N = int(input())

seq_list = ["a"]
for i in range(N - 1):
    tmp = seq_list[:]
    seq_list = get_str(tmp)

for s in seq_list:
    print(s)


Measured memory_bytes: 14196
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<pair<int, int>> p(n);
  REP(i,n){
    cin >> p[i].first >> p[i].second;
  }
  sort(ALL(p));
  ll res=0;
  int l = 0;
  while(true){
    res += p[l].second;
    if(res >= k){
      cout << p[l].first << endl;
      break;
    }
    l++;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( array[ 0 ] ))

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, K;
	cin >> N >> K;
	char s[51];
	cin >> s;
	rep(i,0,N){
		if (i+1 == K)
			printf("%c", tolower(s[i]));
		else
			printf("%c", s[i]);
	}
	cout << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}


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

void deal(double &x)
{
    if (fabs(x) < 1e-6) x = 0;
}

double a, b, c, d, e, f;
void solve(double &x, double &y)
{
    if (b == 0)
    {
        x = c / a;
        y = (f - d * x) / e;
    }
    else
    {
        x = (b * f - e * c) / (b * d - e * a);
        y = (c - a * x) / b;
    }
    deal(x); // !
    deal(y); // !
}

int main()
{
    while (cin >> a >> b >> c >> d >> e >> f)
    {
        double x, y;
        solve(x, y);
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int table[14][14];

int dp[1<<14][14];
int main() {
  int n;
  while(cin>>n,n) {
    string s[n];
    REP(i,n)
      cin >> s[i];
    bool del[14] = {};
    REP(i, n) {
      REP(j, n) {
        if (s[i] != s[j] && s[i].find(s[j]) != -1)
          del[j] = 1;
      }
    }
    vector<string> t;
    REP(i, n) {
      if (!del[i]) {
        t.push_back(s[i]);
      }
    }
    n = t.size();
    REP(i, n) {
      REP(j, n) {
        if (i==j) continue;
        table[i][j] = 0;
        
        for (int k=max(0, (int)t[i].size()-(int)t[j].size()); k<t[i].size() && (int)t[i].size()-k<=t[j].size(); ++k) {
          if (t[i].substr(k) == t[j].substr(0, t[i].size()-k)) {
            table[i][j] = t[i].size() - k;
            //printf("(%d,%d) %d\n",i,j,table[i][j]);
            break;
          }
        }
      }
    }
    REP(S, 1<<n) REP(j, n) dp[S][j] = INF;
    REP(i, n) dp[1<<i][i] = t[i].size();
    REP(S, 1<<n) REP(i, n) {
      if (S>>i&1) REP(j, n) {
          if (!(S>>j&1))
            dp[S|1<<j][j] = min(dp[S|1<<j][j], dp[S][i] + (int)t[j].size() - table[i][j]);
        }
    }
    cout << *min_element(dp[(1<<n)-1], dp[(1<<n)-1]+n) << endl;
    // if (*min_element(dp[(1<<n)-1], dp[(1<<n)-1]+n) == 72) {
    //   FOR(it, t) {
    //     cout << *it << endl;
    //   }
    // }
  }
  
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
 
using namespace std;
 
int main () {
  int n;
  int a[3];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if ((a[2] * a[2]) == (a[1] * a[1]) + (a[0] * a[0]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#!/usr/bin/env python3

def main():
    N = int(input())

    ct = [0] * 128

    for i in range(0, 7 * 4, 7):
        for j in range(0, 104, 4):
            ct[i + j] = 1


    print('Yes' if ct[N] == 1 else 'No')


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
def function(N, K, A):
    for i in range(0, N-K):
        if A[K+i] > A[i]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    numbers = input().split()
    N = int(numbers[0])
    K = int(numbers[1])
    A = input().split()
    A = [int(a) for a in A]
    function(N, K, A)


Measured memory_bytes: 93984
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
};
typedef Point Vector;
Vector operator + (Vector A,Vector B){
    return Vector(A.x+B.x,A.y+B.y);
}
Vector operator - (Vector A,Vector B){
    return Vector(A.x-B.x,A.y-B.y);
}
Vector operator * (Vector A,double p){
    return Vector(A.x*p,A.y*p);
}
Vector operator / (Vector A,double p){
    return Vector(A.x/p,A.y/p);
}
bool operator < (const Point& a,const Point& b){
    return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
const double eps = 1e-10;
int dcmp(double x){
    if(fabs(x)<eps) return 0; else return (x<0?-1:1);
}
bool operator == (const Point& a,const Point& b){
    return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;
}
//点积
double Dot(Vector A,Vector B){
    return A.x*B.x+A.y*B.y;
}
double Length(Vector A){
    return sqrt(Dot(A,A));
}
double Angle(Vector A,Vector B){
    return acos(Dot(A,B)/Length(A)/Length(B));
}

//叉积
double Cross(Vector A,Vector B){
    return (A.x*B.y-A.y*B.x);
}
//三角形面积的二倍的叉乘公式
double Area2(Point A,Point B,Point C){
    return Cross(B-A,C-A);
}
//向量旋转,rad是弧度
Vector Rotate(Vector A,double rad){
    return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
//计算向量的单位法线,先逆时针旋转90度，然后把长度归一化
Vector Normal(Vector A){
    double Len=Length(A);
    return Vector(-A.y/Len,A.x/Len);
}
//求两直线交点
//调用前请确保P+tv和Q+tw有唯一交点，当且仅当Cross(v,w)非0
Point GetLineIntersection(Point P,Vector v,Point Q,Vector w){
    Vector u=P-Q;
    double t=Cross(w,u)/Cross(v,w);
    return P+v*t;
}
//点到直线的距离
double DistanceToLine(Point P,Point A,Point B){
    Vector v1=B-A,v2=P-A;
    return fabs(Cross(v1,v2))/Length(v1);
}
//点到线段的距离
double DistanceToSegment(Point P,Point A,Point B){
    if(A==B) return Length(P-A);
    Vector v1=B-A,v2=P-A,v3=P-B;
    if(dcmp(Dot(v1,v2))<0) return Length(v2);
    else if(dcmp(Dot(v1,v3))>0) return Length(v3);
    else return fabs(Cross(v1,v2))/Length(v1);
}
//点在直线上的投影
Point GetLineProjection(Point P,Point A,Point B){
    Vector v=B-A;
    return A+v*(Dot(v,P-A)/Dot(v,v));
}

const int maxn=100+10;
double PolygonArea(Point* p,int n){
    double area=0;
    for(int i=1;i<n-1;i++){
        area+=Cross(p[i]-p[0],p[i+1]-p[0]);
    }
    return area/2;
}
int main(){
    int n;
    cin>>n;
    Point Pg[maxn];
    for(int i=0;i<n;i++){
        cin>>Pg[i].x>>Pg[i].y;
    }
    cout<<fixed<<setprecision(1)<<PolygonArea(Pg,n)<<"\n";

}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
    ll k,s;cin >>k>>s;
    ll ans=0;
    for (int x = 0; x <=k; ++x) {
        for (int y = 0; y <= k; ++y) {
            if(x+y>s)continue;
            if(s-(x+y)>k)continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const ll MOD = 1000000007;
const ll MAX = 100100;
const double PI = 3.1415926;

#define vll vector<ll>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
#define pll pair<ll,ll>
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";
// #define traverse( container, it) for( typeof(container.begin()) it = container.begin(); it!=container.end(); it++)
int n;
int k;
int arr[110];
ll dp[110][MAX];

ll fill()
{
	for(int i = 0; i <= k; i++)
	{
		if (i <= arr[0])
			dp[0][i] = i+1;
		else
			dp[0][i] = dp[0][i-1];
	}
	for(int i = 1; i < n; i++)
	{
		dp[i][0] = 1;
		for(int j = 1; j <= k; j++)
		{
			dp[i][j] = dp[i][j-1] + dp[i-1][j];
			if (j - arr[i] > 0)
				dp[i][j] -= dp[i-1][j-arr[i]-1];
			dp[i][j] %= MOD;
		}
	}
	return (dp[n-1][k] - dp[n-1][k-1] + MOD)%MOD;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(dp,0,sizeof(dp));
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	cout << fill() << endl;
	return 0;
}


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

template<int MAX_V>
class dinic{
    struct edge{
        int to;
        uint64_t cap;
        int rev;
    };
    vector<edge> edges[MAX_V];
    int level[MAX_V];
    size_t next[MAX_V];

    void set_level(int s){
        memset(level, -1, sizeof(level));
        queue<int> Q;
        level[s] = 0;
        Q.push(s);
        while(!Q.empty()){
            int v = Q.front();
            Q.pop();
            for(edge e:edges[v]){
                if(e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    Q.push(e.to);
                }
            }
        }
    }

    uint64_t blockingflow(int v, int t, uint64_t f){
        if(v == t) return f;
        for(size_t &i = next[v];i<edges[v].size();i++){
            edge &e = edges[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                uint64_t d = blockingflow(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    edges[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
public:
    void add_edge(int from, int to, uint64_t cap){
        edges[from].push_back({to, cap, (int)edges[to].size()});
        edges[to].push_back({from, 0, (int)edges[from].size()-1});
    }

    uint64_t max_flow(int s, int t){
        uint64_t flow = 0;
        while(true){
            set_level(s);
            if(level[t] < 0) return flow;
            memset(next, 0, sizeof(next));
            int f;
            while((f = blockingflow(s, t, -1)) > 0) flow += f;
        }
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int N;
    pair<int,int> red[100], blue[100];
    dinic<202> d;

    cin >> N;
    for(int i=0;i<N;i++){
        int a, b;
        cin >> a >> b;
        red[i] = {a, b};
        d.add_edge(0, i+1, 1);
    }
    for(int i=0;i<N;i++){
        int a, b;
        cin >> a >> b;
        blue[i] = {a, b};
        d.add_edge(100+i+1, 201, 1);
    }

    for(int r=0;r<N;r++){
        for(int b=0;b<N;b++){
            if(red[r].first < blue[b].first && red[r].second < blue[b].second){
                d.add_edge(r+1, 100+b+1, 1);
            }
        }
    }

    cout << d.max_flow(0, 201) << endl;
    
    return 0;
}

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

using namespace std;

int a[1005];
long long pre[1005];

int main(){

	int n,k;
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		pre[i] = pre[i-1] + a[i];
	}
	long long ans=0;
	vector<long long> v;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			v.push_back(pre[j] - pre[i-1]);
		}
	}
	for(int i=50;i>=0;i--){
		vector<long long> temp;
		for(int j=0;j<v.size();j++){
			if((1LL<<i)&v[j]){
				temp.push_back(v[j]);
			}
		}
		if(temp.size()>=k){
			ans |= (1LL<<i);
			v=temp;
		}
	}
	cout << ans;
}

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


int main() {
    int n, freq[100005], ans = 0;
    memset(freq, 0, sizeof freq);
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int val;
        scanf("%d", &val);
        freq[val + 2]++;
        ans = max(freq[val + 2], ans);
        freq[val + 1]++;
        ans = max(freq[val + 1], ans);
        freq[val]++;
        ans = max(freq[val], ans);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
using namespace std;

int n;
string dp[30][30];

template <class T> int GETL(T a)
{
	return a.at(a.size()-1);
}

void serch(vector<int> s)
{
	//used : ·ÅÉgpµ½lpÌ
	//upper : êÂOÌñÌlpÌiãEj
	int used = 0, upper;
	
	//upperÌsetup
	if( s.empty() ) upper = n;
	else			 upper = GETL(s);

	//usedÌsetup
	for(unsigned int i = 0; i < s.size(); i++) used += s[i];

	//ùÉSÄÌ ðgÁÄ¢½ç
	if(used == n){
		for(unsigned int i = 0; i < s.size()-1; i++) cout<<s[i]<<" ";
		cout<<s[s.size()-1]<<endl;
		//cout<<endl;
		//cin.sync(); cin.get();

		//dpÉÇÁAcªoÈ¢
	}

	//pÓ³ê½lpÈãgÁÄ¢½ç³øi¨»ç­KvÈ¢j
	if(used > n){cout<<"Ää¤©âÎg¢Ü¹ñI"<<endl;cin.sync();cin.get();return;}
	
	//ÌñÉÀ×élpÌðST¸
	for(int i = min(upper, n-used); i > 0; i--){
		vector<int> res = s;
		res.push_back(i);
		serch(res);
	}
	return;
}
int main()
{
	vector<int> res;

	for(int i = 0; i < 30; i++)for(int j = 0; j < 30; j++)dp[i][j] ="UNSET";
	while(cin>>n){
		if(n == 0) return 0;
		serch(res);
	}
}

Measured memory_bytes: 956
K=int(input())

from collections import deque

d=deque([1,2,3,4,5,6,7,8,9])

k=1
while True:
    a=d.popleft()
    if k==K:
        print(a)
        exit()
    else:
        k+=1
    r=a%10
    if r==0:
        for i in [0,1]:
            temp=a*10+i
            d.append(temp)
    elif r==9:
        for i in [8,9]:
            temp=a*10+i
            d.append(temp)
    else:
        for i in [-1,0,1]:
            temp=a*10+(r+i)
            d.append(temp)


Measured memory_bytes: 12404
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
stdin.readline()
data = [int(s) for s in stdin.readline().split()]
times = 0
for i in range(len(data)):
    for j in range(len(data)-1, i, -1):
        if data[j] < data[j-1]:
            data[j], data[j-1] = data[j-1], data[j]
            times += 1
print(*data)
print(times)

Measured memory_bytes: 4240
from itertools import permutations

n,m = map(int,input().split())
t = []
for _ in range(m):
    a,b = map(int,input().split())
    t.append([a, b])
    t.append([b, a])
l = [i for i in range(2,n+1)]
p = permutations(l)
cnt = 0
for v in p:
    if [1, v[0]] not in t:
        continue
    for i in range(n-2):
        if [v[i], v[i+1]] in t:
            continue
        else:
            break
    else:
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
use std::cmp::max;
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Input {
    n: usize,
    w: usize,
    wv: Vec<Vec<usize>>,
}

fn read_input(cin_lock: &mut StdinLock) -> Input {
    let n = next_token(cin_lock);
    let w = next_token(cin_lock);
    let wv = (0..n)
        .map(|_| (0..2).map(|_| next_token(cin_lock)).collect())
        .collect();
    Input { n, w, wv }
}

fn solve(input: Input) {
    let mut dp = vec![vec![0; input.w + 1]; 2];

    for i in 0..input.n {
        let ci = i % 2;
        let ni = (i + 1) % 2;
        let w = input.wv[i][0];
        let v = input.wv[i][1];
        for j in 1..input.w + 1 {
            dp[ni][j] = max(dp[ci][j], if j < w { 0 } else { dp[ci][j - w] + v })
        }
    }
    println!("{}", dp[input.n % 2].iter().max().unwrap())
}

fn next_token<T: FromStr>(cin_lock: &mut StdinLock) -> T {
    cin_lock
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
        .parse::<T>()
        .ok()
        .unwrap()
}

fn main() {
    let cin = stdin();
    let mut cin_lock = cin.lock();
    let input = read_input(&mut cin_lock);
    solve(input);
}


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

int tournament(vector<int>* x,int i){
    if(x[i].empty())return 0;
    

    vector<int> y(x[i].size());
    for(int j=0;j<x[i].size();j++){
        y[j]=tournament(x,x[i][j]);
       // cerr << x[i][j] << endl;
    }
    sort(y.begin(),y.end(),greater<int>());
    //for(int j=0;j<y.size();j++)cerr << y[j]<< ' ';
    for(int j=0;j<y.size();j++)y[j]+=j+1;
   sort(y.begin(),y.end(),greater<int>());
    return y[0];
}

signed main(){
    int n;
    cin >>n;
    vector<int> x[n];
    int k;
    for(int i=1;i<n;i++){
        cin >> k;
        x[k-1].push_back(i);
    }
   cout << tournament(x,0);
    return 0;
}

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



int main() {
  int A,B,K; cin >> A >> B >> K;
  if(B-A+1<=K*2){
    for(int i=A;i<B+1;i++){
      cout << i << endl;
    }
  }else{
    for(int i=A;i<A+K;i++){
      cout << i << endl;
    }
    for(int i=B-K+1;i<=B;i++){
      cout << i << endl;
    }
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>

using namespace std;

#define int_ std::int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll a[4];

int main()
{
    for (ll i=0;i<3;i++) scanf("%lld",a+i);
    sort(a,a+3);
    ll ans=0;
    ans+=(a[1]-a[0])/2;
    if ((a[1]-a[0])%2!=0) ans+=2;
    ans+=(a[2]-a[1]);
    printf("%lld\n",ans);
}

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



struct Si{
    int a[6];
void move(char c) {
    int b;
     if (c=='N'){
         b=a[0];
         a[0]=a[1];
         a[1]=a[5];
         a[5]=a[4];
         a[4]=b;
      }
      if (c=='E'){
         b=a[0];
         a[0]=a[3];
         a[3]=a[5];
         a[5]=a[2];
         a[2]=b;
      }
      if(c=='S'){
         b=a[0];
         a[0]=a[4];
         a[4]=a[5];
         a[5]=a[1];
         a[1]=b;
      }
      if(c=='W'){
         b=a[0];
         a[0]=a[2];
         a[2]=a[5];
         a[5]=a[3];
         a[3]=b;
      }
      if (c=='R'){
         b=a[1];
         a[1]=a[2];
         a[2]=a[4];
         a[4]=a[3];
         a[3]=b;
      }
    }
int up(){return a[0];}
int front(){return a[1];}
int right(){return a[2];}
int left(){return a[3];}
};
int main()
{  Si r;
    
     for (int i=0;i<6;i++){
         cin>>r.a[i];
     }
     int c;cin>>c;
     while(c--){
         int e,f;cin>>e>>f;
         if(r.left()==e) r.move('E');
         if(r.right()==e) r.move('W');
         while(r.up()!=e) r.move('N');
         while(r.front()!=f) r.move('R');
         cout<<r.right()<<endl;
     }
    
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 3e5 + 20;
ll dp[maxn][2] , a[maxn] , sum , res = -1e18;
multiset<ll> st;
void f(int n , ll x)
{
    sum = 0;
    st.clear();
    if(x)
    {
        reverse(a , a + 3 * n);
        for(int i = 0; i < 3 * n; i++)
            a[i] *= -1;
    }
    for(int i = 0; i < n; i++)
    {
        st.insert(a[i]);
        sum += a[i];
    }
    dp[n - 1][x] = sum;
    for(int i = n; i < 3 * n; i++)
    {
        if(a[i] > *st.begin())
        {
            sum -= *st.begin() - a[i];
            st.erase(st.begin());
            st.insert(a[i]);
        }
        dp[i][x] = sum;
    }
}
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < 3 * n; i++)
        cin >> a[i];
    for(int i = 0; i < maxn; i++)
        dp[i][0] = dp[i][1] = res;
    f(n , 0);
    f(n , 1);
    for(int i = n - 1; i < 2 * n; i++)
    {
        res = max(res , dp[i][0] + dp[3 * n - i - 2][1]);
    }
    cout << res;
}


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

bool is_divider(int n)
{
  int cnt=0;
  if(n < 16) return false;
  for(int i=1;i*i <= n;i++){
    if(n % i == 0) cnt++;
  }
  if(cnt == 4) return true;
  else return false;
}
int main()
{
  int n;
  cin >> n;

  int cnt=0;
  for(int i=1;i <= n;i+=2){
    if(is_divider(i)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    int n,m,l;
    cin>>n>>m>>l;
    int a[101][101]={};
    int b[101][101]={};
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>b[i][j];
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            long sum=0;
            for(int k=0;k<m;k++){
                sum+=a[i][k]*b[k][j];
            }
            cout<<sum;
            if(j!=l-1){
                cout<<" ";
            }
        }
         cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3184
w,h,n = map(int,input().split())
xs = 0
ys = 0
xe = w
ye = h
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 2:
        xe = min(xe,x)
    elif a == 1:
        xs = max(xs,x)
    elif a == 4:
        ye = min(ye,y)
    else:
        ys = max(ys,y)
if xs < xe and ys < ye:
    print(abs(xs-xe)*abs(ys-ye))
else:
    print(0)

Measured memory_bytes: 9136
program ABC_079_A_GoodInteger
   implicit none
   character(4) N
   read(*, *) N
   if((N(2:2) == N(1:1) .and. N(2:2) == N(3:3)) .or. (N(3:3) == N(2:2) .and. N(3:3) == N(4:4))) then
       write(*, *) 'Yes'
   else
       write(*, *) 'No'
   end if
end program ABC_079_A_GoodInteger

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

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

int main(int argc, char const* argv[])
{
  int h, w;
  cin >> h >> w;
  vector<string> s;
  for(int i = 0; i < h; i++){
    string st;
    cin >> st;
    s.pb(st);
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '#')cout << '#';
      else{
        int res = 0;
        for(int k = 0; k < 8; k++){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(nx >= 0 && nx < h && ny >= 0 && ny < w){
            if(s[nx][ny] == '#')res++;
          }
        }
        cout << res;
      }
    }
    cout << endl;
  }
	return 0;
}


Measured memory_bytes: 256
N=int(input())
S=list(input())
AruFa=['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','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']
ans=[]
for i in S:
	ans.append(AruFa[AruFa.index(i)+N])
print(''.join(ans))

Measured memory_bytes: 3188
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad                    (forM, replicateM)
import           Control.Monad.Trans.State.Strict (State, execState, get, put)
import qualified Data.ByteString.Char8            as BC
import           Data.List                        (delete, sort, sortOn)
import           Data.Maybe                       (fromJust)

main :: IO ()
main = do
  n <- readLn
  abs <- replicateM n getInt2
  cds <- replicateM n getInt2
  print $ solve n abs cds

solve :: Int -> [(Int, Int)] -> [(Int, Int)] -> Int
solve n abs cds = n - m where
  m = length . flip execState abs $
        forM (sort cds) deleteFriend

deleteFriend :: (Int, Int) -> State [(Int, Int)] ()
deleteFriend cd = do
  abs <- get
  let fs = reverse . sortOn snd $ filter (dominate cd) abs
  if null fs
    then return ()
    else put $ delete (head fs) abs

dominate :: (Int, Int) -> (Int, Int) -> Bool
dominate (c, d) (a, b) = a < c && b < d

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine

getInt2 :: IO (Int, Int)
getInt2 = (\[a, b] -> (a, b)) <$> getInts


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

int a[1000000];
int main()
{
	int n,k,q;
	cin >> n >> k >> q;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		a[t]++;
	}
	for(int i = 1; i <= n; i++){
		if(q - a[i] >= k)printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    ll n, x, y;
    std::cin >> n >> x >> y;
    x--; y--;

    auto dists = make_v<ll>(0, n, n);
    for (ll i = 0; i < n; i++) for (ll j = 0; j < n; j++) {
        dists[i][j] = 
            var_min(std::abs(i - j),
                    std::abs(i - x) + 1 + std::abs(y - j),
                    std::abs(i - y) + 1 + std::abs(x - j));
    }
    vec<ll> cnts(n + 1);
    for (ll i = 0; i < n; i++) for (ll j = i + 1; j < n; j++) cnts[dists[i][j]]++;
    for (ll k = 1; k < n; k++) std::cout << cnts[k] << '\n';
    return 0;
}


Measured memory_bytes: 31616
YYMM = False
MMYY = False
f = input()
h1 = f[0] + f[1]
h2 = f[2] + f[3]

if 1 <= int(h2) <= 12:
  YYMM = True
if 1 <= int(h1) <= 12:
  MMYY = True

def ret(c1,c2):
  if c1 and c2:
    return "AMBIGUOUS"
  elif c1:
    return "YYMM"
  elif c2:
    return "MMYY"
  else:
    return "NA"
  
print(ret(YYMM,MMYY))

Measured memory_bytes: 9108
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef pair<int, pair < int, int > > PP;
typedef long long ll;
typedef pair<ll, ll>P;
ll inf = -1;
ll mod = pow(10, 9) + 7;
int main() {
	int n;cin>>n;
	vector<ll> a(n);
	bool flag=false;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0){
			flag=true;
		}
	}
	sort(a.begin(),a.end());
	vector<P>cnt;
	ll c=1;
	for(int i=1;i<n;i++){
		if(a[i-1]==a[i]){
			c++;
		}else{
			cnt.push_back(P(a[i-1],c));
			c=1;
		}
		if(i==n-1){
			cnt.push_back(P(a[i],c));
		}
	}
	if(cnt.size()==1&&cnt[0].first==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(cnt.size()==2&&(cnt[1].second/cnt[0].second==2&&
	cnt[1].second%cnt[0].second==0)){
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(cnt.size()==3&&((cnt[0].second==cnt[1].second)&&
	cnt[1].second==cnt[2].second)){
		if((cnt[0].first^cnt[1].first^cnt[2].first)==0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No";
	
	cout<<endl;
	return 0;
}

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

using namespace std;
typedef long long LL;

#define MAXN 200001
#define MOD 1000000007

int H, W, N;
pair<int, int> bl[3001];
int dp[3001];

// x must be relatively prime to p
int fact[MAXN], inv[MAXN], ifact[MAXN];

// x must be relatively prime to p

template<typename T, typename T1>
T mod(T x, T1 p) {
    x %= p;
    if (x < 0)
        x += p;
    return x;
}

// x must be relatively prime to p

template<typename T>
T inverse(T x, T p) {
    x = mod(x, p);
    if (x == 1)
        return x;
    return mod((1LL * (-p / x) * (inv[p % x] % p)), p);
    // Since inverse of p % x is already calculated.
}

int NcR(int n, int r) {
    int ret = (1LL * ifact[n - r] * ifact[r]) % MOD;
    ret = (1LL * ret * fact[n]) % MOD;
    return ret;
}

int main(int argc, char** argv) {
#ifdef OJ
    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
#endif
    std::ios::sync_with_stdio(false);

    fact[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }

    ifact[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        inv[i] = inverse(i, MOD);
        ifact[i] = (1LL * ifact[i - 1] * inv[i]) % MOD;
    }

    cin >> H >> W >> N;
    for (int i = 0; i < N; i++)
        cin >> bl[i].first >> bl[i].second;

    bl[N].first = H;
    bl[N].second = W;
    N++;

    sort(bl, bl + N);
    for (int i = 0; i < N; i++) {
        int x = bl[i].first;
        int y = bl[i].second;

        dp[i] = NcR(x + y - 2, x - 1);

        for (int j = 0; j < i; j++) {
            if (bl[j].second <= y) {
                int dx = x - bl[j].first;
                int dy = y - bl[j].second;

                dp[i] -= (1LL * dp[j] * NcR(dx + dy, dx)) % MOD;
                if (dp[i] < 0)
                    dp[i] += MOD;
            }
        }
    }

    cout << dp[N - 1] << endl;
    return 0;
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; ++i) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b,a % b);
}
int combination(int n, int k){
    int spaceOptimize[k+1];
    memset(spaceOptimize, 0, sizeof(spaceOptimize));
    spaceOptimize[0] = 1;
    for(int i=1;i<=n; i++){
        for(int j= min(i,k);j>0;j--){
            spaceOptimize[j] = spaceOptimize[j] + spaceOptimize[j-1];
        }
    }
    return spaceOptimize[k];
}
int count_permutation(int arr[], int n){
    int a[n];
    for(int i=0;i<n;i++){
        a[i] = i+1;
    }
    int count = 0;
    do {
        count++;
        if (equal(a, a + n, arr)){
            return count;
        }
    } while (next_permutation(a, a + n));
    return 0;
}

signed main(){
#ifndef ONLINE_JUDGE
    //freopen("input.txt","r", stdin);
#endif
    fastIO

    int n;
    cin >> n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n-1;i++){
        cin >> c[i];
    }
    c[n-1] = 0;
    set<int> allReady;
    int ans = b[a[0]];
//    allReady.insert(a[0]);
    for(int i=1;i<n;i++){
        ans += b[a[i]];

        if(a[i]-1 == a[i-1])
            ans += c[a[i-1]];

//        allReady.insert(a[i]);
    }
    cout << ans;

    return 0;
}


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

#define MAX 100000

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    int tmp;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;
    return i + 1;
}

int main() {
    int A[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    int q = partition(A, 0, n - 1);
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        if (i == q) {
            cout << "[" << A[i] << "]";
        } else {
            cout << A[i];
        }
    }
    cout << endl;
    return 0;
}



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

using namespace std;

int main() {
	long long a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	
	long long x = min(a, c);
	a -= x;
	c -= x;
	x = min(b, c);
	b -= x;
	c -= x;
	
	printf("%lld %lld\n", a, b);
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc151/tasks/abc151_c


N, M = gets.split.map(&:to_i)
ps = Array.new(M)
Ss = Array.new(M)
M.times do |i|
  ps[i], Ss[i] = gets.chomp.split
end
ps.map! { |q| q.to_i - 1 }

fs = Array.new(N, false)
ws = Array.new(N, 0)

M.times do |i|
  next if fs[q = ps[i]]
  if Ss[i] == 'AC'
    fs[q] = true
  else
    ws[q] += 1
  end
end

a = fs.count(&:itself)
b = fs.zip(ws).reduce(0) { |memo, (f, w)| memo + (f ? w : 0) }

puts "#{a} #{b}"


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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string sss = Console.ReadLine();
            int count = sss.Count(x=>x=='1');
            Console.WriteLine(count);
        //     Console.WriteLine(AB[0]*AB[1]);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;

namespace diverta2019
{
	class Program
	{
		static void Main(string[] args)
		{
			// 入力
			int N = int.Parse(Console.ReadLine());
			int[] x = new int[N];
			int[] y = new int[N];
			for (int i = 0; i < N; i++)
			{
				int[] inp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
				x[i] = inp[0];
				y[i] = inp[1];
			}
			// 処理(N<=50)
			// 1:(p,q)の候補は、(x[i]-x[j],y[i]-y[j])(0<=i,j<N)の全ての組み合わせ(O(N^2))
			// 2:(p,q)が決まったとして、そのコストを求めるには(x[i]-x[j],y[i]-y[j])(0<=j<N,j!=i)となるjが存在するiの個数を求めれば良い(O(N^2))
			// 上手くデータを保存しておけば、同時並行でデータを作っていけるのでは？
			// 1
			List<List<int>> subXList=new List<List<int>>(N);
			List<List<int>> subYList=new List<List<int>>(N);
			for (int i = 0; i < N; i++)
			{
				List<int> listX = new List<int>(N);
				List<int> listY = new List<int>(N);
				for (int j = 0; j < N; j++)
				{
					listX.Add(x[i] - x[j]);
					listY.Add(y[i] - y[j]);
				}
				subXList.Add(listX);
				subYList.Add(listY);
			}
			// 2
			int minCost = N;
			for (int a = 0; a < N; a++)
			{
				for (int b = 0; b < N; b++)
				{
					if (a==b)
					{
						// i=jとなる場合は計算しない
						continue;
					}
					int subX = subXList[a][b];
					int subY = subYList[a][b];
					int count = 0;
					for (int c = 0; c < N; c++)
					{
						for (int d = 0; d < N; d++)
						{
							// 同一
							if (subXList[c][d]==subX && subYList[c][d]==subY)
							{
								count++;
								break;
							}
						}
					}
					// 最小コスト更新
					int cost = N - count;
					if (minCost>cost)
					{
						minCost = cost;
					}
				}
			}
			if (minCost==0)
			{
				minCost = 1;
			}
			Console.WriteLine(minCost);
		}
	}
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

int main(void){
	int n,i;
	ll d,t,l=0ll,r=0ll,ans=0ll;
	cin >> n >> d;
	for(i=0; i<n; ++i){
		cin >> t;
		l = max(r,t);
		r = t+d;
		ans += (r-l);
	}
	cout << ans << endl;
	return 0;
}


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

std::string s;
int ch[26];

int main(){
	std::cin >> s;
	
	for(int i = 0; i < s.size(); ++i)++ch[s[i] - 'a'];
	
	for(int i = 0; i < 26; ++i){
		if(ch[i] % 2){
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	
	std::cout << "Yes" << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;
 
typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=105;
 
int main()
{
    int x, y;
    while(~scanf("%d%d", &x, &y)){
        int a=0, b=0;
        if(x==2)a=1;
        if(y==2)b=1;
        if(x==4||x==6||x==9||x==11)a=2;
        if(y==4||y==6||y==9||y==11)b=2;
        printf("%s\n", a==b?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a[100005], b[100005], cnt;

int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) {
		scanf("%lld%lld",&a[i],&b[i]);
	}
	for(int i=n;i>=1;i--) {
		ll tmp = (a[i] + cnt) % b[i];
		if(tmp != 0) cnt += b[i] - tmp;
	}
	printf("%lld\n",cnt);
}


Measured memory_bytes: 1792