akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int a,b,c,d,e;
		   a=1;b=1;e=1;
	       Scanner sc = new Scanner(System.in);
	       while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       }
		}

    }

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

int dp[100010][13],mod13[100010][10],n;
string s;

int main()
{
	cin>>s;
	n=s.size();
	for(int i=1;i<10;i++)
	{
		mod13[0][i]=1;
		mod13[1][i]=i;
		for(int j=2;j<100010;j++)
			mod13[j][i]=mod13[j-1][i]*10%13;
	}
	if(s[n-1]=='?')
		for(int i=0;i<10;i++)
			dp[n-1][i]=1;
	else
		dp[n-1][s[n-1]-48]=1;
	for(int i=n-2;i>=0;i--)
	{
		if(s[i]=='?')
			for(int j=0;j<13;j++)
				for(int k=0;k<10;k++)
					dp[i][j]+=dp[i+1][(j-mod13[n-i][k]+13)%13],dp[i][j]%=1000000007;
		else
			for(int j=0;j<13;j++)
				dp[i][j]+=dp[i+1][(j-mod13[n-i][s[i]-48]+13)%13],dp[i][j]%=1000000007;
	}
	cout<<dp[0][5];
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i++){
    if(i%2==0){
      a+='0';
      b+='1';
    }
    else{
      a+='1';
      b+='0';
    }
  }
  int t=0,k=0;
  for(int i=0;i<n;i++){
    if(s[i]!=a[i])t++;
    if(s[i]!=b[i])k++;
  }
  cout<<min(t,k)<<endl;
  return(0);
}


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

typedef long long ll;

int main(){
    ll x;
    cin>>x;
    int memory=0;
    if(x%11==0){
        memory=0;
    }
    else if(x%11<7){
        memory=1;
    }
    else{
        memory=2;
    }
    ll ans=0;
    ans=x/11;
    ans*=2;
    if(memory==0){
        cout<<ans<<endl;
    }
    else if(memory==1){
        cout<<ans+1<<endl;
    }
    else{
        cout<<ans+2<<endl;
    }
}

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

using namespace std;

void A_Poor(void) {

	int num[3];
	int counter = 0;

	cin >> num[0] >> num[1] >> num[2];

	for (int loop1 = 0; loop1 < 3; loop1++) {
		for (int loop2 = loop1 + 1; loop2 < 3; loop2++) {
			
			if (num[loop1] == num[loop2]) counter++;
		}
	}

	if (counter == 1) cout << "Yes" << flush;
	else cout << "No" << flush;

	return;
}

void B_Papers_Please(void) {

	int N;
	cin >> N;

	int A;
	for (int loop = 0; loop < N; loop++) {
		cin >> A;
		if (A % 2 == 0 && A % 3 > 0 && A % 5 > 0) {
			cout << "DENIED";
			return;
		}
	}

	cout << "APPROVED";
	return;
}

void C_Poll(void) {

	int N;
	cin >> N;

	/*
	vector<string> S(N);
	for (int loop = 0; loop < N; loop++) {
		cin >> S[loop];
	}
	sort(S.begin(), S.end());
	
	int maxNum = 0;
	int counter = 0;
	for (int loop = 0; loop < N; loop++) {

		if (loop == 0 || S[loop].compare(S[loop - 1]) == 0) {

			counter++;
		}
		else {

			counter = 1;
		}

		maxNum = max(counter, maxNum);
	}

	counter = 0;
	for (int loop = 0; loop < N; loop++) {

		if (loop == 0 || S[loop].compare(S[loop - 1]) == 0) {

			counter++;
		}
		else {

			counter = 1;
		}

		if (counter == maxNum) cout << S[loop] << endl;
	}
	*/

	map<string, int> dict;
	string S = "";
	int maxNum = 0;
	for (int loop = 0; loop < N; loop++) {
		cin >> S;
		dict[S] += 1;
		maxNum = max(maxNum, dict[S]);
	}

	for (auto loop = dict.begin(); loop != dict.end(); loop++) {
		if (loop->second == maxNum)	cout << loop->first << endl;
	}

	return;
}

void D_Pairs(void) {

	int N, K;
	cin >> N >> K;

	vector<int> A(N);
	for (int loop = 0; loop < N; loop++) {
		cin >> A[loop];
	}
	sort(A.begin(), A.end());

	int pos = 0;
	int neg = 0;
	int zero = 0;
	for (int loop = 0; loop < N; loop++) {
		if (A[loop] < 0)	neg++;
		else if(A[loop]==0) zero++;
		else				pos++;
	}

	long pro;
	long pro1;
	long pro2;

	if (K <= neg * pos) {

		int loop1 = 0;
		int loop2 = N - 1;

		for (int flag = 0;; flag++) {

			pro1 = A[loop1 + 1] * A[loop2];
			pro2 = A[loop1] * A[loop2 - 1];

			if (pro1 < pro2)	loop1++;
			else				loop2--;

			if (flag == K - 2) {
				cout << min(pro1, pro2) << flush;
				return;
			}
		}
	}
	else {

		for (int loop = 0; loop < N; loop++) {
			if (A[loop] < 0)	A[loop] = -A[loop];
			else				break;
		}
		sort(A.begin(), A.end());

		int loop1 = 0;
		int loop2 = 1;
		for (int flag = neg * pos;; flag++) {

			if (loop1 + 1 == loop2) {

				loop2++;
			}
			else {

				pro1 = A[loop1 + 1] * A[loop2];
				pro2 = A[loop1] * A[loop2 + 1];

				if (pro1 < pro2) {

					loop1++;
				}
				else {

					loop2++;
				}
			}
			if (flag == K - 2) {
				cout << min(pro1, pro2) << flush;
				return;
			}

			flag++;
		}
	}
}

