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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int N = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

inline ll read()
{
	ll x = 0; int f = 1, c = getchar(); 
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; 
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); 
	return x * f; 
}

int a, b; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	a = read(); 
	b = read(); 
	if (a > b) swap(a, b); 
	
	if ((b + a) % 2 != 0) puts("IMPOSSIBLE"); 
	else printf("%d\n", (b + a) / 2); 
	
	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

int main() {
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    std::vector<int> b(N);
    for(auto& val: a)
        std::cin >> val;
    for(auto& val: b)
        std::cin >> val;

    long long less = 0;
    long long gtr = 0;
    for(int i = 0; i < N; ++i) {
        if(a[i] < b[i]) gtr += (b[i] - a[i]) / 2;
        else if(a[i] > b[i]) less += a[i] - b[i];
    }
    if(gtr < less) std::cout << "No" <<std::endl;
    else std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	int k,n;
	cin>>k>>n;
	vector<int>a(n);
	long long int sum = 0;
	int before,now;
	cin>>a[0];
	before=a[0];
	for(int i=1;i<n;i++){
		cin>>now;
		a[i]=now-before;
		before = now;
	}
	a[0]+=k-before;
	long long int max=-1;
	rep(i,n){
		if(max<a[i])max = a[i];
	}
	cout<<k-max<<endl;
	return 0;
}

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

std::string str(const std::set<std::string>& set,int n){
    auto itr = set.begin();
    for(int i=0;i<n;i++)itr++;
    return *itr;
}
 
int main()
{
    std::string s;
    int k;
    std::cin>>s>>k;
    k--;
    std::set<std::string> set;
    for(int i=0;i<(int)s.size();i++){
        for(int j=i;j<(int)s.size() && j <i+k+1;j++){
            std::string tmp;
            for(int k=i;k<=j;k++){
                tmp.push_back(s[k]);
            }
            //std::cout<<tmp<<std::endl;
            set.insert(tmp);
        }
    }
    auto itr = set.begin();
    for(int i=0;i<k;i++)itr++;
    std::cout<<*itr<<std::endl;
    
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define ll long long int 
#define fon(n) for(ll i=0;i<n;i++)

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t,t1;
    cin>>t;
    vector<ll>A(t,0);
    fon(t-1){
    	cin>>t1;
    	A[t1-1]++;
    }
    fon(t){
    	cout<<A[i]<<"\n";
    }
	return 0;
}

Measured memory_bytes: 4780
#!/usr/bin/env python
# -*- coding: utf-8 -*-

reverse = False

s = input()
q = int(input())

queries = []
for i in range(q):
    queries.append(input())

prefix = []
suffix = []

for query in queries:
    qs = query.split()
    if qs[0] == '1':
        reverse = not reverse
    elif qs[0] == '2':
        if qs[1] == '1':
            if reverse:
                suffix.append(qs[2])
            else:
                prefix.append(qs[2])
        elif qs[1] == '2':
            if reverse:
                prefix.append(qs[2])
            else:
                suffix.append(qs[2])

if reverse:
    print (''.join(suffix[::-1]) + s[::-1] + ''.join(prefix))
else:
    print (''.join(prefix[::-1]) + s + ''.join(suffix))


Measured memory_bytes: 18952
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  cin >> s;
  vi v(4);
  string t = "KUPC";
  for (char &c : s) rep(i, 4) v[i] += c == t[i];
  cout << *min_element(all(v)) << endl;
}

Measured memory_bytes: 3180
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

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

  int n;
  cin >> n;
  map<char, int> mp;
  rep(i,26) mp['a'+i] = inf;
  rep(i,n) {
    map<char, int> m;
    string s;
    cin >> s;
    rep(j,s.size()) m[s[j]]++;
    rep(j,26) mp[j+'a'] = min(mp[j+'a'], m[j+'a']);
  }

  string res = "";
  for(auto P : mp) {
    char c = P.fi;
    int num = P.se;
    if(num == inf) continue;
    rep(i,num) res.push_back(c);
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

#ifdef ZERO_IQ
ios_base::sync_with_stdio ( false ), cin.tie ( 0 ), cout.tie ( 0 );
#endif

ll ncr(ll n, ll m) {
    ll res = 1;
    for (int i = n - m + 1; i <= n; ++i) {
        res *= i;
    }
    return res;
}

int main() {
    ll n, c = 0;
    cin >> n;
    map<string, ll> mp;
    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);
        string fake;
        fake.push_back(s[0]);
        fake.push_back(s[s.length() - 1]);
        if (i <= 9)
            mp[s]++;
        else mp[fake]++;
    }
    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);
        string fake;
        fake.push_back(s[s.length() - 1]);
        fake.push_back(s[0]);
        if (i <= 9) {
            c += mp[s];
            c += mp[fake];
        } else {
            c += mp[fake];
            if (fake[0] == fake[1]) {
                fake.pop_back();
                c += mp[fake];
            }
        }
    }
    cout << c;
    return 0;
}











Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

