akhauriyash/Code-Regression huggingface dataset:
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll A;
  double B; cin >> A >> B;
  ll ans;
  
  ll C = B * 100 + 0.5;
  ans = A * C;
  cout << ans / 100 << endl;
}

Measured memory_bytes: 3660
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Readln(s);
    count:=0;
    max  :=0;
    min  :=100;
    tf   :=true;

    if not(s[1]='A') then
      tf:=false;
    if ord(s[2])<ord('a') then
      tf:=false;

    for i:=3 to length(s) do
      if ord(s[i])<ord('a') then begin
        if (s[i]='C')and(i<>length(s)) then
          inc(count)
        else
          tf:=false;
      end;
    if count <> 1 then
      tf:=false;

    if tf then
      Writeln('AC')
    else
      Writeln('WA');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

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

int main()
{
       int a, b;

       scanf("%d %d", &a, &b );

       if( a == 2 && b == 3 ) puts("1");
       else if( a == 3 && b == 2 ) puts("1");
       else if( a == 1 && b == 3 ) puts("2");
       else if( a == 3 && b == 1 ) puts("2");
       else if( a == 1 && b == 2 ) puts("3");
       else puts("3");
       return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int a[1000000] = { 0 };
       for (int i = 0; i < n; i++)
         cin >> a[i];
       int k = 0;
       int max = 0;
       
     for (int i = 0; i < n - 1; i++)
       { 
          if (a[i] >= a[i + 1])
          k++;
       else 
       { 
          if (max < k)
          max = k; 
          k = 0;
        }
      }
if (k > 0 && max < k) max = k;
  if (max >= 1) cout << max;
      else cout << 0;
  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll n = s.size();

  if(((s[0] == s[n - 1]) && (n % 2 == 0)) || ((s[0] != s[n - 1]) && (n % 2 == 1))){
    cout << "First" << endl;
  } else{
    cout << "Second" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 512
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,K;
    cin >> N >> K;
    set<int> C;

    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int c;
            cin >> c;
            C.insert(c);
        }
    }

    cout << N - C.size() << endl;
}

Measured memory_bytes: 3636
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);
  
  int res=0;
  for (int i=0; i<N; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    res += r-l+1;
  }
  
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 504
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int N;
	cin >> N;
	cout << "ABC" << N << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)
H, W, K = map(int, input().split())
HW = [list(map(int, list(str(input().strip())))) for _ in range(H)]

def blocks(hw):
    score = 0
    ret = 1
    delcnt = 0
    while ret:
        ret = check(delcnt, hw)
        score += ret
        delcnt += 1
    return score

def check(delcnt, hw):
    s = 0
    blank = -1
    for h in range(H):
        cnt = 1
        old = hw[h][:]
        for w in range(1, W):
            if hw[h][w-1]==hw[h][w]:
                cnt+=1
                flg = True
            else:
                if cnt>=K:
                    s += cnt*hw[h][w-1]
                    for k in range(1, cnt+1):
                        hw[h][w-k] = blank
                        blank -= 1
                cnt = 1
        if cnt>=K:
            s += cnt*hw[h][W-1]
            for k in range(1, cnt+1):
                hw[h][W-k] = blank
                blank -= 1
    for w in range(W):
        cnt = 1
        for h in range(H-1, -1, -1):
            item = hw[h][w]
            hw[h][w] = blank
            blank -= 1
            if item>0:
                hw[H-cnt][w] = item
                cnt += 1
    return 2**delcnt*s

import copy
ans = []
if K>=4:
    print(0)
else:
    for h in range(1, H):
        for w in range(W):
            hw = copy.deepcopy(HW)
            for i in range(H-h, 0, -1):
                hw[i][w] = hw[i-1][w]
            hw[0][w] = 0
            ans.append(blocks(hw))
print(max(ans))

Measured memory_bytes: 54620
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> X(K);
	int a = N / K;
	int b = N % K;
	for (int i = 0; i < K; i++) {
		if (i <= b) {
			X[i] = a + 1;
		}
		else {
			X[i] = a;
		}
		//cerr << i << " " << X[i] << endl;
	}
	X[0]--;
	int res = X[0] * X[0] * X[0];
	for (int i = 1; i < K; i++) {
		int j = K - i;
		if ((j + j) % K == 0) {
			res += X[i] * X[j] * X[j];
			//cerr << i << " " << j << endl;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
N=int(input())
i=1
D=[]
while i*i<=N:
  if N%i==0:
    D.append(i)
    D.append(N//i)
  i+=1
ans=0
for r in D:
  m=N//r-1
  if r<m:
    ans+=m
print(ans)  

Measured memory_bytes: 40940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var cnt = 0;
            var limit = Math.Sqrt(n);
            for (var p = 2; p <= limit; p++)
            {
                if (n % p == 0)
                {
                    var subCnt = 0;
                    while (n % p == 0)
                    {
                        n /= p;
                        subCnt++;
                    }
                    for (var i = 1;; i++)
                    {
                        subCnt -= i;
                        if (subCnt >= 0)
                            cnt++;
                        else
                            break;
                    }
                }
            }

            Console.WriteLine(n > 1 ? cnt + 1 : cnt);
        }
    }
}

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