void E_Payment(void) {

	string N;
	cin >> N;
}

int main(void) {

	//A_Poor();
	//B_Papers_Please();
	C_Poll();
	//D_Pairs();
	return 0;
}


Measured memory_bytes: 25216
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 2010;
int f[N][N * 3], P, ans, n;
int main(){
	read(n); read(P);
	f[0][0] = 1;
	for (int i = 0; i <= n; i++)
		for (int j = 1; j <= 3 * n; j++){
			if (j > 0) f[i][j] = (f[i][j] + f[i][j - 1]) % P;
			if (j > 1 && i > 0) f[i][j] = (f[i][j] + 1ll * f[i - 1][j - 2] * (3 * n - j + 1)) % P;
			if (j > 2 && i > 0) f[i][j] = (f[i][j] + 1ll * f[i - 1][j - 3] * (3 * n - j + 2) % P * (3 * n - j + 1)) % P;
		}
	for (int i = 0; i <= n; i++)
		ans = (ans + f[i][3 * n]) % P;
	printf("%d\n", ans);
	return 0;
}



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

struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1){}
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x != y){
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    int root(int x) {return data[x] < 0 ? x : data[x] = root(data[x]);}
    int size(int x) {return -data[root(x)];}
};


bool is_bridge(int N, const pair<int, int> & p, const vector<pair<int, int>> & edges){
    UnionFind uf(N);
    for (auto & e : edges){
        if (e == p) continue;
        uf.unite(e.first, e.second);
    }
    return (uf.size(0) != N);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> edges;
    for (int i = 0; i < M; ++i){
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        edges.emplace_back(a - 1, b - 1);
    }
    int c = 0;
    for (auto & e : edges){
        if (is_bridge(N, e, edges)) ++c;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int N, K; cin >> N >> K;
  int x[N]; rep(i,N) cin >> x[i];

  int result = INF;
  for (int i=0; i+(K-1)<N; i++) {
    int tmp = 0;
    tmp += x[i+(K-1)] - x[i];
    tmp += min(abs(x[i]), abs(x[i+(K-1)]));
    result = min(result, tmp);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,t,e,x,ab,a[200005],dp[200005];
int main(){
	n=read(),e=read(),t=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	a[n+1]=e;
	for(int i=1;i<=n;i++){
		while((a[i]-a[ab+1])*2>t)
			x=min(x,dp[ab]-2*a[ab+1]),ab++;
		dp[i]=min((ll)(1e18),dp[ab]+t);
		if(ab)dp[i]=min(dp[i],2*a[i]+x);
	}
	printf("%lld",dp[n]+e);
	return 0;
}  

Measured memory_bytes: 1920
#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 unsigned long long ull;
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, M; cin >> N >> M;
    vector<vi> G(N+1, vi(N+1, 0));
    REP(i, M)
    {
        int a, b; cin >> a >> b;
        G[a][b]++;
        G[b][a]++;
    }

    REP1(i, N)
    {
        int sum = 0;
        REP1(j, N)
        {
            sum += G[i][j];
        }
        cout << sum << endl;
    }
}

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

    return 0;
}

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

typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int h, w, d;
    cin >> h >> w >> d;
    vector<P> v(h * w + 1);
    rep(i, h)
    {
        rep(j, w)
        {
            int x;
            cin >> x;
            v[x] = P(i + 1, j + 1);
        }
    }
    vector<ll> dp(h * w + 1, 0);
    REP(i, d, h * w + 1)
    {
        dp[i] = dp[i - d] + abs(v[i - d].first - v[i].first) + abs(v[i - d].second - v[i].second);
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l] << endl;
    }
}

Measured memory_bytes: 2560
//




#include <bits/stdc++.h>
using namespace std;


#define spdio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define pf push_front
#define ppf pop_front()
#define ff first
#define ss second
#define mp make_pair
#define fr(i,j,n) for(ll i=j; i<n; i++)
#define rfr(i,j,n) for(ll i=n-1; i>=j; i--)
#define pll pair<ll,ll>
#define plb pair<ll,bool>
#define psl pair<string,ll>
#define psb pair<string,bool>
#define srt(v) sort((v).begin(),(v).end())
#define ub(v,val) upper_bound((v).begin(),(v).end(),(val))-(v).begin()
#define lb(v,val) lower_bound((v).begin(),(v).end(),(val))-(v).begin()


