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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

array<array<ll, 2>, 2010> dp;
array<ll, 2010> a;

ll rec(ll z, ll w, int s, int t, int n){
	ll& rtn = dp[s][t];
	if(rtn !=-1) return rtn;
	if(s == n) return abs(z -w);
	
	if(t==0){
		rtn = 0;
		rep2(i, s, n) rtn = max(rtn, rec(a[i], w, i+1, 1, n));
	}else{
		rtn = 1LL<<60;
		rep2(i, s, n) rtn = min(rtn, rec(z, a[i], i+1, 0, n));
	}
	return rtn;
}

int main()
{
 
	cin.tie(0); ios_base::sync_with_stdio(false);
	int  n; ll z,w;
	cin >>n >>z >>w;
	rep(i, n) cin >>a[i];
	rep(i, 2010) dp[i].fill(-1);
	cout << rec(z, w, 0, 0, n) <<endl;
	
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int N,X,L[100],i,count=0,sum=0;
	scanf("%d %d", &N,&X);
	for (i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}
	
	for (i = 0; sum <= X; i++) {
		sum = sum + L[i];
		count++;
	}
	printf("%d", count);
    return 0;
}



Measured memory_bytes: 128
from collections import deque

n = int(input())
tree = {i:[] for i in range(1, n+1)}
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)
c = list(map(int, input().split()))

c = sorted(c, reverse = True)
d = [-1]*(n+1)
que = deque([1])
ic = 0
while len(que) > 0:
    x = que.pop()
    d[x] = c[ic]
    ic += 1
    for y in tree[x]:
        if d[y] < 0:
            que.append(y)
print(sum(c[1:]))
print(*d[1:])


Measured memory_bytes: 7068
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
using namespace std;

typedef tuple<int, int, int> point;
#define x(p) get<0>(p)
#define y(p) get<1>(p)
#define z(p) get<2>(p)

int r(int &a, int &b) {
  static constexpr int C = ~(1 << 31);
  static constexpr int M = (1 << 16) - 1;

  a = 36969 * (a & M) + (a >> 16);
  b = 18000 * (b & M) + (b >> 16);
  return (C & ((a << 16) + b)) % 1000000;
}

bool check(int y, int z, const map<int, int> &contour) {
  const auto it = contour.upper_bound(y);
  return it != contour.end() && it->second < z;
}