main(){
	
	int n,m,p,pos ;
	int c[20020] ;
	cin >> n >> m >> p ;
	for( int i=0 ; i<m ; i++ ){
		cin >> c[i*2] ;
		c[i*2+1] = c[i*2] + n ;
	}
	c[m*2] = p ;
	c[m*2+1] = p + n ;
	m++ ;
	sort(c,c+m*2) ;
	for( int i=0 ; i<m*2 ; i++ ){
		if( c[i] == p ){
			pos = i ;
			break ;
		}
	}
	
	int ans = c[m+pos] - c[pos+1] ;
	for( int i=1 ; i<m ; i++ ){
		int sum1 = c[pos+i] - c[pos] ;
		int sum2 = c[m+pos] - c[pos+i+1] ;
		if( sum1 < sum2 ) sum1 *= 2 ;
		else sum2 *= 2 ;
		
		ans = min( ans , sum1 + sum2 ) ;
	}
	
	cout << ans*100 << endl ;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, k, a[N];
int fact[N];
int mypow(int a, int b){
	int res = 1;
	while(b){
		if (b&1) res = (res * a) % MOD;
		b /= 2;
		a = (a*a) % MOD; 
	}	
	return res;
}
void precalc(){
	fact[0] = 1;
	for(int i=1; i<N; i++) fact[i] = (fact[i-1]*i) % MOD;
}
int C(int n, int k){
	if (n < 0 || k < 0 || k > n) return 0;
	return fact[n] * mypow(fact[n-k], MOD-2) % MOD * mypow(fact[k], MOD-2) % MOD;
}

int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	precalc();
	int mx = 0, mn = 0;
	for(int i=0; i<n; i++){
		mx += C(i, k-1)*a[i] % MOD; mx %= MOD;
		mn += C(n-i-1, k-1)*a[i] % MOD; mn %= MOD;
	}
	int ans = (mx-mn + MOD) % MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  ll x;
  cin >> x;
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n - 1; i++){
    if(x >=a[i]){
      x -= a[i];
    }else{
      cout << i << endl;
      return 0;
    }
  }
  if(x == a[n-1]){
    cout << n << endl;
  }else{
    cout << n - 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stdlib.h>

using namespace std;

const int MAX_W = 1000;
const int MAX_H = 1000;
const int MAX_N = 9;

typedef pair<int, int> P;

int H,W,N;
char field[MAX_H][MAX_W];
int dist[MAX_H][MAX_W];

queue<P> que;

//using limits = std::numeric_limits<int>;

int limits = 99999;

void getStatus(int y, int x, int min_dist){
    for(int i = 0; i< H; i++) {
        for (int j = 0; j < W; j++) {
            if( i == y && j == x){
                cout << "$";
            }else {
                cout << field[i][j];
            }
        }
        cout << endl;
    }
    cout << "-------------min_dist:" << min_dist << endl;
}


int bfs(int goal){

    int gx,gy;

    while( que.size()){
        P p = que.front(); que.pop();
        int a = p.first;
        int b  = p.second;

        if( atoi(&field[p.first][p.second]) == goal ) { gy = p.first; gx = p.second; break; }

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

        for(int i=0; i< 4; i++){

            int ny = p.first + dy[i],
                nx = p.second+ dx[i];

            if( 0 <= nx
                && nx < W
                && 0<= ny
                && ny < H
                && field[ny][nx] != 'X'
                && dist[ny][nx] ==  limits ){

                que.push(P(ny,nx) );
                dist[ny][nx] = dist[p.first][p.second] + 1;

            }
        }
       // getStatus(p.first,p.second,dist[p.first][p.second]);
    }

    return dist[gy][gx];
}


void init_dist(){
    for(int i=0; i< H; i++){
        for(int j=0; j<W; j++){
            dist[i][j] = limits;
        }
    }
    while(que.size()){
        que.pop();
    }

}


void solve(){
    int sum = 0;
    for(int i = 0; i< H; i++){
        for(int j = 0; j< W; j++){

            if( field[i][j] == 'S'){
                init_dist();
                que.push(P(i,j));
                dist[i][j] = 0;
                sum += bfs(1);
            }

            for(int k = 1; k<N; k++){
                if( atoi(&field[i][j]) == k ) {
                    init_dist();
                    que.push(P(i,j));
                    dist[i][j] = 0;
                    sum+=bfs(k+1);
                }

            }
        }
    }

    cout << sum << endl;

}



int main() {

    //while(1){

        string line;
        cin >> H >> W >> N;cin.ignore();
        //if( H == 0 && W == 0 ){
        //    break;
        //}


        for(int i = 0; i< H; i++){
            getline(cin,line);
            for(int j = 0; j< W; j++){
                field[i][j] = line[j];
            }
        }

        solve();

    //}

    return 0;
}

/*
10 10 9
.X...X.S.X
6..5X..X1X
...XXXX..X
X..9X...X.
8.X2X..X3X
...XX.X4..
XX....7X..
X..X..XX..
X...X.XX..
..X.......
 */

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    int cnt = 0;
    for ( int i = 1; i <= n; ++i ) {
        cin >> p[i];
    }
    for ( int i = 1; i <= n; ++i ) {
        if ( p[i] == i ) {
            swap(p[i+1], p[i]);
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        //List<int> values = new List<int>(Console.ReadLine().Split(' ').Select(s => int.Parse(s)));
        //List<int> values = new List<int>();

        string input = Console.ReadLine();
        //int n = int.Parse(input.Split(' ')[0]);
        //int m = int.Parse(input.Split(' ')[1]);
        //int k = int.Parse(input.Split(' ')[2]);
        int n = int.Parse(input);

        List<int>  values = new List<int>();
        values.Add(n);

        int a = 1;

        if (n == 1)
        {
            Console.WriteLine(4);return;
        }
        if (n == 2)
        {
            Console.WriteLine(4); return;
        }

        while (n!=4)
        {
            if(n%2==0)
            {
                n /= 2;
            }
            else
            {
                n = n * 3 + 1;
            }
            a++;
        }



        Console.WriteLine(a+3);
        
    }
}

Measured memory_bytes: 13140
import sys
sys.setrecursionlimit(100000)

def resolve():
    def toC(A, B, C):
        if not (A or B):
            return 0
        if C & 1:
            return toC(A>>1, B>>1, C>>1) # Cにある一番小さいコップは考えない
        if B & 1:
            return (toC(C>>1, B>>1, A>>1) # 一度反対側にどかす
            + toC((A|B|C)>>1, 0, 0) # 反対側からそいつらを持ってくる
            + 1) # B -> C
        if A & 1:
            return (toC(A>>1, B>>1, C>>1) # まずすべてCにまとめる
            + 2 * toC((A|B|C)>>1,0,0) # 端から端へ2回移動させる
            + 2) # A -> B -> C

    while True:
        n, m = map(int, input().split())
        cup = [0 for _ in range(3)]
        if n == 0:
            return
        for i in range(3):
            a = list(map(int, input().split()))
            for s in a[1:]:
                cup[i] |= 1 << s-1
        a = min(toC(*cup), toC(*reversed(cup)))
        print(a if a <= m else -1)

if __name__ == "__main__":
    resolve()
    


Measured memory_bytes: 5612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

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

  int N,S;
  cin>>N>>S;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  
  vector<vector<ll>> dp(N+1,vector<ll> (S+1,0));
  dp[0][0]=1;
  for(int i=0;i<N;i++){
      for(int j=0;j<=S;j++){
          add(dp[i+1][j],dp[i][j]);
          if(j+A[i]<=S){
              ll neco=1;
              if(j==0) neco=i+1;
              ll res=dp[i][j]*neco%MOD;
              add(dp[i+1][j+A[i]],res);
          }
      }
  }

  ll ans=0;
  for(int i=1;i<=N;i++) add(ans,dp[i][S]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 70784
while n=gets
	n=n.to_i
	count=0
	
	a=0
	
	while a < 10
	b=0
		while b < 10
	c=0
			while c < 10
	d=0
				while d < 10
					if a+b+c+d == n
						count += 1
#						puts "#{a} #{b} #{c} #{d} #{count}"
					end
					d+=1
				end
				c+=1
			end
			b+=1
		end
		a+=1
	end
	puts count
end

Measured memory_bytes: 8460
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = (a); (i) < (b); (++(i)))
#define rep(i, n)     repd(i, (0), (n))
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

void pv(vector<u64> v) {
  for(auto i : v) {
    cerr << i << " ";
  }
  cerr << endl;
}

int main(int argc, const char* argv[]) {
  u64 n, k;
  string s;
  cin >> n >> k >> s;
  
  vector<u64> v0 = {0};
  vector<u64> v1 = {0};
  u64 tmp0 = 0, tmp1 = 0;
  char pre = '1';
  rep(i, n) {
    switch(pre) {
      case '0':
        switch(s[i]) {
          case '0':
            ++tmp0;
            break;
          case '1':
            pre = '1';
            v0.push_back(tmp0);
            ++tmp1;
            break;
        }
        break;
      case '1':
        switch(s[i]) {
          case '0':
            pre = '0';
            v1.push_back(tmp1);
            ++tmp0;
            break;
          case '1':
            ++tmp1;
            break;
        }
        break;
    }
  }
  
  if(s[n-1] == '0') {
    v0.push_back(tmp0);
  }
  v1.push_back(tmp1);
  
  if(k < v0.size()) {
    k = k;
  } else {
    k = v0.size() - 1;
  }
  
  u64 ret = 0;
  rep(i, (v1.size() - k - 1)) {
    u64 tmp = v1[k+i+1] - v1[i] + v0[k+i] - v0[i];
    if(tmp > ret) {
      debug(i);
      debug(v1[k+i+1]);
      debug(v1[i]);
      debug(v0[k+i]);
      debug(v0[i]);
      ret = tmp;
    }
  }
  
  cout << ret << endl;
  
  
  for(auto i : v0) {
    cerr << i << " ";
  }
  cerr << endl;
  for(auto i : v1) {
    cerr << i << " ";
  }
  cerr << endl;
  
  return 0;
}


Measured memory_bytes: 1404
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

const ll MAX = 1000005;

vll fac(MAX, 0), finv(MAX, 0), inv(MAX, 0);

void initCombTable() {
  fac.at(0) = 1; fac.at(1) = 1;
  finv.at(0) = 1; finv.at(1) = 1;
  inv.at(1) = 1;
  rep(i, 2, MAX) {
    fac.at(i) = fac.at(i-1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD%i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
  }
}

ll nCk(ll n, ll k) {
    if (k == 0 || n == k) return 1;
  else if (n < 0 || k < 0 || n < k) return 0;
  return fac.at(n) * (finv.at(k) * finv.at(n-k) % MOD) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    initCombTable();
    ll x, y; cin >> x >> y;
    if ((x + y) % 3 != 0 || min(x, y) * 2 < max(x, y)) cout << 0 << '\n';
    else {
        ll tmpx = (x + y) / 3, tmpy = (x + y) / 3 * 2;
        cout << nCk(tmpx, tmpy - y) << '\n';
    }
    return 0;
}


Measured memory_bytes: 23680
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vll a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vll acca(n + 1, 0);
    for (int i = 0; i < n; i++) acca[i + 1] = acca[i] + a[i];

    vvll dp(n, vll(n, HIGHINF));
    auto memo = [&](auto && self, int l, int r) -> ll {
        if (dp[l][r] != HIGHINF) return dp[l][r];
        if (l == r) return dp[l][r] = 0;
        for (int i = l; i < r; i++) {
            chmin(dp[l][r], self(self, l, i) + self(self, i + 1, r) + acca[r + 1] - acca[l]);
        }
        return dp[l][r];
    };
    cout << memo(memo, 0, n - 1) << '\n';
    return 0;
}


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

int main() {
    int number = 0;
    cin >> number;
    int area = number + 1;
    vector<long long> lucas(area);
    for (int i = 0; i < area; ++i) {
        if (i == 0) {
            lucas.at(i) = 2;
        }
        if (i == 1) {
            lucas.at(i) = 1;
        }
        if (i >= 2) {
            lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
        }
    }
    
    cout << lucas.at(number) << endl;
}



Measured memory_bytes: 256
def d_prediction_and_restriction():
    import re
    N, K = [int(i) for i in input().split()]
    R, S, P = [int(i) for i in input().split()]
    T = input()

    can_win = {'r': 'p', 's': 'r', 'p': 's'}
    win_hand = [can_win[ch] for ch in T]
    points = {'r': R, 's': S, 'p': P}

    for i in range(K, N):
        if win_hand[i - K] == win_hand[i]:
            win_hand[i] = 'x'  # 制限に反するので手を適当に変える

    return sum(win_hand.count(ch) * points[ch] for ch in ('r', 's', 'p'))

print(d_prediction_and_restriction())

Measured memory_bytes: 4376
H, W = map(int, input().split())
board = [list(input()) for i in range(H)]

ans = board
dist = [(1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1), (0, 1)]

for i in range(H):
    for j in range(W):
        if board[i][j] == '#':
            continue
        count = 0
        for x, y in dist:
            now_x = j + x
            now_y = i + y
            if now_x >= W or now_x < 0:
                continue
            if now_y >= H or now_y < 0:
                continue
            if board[now_y][now_x] == '#':
                count += 1
        ans[i][j] = str(count)

for line in ans:
    print(''.join(line))




Measured memory_bytes: 3188
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[20][20];
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	y=0;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			x=0;
			for(k=0;k<m;k++)
			{
				x+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			if(int(sqrt(x))*int(sqrt(x))==x)
			{
				y++;
			}
		}
	}
	printf("%d",y);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int t[n][n];
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  t[i][j]=0;
      t[(n/2)+1][n/2]=1;
      int x=(n/2)+2,y=n/2+1;
      int num=2;
      while(num<=(n*n))
	{
	  if(x<=n-1 && y<=n-1 && x>=0 && y>=0 && t[x][y]==0)
	    {
	      //	      cout<<"a"<<endl;
	      t[x][y]=num;
	      x=x+1;  
	      y=y+1;
	      num++;
	    }
	  else{
	    if(y>n-1)
	      {
		//		cout<<"c"<<endl;
		y=0;
	      }
	    if(y<0)
	      {
		//		cout<<"d"<<endl;
		y=n-1;
	      }
	    if(x>n-1)
	      {
		//		cout<<"e"<<endl;
		x=0;
	      }
	    

	    if(t[x][y]!=0)
	      {
		//		cout<<"b"<<endl;
		y=y-1;
		x=x+1;
	      }
	  }
	  //	  cout<<num<<" "<<x<<" "<<y <<endl;
	}
      
      for(int i=0;i<n;i++,cout<<endl)
	for(int j=0;j<n;j++)
	  printf("%4d",t[i][j]);

    }
}