typedef long double ld;
typedef long long int ll;


//getline(cin,string);
const ll inf = (ll) 1e18 + 19;
const ll mod = (ll) 1e9  +  7;




ll ncr(ll n,ll r) {
    ll val=1,i,j,p=2;
    rfr(i,n-r+1,n+1) {
        val*=i;
        while(val%p==0 && p<=r) {
            val/=p;
            p+=1;
        }
    }
    if(p<r) {
        fr(i,p,r+1) val/=i;
    }
    return val;
}




void cazz() {
    ll t=1,i=0,j,n;
    //cin>>t;
    while(t--) {
        string s;
        cin>>s;
        n=s.length();
        ll cnt=0;
        fr(i,0,n) {
            cnt+=(s[i]-'0');
            cnt%=9;
        }
        if(cnt%9==0) cout<<"Yes\n";
        else cout<<"No\n";
    }
}




int main() {
    spdio;
	cazz();
	return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	long long N;
	cin >> N;
	vector<long long> a(5);
	for(int i=0;i<5;i++)	cin >> a.at(i);

	long long x=1e18;
	for(int i=0;i<5;i++){
		x=min(x,a.at(i));
	}
	cout << (N+x-1)/x+4 << endl;
	
	return 0;
}


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

int main() {
	int a,b;
	cin>>a>>b;
	if(a>b){
		cout<<"a > b"<<endl;
	}else if(a==b){
		cout<<"a == b"<<endl;
	}else{
		cout<<"a < b"<<endl;
	}
}

Measured memory_bytes: 3108
# まず、xの値でソート（同値の場合はyでソート）する。
# この状態で、全ての2点について、x,yの差を求める
# 差の情報(p,q)の回数が最も大きいものが答えの候補
# (p,q)で到達できる点にはコスト0で行けるグラフの最短距離を解く

N=int(input())
ball=[None] * N
for i in range(N):
  ball[i] = list(map(int,input().split()))

ball=sorted(ball,key=lambda x:(x[0],x[1]))

from collections import defaultdict
dic = defaultdict(list)

for i in range(N-1):
  for j in range(i+1,N):
    # 点iから点jへは(p,q)で到達できる
    dic[(ball[j][0] - ball[i][0],ball[j][1] - ball[i][1])].append((i,j))

pq=None
target=[]
for item in dic.items():
  if len(item[1]) > len(target):
    target = item[1]
    pq=item[0]
    
# targetの要素で、同じ点を持つものは結合して1つの点にできる。
# UnionFind

# 0-indexed
class UnionFind:
  N=0
  parent=None
  size=None
  def __init__(self,N):
    self.N=N
    self.parent=[i for i in range(self.N)]
    self.size=[1]*self.N
    
  def root(self,x):
    while x!=self.parent[x]:
      self.parent[x]=self.parent[self.parent[x]]
      x=self.parent[x]
    return x
  
  def same(self,x,y):
    return self.root(x)==self.root(y)
  
  def unite(self,x,y):
    x=self.root(x)
    y=self.root(y)
    if x==y:
      return
    if self.size[x]>self.size[y]:
      # 大きい方にくっつける
      self.parent[y]=x
      self.size[x]+=self.size[y]
    else:
      self.parent[x]=y
      self.size[y]+=self.size[x]
      
  def get_group_size(self,x):
    return self.size[self.root(x)]
  
  def get_roots(self):
    r=set()
    for i in range(self.N):
      r.add(self.root(i))
    return r
  
  def show_parent(self):
    print(self.parent)
    
  def show_size(self):
    print(self.size)

UF=UnionFind(N)
for i,j in target:
  UF.unite(i,j)
  
print(len(UF.get_roots()))

Measured memory_bytes: 3700
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

size_t count_substring(const string& str, const string & accept_chars);
bool is_accept_char(const char character, const string & accept_chars);

size_t count_substring(const string& str, const string & accept_chars)
{
    size_t str_len = str.length();
    size_t result = 0;


    for(size_t i = 0; i < str_len; ++i)
    {
        size_t count = 0;
        for(size_t j = i; j < str_len; ++j)
        {
            if (! is_accept_char(str[j], accept_chars)) {
                break;
            }
            count++;
        }
        result = max(result, count);
    }

    return result;
}

bool is_accept_char(const char character, const string & accept_chars)
{
    for(size_t i = 0; i < accept_chars.length(); ++i)
    {
        if (character == accept_chars[i]) {
            return true;
        }
    }
    return false;
}

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

    string str = "";
    cin >> str;
    cout << count_substring(str, "ACGT");

    // string a = "hoge";
    // string b = "fuga";

    // cout << (a[0] == b[3]) << endl;
    // cout << (a[2] == b[2]) << endl;

    // cout << (is_accept_char(a[0], b)) << endl;
    // cout << (is_accept_char(a[1], b)) << endl;
    // cout << (is_accept_char(a[2], b)) << endl;
    // cout << (is_accept_char(a[3], b)) << endl;

    // cout << count_substring("ATCODER", "ACGT") << endl;
    // cout << count_substring("HATAGAYA", "ACGT") << endl;
    // cout << count_substring("SHINJUKU", "ACGT") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = (ll) 1e9+7;