int solve(vector<point> &points) {
  sort(points.begin(), points.end());

  int max_count = 0;
  int prev_x = x(points.front());
  vector<tuple<int, int, int>> buf;
  vector<map<int, int>> maps{{{1, -1}}};
  buf.reserve(points.size());
  maps.reserve(points.size());

  for(const auto &p : points) {
    const int x = x(p);
    const int y = -y(p);
    const int z = z(p);

    if(prev_x != x) {
      maps.resize(max_count + 1);
      prev_x = x;
      for(const auto &e : buf) {
	int k, ty, tz;
	tie(k, ty, tz) = e;

	auto &target = maps[k];
	auto it = target.lower_bound(ty);

	if(it == target.end() || it->second > tz) {
	  target[ty] = tz;
	  it = target.find(ty);

	  while(it != target.begin()) {
	    --it;
	    if(tz > it->second) break;
	    it = target.erase(it);
	  }
	}
      }
      buf.clear();
    }

    int low = 0;
    int high = maps.size();

    while(low + 1 < high) {
      const int mid = (low + high) / 2;
      if(check(y, z, maps[mid])) {
	low = mid;
      }
      else {
	high = mid;
      }
    }

    if(low == max_count) ++max_count;
    buf.emplace_back(high, y, z);
  }
  
  return max_count;
}

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

  for(int m, n, a, b; cin >> m >> n >> a >> b && (m | n);) {
    vector<point> points;
    points.reserve(n + m);

    for(int i = 0; i < m; ++i) {
      int x, y, z;
      cin >> x >> y >> z;
      points.emplace_back(x, y, z);
    }

    for(int i = 0; i < n; ++i) {
      const int x = r(a, b);
      const int y = r(a, b);
      const int z = r(a, b);
      points.emplace_back(x, y, z);
    }

    cout << solve(points) << endl;
  }

  return EXIT_SUCCESS;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    
    int ans=0,cmp=a[0];

    for(int i=0; i<n; i++){
        if(a[i] <= cmp){
            ans++;
            cmp = a[i];
        } 
    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+50;
ll n,ans,pos;
ll a[N],t[N],s1[N],s2[N];
char s[10];
int main()
{
	ll i;
	scanf("%lld",&n);
	scanf("%lld",&a[1]);t[1]=1;
	for(i=2;i<=n;i++)
	{
		scanf("%s",s);scanf("%lld",&a[i]);
		if(s[0]=='+') t[i]=1;
		else t[i]=-1;
	}
	for(i=1;i<=n;i++) s1[i]=s1[i-1]+t[i]*a[i],s2[i]=s2[i-1]+a[i];
	ans=s1[n];
	pos=n+1;
	for(i=n;i>=2;i--)
	{
		if(t[i]==-1) 
		{
			ans=max(ans,s1[i-1]-(s2[pos-1]-s2[i-1])+s2[n]-s2[pos-1]);
			pos=i;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod =  998244353;
int sum(int x, int y){
	if (x+y<0) return x+y+mod;
	if (x+y >= mod) return x+y-mod;
	return x+y;
}
int mult(int x, int y){
	return ((ll) x * (ll) y) % (ll) mod;
}
signed main() {
	#ifdef LOCAL
		freopen("H_input.txt", "r", stdin);
		//freopen("C_output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a=0, b=0, c=0;
    int free=0, pairs=0;
    int ans=1;
    for (int i=0; i < 3*n; i++){
    	if (s[i] == 'R'){
    		a++;
    		if (a > 0 && b > 0 && c > 0){
    			a--, b--, c--;
    			ans = mult(ans, pairs);
    			pairs--;
    			continue;
    		}
    		if (a <= b || a <= c){
    			pairs++;
    			ans = mult(ans, free);
    			free--;
    		}
    		else free++;
    	}
    	else if (s[i] == 'B'){
    		b++;
    		if (a > 0 && b > 0 && c > 0){
    			a--, b--, c--;
    			ans = mult(ans, pairs);
    			pairs--;
    			continue;
    		}
    		if (b <= a || b <= c){
    			pairs++;
    			ans = mult(ans, free);
    			free--;
    		}
    		else free++;
    	}
    	else{
    		c++;
    		if (a > 0 && b > 0 && c > 0){
    			a--, b--, c--;
    			ans = mult(ans, pairs);
    			pairs--;
    			continue;
    		}
    		if (c <= b || c <= a){
    			pairs++;
    			ans = mult(ans, free);
    			free--;
    		}
    		else free++;
    	}
    }
    for (int i=1; i <= n; i++) ans = mult(ans, i);
    cout << ans;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double
   
ll a, b, c, x, y;

int main(){
   // freopen("input.txt", "r", stdin);
    //freopen("output2.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    if (a + b > 2 * c){
    	ll k = min(x, y);
    	if (k % 2 == 1) k--;
    	x -= k;
    	y -= k;
    	ans = k * 2 * (ll)c;
    	while(1){
    		if (x == 0 && y == 0) break;
    		ll c1 = 2 * c;
    		ll c2 = a * (x > 0) + b * (y > 0);
    		if (c1 < c2){
    			ans += c1;
    			x--;
    			y--;
    			x = max(x, (ll)0);
    			y = max(y, (ll)0);
    		} else {
    			ans += a * x + b * y;
    			break;
    		}
    	}
    } else {
    	ans = a * x + b * y;
    }
    cout << ans;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = readline().strip()

    if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8880
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < ((int)(b)); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define sz(c) ((int)c.size())
#define all(c) c.begin(), c.end()

signed main() {
    int N, M;
    cin >> N;
    vector<string> S, T;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        S.push_back(s);
    }
    cin >> M;
    for (int i = 0; i < M; ++i) {
        string s;
        cin >> s;
        T.push_back(s);
    }
    
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        string s = S[i];
        int score = 0;
        for (int j = 0; j < N; ++j) {
            if (s == S[j]) {
                score++;
            }
        }
        for (int j = 0; j < M; ++j) {
            if (s == T[j]) {
                score--;
            }
        }
        if (ans < score) {
            ans = score;
        }
    }
    cout << ans << endl;
}



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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

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

    VVi dp(m+1, Vi(n+1, 1e9));
    REP(i, m+1) dp[i][0] = 0;
    REP2(i, 1, m+1) {
        int c; cin >> c;
        REP(j, n+1) {
            dp[i][j] = dp[i-1][j];
            if (j >= c) {
                dp[i][j] = min({dp[i][j], dp[i-1][j-c] + 1, dp[i][j-c] + 1});
            }
        }
    }
    std::cout << dp[m][n] << '\n';

    return 0;
}



Measured memory_bytes: 7032
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    if a>=b:
        c=a-1
        d=b
    else:
        c=b-1
        d=a
    print(max(a,b)+max(c,d))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int h,w,k;
int c[10][10];
int cnow[10][10];
int ans,anss;
int canx[10],cany[10];
// void DFS(int x,int y){
//     if(x>w||y>h)return ;
//     int sum=0;
//     for(int i=1;i<=h;i++){
//         for(int j=1;j<=w;j++){
//             sum+=cnow[i][j];
//         }
//     }
//     if(sum==k&&same==0)anss++;
//     for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)ccopy[i][j]=cnow[i][j];
//     same=1;
//     DFS(x+1,y);
//     for(int i=1;i<=h;i++){
//         cnow[i][x+1]=0;
//     }
//     same=0;
//     DFS(x+1,y);
//     for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cnow[i][j]=ccopy[i][j];
//     same=1;
//     DFS(x,y+1);
//     for(int i=1;i<=w;i++){
//         cnow[y+1][i]=0;
//     }
//     same=0;
//     DFS(x,y+1);
// }
int main(){
    char cc;
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>cc;
            if(cc=='.')c[i][j]=0;
            else c[i][j]=1;
            cnow[i][j]=c[i][j];
        }
    }
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            memset(canx,0,sizeof(canx));
            memset(cany,0,sizeof(cany));
            int cnt=0;
            int ii=i,jj=j;
            while(ii!=0){
                canx[++cnt]=ii%2;
                ii/=2;
            }
            cnt=0;
            while(jj!=0){
                cany[++cnt]=jj%2;
                jj/=2;
            }
            anss=0;
            for(int p=1;p<=h;p++){
                for(int q=1;q<=w;q++){
                    if(canx[p]||cany[q])continue;
                    anss+=c[p][q];
                }
            }
            if(anss==k)ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

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

    if (a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x,y,z;
	for(;;){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0) break;
		if(x>y){
			z=x;
			x=y;
			y=z;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int c1=0;
    int c2=0;
    string arr;
    cin>>arr;
    for(int i=0; i<arr.size(); i++)
    {
        if(arr[i]=='1')
        {
            c1++;
        }
        if(arr[i]=='0')
        {
            c2++;
        }
    }
    if(c1>0&&c2>0)
    {
        if(c1>c2)
        {
            cout<<c2*2<<endl;
        }
        else
        {
            cout<<c1*2<<endl;
        }
    }
    else
    {
        cout<<"0"<<endl;
    }
}


Measured memory_bytes: 512
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

main = do
 [n] <- readLnInt
 s <- getLine
 putStr $ solve n s

solve n s
 | (length s) <= n = s
 | otherwise = (take n s) ++ "..."


Measured memory_bytes: 3728
#include "bits/stdc++.h"

using namespace std;

int N,M,K,L,R,H,W;
//long long int N,M,K,L,R,H,W;

//const long long int MOD=1000000007;
const int MOD=1000000007;
//const long long int MOD=998244353;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>K;
	vector<long long int>p(100001,1);
	for(int i=2;i<=100000;i++){
		for(int j=2;j*j<i;j++){
			if(i%j==0){
				//if(i==14)cout<<i<<" "<<j<<endl;
				p[i]*=i;
				if(p[i]>=2*i){
					p[i]=2*i;
					break;
				}
			}
		}
		if((int)sqrt(i)*(int)sqrt(i)==i){
			p[i]*=sqrt(i);
			if(p[i]>=2*i)p[i]=2*i;
		}
	}
	vector<int>sum(100001);
	for(int i=1;i<=100000;i++){
		if(p[i]==i*2)sum[i]=1;
		sum[i]+=sum[i-1];
	}
	for(int i=0;i<K;i++){
		cin>>N;
		cout<<sum[N]<<endl;
	}
	return 0;
}


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

int main() {
	
	string s;
	cin >> s;
	
	bool is_AC = true;
	bool is_first_capital = false;
	rep(i, s.size()){
		if(i == 0){
			if(s[i] != 'A'){
				is_AC = false;
				break;
			}
		}else if(i >= 2 && i < s.size() - 1){
			if(s[i] >= 'A' && s[i] <= 'Z'){
				if(!is_first_capital){
					if(s[i] != 'C'){
						is_AC = false;
						break;
					}else{
						is_first_capital = true;
					}
				}else{
					is_AC = false;
					break;
				}
			}
		}else{
			if(s[i] >= 'A' && s[i] <= 'Z'){
				is_AC = false;
				break;
			}
		}
	}
	if(!is_first_capital){
		is_AC = false;
	}
	if(is_AC) puts("AC");
	else puts("WA");
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

ll dp[63][1<<3];
void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

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

	ll l, r;cin >> l >> r;
	dp[0][0] = 1;
	// (y, x)=(0, 0)(1, 0)(1, 1)
	// (l < now)(now < r)(senntou)
	//REP(i, 62)cout << ((l & (1LL << (61-i))) != 0);cout << endl;
	//REP(i, 62)cout << ((r & (1LL << (61-i))) != 0);cout << endl;
	REP(i, 62){
		REP(j, (1LL<<3)){
			REP(x, 2)REP(y, 2){
				if(x == 1 && y == 0)continue;
				int nj = j;
				if(!(nj & 1)){
					int tmp = ((l & (1LL << (61-i))) != 0);
					//cout << i << " " << j << " " << x << " " << y << " " << tmp << endl;
					if(x < tmp)continue;
					else if(x > tmp)nj |= 1;
				}
				if(!(nj & 2)){
					int tmp = ((r & (1LL << (61-i))) != 0);
					if(y > tmp)continue;
					else if(y < tmp)nj |= 2;
				}
				if(!(nj & 4)){
					if(x + y != 0 && x + y != 2)continue;
					if(x + y == 2)nj |= 4;
				}
				mod_add(dp[i+1][nj], dp[i][j]);
			}
		}
	}

	ll ans = 0;
	REP(i, 8)mod_add(ans, dp[62][i]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, s;
			string[] word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			int m = a + b;
			if( b + c < m)
				m = b + c;
			if (a + c < m)
				m = a + c;
			s = m;


			Console.WriteLine(s);


			//Console.ReadKey();
		}
	}
}