bool isATGC(char a)
{
	if (a == 'A')
	{
		return true;
	}
	else if (a == 'T')
	{
		return true;
	}
	else if(a == 'G')
	{
		return true;
	}
	else if (a == 'C')
	{
		return true;
	}

	return false;
}

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

	string s;
	
	cin >> s;

	int ans = 0;

	int len = s.size();

	int tmp = 0;

	rep(i, len)
	{
		
		if (isATGC(s[i]))
		{
			tmp++;
		}
		else
		{
			ans = max(ans, tmp);
			tmp = 0;
		}
	}
	ans = max(ans, tmp);

	cout << ans << endl;


	
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    bool frag = false;

    for(int i = 0; i < N; i++){
        char S;
        cin >> S;

        if(S == 'Y') frag = true;
    } 
    if(frag == true) cout << "Four" << endl;
    else cout << "Three" << endl;
    
    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int memo = 0;
  memo = a+b+c;
  memo += max(a,max(b,c))*9;
  
  cout << memo << endl;
  return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n + 1)]
        self.sizes = [1] * (n + 1)

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if y < x:
            x, y = y, x
        self.parents[y] = x
        self.sizes[x] += self.sizes[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self.sizes[self.find(x)]


n, m, k = map(int, input().split())
uf = UnionFind(n)
friends = [0] * n
blocks = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    friends[a - 1] += 1
    friends[b - 1] += 1
    uf.unite(a - 1, b - 1)
for i in range(k):
    c, d = map(int, input().split())
    if uf.same(c - 1, d - 1):
        blocks[c - 1] += 1
        blocks[d - 1] += 1
ans = [0] * n
for i in range(n):
    ans[i] = uf.size(i) - friends[i] - blocks[i] - 1
print(*ans)

Measured memory_bytes: 12584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
const int MOD=1e9+7;
ll dp[100005][15];//dp[下から数えて,今見ている桁数][ここまでの13で割った余り]
ll amari[100005][15];//amari[桁数][0~9]
string s;
int main(void)
{
    cin >> s;
    memset(amari,0,sizeof(amari));
    for(int i=1;i<=100000;i++)
    {
        for(int j=0;j<10;j++)
        {
            if(i==1)
            {
                amari[i][j]=j;
            }
            else
            {
                amari[i][j]=(amari[i-1][j]*10)%13;
            }
        }
    }
    int N=int(s.size());
    s+='#';//1-indexから始めるための番兵
    reverse(s.begin(),s.end());
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=N;i++)
    {
        if(s[i]=='?')
        {
            for(int j=0;j<10;j++)//数字を代入.桁数によって%13の値は大きく変わるぞ.
            {
                int nowmod=amari[i][j];
                for(int k=0;k<13;k++)
                {
                    int nextmod=(nowmod+k)%13;
                    dp[i][nextmod]=(dp[i][nextmod]+dp[i-1][k])%MOD;
                }
            }
        }
        else
        {
            int num=int(s[i]-'0');
            int nowmod=amari[i][num];
            for(int k=0;k<13;k++)
            {
                int nextmod=(nowmod+k)%13;
                dp[i][nextmod]=(dp[i][nextmod]+dp[i-1][k])%MOD;
            }
        }
    }
    cout << dp[N][5] << endl;
}

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

signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> AC(N+1);
  vector<int> WA(N+1);
  
  int P;
  string A;
  for( int i = 0; i < M; i++ ){
    cin >> P >> A;
    if( A == "AC" ){
      AC.at(P)++;
    }else if( A == "WA" && AC.at(P) == 0 ){
      WA.at(P)++;
    }
  }
  
  int ac = 0;
  int wa = 0;
  for( int i = 0; i <= N; i++ ){
    if( AC.at(i) > 0 ) ac++;
    if( AC.at(i) > 0 && WA.at(i) > 0 ) wa += WA.at(i);
  }
  cout << ac << " " << wa << endl;
  
    
}


Measured memory_bytes: 1792
a=input().strip()
t=1
for i in range(len(a)):
  if i%2==0 and a[i] not in ['R','U','D']:
    t=0
    break
  elif i%2!=0 and a[i] not in ['L','U','D']:
    t=0
    break