int n;
ll f[2000005], ax[2000005];
int main(){
   cin >> n;
   f[0] = 1;
   ll ans = 0, tmp = 0;
   for(int i=0;i<n;i++){
      tmp = (tmp + ax[i]) % mod;
      f[i] = (f[i] + tmp) % mod;
      if (i == n-1)
         ans = (ans + f[i] * n) % mod;
      else{
         ans = (ans + f[i] * (n-1) % mod * (n-1) % mod) % mod;
         ans = (ans + (i+1) * f[i]) % mod;
         if (i == n-1) ans = (ans - f[i] + mod) % mod;
      }
      if (i != n-1)
      ax[i+1] = (ax[i+1] + f[i]) % mod,
      ax[i+2] = (ax[i+2] - f[i] + mod) % mod,
      ax[i+3] = (ax[i+3] + f[i]) % mod;
      //cout << i << ' ' << ans << ' ' << f[i] << endl;
   }
   tmp = (tmp + ax[n]) % mod;
   f[n] = (f[n] + tmp) % mod;
   ans = (ans + f[n]) % mod;
//   for(int i=n;i<=n;i++){
//      tmp = (tmp + ax[i]) % mod;
//      f[i] = (f[i] + tmp) % mod;
//      ans =  (ans + f[i]) % mod;
//   }
   cout << ans;
}


Measured memory_bytes: 18688
N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

from collections import defaultdict

ds = defaultdict(set)

for a, b in AB:
    ds[a - 1].add(b - 1)
    ds[b - 1].add(a - 1)

result = 0

for i in range(N):
    # print(i, H[i], ds[i])
    if not ds[i] or all(H[d] < H[i] for d in ds[i]):
        result += 1

print(result)


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define vul vector<ull>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi2d vector<vi >
#define vl2d vector<vl >
#define vpll vector<pll >

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rz resize
#define fr(i,n) for(i=0;i<(n);i++)
#define frr(i,n) for(i=(n-1);i>=0;i--)
#define fre(i,n) for(i=0;i<=(n);i++)
#define frre(i,n) for (i=(n);i>=0;i--)
#define frab(i,a,b) for(i=(a);i<(b);i++)
#define freab(i,a,b) for(i=(a);i<=(b);i++)
#define frrab(i,a,b) for(i=(b-1);i>=a;i--)
#define frreab(i,b,a) for(i=(b);i>=a;i--)

#define sz(a) int((a).size())
#define mset(a,b) (memset(a,b,sizeof(a)))
#define max3(a,b,c) (max((a),max((b),(c))))
#define min3(a,b,c) (min((c),min((a),(b))))
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <ll> sprime;
vector<char> prime (1000000, true);
void sieve(ll n)
{
  //O(nloglogn) time
  sprime.pb(0);
  prime[0] = prime[1] = false;
  ll cnt = 0;
  for (ll i = 2; i <= n; ++i)
  {
    if (prime[i])
    {
      cnt++;
      sprime.pb(i);
      for (ll j = 2 * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p, ll MOD) { if (p == 0) return 1; ll z = fastpowMOD(a, p / 2, MOD); z = (z * z) % MOD; if (p % 2) z = (z * a) % MOD; return z; }
ll fastpow(ll a, ll p) { if (p == 0) return 1; ll z = fastpow(a, p / 2); z = (z * z); if (p % 2) z = (z * a); return z; }

#define mod 1000000007
#define inf LLONG_MAX
#define minf LLONG_MIN
#define pi 3.14
#define ex 2.71

//*********************************************///
const int N = 1e5 + 5;
int i,j;
ll a[105];
ll dp[105][N];
ll ans=0;
int n,k;


void solve()
{
  cin>>n>>k;
  freab(i,1,n)
    cin>>a[i];
  mset(dp,0);
  dp[0][0]=1;
  freab(i,1,n)
  {
    ll sum=0;
    freab(j,0,k)
    {
      if(j<=a[i])
      {
        sum=(sum+dp[i-1][j])%mod;
        dp[i][j]=sum;
      }
      else
      {
        sum=(sum+dp[i-1][j])%mod;
        sum=(sum-dp[i-1][j-a[i]-1]+mod)%mod;
        dp[i][j]=(sum%mod);
      }
    }
  }
  cout<<dp[n][k]<<endl;
}

int main()
{
  fast;
  int z;
  //cin>>z;
  z=1;
  while(z--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 83328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int getmd(int a,int b,int c,int d){
    return abs(a-c)+abs(b-d);
}

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='7'){
            puts("Yes");
            return 0;
        }
    }
    puts("No");

    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200005;
int n,x,y,i,j,k,head[N],adj[N*2],nxt[N*2],Head[N],Adj[N*2],Nxt[N*2],dis[N],Dis[N],Fa[N],ans;
bool ok[N];
void dfs(int x,int dad)
{
	for(int y=head[x];y;y=nxt[y])
		if(adj[y]!=dad)
		{
			dis[adj[y]]=dis[x]+1;
			dfs(adj[y],x);
		}
}
void Dfs(int x,int dad)
{
	for(int y=Head[x];y;y=Nxt[y])
		if(Adj[y]!=dad)
		{
			Dis[Adj[y]]=Dis[x]+1;
			Fa[Adj[y]]=x;
			Dfs(Adj[y],x);
		}
}
int dist(int a,int b)
{
	int rtn=0;
	while(a!=b)
	{
		if(Dis[a]<Dis[b])
			swap(a,b);
		a=Fa[a];
		++rtn;
		if(rtn>2)
			return rtn;
	}
	return rtn;
}
void work(int x,int dad)
{
	for(int y=head[x];y;y=nxt[y])
		if(dist(x,adj[y])>2)
			ans=1<<30;
	ans=max(ans,Dis[x]);
	for(int y=head[x];y;y=nxt[y])
		if(adj[y]!=dad&&ok[adj[y]])
			work(adj[y],x);
}
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i*2-1]=k;
		nxt[i*2-1]=head[j];
		head[j]=i*2-1;
		adj[i*2]=j;
		nxt[i*2]=head[k];
		head[k]=i*2;
	}
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&k);
		Adj[i*2-1]=k;
		Nxt[i*2-1]=Head[j];
		Head[j]=i*2-1;
		Adj[i*2]=j;
		Nxt[i*2]=Head[k];
		Head[k]=i*2;
	}
	dfs(x,-1);
	Dfs(y,-1);
	for(i=1;i<=n;++i)
		if(dis[i]<Dis[i])
			ok[i]=true;
	work(x,-1);
	if(ans==(1<<30))
	{
		printf("-1");
		return 0;
	}
	printf("%d",2*ans);
	return 0;
}


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

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

	int h , n;
	cin >> h >> n;
	int sum = 0 , x;
	for(int i = 0; i < n; i++) cin >> x , sum += x;
	if(sum >= h) cout << "Yes\n";
	else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
