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

int main(){
	string s;
	cin >> s;
	if (s[0] != 'A') {cout << "WA"; return 0;}
	int count = 0;
	for (int i = 2; i < (int) s.length() - 1; i++){
		if(s[i] == 'C') count++;
	}
	if (count!=1) {cout << "WA"; return 0;}
	
	for(int i = 1; i<(int) s.length(); i++){
		if(s[i] == 'C' && (i > 1 && i<(int) s.length()-1)) continue;
		else if(!('a'<= s[i]  && s[i] <= 'z')) {cout << "WA"; return 0;}
	}
	cout << "AC";
 }


Measured memory_bytes: 256
#include  <cstdio>
using namespace std;
#define INF (1<<29)
int N,M,R;
int d[201][201];
int r[9];
int A,B,C;
int  res;
bool used [9];

void dfs(int c, int las, int dist) {
    if (c==R+1) {
        if (res >dist)
            res=dist;
        return;
    }
    for (int i=1;i<=R;i++)
        if(!used[i]){
            used[i]=true;if(las==-1)dfs(c+1,i,0);else  dfs(c+1,i,dist+d[r[las]][r[i]]);used[i]=false;
        }
}

int main(){scanf("%d%d%d",&N,&M,&R);for(int i=1;i<=N;i++) for(int j=1;j<=N;j++)if(i!=j)d[i][j]=INF;for(int i=1;i<=R;i++) scanf("%d",&r[i]);for(int i=1;i<=M;i++){scanf("%d%d%d",&A,&B,&C);if(d[A][B]>C)d[A][B]=d[B][A]=C;}for(int k=1;k<=N;k++)for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)if(d[i][j]>d[i][k]+d[k][j])d[i][j]=d[i][k]+d[k][j];res=INF;dfs(1,-1,0);printf("%d\n",res);}

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

#define MAX 30

int n, m;
bool map[MAX][MAX] = { false };

inline bool hasNext(bool a[]) {
	bool judge = true;
	for (int i = 0; i < n; i++) {
		if (a[i]) {
			judge = false;
			break;
		}
	}
	return judge;
}

int solve(int num, bool visit[]) {
	if (hasNext(visit)) {
		return 1;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!map[num][i] || !visit[i]) continue;

		visit[i] = false;
		ans += solve(i, visit);
		visit[i] = true;
	}
	return ans;
}

int main() {
	cin >> n >> m;

	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--, b--;
		map[a][b] = true;
		map[b][a] = true;
	}

	bool visit[8] = { false };
	for (int i = 1; i < n; i++) visit[i] = true;
	cout << solve(0, visit) << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
f = list(map(int,input().split()))
ans = 0

def chr(l,b):
    global ans
    if len(l) != 0:
        a = min(l)
        ans += a-b
        c = l.index(a)
        chr(l[:c],a)
        chr(l[c+1:],a)
chr(f,0)
print(ans)

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m;
	cin >> n >> m;
	
	vl dp(1 << n,oo);
	dp[0] = 0;

	while (m--) {
		ll a, b;
		cin >> a >> b;
		ll nmask = 0;
		while (b--) {
			ll c; cin >> c;
			nmask |= 1 << (c-1);
		}
		FOR(mask,0,1 << n) dp[mask|nmask] = min(dp[mask|nmask], dp[mask] + a);
	}

	ll res = dp.back();
	if (res == oo) res = -1;
	cout << res << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

int main(void) {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%d %d %d\n", c, a, b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e18
    const int N=1e6+6;
    const int MOD=1e9+7;
    void solve()
    {
    	string s;
    	cin>>s;
    	int t1=(s[0]-'0')*10+(s[1]-'0');
    	int t2=(s[2]-'0')*10+(s[3]-'0');
    	if(t1>=1 && t1<=12 && t2>=1 && t2<=12)
    	cout<<"AMBIGUOUS"<<endl;
    	else if(t1>=1 && t1<=12)
    	cout<<"MMYY"<<endl;
    	else if(t2>=1 && t2<=12)
    	cout<<"YYMM"<<endl;
    	else
    	cout<<"NA";
    }
	signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
        	solve();
        }
    }

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