if t==1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
S = list(input())
K = int(input())
lsS = [int(i) for i in S]
ii = 0
for i in range(len(S)):
    if lsS[i] == 1:
        ii += 1
    else:
        a = lsS[i]
        break
if ii >= K:
    print(1)
else:
    print(a)

Measured memory_bytes: 9172
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=410,Mo=1000000007;
int a[N],b[N],d[N][N],f[N][N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,C;
    cin>>n>>C;
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=1;i<=n;i++) b[i]=gi();
    for(int i=0;i<=400;i++)
	for(int j=d[i][0]=1;j<=C;j++)
	    d[i][j]=1LL*d[i][j-1]*i%Mo;
    for(int j=0;j<=C;j++)
	for(int i=0;i<=400;i++)
	    d[i][j]=(d[i-1][j]+d[i][j])%Mo;
    f[0][0]=1;
    for(int i=1;i<=n;i++)
	for(int j=0;j<=C;j++)
	    for(int k=0;j+k<=C;k++)
		f[i][j+k]=(f[i][j+k]+1LL*f[i-1][j]*(d[b[i]][k]-d[a[i]-1][k]))%Mo;
    cout<<(f[n][C]+Mo)%Mo;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <map>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    using ll = long long;

    int n;
    cin >> n;

    vector<int> h(n);

    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    vector<ll> a(n);

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

    map<int, ll> s;

    s[0] = 0;

    for (int i = 0; i < n; i++) {
        auto it = s.lower_bound(h[i]);
        --it;

        it = s.insert({h[i], a[i] + it->second}).first;

        while (true) {
            auto nxt = next(it);

            if (nxt == s.end()) {
                break;
            }

            if (it->second > nxt->second) {
                s.erase(nxt);
            } else {
                break;
            }
        }
    }

    cout << s.rbegin()->second << endl;
}


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

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

    vector<int> student(N);

    for (int i = 0; i < N; i++)
    {
        cin >> s;

        student.at(s - 1) = i + 1;
    }

    for (int i = 0; i < N; i++)
    {
        cout << student.at(i) << " ";
    }

    cout << endl;
}

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

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

  int n = s.size();
  for(int i = 0; i < n; i++){
    if(i % 2 == 1){
      if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
 cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ALDS1_2B{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var A = sr.Next<int>(N);

            var cnt = 0;
            for(var i = 0; i < N; i++){
                var minj = i;
                for(var j = i; j < N; j++){
                    if(A[minj] > A[j]){
                        minj = j;
                    }
                }
                if(i != minj){
                    Ex.Swap(ref A[i], ref A[minj]);
                    cnt++;
                }
            }

            Console.WriteLine(string.Join(" ", A.Select(x => x.ToString()).ToArray()));
            Console.WriteLine(cnt);
            //---------------------------------
        }
    }

    public class Ex{
        public static void Swap<T>(ref T left, ref T right){
            var tmp = left;
            left = right;
            right = tmp;
        } 
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }
    }
}

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

int main(){
  int N;
  bool ans=0;
  cin >> N;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    if(s=="Y"){
      ans=1;
      break;
    }
  }
  if(ans) cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	string S;

	cin >> S;

	int ans = 0;
	for(int i = 0; i < S.size(); i++){
		if(S[i] == '+') ans++;
		else ans--;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()

    cnt = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                ii = s.find(str(i))
                if ii == -1:
                    continue
                jj = s[ii+1:].find(str(j))
                if jj == -1:
                    continue
                jj += ii+1
                kk = s[jj+1:].find(str(k))
                if kk == -1:
                    continue
                cnt += 1


    print(cnt)


main()

Measured memory_bytes: 72532
n = input()
K = int(input())

len_n = len(n)

dp = []
for _ in range(len_n + 1):
    dp.append([[0] * 4 for __ in range(2)])

# dp = [ [[0] * K] for __ in range(2)  for _ in range(len_n + 1)]
dp[0][1][0] = 1

for i in range(1, len_n+1):
    now = int(n[i-1])

    dp[i][0][0] = 1
    for j in range(1,4):
        dp[i][0][j] = dp[i-1][0][j] + dp[i-1][0][j-1] * 9
        if(now == 0):
            dp[i][1][j] = dp[i-1][1][j]
        else:
            dp[i][0][j] += dp[i-1][1][j]
            dp[i][0][j] += dp[i-1][1][j-1] * (now-1)
            dp[i][1][j] = dp[i-1][1][j-1]

print(dp[-1][0][K] + dp[-1][1][K])

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

using namespace std;

int main(){
  int n;
  cin >> n;
  if(n%10==3){
    cout << "bon" << endl;
  }
  else if( (n%10==0)||(n%10==1)||(n%10==6)||(n%10==8) ){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
  return 0;
}


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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: usize, b: usize) -> usize {
    a * b / gcd(a, b)
}

fn main() {
    let input = read_vec::<usize>();
    let _n = input[0];
    let m = input[1];
    let mut an = read_vec::<usize>();

    an = an.iter().map(|a| a / 2).collect();

    let l = an.iter().fold(1, |acc, &x| lcm(acc, x));
    for a in an.iter() {
        if l / *a % 2 == 0 {
            println!("0");
            return;
        }
    }

    println!("{}", (m+l) / l / 2);

}

Measured memory_bytes: 8444
import sys
sys.setrecursionlimit(10**9)

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

def num_p(n):
  return 2**(n+1) - 1

def num_layer(n):
  return 2**(n+2) - 3

def solve(n, x):
  if x <= 0:
    return 0
  num = num_layer(n-1) + 2
  if x == num*2 - 1:
    return num_p(n)
  elif x == num:
    return num_p(n-1) + 1
  elif x < num:
    return solve(n-1, x-1) # 1番下のバンを食べる
  else:
    return solve(n-1, x-num) + num_p(n-1) + 1

print(solve(N, X))

Measured memory_bytes: 3064
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 4500000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos) b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


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