//08-6 船旅
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#define LL long long
#define INT_MIN –2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while(true)

int n,k;
LL island[101][101];

void visit(int start, int now){ //スタート地点から各地へのコストを計算してislandに保存
    for(int i=1; i<n+1; i++){
        if(i!=start && i!=now && island[now][i] < INT_MAX && island[start][i] > island[start][now]+island[now][i]){
            island[start][i] = island[start][now]+island[now][i];
            visit(start,i);
        }
    }
}

int main(){
    ofstream outputfile("/Users/yuuki/Desktop/output.txt");
    ROOP(){
        cin >> n >> k;
        if(n==0) break;

        for(int i=0; i<n+1; i++){
            for(int j=0; j<n+1; j++){
                island[j][i] = INT_MAX;
                if(i==j) island[j][i] = 0;
            }
        }

        for(int i=0; i<k; i++){
            int tmp;
            cin >> tmp;
            if(tmp==0){//注文
                int a,b;
                cin >> a >> b;
                if(island[a][b] == INT_MAX){
                    cout << -1 << endl;
                    outputfile << -1 << endl;
                }
                else{
                    cout << island[a][b] << endl;
                    outputfile << island[a][b] << endl;
                }
                assert(island[a][b]==island[b][a]);
            }
            else{//運行情報
                int c,d,e;
                cin >> c >> d >> e;
                if(island[c][d] > e){
                    island[c][d] = e;
                    island[d][c] = e;
                }
                visit(c,c);
                for(int i=1; i<n+1; i++){
                    island[i][c] = island[c][i];
                }
                visit(d,d);
                for(int i=1; i<n+1; i++){
                    island[i][d] = island[d][i];
                }
                for(int i=1; i<n+1; i++){
                    for(int j=1; j<n+1; j++){
                        if(island[i][j] > island[i][c]+island[c][j]){
                            island[i][j] = island[i][c]+island[c][j];
                            island[j][i] = island[i][c]+island[c][j];
                        }
                        if(island[i][j] > island[i][d]+island[d][j]){
                            island[i][j] = island[i][d]+island[d][j];
                            island[j][i] = island[i][d]+island[d][j];
                        }
                    }
                }
            }
        }
        outputfile << "===" << endl;
    }
    outputfile.close();
    return 0;
}



Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;
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;}

const long long INF = 1LL << 60;

//Input
int N;
long long h[100010];