int main(){
  ll n;
  cin>>n;
  //Nの素因数分解
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  ll ans=0;
  for(auto t:ret){
  	ll a=t.first,b=t.second;
    ll i=1ll;
    while(true){
      b=b-i;
      if(b<0){break;}
      ans++;i++;
      
    }
  }
  cout<<ans;
  
  
}

Measured memory_bytes: 3632
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>

using usize = std::size_t;
using u64 = std::uint_fast64_t;

template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}

int main() {
  static constexpr u64 Inf = std::numeric_limits<u64>::max();
  usize n;
  std::cin >> n;

  if (n == 1) {
    std::cout << 0 << std::endl;
    return 0;
  }

  std::vector<u64> x(n), y(n);
  for (usize i = 0; i != n; i += 1) {
    std::cin >> x[i] >> y[i];
  }
  auto dph = md_vec(n, n, Inf), dpv = dph;
  auto ah = md_vec(n, n, usize()), av = ah;

  for (usize i = 0; i != n; i += 1) {
    dph[i][i] = 0;
    dpv[i][i] = 0;
    ah[i][i] = i;
    av[i][i] = i;
  }

  for (usize w = 1; w < n - 1; w += 1) {
    for (usize l = 0, r; (r = l + w) < n; l += 1) {
      // dph
      for (usize m = ah[l][r - 1]; m <= ah[l + 1][r]; m += 1) {
        if (!(l <= m && m + 1 <= r)) {
          continue;
        }
        const u64 t = dpv[l][m] + dph[m + 1][r] + (y[l] - y[r]);
        if (dph[l][r] > t) {
          dph[l][r] = t;
          ah[l][r] = m;
        }
      }
      // dpv
      for (usize m = av[l][r - 1]; m <= av[l + 1][r]; m += 1) {
        if (!(l <= m && m + 1 <= r)) {
          continue;
        }
        const u64 t = dpv[l][m] + dph[m + 1][r] + (x[r] - x[l]);
        if (dpv[l][r] > t) {
          dpv[l][r] = t;
          av[l][r] = m;
        }
      }
    }
  }

  u64 ans = Inf;
  for (usize m = 0; m < n - 1; m += 1) {
    const u64 t =
        dpv[0][m] + dph[m + 1][n - 1] + (y[0] - y[n - 1]) + (x[n - 1] - x[0]);
    if (ans > t) {
      ans = t;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 34128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a+b){
  	cout<<min(a,k)<<endl;
  	return 0;
  }
  cout<<a+a+b-k<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll MOD=998244353;
const int N=3099;
int n, s, a[N];
ll dp[N][N];
int main() {
    IOS; cin >> n >> s;
    for(int i=0; i<n; ++i) {
        cin >> a[i];
    }
    dp[0][0]=1LL;
    for(int elem=0; elem<n; ++elem) {
        for(int trenS=0; trenS<=s; ++trenS) {
            dp[elem+1][trenS]+=2*dp[elem][trenS];
            dp[elem+1][trenS]%=MOD;
            if(trenS+a[elem]<=s) {
                dp[elem+1][trenS+a[elem]]+=dp[elem][trenS];
                dp[elem+1][trenS+a[elem]]%=MOD;
            }
        }
    }
    cout << dp[n][s];
    return 0;
}


Measured memory_bytes: 76280
#include<bits/stdc++.h>
using namespace std;
int main() {
    int x,y;
    cin>>x>>y;
    if(abs(x)<abs(y))
        cout<<abs(y)-abs(x)+2*(x<0 && y<0)+(x<0 && y>0)+(x>=0 && y<0);
    else
        cout<<abs(x)-abs(y)+2*(x>0 && y>0)+(x<0 && y>0)+(x>0 && y<=0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main()
{
    char a,b;
    cin>>a>>b;
    if(a=='H')
	{
        cout << (b=='H'?'H':'D') << endl;
    }
	else if(a=='D')
	{
        cout << (b=='D'?'H':'D') << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


#define INF INT_MAX/2
int N, F[101][11], P[101][11];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) rep(j, 0, 10) cin >> F[i][j];
    rep(i, 0, N) rep(j, 0, 11) cin >> P[i][j];

    int ans = -INF;
    rep(msk, 1, 1 << 10) {
        int sm = 0;
        rep(i, 0, N) {
            int c = 0;
            rep(j, 0, 10) if (msk & (1 << j)) if (F[i][j]) c++;
            sm += P[i][c];
        }
        ans = max(ans, sm);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std ;
const int N= 3e5;
int Mod = 1e9+7 ;
long long cum [N];


int main(){
    int N;
    int ac= 0, wa= 0, tle = 0, re = 0;
    string tmp;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> tmp;
        if (tmp == "AC") {
            ac++;
        } else if (tmp == "WA") {
            wa++;
        } else if (tmp == "TLE") {
            tle++;
        } else if (tmp == "RE") {
            re++;
        }
    }

    std::cout << "AC x "  << ac << std::endl;
    std::cout << "WA x "  << wa << std::endl;
    std::cout << "TLE x " << tle << std::endl;
    std::cout << "RE x "  << re << std::endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int i;
	int sum1 = 0;
	int sum2 = 0;
	cin >> n;
	vector<int>a(n, 0);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (i = 0; i < n; i++) {
			if (i % 2 == 0) {
				sum1 += a[i];
			}
			else {
				sum2 += a[i];
			}
	}
	cout << sum1 - sum2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();

		long answer = 1;
		for (long i = 1; i * i <= m && i <= m / n; i++) {
			if (m % i == 0) {
				answer = Math.max(answer, i);
				if (m / i <= m / n) answer = Math.max(answer, m / i);
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 22740
#include <stdio.h>

int makeFibonatti( int );
int main()
{
  int n;
  
  scanf("%d", &n);

  printf("%d\n", makeFibonatti(n));
  
  return 0;
}

int makeFibonatti(int N)
{
  int F[50];
  int i;
  
  F[0] = 1;
  F[1] = 1;
  for(i = 2; i <= N; i++)
    F[i] = F[i-2]+F[i-1];
  return F[i-1];
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define vi vector<ll>
#define vvi vector<vi>
const ll mod = 1000000007LL;

#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pi pair<ll, ll>
#define ppi pair<ll, pi>
#define pb push_back
#define all(v) v.begin(), v.end()
const ll inf = 1e18;

#define cerr                                                                   \
  if (false)                                                                   \
  cerr
#define db(x) cerr << "\n" << (#x) << " is " << (x) << endl;
inline int max(int a, int32_t b) { return a > b ? a : b; }
inline int max(int32_t a, int b) { return a > b ? a : b; }
inline int min(int a, int32_t b) { return a < b ? a : b; }
inline int min(int32_t a, int b) { return a < b ? a : b; }
int d4_1[4] = {1, 0, -1, 0};
int d4_2[4] = {0, 1, 0, -1};
int d8_1[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int d8_2[8] = {0, -1, 1, 0, -1, 1, 1, -1};

ll seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll l = 0, ll r = 1e18) {
  return uniform_int_distribution<ll>(l, r)(rng);
}

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(10);

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif

  ll t = 1;
  // cin>>t;

  while (t--) {
    int k, a, b;
    cin >> k >> a >> b;
    if (a % k == 0 || b % k == 0) {
      cout << "OK\n";
      continue;
    }
    if (a / k == b / k) {
      cout << "NG\n";
    } else {
      cout << "OK\n";
    }
  }
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> Q;

int main() {
	int n;
	cin >> n;
	int a, b, c, d;
	c = 1;
	cin >> a;
	d = a;
	b = a;
	vector<Q> q;
	for (int i = 1; i < n; i++) {
		cin >> a;
		if (a == b) {
			P p = P(d, a);
			q.push_back(Q(c, p));
			d = a;
			c = 1;
		} else {
			c++;
			b = a;
		}
	}
	if (c != 0) {
		q.push_back(Q(c, P(d, a)));
	}
	int MAX = q[0].first;
	int sz = q.size();
	/*for (int i = 0; i < sz; i++) {
		cout << q[i].first << ' ' << (q[i].second).first << ' ' << (q[i].second).second << endl;
	}*/
	for (int i = 0; i < sz; i++) {
		if (i+1 < sz) {
			MAX = max(MAX, q[i].first+q[i+1].first);
		}
		if (i+2 < sz) {
			if (((q[i].second).second == (q[i+1].second).first) && ((q[i+1].second).second == (q[i+2].second).first)) {
				MAX = max(MAX, q[i].first+q[i+1].first+q[i+2].first);
			}
		}
	}
	cout << MAX << endl;
	return 0;
}

Measured memory_bytes: 1980
#include <iostream>
using namespace std;
int prime_number(int n){
    int i;
    if(n<=1) return 0;
    for(i=2;i<=n/2;i++) if(n%i==0) return 0;
    return 1;
}

int main(){
    int i,j,k,n[10000],a=0;
    for(j=0;j<10000;j++){
        cin >> n[j];
        if(n[j]==0) break;
    }
    for(k=0;k<j;k++){
        for(i=n[k];i>4;i--) if(prime_number(i)) if(prime_number(i-2)){
            a=i;
            break;
        }
        if(a!=0) cout << i-2 << " " << i << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = c - a, y = d - b;
  printf("%d %d %d %d", c - y, d + x, a - y, b + x);
}

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

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

int main() {
    int H, W; cin >> H >> W;
    string S[H+2];

    S[0] = "";
    S[H+1] = "";
    rep(i, W+2) S[0] += ".";
    rep(i, W+2) S[H+1] += ".";

    reup(i, 1, H+1) {
        cin >> S[i];
        S[i] = "." + S[i] + ".";
    }

    reup(i, 1, H+1) {
        reup(j, 1, W+1) {
            if(S[i][j] == '#') {
                cout << "#";
            } else {
                cout << (S[i-1][j-1] == '#') +
                        (S[i-1][j] == '#') +
                        (S[i-1][j+1] == '#') +
                        (S[i][j-1] == '#') +
                        (S[i][j+1] == '#') +
                        (S[i+1][j-1] == '#') +
                        (S[i+1][j] == '#') +
                        (S[i+1][j+1] == '#');
            }
        }
        cout << endl;
    }
}


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

using namespace std;
const int N = 200050;

int n, v, x[N];
int dp1[(1 << 19) + 3], dp2[(1 << 19) + 3];
int tor[20][N], tol[20][N], len[20], dep, mxr[N];
inline void gi(int &x){
	int f = 1; x = 0; char c = getchar();
	while(c < '0' || c > '9'){
		if(c == '-')f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9'){
		x = x * 10 + c - '0';
		c = getchar();
	}
	x *= f;
}
int main()
{

int i, j, d;
    gi(n), gi(v), x[0] = -2e9, x[n+1] = 2e9;
    for(len[0] = v; len[dep] != 0; dep ++)
		len[dep + 1] = len[dep] >> 1;
    for(dep ++, i = 1; i <= n; i ++)gi(x[i]);
    for(d = 0; d < dep; d ++){
        tol[d][0] = n, tor[d][n + 1] = n;
        for(i = 1; i <= n; i ++)tol[d][i] = (x[i] - x[i - 1] <= len[d]) ? tol[d][i - 1] : n + 1 - i;
        for(i = n; i >= 1; i --)tor[d][i] = (x[i + 1] - x[i] <= len[d]) ? tor[d][i + 1] : i;
    }
    for(i = 0; i < (1 << dep); i += 2){
        for(j = 1; j < dep; j ++){
            if((i & (1 << j)) == 0){
                dp1[i | (1 << j)] = max(dp1[i | (1 << j)], tor[j][dp1[i] + 1]);
                dp2[i | (1 << j)] = max(dp2[i | (1 << j)], tol[j][n - dp2[i]]);
            }
        }
    }
    memset(mxr, 0xc0, sizeof(mxr));
    for(i = 0, j = ((1 << dep) - 1) ^ 1; j >= 0; i += 2, j -= 2)
        mxr[dp1[i]] = max(mxr[dp1[i]], dp2[j]);
    for(i = 1; i <= n; i ++){
        if(mxr[n - tol[0][i]] + tor[0][i] >= n)puts("Possible");
        else puts("Impossible");
    }
	    
    return 0;
}

Measured memory_bytes: 39296
// 問題: H*Wのタイルが与えられる。タイルは綺麗か汚れているかのいずれか。
//       綺麗なタイルのみでできる最大の正方形の最大値を求める
// 解法: http://prdc.hatenablog.com/entry/2017/09/11/105211
//       dp[i][j]: 位置(i,j)から見て、左上に向かってできる最大の正方形の数

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

int largest_square(const int H, const int W, const vector<vector<int>>& cells) {
    vector<vector<int>> dp(H, vector<int>(W));
    REP(h, H) {
        REP(w, W) {
            auto val = cells[h][w];
            if (h == 0 || w == 0) {
                dp[h][w] = (val == 0);
            }
            else {
                if (val == 0) {
                    dp[h][w] = min(dp[h][w-1], min(dp[h-1][w], dp[h-1][w-1])) + 1;
                }
                else {
                    dp[h][w] = 0;
                }
            }
        }
    }
    int size = 0;
    REP(h, H) {
        REP(w, W) {
            size = max(size, dp[h][w]);
            // cout << dp[h][w] << " ";
        }
        // cout << endl;
    }
    return size * size;
}


int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<int>> cells(H, vector<int>(W));
    REP(h, H) {
        REP(w, W) {
            cin >> cells[h][w];
        }
    }
    cout << largest_square(H, W, cells) << endl;
    return 0;
}



Measured memory_bytes: 18196
import collections
n = int(input())
a = [int(i) for i in input().split()]
c = collections.Counter(a)
answer = 0
for i in c.most_common():
	if i[0]>i[1]:
		answer += i[1]
	elif i[0]<i[1]:
		answer += i[1]-i[0]
print(answer)

Measured memory_bytes: 21232
import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

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

string S;

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

  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

  return 0;
}

Measured memory_bytes: 764
n = int(input())
*P, = map(float, input().split())
DP = [[0.0 for j in range(n+1)] for i in range(n+1)]
DP[0][0] = 1.0
for i in range(1, n+1):
    DP[i][0] = DP[i-1][0]*(1-P[i-1])
    for j in range(1, n+1):
        DP[i][j] = DP[i-1][j]*(1-P[i-1])+DP[i-1][j-1]*P[i-1]
print(sum(DP[n][(n+1)//2:]))


Measured memory_bytes: 122076
#include <iostream>

using namespace std;
int ret[50];
int map[50];
int count2 = 0;

struct treenode{
	int data;
	treenode* leftchild;
	treenode* rightchild;
	treenode(int v) {
		data = v;
		leftchild = NULL;
		rightchild = NULL;
	}
};

void remap(int inorder[],int n) {
	for (int i = 0; i < n; i++) {
		map[inorder[i]] = i;
	}
}

treenode* bip(int pre[], int n, int offset) {
	if (n == 0) return NULL;
	int rootval = pre[0];
	int i = map[rootval] - offset;
	treenode* root = new treenode(rootval);
	root->leftchild = bip(pre + 1, i, offset);
	root->rightchild = bip(pre + i + 1, n - i - 1, offset + i + 1);
	return root;
}

void lastorder(treenode* ptr) {
	if (ptr) {
		lastorder(ptr->leftchild);
		lastorder(ptr->rightchild);
		ret[count2++] = ptr->data  ;
	}
}

int main() {
	int n;
	cin >> n;
	int pre[50];
	for (int i = 0; i < n; i++) {
		cin >> pre[i];
	}
	int inorder[50];
	for (int i = 0; i < n; i++) {
		cin >> inorder[i];
	}
	remap(inorder, n);
	treenode* root;
	root = bip(pre, n, 0);
	lastorder(root);
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << ret[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(void){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  if(x+r>w||x-r<0||y+r>h||y-r<0)
  cout<<"No"<<endl;
  else
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1160
//AtCoder ABC101 A - Eating Symbols Easy
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string S;
    cin>>S;
    ll ans=0;
    for(const auto&s:S){
        if(s=='+') ++ans;
        else --ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

bool isPalindrome(string s)
{

    forn(i,0,s.sze/2)
    {
        if(s[i] != s[s.sze-i-1]) return false;
    }

    return true;
}


int main()
{
    fast
    pre
/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

    // string s;
    // cin>>s;

    // int n = s.sze;
    // if(isPalindrome(s) && isPalindrome(s.substr(0,(n-1)/2)) && isPalindrome(s.substr((n+1)/2))) cout<<"Yes";
    // else cout<<"No";

    ld n;
    cin>>n;

    ld x = (n/3)*(n/3)*(n/3); 

    cout<<x;


    return 0;
}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

int dp[3001][3001];

void resolve()
{
    string s, t;
    cin >> s >> t;

    // dp[i][j] : sをi文字目、tをj文字目まで見た時の最長共通部分列の長さ
    dp[0][0] = 0;
    RPT1(i, s.length()) dp[i][0] = 0;
    RPT1(j, t.length()) dp[0][j] = 0;

    RPT1(i, s.length())
    RPT1(j, t.length())
    {
        dp[i][j] = (s[i - 1] == t[j - 1]) ? dp[i - 1][j - 1] + 1
                                          : max(dp[i - 1][j], dp[i][j - 1]);
    }

    // この時点でdp[s.length()][t.length()]が求める最長共通部分列の長さ
    // 文字列の作成は、この配列の後ろから見ていく

    string ans;
    int i = s.length(), j = t.length(), len = dp[i][j];
    while (len > 0) {
        if (s[i - 1] == t[j - 1]) {
            ans.push_back(s[i - 1]);
            i--;
            j--;
            len--;
        } else if (dp[i][j] == dp[i - 1][j])
            i--;
        else
            j--;
    }
    reverse(ALL(ans));
    cout << ans << endl;
}

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


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

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

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

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

// N^P mod M（ただしM == -1の時はmodを取らない）
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int Q;
    cin >> Q;
    for(int i = 0;i < Q;i++) {
        ll A,B;
        cin >> A >> B;
        if(A == B) {
            cout << 2 * A - 2 << endl;
        }
        else {
            ll ok = 0;
            ll ng = 1000000001;
            ll mid = 0;
            while(ng - ok > 1) {
                mid = (ok + ng) / 2;
                if(mid * mid < A * B) {
                    ok = mid;
                }
                else {
                    ng = mid;
                }
            }
            if(ok * (ok + 1) >= A * B) {
                cout << 2 * ok - 2 << endl;
            }
            else {
                cout << 2 * ok - 1 << endl;
            }
        }
    }
}

Measured memory_bytes: 3596
n = int(input())
H = list(map(int, input().split()))

A = [0]

for i in range(1,n):
    if i == 1:
        a = abs(H[i] - H[i-1])
        A.append(a)
    else:
        a = min(abs(H[i] - H[i-1]) + A[i-1], abs(H[i] - H[i-2]) + A[i-2])
        A.append(a)

ans = A[-1]
print(ans)

Measured memory_bytes: 13980
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void){
    ABC148();
}

void ABC148(){
    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    int n = (int)s.size();

    vector<int> r(n);
    char c[2] = { 'R', 'L' };
    for (int j = 0; j < 2; j++) {
        int k = 0;
        for (int i = 0; i < n - 1; i++) {
            if (s[i] == c[j]) {
                k++;
                if (s[i + 1] != c[j]) {
                    r[i + 0] += k / 2 + k % 2;
                    r[i + 1] += k / 2;
                    k = 0;
                }
            }
        }
        reverse(s.begin(), s.end());
        reverse(r.begin(), r.end());
    }


    for (int i = 0; i < n; i++) {
        cout << r[i] << " \n"[i == n - 1];
    }

    //移動は偶数回
    //RLペアは変化しないので取り除く R++LLR++
    //残ったところからRLへ流れ込む 奇数回目は近いほうが多く 偶数回目は同じに 奇数個流れ込むなら偶数回目は遠いほうが多くなる

    return 0;
}

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
int N,Ans=0;
int P[15];
int main()
{
	cin>>N;
	int Pos=0;
	for(int i=1;i<=N;i++)
	{
		cin>>P[i];
		if(P[i]>P[Pos]) Pos=i;
	}
	for(int i=1;i<=N;i++)
		if(i==Pos) Ans+=P[i]/2;
		else Ans+=P[i];
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2017/10/22 20:38:02 UTC+8
File Name     :ion.cpp
*************************************** */

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

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

const int maxn = 200010;

char s[maxn];
int dp[maxn];

struct st
{
	bool val[26];
	st()
	{
		memset(val, 0, sizeof val);
	}
	bool operator <(const st& b)const
	{
		for (int j = 0; j < 26; ++ j)
		{
			if (val[j] == b.val[j]) continue;
			return val[j] < b.val[j];
		}
		return 0;
	}
};

int main()
{
	IOS;
	cin>>(s + 1);
	int n = strlen(s + 1);
	map<st, int> mp;
	st nowst;
	mp[nowst] = 0;
	for (int j = 1; j <= n; ++ j)
	{
		dp[j] = dp[j - 1] + 1;
		nowst.val[s[j] - 'a'] = !nowst.val[s[j] - 'a'];
		map<st, int>::iterator it = mp.find(nowst);
		if (it != mp.end())
		{
			dp[j] = min(dp[j], dp[it->Y] + 1);
		}
		for (int k = 0; k < 26; ++ k)
		{
			nowst.val[k] = !nowst.val[k];
			it = mp.find(nowst);
			if (it != mp.end())
			{
				dp[j] = min(dp[j], dp[it->Y] + 1);
			}
			nowst.val[k] = !nowst.val[k];
		}
		it = mp.find(nowst);
		if (it == mp.end() || dp[it->Y] > dp[j]) mp[nowst] = j;
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 16896
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    int d = a / b;
    int r = a % b;
    double f = double (a) / double (b);
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed << setprecision(5) << f;
    cout << endl;
}
   


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define all(v) v.begin(), v.end()
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define T ll t; cin>>t; while(t--)

ll gen(){
    ll temp;
    cin>>temp;
    return temp;
}

int main(){
  FAST

  int n ;
  cin>>n;
  cout<<(2.0*PI*n);
  
  return 0;
}







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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int MOD = 1e9 + 7;

void add(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int dp[2001];

void solve() {
  int S; cin >> S;
  dp[0] = 1;
  for (int s = 0; s < S; s++) {
    for (int v = 3; v + s <= S; v++) {
      add(dp[v + s], dp[s]);
    }
  }
  cout << dp[S];
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; i++){
    cin >> X.at(i);
  }
  int ans = 100000000;
  for(int i=1; i<=100; i++){
    int tmp = 0;
    int tmp2;
    for(int j=0; j<N; j++){
      tmp2 = X.at(j) - i;
      tmp += tmp2 * tmp2;
    }
    if(tmp < ans) ans = tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def gcd(a, b):
    return gcd(b, a % b) if a % b else b

def lcm(a, b):
    return a * b / gcd(a, b)

for line in sys.stdin:
    data = map(int, line.split())
    a, b = data
    print "%d %d" % (gcd(a, b), lcm(a, b))

Measured memory_bytes: 4228
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;

#define N 5003
#define INF 0x3f3f3f3f3f3f3f3f

inline void cmax(long long &x, long long y) { if (x < y) x = y;}
inline void cmin(long long &x, long long y) { if (x > y) x = y;}

int n, A, B, a[N], pos[N];
long long f[N][N << 1], res = INF;

int main() {
    cin >> n >> A >> B;
    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i), pos[a[i]] = i;
    for (int i = 1; i <= n; ++i) {
        long long tmp = INF;
        for (int j = 0; j <= n << 1; ++j) {
            if (j & 1) {
                int p = (j + 1) >> 1;
                cmin(tmp, f[i - 1][j] + (p == pos[i] ? 0 : (p < pos[i] ? B : A)));
            } else {
                int p = j >> 1;
                cmin(tmp, f[i - 1][j] + (p < pos[i] ? B : A));
            }
            f[i][j] = tmp;
        }
    }
    long long ans = INF;
    for (int j = 0; j <= n << 1; ++j)
        cmin(ans, f[n][j]);
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n,k,ans;
    while(cin >> n >> k)
    {
        if(k == 0)
        {
            cout << n*n << '\n';
            continue;
        }
        ans = 0;
        for(ll i = k+1; i <= n; i++)
        {
            ll blocks = n/i;
            ll left = n%i;
            ans += blocks * (i-k) + max(0LL, left-k+1);
        }
        cout << ans << '\n';
    }
    return 0;
}

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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int total = h*w;
    int kesu = max(h, w);

    if (n%kesu==0) {
        cout << n/kesu << endl;
    }
    else {
        cout << n/kesu + 1 << endl;
    }
}

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

int main(){
  int i,j,cnt=0;
  string x;
  cin>>x;
  int s=0,t=0;
  for(i=0;i<x.size();i++){
    if(x[i]=='S')s++;
    if(x[i]=='T'){
      if(s!=0)s--;
    }
  }
  cout<<2*s<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll x;cin>>x;
  for(ll a=-1000;a<1000;a++){
    ll a5=pow(a,5);
    for(ll b=-1000;b<1000;b++){
      ll b5=pow(b,5);
      ll ans=a5-b5;
      if(ans==x){
          cout<<a<<" "<<b<<endl;
          return 0;
      }
    }
  }
  cout<<0<<" "<<x<<endl;
  return 0;
}


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

const int Nmax = 8; 
bool node[Nmax][Nmax];

int DFS(int v, int N, vector<bool>visit){
    bool all_visit = true;
    for(int i=0; i<N; i++){
        if(visit.at(i) == false) all_visit = false;
    }
    if(all_visit)return 1;

    int ans = 0;

    for(int i=0; i<N; i++){
        if(visit.at(i)) continue;
        if(node[v][i] == false) continue;

        visit[i] = true;
        ans += DFS(i,N,visit);
        visit[i] = false; 
    }
    return ans;
}

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

    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        node[a-1][b-1] = node[b-1][a-1] = true;
    }
    
    vector <bool>visit(N,false);
    visit.at(0)=true;

    cout << DFS(0, N, visit)<<"\n";

    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut ans: usize = 1000;
    for i in 1..n {
        if a[i - 1] < a[i] {
            ans += (a[i] - a[i - 1]) * (ans / a[i - 1]);
        }
    }
    ans.to_string()
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
#define N 100005
#define LL long long 
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
using namespace std;
LL int n,ar[N],sum;
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n*2;i++)
		cin>>ar[i];
	sort(ar+1,ar+n+n+1);
	for(int i=1;i<=n+n;i++)
		if(i%2==1)
			sum+=ar[i];
	cout<<sum;
}


Measured memory_bytes: 256
{-# LANGUAGE TypeApplications, BangPatterns #-}
{-# LANGUAGE LambdaCase, DeriveFunctor #-}

import           Control.Applicative
import           Control.Arrow
import           Control.Monad
import           System.IO
import           Data.Bits
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import           Data.Foldable
import           Data.Monoid
import           Control.Monad.Fix
import           Control.Monad.ST
import qualified Data.Set                      as S
import qualified Data.Vector.Unboxed.Mutable   as V
import qualified Data.ByteString.Char8         as BS

twice :: (a -> a -> b) -> a -> b
twice f x = f x x

both :: Arrow a => a b c -> a (b, b) (c, c)
both = twice (***)

readsLn :: Read a => IO [a]
readsLn = mapM readIO . words =<< getLine





main = do
  n <- readLn @Int
  putStrLn $ take (n * 3) (cycle "ACL")


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
    cin >>x;
    cout <<"ABC"<<x;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int n, m, ans;
int h[100005];
bool j[100005];

int main() {

	cin >> n >> m;

	rrep(i, n)j[i] = true;

	rrep(i, n)cin >> h[i];

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		if (h[a] < h[b])j[a] = false;
		else if (h[b] < h[a])j[b] = false;
		else {
			j[a] = false;
			j[b] = false;
		}
	}

	rrep(i, n) if (j[i])ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4124
d = ['','a','b','c','d','e','f','g','h','i','j']
N = int(input())
if N == 1:
  print("a")
elif N == 2:
  print("aa")
  print("ab")
else:
  ans = [[[]]for _ in range(N - 1)]
  ans[0][0] = [1]
  ans[1][0] = [1,1]
  ans[1].append([1,2])
  ansstr = []
  for i in range(N -2):
    for i2 in range(len(ans[i + 1])):
      for i3 in range(max(ans[i + 1][i2]) + 1):
        if i == N - 3:
          ansstr.clear()
          for i4 in range(N - 1):
            ansstr.append(d[ans[i + 1][i2][i4]])
          ansstr.append(d[i3 + 1])
          print("".join(ansstr))
        else:
          ans[i + 2].append(ans[i + 1][i2] + [i3 + 1])
    if i < N - 3:
      ans[i + 2].pop(0)

Measured memory_bytes: 8356
package main

import "fmt"

func main() {
	var N, M, C int
	fmt.Scan(&N, &M, &C)
	B := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&B[i])
	}

	ans := 0
	for i := 0; i < N; i++ {
		var A int
		sum := 0
		for j := 0; j < M; j++ {
			fmt.Scan(&A)
			sum += A * B[j]
		}
		if sum+C > 0 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512