namespace ConsoleApp1 {
	class Program {
		static void Main(string[] args) {
			//int[][] input = new int[3][];
			//var rand = new Random();
			//for (int i = 0; i < 3; ++i) input[i] = new int[3];
			//for(int k = 0; k < 100000; ++k) {
			//	for (int i = 0; i < 3; ++i) {
			//		for (int j = 0; j < 3; ++j) {
			//			input[i][j] = rand.Next(0, 101);
			//			Ngo(input);
			//		}
			//	}
			//	if (k % 1000 == 0) Console.WriteLine(k+"----------------------------------------");
			//}
			int[][] input = new int[3][];
			for (int i = 0; i < 3; ++i) {
				input[i] = Console.ReadLine().Split().Select(select => int.Parse(select)).ToArray();
			}
			Ngo(input);
		}

		static void Ngo(int[][] input) {
			//int[][] input = new int[3][];
			//for (int i = 0; i < 3; ++i) {
			//	input[i] = Console.ReadLine().Split().Select(select => int.Parse(select)).ToArray();
			//}
			bool flag = true;
			int[] a = new int[3];
			int[] b = new int[3];
			for (int i = 0; i < 3; ++i) b[i] = input[0][i] - input[0][0];
			for (int i = 1; i < 3; ++i) {
				for (int j = 0; j < 3; ++j) {
					if (input[i][j] - input[i][0] != b[j]) {
						//foreach (var n in b) Console.WriteLine(n + " ");Console.WriteLine();
						//Console.WriteLine("No");
						flag = false;
					}
				}
			}
			for (int i = 0; i < 3; ++i) a[i] = input[i][0] - input[0][0];
			for (int j = 1; j < 3; ++j) {
				for (int i = 0; i < 3; ++i) {
					if (input[i][j] - input[0][j] != a[i]) {
						//Console.WriteLine("No");
						flag = false;
					}
				}
			}
			Console.WriteLine(flag ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <math.h>

int main(void){
  int a,b,h,m,theta1;
  double theta2,d,l;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  theta1=6*m;
  theta2=30*h+0.5*m;
  d=fabs(theta1-theta2);
  if(d<=180) l=sqrt(a*a+b*b-2*a*b*cos(2*M_PI*d/360));
  if(d>180) l=sqrt(a*a+b*b-2*a*b*cos(2*M_PI*(360-d)/360));
  printf("%.20f",l);

  return 0;
}

Measured memory_bytes: 2584
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
	}
	cout << ceil((double)(N - 1) / (K - 1)) << endl;
}

Measured memory_bytes: 256
from sys import stdin


def main() -> int:
    n = next_int()
    m = next_int()
    dic = dict()

    for i in range(1, n + 1):
        dic[i] = 0

    for _ in range(m):
        a, b = map(int, input().split())

        dic[a] += 1
        dic[b] += 1