//DP table
long long dp[100010];

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

  for (int i=0; i<100010; ++i) dp[i] = INF;

  dp[0] = 0;

  for (int i=0; i<N; ++i){
    chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
    if (i < N-2) chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
  }

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


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Direction
    {
        internal int l, u, lu, ru;
    }

    class Grid
    {
        readonly int n;

        char[,] map;
        Direction[,] memo;

        public Grid(int n)
        {
            this.n = n;
            map = new char[n + 2, n + 2];
            memo = new Direction[n + 2, n + 2];
        }

        public void MakeMap()
        {
            for (int i = 1; i <= n; i++)
            {
                string input = Console.ReadLine();

                for (int j = 0; j < n; j++)
                {
                    map[i, j + 1] = input[j];
                }
            }
        }

        public int SearchMax()
        {
            int ret = 0;

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    if (map[i, j] == '1')
                    {
                        memo[i, j].l = memo[i, j - 1].l + 1;
                        ret = Math.Max(ret, memo[i, j].l);
                        memo[i, j].u = memo[i - 1, j].u + 1;
                        ret = Math.Max(ret, memo[i, j].u);
                        memo[i, j].lu = memo[i - 1, j - 1].lu + 1;
                        ret = Math.Max(ret, memo[i, j].lu);
                        memo[i, j].ru = memo[i - 1, j + 1].ru + 1;
                        ret = Math.Max(ret, memo[i, j].ru);
                    }
                }
            }
            return ret;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Grid g = new Grid(n);
                g.MakeMap();
                sb.AppendLine(g.SearchMax().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 12928
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, u, v, g[666][666] = {}, b[666] = {}, c[666] = {};
    double d[666] = {}, z;
    cin >> n >> m;
    while (m--) cin >> u >> v, g[u][v] = 1, b[u]++, c[v]++;
    for (int i = n - 1; i; i--) {
        d[i] = 1;
        for (int j = i + 1; j <= n; j++) if (g[i][j]) d[i] += d[j] * 1.0 / b[i];
    }
    z = d[1];
    for (int i = 1; i < n; i++) if (b[i] > 1) {
        double e = 0;
        int f = 0;
        for (int j = i + 1; j <= n; j++) if (g[i][j] && d[j] > e) e = d[j], f = j;
        double h[666] = {};
        for (int k = n - 1; k; k--) {
            h[k] = 1;
            for (int j = k + 1; j <= n; j++) if (g[k][j] && (k != i || j != f)) h[k] += h[j] * 1.0 / (b[k] - (k == i));
        }
        //cout << i << ' ' << f << ' ' << h[1] << ' ' << h[2] << ' ' << h[3] << '\n';
        z = min(z, h[1]);
    }
    cout << setprecision(13) << z;
}


Measured memory_bytes: 5536
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/

#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define fo(x,y) for(int x = 1 ; x <= y ; ++x)
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;

typedef long long ll;
typedef unsigned int uint;
const int nmax = 200005;
const ll linf = LLONG_MAX;
const int mod = 1e9+7;
const int inf = INT_MAX;
#define pll pair<ll,ll>

int n, k;
int a[nmax];
int main(){
    cin >> n >> k;
    ll sum = 0 , msum = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += a[i];
        if(i - k > 0) sum -= a[i-k];
        msum = max(sum , msum);
    }
    cout << setprecision(10);
    cout << (double)(msum + k)/2 << '\n';

}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int total = Math.Abs(A[0]);
        for (int i = 0; i < N - 1; i++)
        {
            total += Math.Abs(A[i + 1] - A[i]);
        }
        total += Math.Abs(A[N - 1]);
        
        Console.WriteLine(total - Math.Abs(A[0]) - Math.Abs(A[1] - A[0]) + Math.Abs(A[1]));
        for (int i = 1; i < N - 1; i++)
        {
            Console.WriteLine(total - Math.Abs(A[i] - A[i - 1]) - Math.Abs(A[i + 1] - A[i]) + Math.Abs(A[i + 1] - A[i - 1]));
        }
        Console.WriteLine(total - Math.Abs(A[N - 1] - A[N - 2]) - Math.Abs(A[N - 1]) + Math.Abs(A[N - 2]));
    }
}

Measured memory_bytes: 28124
S = input()
b = True

if len(S)%2!=0:
	b = False

for i in range(1, len(S), 2):
	if S[i-1] == 'h':
		if S[i] == 'i':
			continue
	b = False

if b:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

int N, K;
string S;