Measured memory_bytes: 1192
N,M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

ans = "No"
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = False
                    break
        if flag:
            ans = "Yes"
            break
print(ans)

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n, i, k, ans = 0;
	cin >> n >> k;
	vector<ll>v(n);
	rep(i,0,n)cin >> v[i];
	sort(all(v));
	rep(i,0,n-k)ans += v[i];
	cout << ans << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}



Measured memory_bytes: 4728
#include <stdio.h>
	#include<iostream>
	#include<string.h>
	#include<math.h>
	#include<stdlib.h>
	#include <time.h>
	#include <bits/stdc++.h>

	using namespace std;


	int main(int argc, char const *argv[])
	{
		int n;
		cin>>n;
		int a[n];
		int sum=1;		

		for(int i=0;i<n;i++)
			cin>>a[i];

		for(int i=0;i<n;i++)
		{
			if(a[i]%2==0)
				sum=sum*2;

		}

		cout<<(int)(pow(3,n)-sum);

		return 0;
	}

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

using namespace std;

int main()
{
		int N,L;
		
		cin>>N>>L;
		string s[N];
			for(int i=0;i<N;i++)
			{
				cin>>s[i];
			}
			sort(s,s+N);
		for(int i=0;i<N;i++)
			cout<<s[i];
			
	return 0;
}

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