    for i in range(1, n + 1):
        print(dic[i])

    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter,defaultdict
mod=10**9+7
def main():
    n,k=map(int,input().split())
    A=[int(_) for _ in input().split()]
    ac=Counter(A)
    aci=list(ac.items())
    aci.sort(reverse=True)
    nn=len(aci)
    aciv_cum=[0]*nn
    m2=defaultdict(int)
    for i in range(1,nn):
        aciv_cum[i]=aciv_cum[i-1]+aci[i-1][1]
        m2[aci[i][0]]+=aciv_cum[i]
    ans=0
    for i,a in enumerate(A):
        b=m2[a]
        x=0
        for j in range(i):
            if A[j]>a:
                x+=1
        ans+=k*(2*x+(k-1)*b)//2%mod
    print(ans%mod)

if __name__=='__main__':
    main()

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

using namespace std;
 
int main() {
  int n;
  int length;
  string a; 
  
  cin >> n;
  cin >> length;
  cout <<std::string(length+2, '#')<<endl;
  for(int i=0;i<n;i++){
    cin >>a;
    cout<<"#"<<a<<"#"<<endl;
  }
    cout <<std::string(length+2, '#')<<endl;


  }     



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

int main(){
	ll a,b,v,w,t;
	cin >> a >> v >> b >> w >> t;

	ll dist = abs(a-b);
	if(v-w <= 0){
		cout << "NO" << endl;
		return 0;
	}

	ll diff = v-w;
	if(dist <= diff*t) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0; 
}


Measured memory_bytes: 3572
#include<iostream>

using namespace std;

int main() {
	int holi;
	int syuku;

	cin >> holi >> syuku;
	long  int niss;
	long int tot = 0;
	int i;
	for (i = 0; i < syuku; i++) {
		cin >> niss;
		tot += niss;
	}
	long  int ans;
	if (tot > holi) {
		cout <<" -1" << endl;
	}
	else {	
		ans = (long int)holi - tot;
		cout << ans << endl;
	}
	return 0;
}

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

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

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

        int max = m;
        int now = m;

        for (int i = 0; i < n; i++) {
            String[] line = br.readLine().split(" ");
            int diff = Integer.parseInt(line[0]) - Integer.parseInt(line[1]);

            if (now + diff < 0) {
                max = 0;
                break;
            }

            now += diff;

            max = Math.max(max,now);
        }

        System.out.println(max);

    }
}


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

int main(void){
  int x,i;
  for(i=1; ;i++){
          cin >> x;
          
          if(x != 0){
              cout << "Case " << i << ":" << " " << x;
              cout << endl;
          }
          else break;
      }
}


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

const int mod=998244353;

void add(int &a,int b)
{
   a+=b;
   if(a>=mod) a-=mod;
}

signed main()
{
   int N; cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++) cin>>a[i];

   int S=0;
   for(int i=0;i<N;i++) S+=a[i];

   vector<int> dp(S+1);
   dp[0]=1;
   for(int i=0;i<N;i++){
      vector<int> nxt(S+1);
      for(int j=0;j<=S;j++){
         add(nxt[j],dp[j]*2%mod);
         if(j+a[i]<=S) add(nxt[j+a[i]],dp[j]);
      }
      for(int j=0;j<=S;j++){
         dp[j]=nxt[j];
      }
   }
   
   vector<int> dp2(S+1);
   dp2[0]=1;
   for(int i=0;i<N;i++){
      vector<int> nxt(S+1);
      for(int j=0;j<=S;j++){
         add(nxt[j],dp2[j]);
         if(j+a[i]<=S) add(nxt[j+a[i]],dp2[j]);
      }
      for(int j=0;j<=S;j++){
         dp2[j]=nxt[j];
      }
   }

   int ans=1;
   for(int i=0;i<N;i++) ans=ans*3%mod;

   for(int i=S/2+1;i<=S;i++){
      add(ans,(mod-dp[i])*3%mod);
   }
   if(S%2==0){
      add(ans,(mod-dp[S/2])*3%mod);
      add(ans,dp2[S/2]*3%mod);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 2376
#include <bits/stdc++.h>
    using namespace std;
     
    #define ll long long
     
    int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
     
        ll N, M;
        ll K;
        cin >> N >> M >> K;
        // cout << N << M << K << endl;
     
        ll A[N+1];
        A[0] = 0;
     
        for (ll i = 1; i <= N; i++) {
            cin >> A[i];
            A[i] += A[i-1];
        }
     
        ll B[M+1];
        B[0] = 0;
     
        for (ll i = 1; i <= M; i++) {
            cin >> B[i];
            B[i] += B[i-1];
        }
     
        // for (const auto& value: A) {
        //     cout << value << ' ';
        // }
     
        ll cur_max = 0;
     
        ll books_stack_b = M;
     
        ll diff = -1;
        for (ll books_stack_a = 0; books_stack_a <= N; books_stack_a++) {
            if (A[books_stack_a] > K) {
                break;
            }
            diff = K - A[books_stack_a];
            while (diff < B[books_stack_b]) { // guaranteed to terminate at zero
                books_stack_b--;
            }
            // cout << books_stack_b << ' ' << B[books_stack_b] << '\n';
            cur_max = max(cur_max, books_stack_a + books_stack_b);
        }
     
        cout << cur_max;
    }