int main() {
    cin >> N >> K >> S;
    S[K-1] = tolower(S[K-1]);
    cout << S << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a , b , sum = 0;
    cin >> a >> b;
    for (int i = 0 ; i < 2 ; i++){
        if (a >= b){
            sum += a;
            a--;
        }else{
            sum += b;
            b--;
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3452
let input() = stdin.ReadLine()
let inputs() = input().Split()

let YN b = printfn "%s" (if b then "Yes" else "No")
let print x = printfn "%A" x
let printS (s: string) = printfn "%s" s


let N = int (input())

seq {
    for i in [ 1 .. 9 ] do
        for j in [ 1 .. 9 ] do
            if i * j = N then yield 1
}
|> Seq.isEmpty
|> not
|> YN


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

template< typename Data, typename T >
struct ReRooting {
 
  struct Node {
    int to, rev;
    Data data;
  };
 
  using F1 = function< T(T, T) >;
  using F2 = function< T(T, Data) >;
 
  vector< vector< Node > > g;
  vector< vector< T > > ldp, rdp;
  vector< int > lptr, rptr;
  const F1 f1;
  const F2 f2;
  const T ident;
 
  ReRooting(int n, const F1 &f1, const F2 &f2, const T &ident) :
      g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {}
 
  void add_edge(int u, int v, const Data &d) {
    g[u].emplace_back((Node) {v, (int) g[v].size(), d});
    g[v].emplace_back((Node) {u, (int) g[u].size() - 1, d});
  }
 
  void add_edge_bi(int u, int v, const Data &d, const Data &e) {
    g[u].emplace_back((Node) {v, (int) g[v].size(), d});
    g[v].emplace_back((Node) {u, (int) g[u].size() - 1, e});
  }
 
 
  T dfs(int idx, int par) {
 
    while(lptr[idx] != par && lptr[idx] < g[idx].size()) {
      auto &e = g[idx][lptr[idx]];
      ldp[idx][lptr[idx] + 1] = f1(ldp[idx][lptr[idx]], f2(dfs(e.to, e.rev), e.data));
      ++lptr[idx];
    }
    while(rptr[idx] != par && rptr[idx] >= 0) {
      auto &e = g[idx][rptr[idx]];
      rdp[idx][rptr[idx]] = f1(rdp[idx][rptr[idx] + 1], f2(dfs(e.to, e.rev), e.data));
      --rptr[idx];
    }
    if(par < 0) return rdp[idx][0];
    return f1(ldp[idx][par], rdp[idx][par + 1]);
  }
 
  vector< T > solve() {
    for(int i = 0; i < g.size(); i++) {
      ldp[i].assign(g[i].size() + 1, ident);
      rdp[i].assign(g[i].size() + 1, ident);
      lptr[i] = 0;
      rptr[i] = (int) g[i].size() - 1;
    }
    vector< T > ret;
    for(int i = 0; i < g.size(); i++) {
      ret.push_back(dfs(i, -1));
    }
    return ret;
  }
};

int main(void) {
  string S;
  cin >> S;
  sort(all(S));
  if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<bool> ok(n);
  vector<int> wa(n);
  int ac=0;
  for(int i=0; i<n; i++){
    ok.at(i)=false;
  }
  for(int i=0;i<m; i++){
    int pi;
    string si;
    cin>>pi>>si;
    if(si=="AC"&&!ok.at(pi-1)){
      ac++;
      ok.at(pi-1)=true;
    }
    else if(!ok.at(pi-1)){
      wa.at(pi-1)++;
    }
  }
  int wacount=0;
  for(int i=0;i<n;i++){
    if(ok.at(i)){
      wacount +=wa.at(i);
    }
  }
  cout<<ac<<" "<<wacount;
}

Measured memory_bytes: 640
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

//qsort(a, 3, sizeof(int), sort_inc);
int sort_inc(const void *a, const void *b)
{
    return (*(int*)a - *(int*)b);
}
int sort_dec(const void* a, const void* b)
{
    return (*(int*)b - *(int*)a);
}

int v[51] = {0};

int main()
{
	int N = 0, i = 0;
	double ans = 0.0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &v[i]);
	}
	qsort(v, N, sizeof(int), sort_inc);
	ans = (double)v[0];
	for (i = 1; i < N; i++) {
		ans = (ans + v[i])/2.0;
	}
	printf("%f\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x(x % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) {
      x -= mod;
    }
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) {
      x -= mod;
    }
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) {
      return 1;
    }
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) {
      a *= *this;
    }
    return a;
  }

  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint f(int n) {
  if (n == 0) {
    return 1;
  }
  mint x = f(n / 2);
  x *= x;
  if (n % 2 == 1) {
    x *= 2;
  }
  return x;
}
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i, a) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n, a);
  ans -= choose(n, b);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}
template<class T,enable_if_t<is_integral<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-(-a%b);}
template<class T,enable_if_t<is_floating_point<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-fmod(-a,b);}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int n;
    string s;
    cin>>n>>s;
    bool a[10]={};
    bool b[10][10]={};
    bool c[10][10][10]={};
    
    REP(i,n){
        REP(j,10)REP(k,10)if(b[j][k])c[j][k][s[i]-'0']=1;
        REP(j,10)if(a[j])b[j][s[i]-'0']=1;
        a[s[i]-'0']=1;
    }
    ll ans=0;
    REP(i,10)REP(j,10)REP(k,10)ans+=c[i][j][k];
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#!/usr/bin/env python
"""NOMURA プログラミングコンテスト 2020: B - Postdocs
https://atcoder.jp/contests/nomura2020/tasks/nomura2020_b
"""


def main():
    T = input()

    ans = T.replace('?', 'D')
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9264
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num):>, lower_bound(A, A+N, num):>=
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>	// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>		// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>	// push(x), front(), pop()
#include <deque>
#include <stack>	// push(x), top(), pop()
#include <map>		// M[key],  insert(key, val), erase(key), find(key), 
#include <set>		// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