Measured memory_bytes: 27456
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
        cout<<k<<endl;
    else if(k>a&&k<=a+b)
         cout<<a<<endl;
    else if(k>a+b&&k<=a+b+c)
          cout<<a-(k-a-b)<<endl;
}


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


int main() {
  int N;
  cin >> N;
  vector<int64_t> data(N, 1);
  int64_t ans = 0;
  for(int i = 2; i <= N; i++) {
    if(data.at(i - 1) == 1) {
      for(int j = 1; j * i <= N; j++) {
        int64_t count = 1;
        int a = j;
        while(a % i == 0 && a >= i) {
          a /= i;
          count++;
        }
        data.at(j * i - 1) *= count + 1;
      }
    }
  }
  for(int i = 0; i < N; i++) {
    ans += (i + 1) * data.at(i);
  }
  cout << ans << endl;  
}

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int count = 0;
	for (int i = min(a, b); i >= 1; i--) {
		if (a % i == 0 && b % i == 0)
			count++;
		if (count == k) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100000

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, H[MAX_N + 1], sub[MAX_N];
int main(int argc, char **argv) {
    cin >> N;

    for(int i = 0; i < N; ++i)
        cin >> H[i];
        
    bool res = true;
    int max_H = -INF;
    for(int i = 0; i < N; ++i) {
        if(max_H - H[i] >= 2) {
            res = false;
            break;
        }
        max_H = max(max_H, H[i]);
    }
    
    cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] p = new int[N];
    for (int i = 0; i < N; i++) p[i] = scanner.nextInt() - 1;
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (p[i] == i) {
        count++;
        if (i < N - 1 && p[i + 1] == i + 1) i++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 50968
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  int ans = 0;
  for (int i = 1; i < N; i++){
    if (a[i - 1] == a[i]){
      ans++;
      a[i] = 0;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define FLASH ios_base::sync_with_stdio(false); cin.tie(0)
#define PI  3.141592653589793
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define FI first
#define SE second
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}

lli gcd(lli a, lli b) { 
   if (b == 0) return a; 
   return gcd(b, a % b);  
} 

void solve(){

lli n,k;
cin>>n>>k;
vi a(n);
fo(i,n){
  cin>>a[i];
}
vi dp(n,-1);
dp[0] = 0;
fo(i,n-1){
  for(lli j = i+1;j-i <= k && j < n; j++){
    if(dp[j]==-1){dp[j] = dp[i] + abs(a[i]-a[j]);}
    dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
  }
}
cout<<dp[n-1]<<endl;


}


int main(){
    FLASH;
    lli t =1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;

}





Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
typedef struct{
    int id;
    pii n,n2,n3,n4;
    int sum=0;
}data;
int main(){
    int n;
    while(cin>>n,n){
    vector<data>u(n);
    rep(i,n){
        pii n, n2,n3,n4;int id;
        cin>>id>>n.first>>n.second>>n2.first>>n2.second>>n3.first>>n3.second>>n4.first>>n4.second;
        u[i].id=id;
        u[i].n=n;u[i].n2=n2;u[i].n3=n3;u[i].n4=n4;
        u[i].sum=(n.first+n2.first+n3.first+n4.first)*60+(n.second+n2.second+n3.second+n4.second);
    }
    rep(i,n-1)rep(j,n-1)if(u[j].sum>u[j+1].sum)swap(u[j],u[j+1]);
    rep(i,2)cout<<u[i].id<<endl;
    cout<<u[n-2].id<<endl;
    }
}

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

int main(){
  string s; cin>>s;
  vector<int>V(4);
  rep(i,4) V[i] = s[i]-'0';
  
  for (int bit=0; bit<(1<<3); bit++){
  	int sum = V[0];
    for (int i=0; i<3; i++){
      if (bit & (1<<i)) sum += V[i+1];
      else sum -= V[i+1];
    }
    if (sum == 7){
      cout << V[0];
      for (int i=0; i<3; i++){
        if (bit & (1<<i)) cout << "+" << V[i+1];
        else cout << "-" << V[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc,char* argv[]){
  int n,i;
  int hist[6] = {0,0,0,0,0,0};
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    double d;
    
    scanf("%lf",&d);

    int d2;
    if((d - 165.0) < 0){
      d2 = 0;
    }else{
      d2 = d - 165.0;
      d2 /= 5;
      d2 += 1;
      if(d2 > 5){
	d2 = 5;
      }
    }
    
    hist[d2] += 1;
  }

  for(i = 0; i < 6; i++){
    int j;
    printf("%d:",i+1);
    for(j = 0; j < hist[i]; j++){
      printf("*");
    }
    printf("\n");
  }

  return 0;
  
}

Measured memory_bytes: 0
A, B, K = map(int, input().split())

max_num = max(A, B)
min_num = min(A, B)
divs = [m for m in range(1, min_num+1) if min_num % m == 0]

ans = []
for d in divs:
    if max_num % d == 0:
        ans.append(d)
ans = sorted(ans)[::-1]
print(ans[K-1])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
struct member{
	int a;
	int b;
	int goods;
};
int main(void){
	member mem[101];
	int n;
	int i;
	int m,x;
	int sum;
	cin>>n;
	for(i=1;i<=n;i++){
		mem[i].a=0;
		mem[i].b=0;
		mem[i].goods=0;
	}
	cin>>m;
	for(i=0;i<m;i++){
		cin>>x;
		mem[x].a=1;
	}
	cin>>m;
	for(i=0;i<m;i++){
		cin>>x;
		mem[x].b=1;
	}
	cin>>m;
	for(i=0;i<m;i++){
		cin>>x;
		mem[x].goods=1;
	}
	sum=0;
	for(i=0;i<=n;i++){
		if(mem[i].a==0&&mem[i].goods==1||mem[i].b==1&&mem[i].goods==1){
			sum++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


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

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        prime = self.sieve(1299709)
        while True:
            n = input()
            if n == 0:
                break
            if prime[n]:
                print 0
            else:
                lower = upper = n
                while not prime[lower]:
                    lower -= 1
                while not prime[upper]:
                    upper += 1
                print upper - lower
        
        return None

    def sieve(self, n):
        f = [True for i in xrange(n+1)]
        f[0] = False
        f[1] = False
        i = 2
        while i * i <= n:
            if f[i]:
                j = 2
                while i * j <= n:
                    f[i * j] = False
                    j += 1
            i += 1
        return f


if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 14980
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		int[] h=new int[n];
		for(int i = n-2;i>=0;i--) {
			if(a[i]>=a[i+1]){h[i]=h[i+1]+1;}
		}
		Console.WriteLine("{0}",h.Max());
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

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

    vector<string> day = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    rep(i, 7){
        if(S ==day.at(i)){
            cout << 7 - i << endl;
            return 0;
        }
    }
}

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

int main(void){
    int n, m, ans = 0;
    map<string, int> blue, red;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        blue[s]++;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        string s;
        cin >> s;
        red[s]++;
    }
    for (auto item : blue) {
        if (item.second > red[item.first])
            ans = max(ans, item.second - red[item.first]);
    }
    cout << ans << endl;
}


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

#define int long long

int N, A;
vector<int> x;
int dp[55][2555]; // dp[インデックス][合計] = 総数

int rec(int idx, int sum) {
  // 全部調べ終わる
  if (idx >= N) {
    return sum == 0;
  }

  // 計算済み
  if (dp[idx][sum] != -1) {
    return dp[idx][sum];
  }

  int ret = 0;

  // index枚目のカードを選ぶ
  int yes = rec(idx + 1, sum + x[idx]);
  // index枚目のカードを選ばない
  int no = rec(idx + 1, sum);

  ret += yes + no;

  return dp[idx][sum] = ret;
}

signed main() {
  cin >> N >> A;
  x.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    x[i] -= A; // あらかじめAを引いておく
  }

  memset(dp, -1, sizeof(dp));
  int ans = rec(0, 0) - 1;

  cout << max(0LL, ans) << endl;

  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    public static int n, q;
    public static int[] S = new int[100001];
    public static int[] T = new int[50001];
    public static void main(String[] args) {
        //データの読込
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        //データの処理
        int cnt = 0;
        for (int i = 0; i < q; i++) {
            if (binarySearch(T[i])) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }

    public static boolean binarySearch(int key) {
        int left = 0, right = n;
        int mid;

        while (left < right) {
            mid = (left + right) / 2;
            if (S[mid] == key) {
                return true;
            } else if (key < S[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }

        return false;
    }
}


Measured memory_bytes: 68356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/*
		String[] tmpArray = br.readLine().split(" ");
		int w = Integer.parseInt(tmpArray[0]);
		int h = Integer.parseInt(tmpArray[1]);
		int x = Integer.parseInt(tmpArray[2]);
		int y = Integer.parseInt(tmpArray[3]);
		int r = Integer.parseInt(tmpArray[4]);
		*/
		int i = 1;
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int a = Integer.parseInt(tmpArray[0]);
			int b = Integer.parseInt(tmpArray[1]);
			if(a == 0 && b == 0){
				break;
			}
			if(a > b){
				int tmp = a; 
				a = b;
				b = tmp;
			}
			System.out.println(a + " "+b);
			
		}

		//		int[] array = new int[3];
//		array[0] = a; array[1] = b; array[2] = c;
//
//		Arrays.sort(array);
//		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

Measured memory_bytes: 26744
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x;}
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    vl as(n); cin>>as;

    Sieve s(1001001);
    map<ll, ll> fs;
    bool f = true;
    rep(i, n) {
        vector<P> ps = s.factor(as[i]);
        for (P p : ps) {
            if (fs[p.fi]) {
                f = false;
                break;
            }
            fs[p.fi] += p.se;
        }
    }
    if (f) {
        cout<<"pairwise coprime"<<endl;
        return 0;
    }

    ll g = 0;
    rep(i, n) g = __gcd(g, as[i]);
    if (g == 1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}

Measured memory_bytes: 20104
#include <iostream>
#include <algorithm>

using namespace std;
const int MOD=100000;


int main()
{
    int w, h;
    while (cin >> w >> h, w | h)
    {
        int dp[101][101][5] = {0};

        for (int i = 1; i <= h; i++)
            dp[i][1][1] = 1;

        for (int i = 1; i <= w; i++)
            dp[1][i][3] = 1;

        for (int y = 2; y <= h; y++)
        {
            for (int x = 2; x <= w; x++)
            {
                dp[y][x][1] += (dp[y - 1][x][1] + dp[y - 1][x][2]) % MOD;
                dp[y][x][2] += dp[y - 1][x][3] % MOD;
                dp[y][x][3] += (dp[y][x - 1][3] + dp[y][x - 1][4]) % MOD;
                dp[y][x][4] += dp[y][x - 1][1] % MOD;
            }
        }

        int ans = 0;
        for(int t = 1; t < 5; t++)
        {
            ans += dp[h][w][t];
        }

        cout << ans % MOD << endl;       
    }
}


Measured memory_bytes: 3272
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
P = [0]*(N+1)
Q = [0]*(N+1)

for _ in range(M):
    f, b = map(str, input().rstrip().split())
    a = int(f)
    if b == "WA":
        if not Q[a]:
            P[a] += 1
    else:
        Q[a] = 1

p = 0
for i in range(N+1):
    if Q[i]:
        p += P[i]
print(sum(Q), p)

Measured memory_bytes: 4596
<?php

$in = trim(fgets(STDIN));
$array = explode(' ', $in);
$sum = 0;
foreach ($array as $item) {
    $val = intval($item);
    $sum += $val;
}

if ($sum >= 22) {
    print("bust\n");
} else {
    print("win\n");
}


Measured memory_bytes: 4604
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int a, b, c;
int ans;
int N;

int main() {
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);

	cout << a <<" "<< b <<" "<< c;

	return 0;
}

Measured memory_bytes: 768
#include<cstdio>
int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	long long ans=m-n*2;
	if(ans<0)
	{
		printf("%lld\n",m>>1);
		return 0;
	} 
	printf("%lld\n",n+(ans>>2));
}

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

int main()
{
  int N, M, A, B;
  long long Sum=0;
  cin >> N >> M;
  priority_queue<int> P;
  rep(i, N){
    cin >> A;
    P.push(A);
  }
  rep(i, M){
    int B= P.top(); P.pop();
    P.push(B/2);
  }
  rep(i, N){
    Sum=Sum+P.top();
    P.pop();
  }
  cout << Sum << endl;
} 

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    rep(i, 0, M) {
        cin >> A[i] >> B[i];
    }
    vector<P> interval;
    rep(i, 0, M) {
        interval.emplace_back(B[i], A[i]);
    }
    sort(all(interval));
    int prev = -1;
    int ans = 0;
    for (auto& i : interval) {
        if (i.second > prev) {
            ++ans;
            prev = i.first - 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


int main(){
    string s,t;
    cin >> s >> t;
    int slen = s.size();
    int tlen = t.size();
    int ans = t.size();
    for(int i = 0; i < slen-tlen+1; i++){
        int match = 0;
        for(int j = 0; j < tlen; j++){
            if(s[i+j] == t[j]){
                match++;
            }
        }
        ans = min(ans, tlen - match);
    }
    cout << ans << endl;
}


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

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

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

vector<int> edges[100000];

int dfs(int i, int par){
    int num = 0;
    for(int j : edges[i]){
        if(j != par) num += dfs(j, i);
    }
    if(num >= 2){
        cout << "First" << endl;
        exit(0);
    }else{
        return 1-num;
    }
}

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    int result = dfs(0, -1);
    cout << (result ? "First" : "Second") << endl;
    return 0;
}

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

int main()
{
    vector<int> dist(3);

    for (int i = 0; i < 3; i++)
    {
        cin >> dist.at(i);
    }

    sort(dist.begin(), dist.end());
    cout<< dist.at(0)+dist.at(1)<<endl;
    //for (int i = 0; i < 3;i++)
    //    cout << dist.at(i);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public void run() {
        Scanner sc = new Scanner(System.in);
        String orders = sc.next();
        int destX = sc.nextInt();
        int destY = sc.nextInt();

        String[] Fs = orders.split("T");

        List<Integer> horizontals = new ArrayList<>();
        List<Integer> verticals = new ArrayList<>();
        for (int i = 2; i < Fs.length; i+=2) {
            horizontals.add(Fs[i].length());
        }
        for (int i = 1; i < Fs.length; i+=2) {
            verticals.add(Fs[i].length());
        }

        int startX = 0;
        int startY = 0;
        if(Fs.length > 0) startX += Fs[0].length();

        Set<Integer> positionsX = new HashSet<>();
        Set<Integer> positionsY = new HashSet<>();

        positionsX.add(startX);
        positionsY.add(startY);

        for (int length: horizontals) {
            Set<Integer> newPositionsX = new HashSet<>();
            for (int positionX: positionsX) {
                newPositionsX.add(positionX + length);
                newPositionsX.add(positionX - length);
            }
            positionsX = newPositionsX;
        }

        for (int length: verticals) {
            Set<Integer> newPositionsX = new HashSet<>();
            for (int positionY: positionsY) {
                newPositionsX.add(positionY + length);
                newPositionsX.add(positionY - length);
            }
            positionsY = newPositionsX;
        }

        if(positionsX.contains(destX) && positionsY.contains(destY)) System.out.println("Yes");
        else System.out.println("No");
    }

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

Measured memory_bytes: 136084
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define ll long long int
#define INF 1000000005
#define PI acos(-1.0)
#define f first
#define s second
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n,m,i,j,x,y,t,k;
   bool flag;
   cin>>n>>m;
   char a[n][n],b[m][m];
   loop(i,0,n)
   {
    loop(j,0,n)
     cin>>a[i][j];
   }
   loop(i,0,m)
   {
    loop(j,0,m)
     cin>>b[i][j];
   }
   loop(i,0,n-m+1)
   {
     loop(j,0,n-m+1)
     {
       x=i;
       y=j;
       flag=true;
       loop(k,0,m)
       {
        loop(t,0,m)
        {
          if(b[k][t] == a[x][y])
           y++;
          else
          {
            flag=false;
            break;
          }
        }
        x++;
        if(!flag)
         break;
       }
       if(flag)
        break;
     }
     if(flag)
      break;
   }
   if(flag)
    cout<<"Yes";
   else
    cout<<"No";
   return 0;
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int main() {
    
    
  int a , b ;
  char op ;
  cin >> a >> op >> b ;
  if( op == '+' ) cout << a + b ;
  else cout << a - b ;  
    

  return 0 ;
}









Measured memory_bytes: 256
def main():
  N, Q = map(int, input().split())
  S = input()
  counts = [0] * (N + 1)
  for i in range(0, len(S)):
    counts[i + 1] = counts[i] + (1 if S[i:i + 2] == 'AC' else 0)
  for i in range(Q):
    l, r = map(int, input().split())
    print(counts[r - 1] - counts[l - 1])


if __name__ == "__main__":
  main()


Measured memory_bytes: 7748
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    cnt = 0

    def merge(A, l, mid, r):
        nonlocal cnt
        n1 = mid - l
        n2 = r - mid
        L = [A[l + i] for i in range(n1)]
        R = [A[mid + i] for i in range(n2)]
        L.append(1 << 60)
        R.append(1 << 60)
        i = 0
        j = 0
        for k in range(l, r):
            if L[i] <= R[j]:
                A[k] = L[i]
                i = i + 1
            else:
                cnt += n1 - i
                A[k] = R[j]
                j = j + 1

    def merge_sort(A, left, right):
        if len(A) == 1:
            return
        if left+1 < right:
            mid = (left + right) // 2
            merge_sort(A, left, mid)
            merge_sort(A, mid, right)
            merge(A, left, mid, right)

    merge_sort(A, 0, N)

    print(cnt)


if __name__ == '__main__':
    main()



Measured memory_bytes: 27496
#include <stdio.h>
int main(void){
    // Your code here!
    int n,i,ans=0;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n-1;i++) scanf("%d",&b[i]);
    a[0]=b[0];
    for(i=0;i<n-2;i++){
        if(b[i]<=b[i+1]) a[i+1]=b[i];
        else a[i+1]=b[i+1];
    }
    a[n-1]=b[n-2];
    for(i=0;i<n;i++) ans+=a[i];
    printf("%d\n",ans);
    return 0;
}


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

const int MOD = 1000000007;
int A[100005];

int main() {
    int N, a;
    scanf("%d", &N);
    bool flag = true;
    for (int i = 0; i < N; i++) {
        scanf("%d", &a);
        if (N % 2 == a) flag = false;
        if (++A[a] > 2) flag = false;
    }
    if (N % 2 == 1 && A[0] > 1) flag = false;
    if (flag) {
        long long ans = 1;
        for (int i = 0; i < N / 2; i++) ans = ans * 2 % MOD;
        printf("%lld\n", ans);
    } else {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 640
/*
 * src.cpp
 *
 *  Created on: 2016/08/08
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=1e2;

int N;
int H[MAX_N+1];

vector<int> vec;

int main(){
	do{
		scanf("%d",&N);
		if (N){
			REP(i,N+1){
				scanf("%d",&H[i]);
			}
			REP(i,N+1){
				vec.clear();
				REP(j,N+1){
					if (i!=j){
						vec.push_back(H[j]);
					}
				}
				int d=vec[1]-vec[0];
				bool flg=true;
				FOR(k,1,(int)vec.size()-1){
					if (d!=vec[k+1]-vec[k]){
						flg=false;
					}
				}
				if (flg){
					printf("%d\n",H[i]);
					i=N+1;
				}
			}
		}
	}while (N);
	return 0;
}

Measured memory_bytes: 1208
//Volume5-0512
import java.util.HashMap;
import java.util.Scanner;

class Main {



	private static HashMap<Character,Character> tr = new HashMap<Character,Character>();

	public static void main(String[] args){

		char[] c;
		String s = "";

		init();

		Scanner sc = new Scanner(System.in);
		c = sc.nextLine().toCharArray();
		for(int i=0;i<c.length;i++){
			s += tr.get(c[i]);
		}
		System.out.println(s);
	}

	private static void init(){
	tr.put('D', 'A');
	tr.put('E', 'B');
	tr.put('F', 'C');
	tr.put('G', 'D');
	tr.put('H', 'E');
	tr.put('I', 'F');
	tr.put('J', 'G');
	tr.put('K', 'H');
	tr.put('L', 'I');
	tr.put('M', 'J');
	tr.put('N', 'K');
	tr.put('O', 'L');
	tr.put('P', 'M');
	tr.put('Q', 'N');
	tr.put('R', 'O');
	tr.put('S', 'P');
	tr.put('T', 'Q');
	tr.put('U', 'R');
	tr.put('V', 'S');
	tr.put('W', 'T');
	tr.put('X', 'U');
	tr.put('Y', 'V');
	tr.put('Z', 'W');
	tr.put('A', 'X');
	tr.put('B', 'Y');
	tr.put('C', 'Z');
	}
}

Measured memory_bytes: 22176