Measured memory_bytes: 6748
#include <cstdio>
#include <cstring>
#include <vector>

#define PB push_back

using namespace std;

typedef long long ll;
typedef vector < int > vi;

const int N = 2005;
const int MOD = 924844033;

int fak[N], n, k, dp[N][N][4];

inline int add(int A, int B){
	if(A + B >= MOD)
		return A + B - MOD;
	return A + B;
}

inline int sub(int A, int B){
	if(A - B < 0)
		return A - B + MOD;
	return A - B;
}

inline int mul(int A, int B){
	return (ll)A * B % MOD;
}

int f(int i, int x, int lst){
	if(x < 0) return 0;
	if(i == 0) return (x == 0) && ((lst & 1) == 0);
	if(dp[i][x][lst] != -1)
		return dp[i][x][lst];
	return dp[i][x][lst] = add(add(f(i - 1, x, (2 * lst) % 4), (!(lst & 2)) * (f(i - 1, x - 1, (2 * lst) % 4))), f(i - 1, x - 1, (2 * lst + 1) % 4));
}

vi mul(vi A,vi B){
	vi C(A.size() + B.size() - 1, 0);
	for(int i = 0;i < (int)A.size();i++)
		for(int j = 0;j < (int)B.size();j++)
			C[i + j] = add(C[i + j], mul(A[i], B[j])); 
	return C;
}

vi pot(vi A, int B){
	vi bs = A, ret = {1};
	for(;B;B >>= 1){
		if(B & 1)
			ret = mul(ret, bs);
		bs = mul(bs, bs);
	}
	return ret;
}


void precompute(){
	fak[0] = 1;
	for(int i = 1;i < N;i++)
		fak[i] = mul(fak[i - 1], i);
}

int main(){
	precompute();
	memset(dp, -1, sizeof(dp));
	scanf("%d%d", &n, &k);
	vi v;
	for(int i = 0;i <= (n / k);i++)
		v.PB(f(n / k, i, 2));
	vi bit = pot(v, k - (n % k));
	v.clear();
	for(int i = 0;i <= (n / k) + 1;i++)
		v.PB(f((n / k) + 1, i, 2));
	bit = mul(bit, pot(v, (n % k)));
	int sol = 0;
	for(int i = 0;i <= n;i++){
		if((i & 1))
			sol = sub(sol, mul(fak[n - i], bit[i]));
		else
			sol = add(sol, mul(fak[n - i], bit[i]));
	}
	printf("%d\n", sol);
}





Measured memory_bytes: 63232
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

long long L, R, fib[100], power[100009], hush[100009]; string S, T;

void init() {
	fib[0] = 0; fib[1] = 1; for (int i = 2; i <= 99; i++) fib[i] = fib[i - 1] + fib[i - 2];
	power[0] = 1; for (int i = 1; i <= 100008; i++) power[i] = power[i - 1] * 331LL;
	hush[0] = 0; for (int i = 0; i < T.size(); i++) { hush[i + 1] = hush[i] * 331LL; hush[i + 1] += (T[i] - 'a' + 1); }
}
long long val(long long l, long long r) {
	return hush[r] - hush[l] * power[r - l];
}

long long reps() {
	long long G = 0;
	for (int i = 1; i <= T.size(); i++) {
		if (T.size() % i != 0) continue;
		bool OK = true;
		for (int j = 0; j < T.size(); j += i) {
			if (T.substr(0, i) != T.substr(j, i)) OK = false;
		}
		if (OK == true) { G = T.size() / i; break; }
	}
	return G;
}
vector<long long> solve_1(long long Y, long long Z) {
	vector<long long>rem(26, 0);
	for (int i = 0; i < Y; i++) rem[T[i] - 'a'] += Z / Y;
	for (int i = 0; i < Z%Y; i++) rem[T[i] - 'a']++;
	return rem;
}

long long a, b; map<long long, vector<long long>>M;

vector<long long>solve(long long Z) {
	if (M[Z].size() >= 1) return M[Z];
	if (Z <= a) {
		vector<long long>A1(26, 0);
		for (int i = 0; i < Z; i++) A1[T[i] - 'a']++;
		M[Z] = A1;
		return A1;
	}
	vector<long long>A2(26, 0);
	for (int i = 1; i <= 90; i++) {
		long long G = fib[i] * a + fib[i - 1] * b;
		if (Z <= G) {
			vector<long long>P1 = solve(fib[i - 1] * a + fib[i - 2] * b);
			vector<long long>P2 = solve(Z - (fib[i - 1] * a + fib[i - 2] * b));
			A2 = P1;
			for (int j = 0; j < 26; j++) A2[j] += P2[j];
			break;
		}
	}
	M[Z] = A2;
	return A2;
}