char s[200005];

void solve() {
	cin >> s;
	bool flag = false;
	int cntS = 0;
	int ans = 0, cnt = 0;
	for (int i = 0;  s[i] != '\0'; i++) {
		cnt++;
		if (s[i] == 'S') {
			cntS++;
			flag = false;
		}
		if (s[i] == 'T' ) {
			if (cntS) ans++;
			cntS = max(--cntS, 0);
			flag = true;
			
		}
	}
	cout << cnt - 2 *ans << endl;
}

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

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


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

    int n, x;
    cin >> n;

    int mx = 0;
    long long ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        mx = max(mx, x);
        ans += mx - x;
    }

    cout << ans << '\n';



    return 0;
}



Measured memory_bytes: 3592
# coding: utf-8
# Your code here!
def saiki(num,lis):
    if num==13:
        #print(lis)
        temp=10**9
        lis.sort()
        for i in range(len(lis)-1):
            temp=min(temp,abs(lis[i+1]-lis[i]))
        if temp!=10**9:
            ans.append(temp)
        
    else:
        if dp[num]>2:
            print(0)
            exit()
        elif dp[num]==2:
            saiki(num+1,lis+[num]+[24-num])
            saiki(num+1,lis+[num]+[num])
            saiki(num+1,lis+[24-num]+[24-num])
        elif dp[num]==1:
            saiki(num+1,lis+[num])
            saiki(num+1,lis+[24-num])
        else:
            saiki(num+1,lis)            


N=int(input())
D=list(map(int,input().split()))

dp=[0]*13
#dp[0]+=1
for d in D:
    dp[d]+=1

ans=[]
saiki(0,[0,24])

print(max(ans))

Measured memory_bytes: 95192
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll ans , n , k;
ll a1 , a2;

int main ( void ) {
	scanf ( "%lld%lld" , &n , &k );
	ll ans1 = n / k;
	ans += ans1 * ans1 * ans1;
	if ( k % 2 == 0 ) {
		ans1 = ( n + k / 2 ) / k;
		ans += ans1 * ans1 * ans1;
	}
	printf ( "%lld\n" , ans );
	return 0;
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string w;
    cin >> w;
    bitset<26> b;
    for (auto &c : w) {
        b[c - 'a'] = !b[c - 'a'];
    }
    cout << (b.none() ? "Yes\n" : "No\n");
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


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


int main(){
  int n;
  cin >> n;
  vector<int64_t> a(n);
  rep(i,n) cin >> a.at(i);
  int64_t sum = accumulate(a.begin(),a.end(),0LL);
  int64_t psum = 0;
  rep(i,n/2){
    psum += a.at(2*i+1)*2;
  }
  vector<int64_t> result(n);
  //cout << sum << "#" << psum;
  result.at(0) = sum - psum;
  for(int i=0;i<n-1;i++){
    result.at(i+1) = 2*a.at(i) - result.at(i);
  }
  rep(i,n) cout << result.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 2944
N = int(input())
dp = [10**9]*(N+1)
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i]+1,dp[i+1])
    k = 1
    while i+6**k <= N:
        dp[i+6**k] = min(dp[i]+1,dp[i+6**k])
        k += 1
    k = 1
    while i+9**k <= N:
        dp[i+9**k] = min(dp[i]+1,dp[i+9**k])
        k += 1

print(dp[N])


Measured memory_bytes: 43116
from functools import reduce

n = int(input())
t = [int(input()) for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def lcm(x, y):
    return x * y // gcd(x, y)


def lcmm(l):
    return reduce(lcm, l)


print(lcmm(t))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    vector<long long>vec(N);
    long long sum=0;
    for(int i=0;i<N;i++){
        cin>>vec[i];
        sum+=vec[i];
    }
    sort(vec.begin(),vec.end());
    long long s=0;
    for(int i=0;i<N/2;i++)s+=vec[i];
    long long m=sum-s;
    if(N%2==0){
        cout<<(m-vec[N/2])*2+vec[N/2]-(s-vec[N/2-1])*2-vec[N/2-1]<<endl;
    }
    if(N%2==1){
        long long x=(m-vec[N/2]-vec[N/2+1])*2+vec[N/2]+vec[N/2+1]-s*2;
        long long y=(m-vec[N/2])*2-(s-vec[N/2-1])*2-vec[N/2]-vec[N/2-1];
        cout<<max(x,y)<<endl;
    }
}

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

int main() {
 int A, B, C, D;
 string op;
 cin >> A >> B >> C >> D;
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  else if (A+B <= C+D) {
    cout << "Right" << endl;
  }
  else {
   cout << "Left" << endl;
  }
} 


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

int main(){
  ll b1,b2,b3;
  cin>>b1 >>b2 >>b3;
  bool ok = true;
  for(int i=0;i<2;i++){
    ll x,y,z;
    cin>>x >>y >>z;
    ll now=b1-x;
    if(now!=b2-y||now!=b3-z){
      ok = false;
    }
  }
  cout<<(ok?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256