const int MOD = 1e9 + 7;

int main(){
	
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	vector<vector<ll>> dp(n+1,vector<ll>(k+1));
	rep(i,n+1){
		dp[i][0] = 1;
	}
	
	for(int i = 1; i < n+1; i++){
		rep(j,k){
			if(j-a[i-1] >= 0){
				dp[i][j+1] = ( dp[i][j] + dp[i-1][j+1] - dp[i-1][j-a[i-1]] + MOD) % MOD;
			}
			else{
				dp[i][j+1] = ( dp[i][j] + dp[i-1][j+1] ) % MOD;
			}
		}
	}
	
	cout << dp[n][k] << endl;
	return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>
int main(void)
{
	int i,j,n,flag,b_index,c_index;
	int a[10];

	scanf("%d",&n);

	while (n--)
	{
		int b[10], c[10];
		flag = 1;
		b_index = 1;
		c_index = 1;
		i = 0;
		while (i < 10) {
			scanf("%d", &a[i]);
			i++;
		}

		b[0] = a[0];
		c[0] = 0;
			for (j = 1; j < 10; j++) {

				if (a[j] > b[b_index-1]) {
					flag = 1;
					b[b_index] = a[j];
					b_index++;
				}
				else if(a[j] > c[c_index-1]){
					flag = 1;
					c[c_index] = a[j];
					c_index++;
				}
				else {
					flag = 0;
					printf("NO\n");
					break;
				}			
			}
			if (flag) {
				printf("YES\n");
			}
	};

	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int N;
long long res,B_,_A,BA;
int main()
{
	cin>>N;
	while(N--)
	{
		string S;
		cin>>S;
		long long cnt=0;
		for(int i=0;i<S.length()-1;i++)
			if(S[i]=='A'&&S[i+1]=='B')
				cnt++;
		res+=cnt;
		if(S[0]=='B'&&S[S.length()-1]=='A')
			BA++;
		else if(S[0]=='B')
			B_++;
		else if(S[S.length()-1]=='A')
			_A++;
	}
	long long res1=0;
	res1+=min(B_,_A);
	res1+=BA;
	if(!B_&&!_A&&BA)
		res1--;
	cout<<res+res1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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() {
    int n; cin >> n;
    set<string> s;
    rep(i, n) {
        string x; cin >> x;
        s.insert(x);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 19008
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

typedef vector<int> vi;

int v, d;
const int N = 1001;
int p[N];
int r[N];
int f[N];

int find(int x) {
	if(p[x] == x) {
		return x;
	} else {
		return p[x] = find(p[x]);
	}
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(r[x] < r[y]) {
		p[x] = y;
	} else {
		p[y] = x;
		if(r[x] == r[y]) r[x]++;
	}
}

void uft() {
	repa(i,1,v) {
		p[i] = i;
		r[i] = 0;
	}

	repa(i,1,v) {
		repa(j,i,v) {
			if(abs(f[i] - f[j]) < d) unite(i, j);
		}
	}

	int ans = 0;
	vector<int> memo(v+1, 0);
	repa(i,1,v) {
		int root = find(i);
		if(memo[root] == 0) {
			memo[root] = 1;
			ans++;
		}
	}
	cout << ans << endl;
}

void dfs(int n, int g, vi& groups) {
	queue<int> que;
	que.push(n);

	while(!que.empty()) {
		int p = que.front();
		que.pop();

		if(groups[p] != 0) continue;

		groups[p] = g;
		repa(i,n+1,v) {
			if(groups[i] == 0 && abs(f[p] - f[i]) < d) {
				que.push(i);
			}
		}
	}
}

void solve() {
	int g = 1;
	vi groups(v+1, 0);
	repa(i,1,v) {
		if(groups[i] == 0) {
			dfs(i, g, groups);
			g++;
		}
	}
	cout << (g-1) << endl;
}

int main() {
	fill(f, f+N, 0);
	f[0] = 1;
	f[1] = 2;
	repa(i,2,N-1) {
		f[i] = (f[i-1] + f[i-2]) % N;
	}

	long t, elapsed;
	while(cin>>v>>d) {
		//t = clock();
		uft();
		//elapsed = clock() - t;
		//cout << "Time = " <<  elapsed / 1000.0 << endl;

		//t = clock();
		//solve();
		//elapsed = clock() - t;
		//cout << "Time = " <<  elapsed / 1000.0 << endl;
	}
}

Measured memory_bytes: 1212
from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1mc = v1.most_common()
v2mc = v2.most_common()
if(v1mc[0][0] == v2mc[0][0]):
    if(len(v1mc) == 1 and len(v2mc) == 1):
        print(int(n/2))
    elif(len(v1mc) == 1):
        print(n - (v1mc[0][1]+v2mc[1][1]))
    elif(len(v2mc) == 1):
        print(n - (v2mc[0][1]+v1mc[1][1]))
    else:
        print(n - max(v1mc[0][1]+v2mc[1][1], v2mc[0][1]+v1mc[1][1]))
else:
    print(n - (v1mc[0][1]+v2mc[0][1]))


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

int main(){
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X);
  vector<long long> B(Y);
  vector<long long> C(Z);
  for (int i=0;i<X;i++){
    cin >> A.at(i);
  }
  for (int i=0;i<Y;i++){
    cin >> B.at(i);
  }
  for (int i=0;i<Z;i++){
    cin >> C.at(i);
  }
  vector<long long> F(X*Y);
  for (int i=0;i<X;i++){
    for (int j=0;j<Y;j++){
      F.at(i*Y+j) = A.at(i) + B.at(j);
    }
  }
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());
  int M = min(X*Y, K);
  vector<long long> G(M*Z);
  for (int i=0;i<M;i++){
    for (int j=0;j<Z;j++){
      G.at(i*Z+j) = F.at(i) + C.at(j);
    }
  }
  sort(G.begin(), G.end());
  reverse(G.begin(), G.end());
  for (int i=0;i<K;i++){
    cout << G.at(i) << endl;
  }
  return 0;
}

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

#define NUM 131072
#define LOOTNUM 363

int main()
{
	bool prime[NUM];
	unsigned num;

	prime[1] = false;
	prime[2] = true;
	for(long i = 3; i < NUM; i += 2) {
		prime[i] = true;
	}

	for(long i = 3; i <= LOOTNUM; i += 2) {
		if(prime[i] == true)
			for(long j = 2 * i; j < NUM; j += i)
				prime[j] = false;
	}

	while(1) {
		cin >> num;

		if(num == 0) break;
		else if(num == 1) {cout << 2 << endl;}
			else {
			unsigned long sum = 2;
			long I = 3;
			num--;
	
			while(num) {
				if(prime[I] == true) {
					sum += I;
					num--;
				}
				I += 2;
			}
			cout << sum << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
typedef long long int64;

int sum[1000000][3];
int sum2[1000000][3];

int main(){
  string str;
  cin >> str;

  for(int i = 0; i < str.size(); i++){
    int pos = string("JOI").find(str[i]);
    if(i) sum[i][pos] = sum[i - 1][pos] + 1;
    else sum[i][pos] = 1;
  }
  for(int i = str.size() - 1; i >= 0; i--){
    int pos = string("JOI").find(str[i]);
    if(i == str.size() - 1) sum2[i][pos] = 1;
    else sum2[i][pos] = sum2[i + 1][pos] + 1;
  }
  

  int ret = 0;
  for(int i = 1; i < str.size() - 1; i++){
    if(sum[i][1] > 0){ // 真ん中'O'の長さに依存してそう( こうさつ
      int J_pos = i - sum[i][1]; //これが'J'の終わり
      int I_pos = i + 1; // これが'I'の始まり
      if(J_pos >= 0 && (sum[J_pos][0] >= sum[i][1] && sum2[I_pos][2] >= sum[i][1])) ret = max( ret, min( sum[i][1], min( sum[J_pos][0], sum2[I_pos][2])));
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 25652
#include<bits/stdc++.h>
using namespace std;
int MIN=9999;
string S;
void solve(int n,int m,int now){
 	if(m == 3){
      MIN = min(MIN,abs(753-now));
      return;
    }
  	if(n == S.size())
      return;
  	solve(n+1,m+1,10*now+(S[n]-'0'));
}
int main(){
    int A,B,C;
  cin >> A >> B >> C;
  cout << ((A*B)/2) << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;


struct jie
{
    ll x,y,k;
}a[100005];
struct dai
{
    ll u,v,c;
}e[200005];
int fa[100005];
int fnd(int x)
{
    if(fa[x]==x)
    {
        return x;
    }
    return fa[x]=fnd(fa[x]);
}
bool cmp1(jie i,jie j)
{
    return i.x<j.x;
}
bool cmp2(jie i,jie j)
{
    return i.y<j.y;
}
bool cmp3(dai i,dai j)
{
    return i.c<j.c;
}
int main()
{
    int n,i,m=0,cnt=0;
    ll ans=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        fa[i]=i;
        scanf("%d %d",&a[i].x,&a[i].y);
        a[i].k=i;
    }
    sort(a+1,a+n+1,cmp1);
    for(i=2;i<=n;i++)
    {
        e[m].c=a[i].x-a[i-1].x;
        e[m].u=a[i-1].k;
        e[m].v=a[i].k;
        m++;
    }
    sort(a+1,a+n+1,cmp2);
    for(i=2;i<=n;i++)
    {
        e[m].c=a[i].y-a[i-1].y;
        e[m].u=a[i-1].k;
        e[m].v=a[i].k;
        m++;
    }
    sort(e,e+m,cmp3);
    for(i=0;i<m;i++)
    {
        int p,q;
        if((p = fnd(e[i].u)) != (q = fnd(e[i].v)))
        {
            fa[q] = p;
            ans=ans+e[i].c;
            cnt++;
            
        }
        if(cnt==n-1)
        {
            break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


string s;
ll x, y, nm = 1, now = 0;
vector<ll> a, b;
bool dp[2][8100][16200], ok, ok2 = true;
int main() {
	cin >> s;
	cin >> x >> y;
	s.push_back('T');
	// 0 = 8000
	dp[0][0][8000] = true;
	dp[1][0][8000] = true;
	REP(i, s.size()) {
		if (s[i] == 'T') {
			if (now > 0) {
				if (nm == 1) {
					a.push_back(now);
					if (!ok and a.size() == 1)ok2 = false;
				}
				else b.push_back(now);
			}
			ok = true;
			now = 0;
			nm *= -1;
		}
		else now++;
	}
	REP(i, a.size()) {
		REP(j, 16200) {
			if (dp[0][i][j]) {
				dp[0][i + 1][j + a[i]] = true;
				if(ok2 or i > 0)dp[0][i + 1][j - a[i]] = true;
			}
		}
	}
	REP(i, b.size()) {
		REP(j, 16200) {
			if (dp[1][i][j]) {
				dp[1][i + 1][j + b[i]] = true;
				dp[1][i + 1][j - b[i]] = true;
			}
		}
	}
	if (dp[0][a.size()][8000 + x] and dp[1][b.size()][8000 + y])cout << "Yes" << endl;
	else cout << "No" << endl;
}




Measured memory_bytes: 66432
#include <bits/stdc++.h>
namespace std {
    template <>
    class hash<std::pair<string, string>> {
    public:
        size_t operator()(const std::pair<string, string>& x) const{
            return hash<string>()(x.first) ^ hash<string>()(x.second);
        }
    };
}
using namespace std;
#define int long long



signed main(){
    int n;
    cin >>n;
    char s1[n],s2[n];
    for(int i=0;i<n;i++)cin >> s1[i];
    for(int i=n-1;i>=0;i--)cin >> s2[i];
    unordered_map<pair<string,string>,int> p1;
    int k=pow(double(2),double(n)),k0;
    string k1="",k2="";
   
    for(int i=0;i<k;i++){
        k0=i;
        k1="";k2="";
        for(int j=0;j<n;j++){
            if(k0%2==0)k1.push_back(s1[j]);
            else k2.push_back(s1[j]);
            k0 /=2;
        }
      //  cerr << k1[0]<<endl;
        p1[make_pair(k1,k2)]++;
    }
    int ans=0;
    for(int i=0;i<k;i++){
        k0=i;
        k1="";k2="";
        for(int j=0;j<n;j++){
            if(k0%2==0)k1.push_back(s2[j]);
            else k2.push_back(s2[j]);
            k0 /=2;
        }
        if(p1.find(make_pair(k1,k2))!=p1.end())ans+=p1.at(make_pair(k1,k2));
        
    }
    cout <<ans;

    return 0;
}

Measured memory_bytes: 47048
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<pair<int, int>> p_vec;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  p_vec.resize(N);
  for (int i = 0; i < N; i++) {
    int ai, bi;
    cin >> ai >> bi;
    p_vec[i] = make_pair(bi, ai);
  }
  sort(p_vec.begin(), p_vec.end());

  bool ok = true;
  int cur = 0;
  for (int i = 0; i < N; i++) {
    cur += p_vec[i].second;
    if (cur > p_vec[i].first) {
      ok = false;
      break;
    }
  }

  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int n) : par(n), siz(n, 1) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root (int i) {
        while (par[i] != i) {
            i = par[i] = par[par[i]];
        }
        return i;
    }
    bool marge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool is_same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int i) {
        return siz[root(i)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind card(n);
    rep(i,m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        card.marge(x, y);
    }
    int ans = 0;
    rep(i,n) {
        if (card.par[i] == i) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#define inf 1e18
using namespace std;
long long dp[3005][3005];
long long a[3005];
long long int rec(int i,int j){
	if(i>j)return 0;
	if(dp[i][j]!=-inf)return dp[i][j];
	return dp[i][j]=max(a[i]-rec(i+1,j),a[j]-rec(i,j-1));
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=-inf;
	cout<<rec(0,n-1);
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
//#include <conio.h>
#define MAX 200000100
using namespace std;

bool isodd(int n)
{
    return (n%2==0);
}

int main()
{
    int a,b,c,co=0,flag=1;
    cin>>a>>b>>c;

    int s=b/2;
    while(isodd(a) && isodd(b) && isodd(c))
    {
        a/=2;
        c/=2;
        a+=s;
        c+=s;
        co++;
        if(a==b && b==c && a==c){
            cout<<-1<<"\n";
            flag=0;
            break;
        }
    }
    if(flag)
        cout<<co<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

/*aのb進数時の桁数*/
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}
/*nをa進数にしたときの、i桁目の数*/
ll placenai(ll n, ll a, ll i){return i==1?n%a:placenai(n/a,a,i-1);}
/*aのn乗(mod) 繰り返し二乗法*/
ll modpow(ll a, ll n, ll mod){
    ll s[digits(n,2)],ans=1;
    rep(i,0,digits(n,2)){
        s[i]= i==0 ? a : s[i-1]*s[i-1]%mod ;
        ans*=placenai(n,2,i+1)==1?s[i]:1; ans%=mod;
    }
    return n?ans:1;
}
ll inv[200005],finv[200005];
void makeinv(ll n){
    inv[1]=1;finv[0]=finv[1]=1;
    rep(i,2,n+1){
        inv[i]=MOD1 - inv[MOD1%i] * (MOD1 / i) % MOD1;
        finv[i] = finv[i - 1] * inv[i] % MOD1;
    }
}
ll modfac(ll n, ll mod){
    ll x=1;
    rep(i,2,n+1){x*=i%mod;x%=mod;}
    return x;
}

int main(void){
    // char ;
    ll n,a,b,ans=0;
    scanf("%lld%lld%lld",&n,&a,&b);
    // ll [n];
    makeinv(200003);
    ans = modpow(2,n,MOD1) + mod(-1);
    ll tmp=1;
    rep(i,0,a){
        tmp = tmp * inv[i+1] %MOD1 * (n-i) %MOD1;
    }
    ans += mod(-tmp);
    // printf("%lld\n",tmp );
    rep(i,a,b){
        tmp = tmp * inv[i+1] %MOD1 * (n-i) %MOD1;
        // tmp = mod( tmp * (n-i) );
        // tmp = mod( tmp*inv[i+1] );
        // printf("%lld %lld ",i,6*finv[6]%MOD1);
        // tmp%=MOD1;
        // printf("%lld\n",tmp);
    }
    ans += mod( -tmp );


    
    printf("%lld\n",mod(ans) );
    return 0;
}


Measured memory_bytes: 3328
s = input()

a = [0] * (len(s) + 1)

for i in range(len(s)):
    if s[i] == '<':
        a[i+1] = max(a[i+1], a[i] + 1)
for i in range(len(s)-1, -1, -1):
    if s[i] == '>':
        a[i] = max(a[i], a[i+1] + 1)

print(sum(a))

Measured memory_bytes: 28944