vector<long long>solve_2(long long Z) {
	a = T.size(), b = 0;
	for (int i = 0; i < T.size(); i++) { if (val(0, i) == val(T.size() - i, T.size())) b = T.size() - i; }
	return solve(Z);
}

int main() {
	cin >> S >> L >> R; T = S.substr(0, S.size() / 2);
	init();
	long long V = reps(); vector<long long>ans1, ans2;
	if (V >= 2) { ans1 = solve_1(T.size() / V, R); ans2 = solve_1(T.size() / V, L - 1); }
	else { ans1 = solve_2(R); ans2 = solve_2(L - 1); }
	for (int i = 0; i < ans1.size(); i++) { if (i)cout << " "; cout << ans1[i] - ans2[i]; }cout << endl;
	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    sort(ALL(A), greater<>());

    ll l1 = 0, l2 = 0;
    REP(i, N-1)
    {
        if(l1 != 0 && l2 == 0 && A[i] == A[i+1])
        {
            l2 = A[i];
            i++;
        }
        if(l1 == 0 && A[i] == A[i+1])
        {
            l1 = A[i];
            i++;
        }
    }

    cout << l1 * l2 << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

typedef long long ll;

ll N, K;
ll P[5000 + 10], C[5000 + 10];

int main() {
	//No sub撤退しないぞ
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		P[i]--;
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}

	ll ans = -100000000000000000;
	for (int i = 0; i < N; i++) {
		//iからスタート
		vector<ll> res;
		vector<bool> visited(N);
		int nw = i;
		int cnt = 0;
		while (true) {
			if (visited[P[nw]])break;
			res.push_back(0);
			visited[P[nw]] = true;
			nw = P[nw];
			if (cnt == 0)res[cnt] = 0 + C[nw];
			else res[cnt] = res[cnt - 1] + C[nw];
			cnt++;
		}
		if (K <= cnt) {
			ll tmp = -100000000000000000;
			for (int j = 0; j < K; j++) {
				tmp = max(tmp, res[j]);
			}
			ans = max(tmp, ans);
		}
		else {
			ll tmp = -100000000000000000;
			for (int j = 0; j < (K % res.size()) + res.size(); j++) {
				tmp = max(tmp, res[j % res.size()] + (j >= res.size() ? res.back() : 0));
			}
			ll tmp2 = tmp + max(0LL, res.back()) * (K / res.size() - 1);
			if (ans < tmp2) {
				ans = tmp2;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3808
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "abc160_e.cpp"

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vl p(a), q(b), r(c);
  REP(i, a) { cin >> p[i]; }
  REP(i, b) { cin >> q[i]; }
  REP(i, c) { cin >> r[i]; }

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());

  priority_queue<ll, vl, greater<ll>> red;
  priority_queue<ll, vl, greater<ll>> green;
  REP(i, x) { red.push(p[i]); }
  REP(i, y) { green.push(q[i]); }

  REP(i, c) {
    ll minR = red.top();
    ll minG = green.top();

    if (r[i] == min(minR, min(minG, r[i]))) {
      continue;
    }

    if (r[i] - minR > r[i] - minG) {
      red.pop();
      red.push(r[i]);
    } else {
      green.pop();
      green.push(r[i]);
    }
  }

  ll ans = 0;
  REP(i, x) {
    ans += red.top();
    red.pop();
  }
  REP(i, y) {

    ans += green.top();
    green.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 4852
#include <stdio.h>
int main (){
  int a,b,c;
  scanf("%d%d",&a,&b);
  while(b>0){
    if(a<b){
      c=a;
      a=b;
      b=c;
    }
    c=a%b;
    a=b;
    b=c;
  }
  printf("%d\n",a);
  return 0;
}

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

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

    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }

    int M;
    cin >> M;
    vector<string> T(M);
    for (int i = 0; i < M; i++)
    {
        cin >> T[i];
    }

    // vector<int> points(N, 0);
    int point;
    int maximum = 0;
    for (int i = 0; i < N; i++)
    {
        point = 0;
        for (int j = 0; j < N; j++)
        {
            if (S[i] == S[j])
                point++;
        }
        for (int k = 0; k < M; k++)
        {
            if (S[i] == T[k])
                point--;
        }
        // printf("%d\n", point);
        maximum = max(maximum, point);
    }
    cout << maximum << endl;
    return (0);
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"
#define SP " "

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

  rep0(i, q) {
    string order, temp;
    cin >> order;
    temp = s;

    int start, end;
    cin >> start >> end;
    end++;

    if (order == "print") {
      rep(j, start, end) {
        std::cout << s[j];
      }
      std::cout << BR;
    }
    else if (order == "replace") {
      string word;
      cin >> word;
      s = temp;
      rep(j, start, end) s[j] = word[j - start];
    }
    else {
      s = temp;
      rep(j, start, end) s[j] = temp[end - 1 - (j - start)];
    }
    // std::cout << s << BR;
  }
  return 0;
}


Measured memory_bytes: 3240
i,a[1<<17],b[1<<17];c;
main(s){
	for(;~(c=getchar_unlocked());)c-10?a[i]=a[i]*10+c-48:i++;
	for(b[i=s]=1;!b[s=a[s]]&&s-2;i++)b[s]=1;
	printf(s==2?"%d":"-1",i);
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, 0);
  vector<int> b(n, 0);
  for (int i = 0; i < m; ++i) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s[0] == 'W' && a[p] < 1) {
      b[p]++;
    } else if (s[0] == 'A' && a[p] < 1) {
      a[p]++;
    }
  }

  int ans1 = 0;
  int ans2 = 0;
  for (int i = 0; i < n; ++i) {
    ans1 += a[i];

    if (a[i] > 0) {
      ans2 += b[i];
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int a[5];
  int res=0,r=10,t;
  for(int i=0;i<5;i++){
    cin >> a[i];
    t=a[i]%10;
    res+=(int)(ceil((double)a[i]/10)*10);
    if(t>0&&t<r)
      r=t;
  }
  res=res-10+r;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INPUT_OUTPUT { \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout); \
}
#define ll long long
 
int main()
{
    // INPUT_OUTPUT;
    ll n, ans = 0;
    cin >> n;
    map<string, int> m;
    for(int i=0; i<n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if(m[s] == 0) m[s]++;
        else {
            ans += m[s];
            m[s]++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
n = int(input())
s = input()
w = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(n):
    if s[i] == '.':
        w[i + 1] += 1
    else:
        b[i + 1] += 1

for i in range(1, n + 1):
    w[i] += w[i - 1]
    b[i] += b[i - 1]

num = float('inf')
for i in range(n + 1):
    num = min(num, b[i] + w[n] - w[i])

print(num)


Measured memory_bytes: 19108
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
string S;

int main() {
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy";
	} else if (S == "Cloudy") {
		cout << "Rainy";
	} else {
		cout << "Sunny";
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
#define rep(i,N) for(int i = 0; i<N,i++)
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N, M, P[100100];
llong Y[100100];
pair<pair<int, llong>, int> v[100100];


bool NIN(pair<pair<int, llong>, int>p, pair<pair<int, llong>, int> q) {
	if (p.first.first != q.first.first) return p.first < q.first;
	else return p.first.second < q.first.second;
}

bool MIM(pair<pair<int, llong>, int>p, pair<pair<int, llong>, int> q) {
	return p.second < q.second;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> v[i].first.first >> v[i].first.second;
		v[i].second = i;
	}
	sort(v, v + M, NIN);

	llong x = 1;

	v[0].first.second = x;

	x++;

	for (int i = 1; i < M; i++) {
		if (v[i].first.first == v[i - 1].first.first) {
			v[i].first.second = x;
			x++;
		}

		else {
			x = 1;
			v[i].first.second = x;
			x++;
		}
	}

	sort(v, v + M, MIM);

	for (int i = 0; i < M; i++) {
		cout << setfill('0') << right << setw(6) << v[i].first.first;
		cout << setfill('0') << right << setw(6) << v[i].first.second;
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3840
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := scanString()

	s += string(s[0])

	a := []rune("SSWW")
	b := []rune("SWSW")
	inv := map[rune]rune{'S':'W','W':'S'}

	for i := 0; i < 4; i++ {
		ans := make([]rune, n+2)
		ans[0] = a[i]
		ans[1] = b[i]
		
		for j := 1; j < n+1; j++ {
			if s[j] == 'o' {
				if ans[j] == 'S' {
					ans[j+1] = ans[j-1]
				} else {
					ans[j+1] = inv[ans[j-1]]
				}
			} else {
				if ans[j] == 'S' {
					ans[j+1] = inv[ans[j-1]]
				} else {
					ans[j+1] = ans[j-1]
				}
			}
		}

		if ans[n] != ans[0] || ans[n+1] != ans[1] {
			continue
		}

		fmt.Fprintln(wr, string(ans[:n]))
		return
	}

	fmt.Fprintln(wr, -1)

}


Measured memory_bytes: 3072