akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int mcxitoint(string s)
{
    int num = 1;
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        if(isdigit(s[i])){
            num = s[i] - '0';
        } else {
            if(s[i] == 'm'){
                ans += num * 1000;
            } else if(s[i] == 'c'){
                ans += num * 100;
            } else if(s[i] == 'x'){
                ans += num * 10;
            } else {
                ans += num * 1;
            }
            num = 1;
        }
    }
    return ans;
}

string inttomcxi(int n)
{
    string ans = "";
    if(n / 1000 != 0){
        if(n / 1000 != 1) ans += n / 1000 + '0';
        ans += 'm';
        n = n % 1000;
    }
    if(n / 100 != 0){
        if(n / 100 != 1) ans += n / 100 + '0';
        ans += 'c';
        n = n % 100;
    }
    if(n / 10 != 0){
        if(n / 10 != 1) ans += n / 10 + '0';
        ans += 'x';
        n = n % 10;
    }
    if(n != 0){
        if(n != 1) ans += n + '0';
        ans += 'i';
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s1, s2;
        cin >> s1 >> s2;
        int n1 = mcxitoint(s1);
        int n2 = mcxitoint(s2);
        n1 += n2;
        cout << inttomcxi(n1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int s[] = new int[n];
    
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      s[i]=a[i];
    }
    
    Arrays.sort(s);
    if(s[n-1]==s[n-2]){
     for(int i=0;i<n;i++){
       System.out.println(s[n-1]); 
     }
    }else{
     for(int i=0;i<n;i++){
       if(a[i]==s[n-1]){
         System.out.println(s[n-2]);
       }else{
         System.out.println(s[n-1]);
       }
     }
    }
    
    
    
    
  }
  

  
}

Measured memory_bytes: 94092
using System;
class p
{
  static void Main()
  {
    string S = Console.ReadLine();
    if (S == "SUN") {
      Console.WriteLine(7);
    } else if (S == "MON") {
      Console.WriteLine(6);
    } else if (S == "TUE") {
      Console.WriteLine(5);
    } else if (S == "WED") {
      Console.WriteLine(4);
    } else if (S == "THU") {
      Console.WriteLine(3);
    } else if (S == "FRI") {
      Console.WriteLine(2);
    } else {
      Console.WriteLine(1);
    }
  }
}

Measured memory_bytes: 11092
n = int(input())

A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))

sat = 0

prev_dish = -1
for i, dish in enumerate(A[1:]):
  sat += B[dish]
  if prev_dish == dish-1:
    sat += C[prev_dish]
  prev_dish = dish
  

print(sat)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void) {
int A,B,C,K,P=0;
scanf("%d%d%d%d",&A,&B,&C,&K);
if(K<=A)
P=K;
else if(K<=A+B)
P=A;
else
P=2*A-K+B;
printf("%d\n",P);
return 0;
}

Measured memory_bytes: 1704
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xx first
#define yy second
#define sci(n) scanf("%d",&n)
#define scii(n,m) scanf("%d%d",&n,&m)
#define sciii(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define sclll(n,m,w) scanf("%lld%lld%lld",&n,&m,&w)
#define pf(a)   printf("%d\n",a)
#define CASE(a) printf("Case %d:\n",a)
#define dbg(i) printf("yo %lld\n", i)
#define endl '\n'
#define READ  freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout);
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define SQR(a) (a)*(a)
#define all(v) v.begin(),v.end()
#define pb push_back
#define pri priority_queue<int>
#define rev_pri priority_queue<int,vector<int>,greater<int> >
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define inf INT_MAX
#define eps 1e-9

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

using namespace __gnu_pbds;
using namespace std;


#define mxn 100005


//bool vis[1LL << 19];
const ll nax=100005;
char br[1002][1002];
ll ar[1002][1002];
void solve()
{
    ll a,b,n,k=0,c,i,q=0,j,l,m,mx=-1;
    ll h,w;
    cin>>h>>w;
    FOR(i,1,h+1) FOR(j,1,w+1) cin>>br[i][j];
    ar[1][1]=1;
    FOR(i,1,h+1) FOR(j,1,w+1){
        if(br[i][j]=='#') ar[i][j]=0;
        else ar[i][j]=((ar[i][j]%mod)+ ((ar[i-1][j]%mod)+(ar[i][j-1]%mod) )%mod)%mod;
    }cout<<ar[h][w]<<'\n';
}
int main()
{
    //IOS;
    double start_time = clock();
    ll t=1,mex=1;
   //cin>>t;
    while(t--){
        solve();
    }
    double end_time = clock();
    //fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
    return 0;
}


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

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

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;

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

  stack<int> st;
  char c[100];
  while (scanf("%s", c) != EOF) {
    if (c[0] == '+' or c[0] == '-' or c[0] == '*') {
      int y = st.top();
      st.pop();
      int x = st.top();
      st.pop();
      int ret;
      if (c[0] == '+') {
        ret = x + y;
      }
      if (c[0] == '-') {
        ret = x - y;
      }
      if (c[0] == '*') {
        ret = x * y;
      }
      st.push(ret);
    } else {
      st.push(atoi(c));
    }
  }
  cout << st.top() << endl;

  return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N;
cin >> N;
vi a(N);
rep(i,N) cin >> a[i];

sort(all(a),greater<int>());

int p = a[0], q;
int dist = -1;
rrep(i,N-1) {
    int cur = min(p - a[i], a[i]);
    if(chmax(dist, cur)) q = a[i];
}
cout << p << ' ' << q << endl;
return 0;
}

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

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

    map <ll,ll> table;  //<種類、枚数>
    vector <ll> num(0); //種類

    rep(i,n){
        ll a;
        cin >> a;
        if(!table.count(a)){
            table[a] = 1;
            num.push_back(a);
        }
        else{
            table.at(a) ++;
        }
    }

    rep(i,m){
        ll b,c;
        cin >> b >> c;
        if(!table.count(c)){
            table[c] = b; 
            num.push_back(c);
        }
        else{
            table.at(c) += b;
        }
    }

    sort(all(num));
    reverse(all(num));  //大きい順

    int sum = 0;    //枚数の合計
    int cur = 0;    //次のite
    ll ans = 0;     //和
    while(sum < n){
        if(sum + table.at(num[cur]) <= n){
            ans += num[cur] * table.at(num[cur]);
            sum = sum + table.at(num[cur]);
            cur ++;
        }
        else{
            ans += num[cur] * (n-sum);
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 17308
from itertools import product

n, k = map(int, input().split())
d = set(range(10)) - set(map(int, input().split()))

for i in product(d | set([0]), repeat=len(str(n)) + 1):
    i = int("".join(str(j) for j in i))
    if (i >= n) and all(int(k) in d for k in str(i)):
        print(i)
        break


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
	char s[10];
	scanf("%s",s);
	int flag=0;
	for(int i=0;i<strlen(s)-1;i++)
		if(s[i]=='A' && s[i+1]=='C')
			flag=1;
	if(flag)
		printf("Yes");
	else
		printf("No");
	printf("\n");
	return 0;
 } 

Measured memory_bytes: 128
/*    
                                                                             
	1. Practice makes a man perfect.
	2. Let go of the past.
	3. Without pain, without sacrifice, we would have nothing.
	4. Great things never come from comfort zones.
	5. Turn your wounds into wisdom.
	6. No pain ... no palm, no throne, no glory,no cross, no crown.
	7. You never know how strong you are until being strong is your only choice.
	8. Smooth seas do not make skillful sailors.
	9. I am not what happened to me, I am what I choose to become.
	10. No matter how fail life pushes you down, No matter how much you hurt,You can always bounce back.
		
		
	--> This lines keep me motivated.		

	Author:- Gaurang_Kothiya
	
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;


 
void Solve()
{	
	int n;
	cin>>n;
	cout<< (n*(n+1))/2 ;
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int sz = 1<<17;
struct segtree {
	vector<ll> dat1, dat2;

	void init(int n_) {
		dat1.resize(sz * 2);
		dat2.resize(sz * 2);	
		rep(i, sz * 2) dat1[i] = dat2[i] = 0;
	}

	void add(int a, int b, ll x, int k, int l, int r) {
		if(b <= l || r <= a) return ;
		if(a <= l && r <= b) dat1[k] += x;
		else{
			dat2[k] += (min(b, r) - max(a, l)) * x;
			add(a, b, x, k * 2 + 1, l, (l + r) / 2);
			add(a, b, x, k * 2 + 2, (l + r) / 2, r);
		}
	}

	ll sum(int a, int b, int k, int l, int r) {
		if(b <= l || r <= a) return 0;
		if(a <= l && r <= b) return dat1[k] * (r - l) + dat2[k];
		else{
			ll res = (min(b, r) - max(a, l)) * dat1[k];
			res += sum(a, b, k * 2 + 1, l, (l + r) / 2);
			res += sum(a, b, k * 2 + 2, (l + r) / 2, r);
			return res;
		}
	}

	void add(int a, int b, ll x) {
		add(a, b, x, 0, 0, sz);
	}
	ll sum(int a, int b) {
		return sum(a, b, 0, 0, sz);
	}
} seg;

int X, K, Q;
vector<pii> event;
vector<pair<pii,int>> st;

int main() {
	scanf("%d%d", &X, &K);
	rep(i, K) {
		int t;
		scanf("%d", &t);
		event.eb(t, -1);
	}
	scanf("%d", &Q);

	rep(i, Q) {
		int a, t;
		scanf("%d%d", &t, &a);
		st.eb(mp(a, t), i);
	}
	vi rr(Q);

	sort(ALL(st));

	rep(i, Q) {
		event.eb(st[i].fi.se, i);
		rr[st[i].se] = i;
	}

	sort(ALL(event));
	seg.init(Q);

	rep(i, Q) {
		seg.add(i, i + 1, st[i].fi.fi);
	}

	int c = 0, la = 0;
	int l = 0, r = Q-1;
	int sl = st[0].fi.fi, sr = st[Q-1].fi.fi;
	vi ans(Q);

	for (auto dt : event) {
		if (dt.se >= 0) {
			int id = dt.se;
			int x = seg.sum(id, id + 1);

			if (id <= l) {
				ans[dt.se] = sl;
			} else if (id >= r) {
				ans[dt.se] = sr;
			} else {
				ans[dt.se] = x;
			}

			if (c) {
				ans[dt.se] = min(X, ans[dt.se] + dt.fi - la);
			} else {
				ans[dt.se] = max(0, ans[dt.se] - (dt.fi - la));				
			}
		} else {
			int tt = dt.fi - la;
			if (c == 0) {
				while (l+1 < r && seg.sum(l+1, l+2) <= tt) {
					++l;
				}
				sl = max(0, sl - tt);
				sr = max(0, sr - tt);
				if (l+1 < r) {
					seg.add(l+1, r, -tt);
				}
			} else {
				while (r-1 >= l && seg.sum(r-1, r) >= X-tt) {
					--r;
				}
				sr = min(X, sr + tt);
				sl = min(X, sl + tt);
				if (l+1 < r) {
					seg.add(l+1, r, tt);
				}				
			}

			la = dt.fi;
			c ^= 1;
		}
	}

	rep(i, Q) {
		printf("%d\n", ans[rr[i]]);
	}

	return 0;
}

Measured memory_bytes: 8812
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int H,N;
  cin >> H >> N;
  vp ab(N);
  rep(i,N) {
    cin >> ab[i].first >> ab[i].second;
  }
  vi dp(20000,INF);
  dp[0] = 0;
  rep(i,N) {
    int a = ab[i].first;
    int b = ab[i].second;
    rep(k,20000) {
      if(k-a>=0) {
        dp[k] = min(dp[k],dp[k-a]+b);
      }
    }
  }
  int ans = INF;
  srep(k,H,20000) {
    ans = min(ans,dp[k]);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    M = int(input())
    dist = [[INF]*N for _ in range(N)]
    for _ in range(M):
        a,b,c,d = map(int,input().split(','))
        a -= 1
        b -= 1
        dist[a][b] = c
        dist[b][a] = d
    s,g,v,p = map(int,input().split(','))
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][k] + dist[k][j],dist[i][j])
    s -= 1
    g -= 1
    ans = v - dist[s][g] - dist[g][s] - p
    print(ans)
if __name__ == '__main__':
    main()


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M), road(N);
  
  for(int i = 0; i < M; i++)
    cin >> A.at(i) >> B.at(i);
  
  for(int i = 0; i < M; i++){
    road.at(A.at(i) - 1) ++;
    road.at(B.at(i) - 1) ++;
  }
  
  for(int i = 0; i < N; i++)
    cout << road.at(i) << endl;
  
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String s = sc.next(), t = sc.next();
        char[] s1 = s.toCharArray(), t1 = t.toCharArray();
        int[][] f = new int[s1.length + 1][t1.length + 1];
        for(int i = 1; i <= s1.length; i ++){
            for(int j = 1; j <= t1.length; j ++){
                if(s1[i - 1] == t1[j - 1])f[i][j] = f[i - 1][j - 1] + 1;
                else f[i][j] = Math.max(f[i][j - 1],f[i - 1][j]);
            }
        }
        StringBuilder sb = new StringBuilder();
        int x = s1.length - 1, y = t1.length - 1;
        while(f[x + 1][y + 1] > 0){
            if(s1[x] == t1[y]){
                sb.append(s1[x]);
                x--;y--;
            }
            else{
                if(f[x + 1][y + 1] == f[x][y + 1])x--;
                else y--;
            }
        }

//        for(int i = 0; i <= s1.length; i ++){
//            for(int j = 0; j <= t1.length; j ++){
//                System.out.print(f[i][j] + " ");
//            }
//            System.out.println();
//        }
        System.out.println(sb.reverse().toString());
    }
}


Measured memory_bytes: 80840
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
#define mid ((l+r)>>1)
using namespace std;
const ldb eps=1e-12,PI=acos(-(ldb)1.0);
const int inf=1e9;
int n,a[mxn],b[mxn];
LL K,sl,fh,sum,ans;
multiset<int> st;
LL rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
bool check(LL lim)
{
	LL x,tot=0;
	for(int i=n;i;--i)
	{
		x=lim/b[i];
		tot+=max(0ll,a[n-i+1]-x);
	}
	return tot<=K;
}
int main()
{
	n=rd();K=rd();
	for(int i=1;i<=n;++i) a[i]=rd(),sum+=a[i];
	for(int i=1;i<=n;++i) b[i]=rd();
	sort(a+1,a+n+1);sort(b+1,b+n+1);
	if(K>=sum) return puts("0"),0;
	LL l=1,r=1e12;
	for(;l<=r;)
	{
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
	
	long long int a,b,c,d;
	
	cin >> a;
	
	for(b=1; b<=a; b++){
		c = 1;
		for(d=b; d>=1; d--){
			c *= d;
		}
	}
	
	cout << c << '\n';
	
	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	string S,T;
	cin>>S>>T;
	vint A,B;
	A.pb(0);
	B.pb(0);
	for(int i=0;i<S.length();i++){
		if(S[i]=='A')
			A.pb(1);
		else
			A.pb(2);
	}
	for(int i=0;i<T.length();i++){
		if(T[i]=='A')
			B.pb(1);
		else
			B.pb(2);
	}
	for(int i=1;i<=S.length();i++)
		A[i]+=A[i-1];
	for(int i=1;i<=T.length();i++)
		B[i]+=B[i-1];
	int Q;
	cin>>Q;
	while(Q--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if((A[b]-A[a-1])%3==(B[d]-B[c-1])%3)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=2e5+5;
ll a[mxn],b[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m,k;
	cin >> n >> m >> k;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		a[i] += a[i-1];
	}
	for(int i=1; i<=m; i++){
		cin >> b[i];
		b[i] += b[i-1];
	}
	auto ptr = lower_bound(a,a+n,k)-a;
	if(a[ptr]>k)ptr--;
	int ans = 0;
	for(int i=ptr; i>=0; i--){
		ll left = k-a[i];
		int ptr2 = lower_bound(b,b+m,left)-b;
		if(b[ptr2]>left)ptr2--;
		ans = max(ans,i+ptr2);
	}
	cout << ans << '\n';
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 6772
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;


int main()
{
    FAST
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


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

using namespace std;

int n, w;
pair<int, int> items[100];

map<int, int> dp[100];

int dfs(int now, int weight) {
	if (now == 100) return 0;
	if (dp[now].count(weight)) return dp[now][weight];
	int res = dfs(now + 1, weight);
	if (weight + items[now].first <= w) {
		res = max(res, dfs(now + 1, weight + items[now].first) + items[now].second);
	}
	return dp[now][weight] = res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		cin >> items[i].first >> items[i].second;
	}
	cout << dfs(0, 0) << "\n";
	return 0;
}



Measured memory_bytes: 4736
#include<iostream>
using namespace std;
const int INF = 2e9;

int n, r[200000];
int after[200000];
int ans = -INF;
int main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> r[i];

  after[n - 1] = -INF;
  for(int i = n - 2; i >= 0; i--)
    after[i] = max(after[i + 1], r[i + 1]);

  for(int i = 0; i < n - 1; i++)
    ans = max(ans, after[i] - r[i]);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2720
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n, h, w;
	cin >> n >> h >> w;
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		if (a >= h && b >= w)
			res++;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int a[200010];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n)scanf("%d",a+i);
	rep(i,k,n)puts(a[i]>a[i-k]?"Yes":"No");
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


ll n;

int main() {
  IOS;
  cin >> n;
  ll ans = 0;
  vector<ll> memo(n+1, 2);
  memo[0] = 0;
  for(ll i=2; i <= n+1; i++) {
    for(ll j=2*i; j <= n+1; j+=i) {
      memo[j]++;
    }
  }

  for (ll i = 1; i <= n; i++) {
    ans += i * memo[i];
  }

  COUT(ans-1);
  return 0;
}


Measured memory_bytes: 81320
#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;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  string s;
  cin >> s;
  int MX = 0;
  int cnt = 0;

  REP(i,s.size()){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      ++cnt;
    }
    else{
      MX = max(MX,cnt);
      cnt = 0;
    }
  }
  MX = max(MX, cnt);  
  cout << MX << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define rep(i,n) for(re int (i)=1;(i)<=(n);++(i))
typedef long long ll;
const int maxn=1e5+5;
int n,m,a[maxn];
il int read(){
	re char ch(getchar());
	re int f(1),x(0);
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int main(){
	n=read(),m=read();
	for(re int i=m-n+1;i<=m+n-1;++i) cout<<i<<" ";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int n,m;
    cin >> n >> m;

    map<ll,int> cnt;

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

    for(int i = 1;i < n;i++)a[i] = (a[i] + a[i-1]) % m;

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

    cout << ans << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<iomanip>

#define PI 3.14159265359
using namespace std;
int main(){
    int a,b,d;
    char c;
    while(1){
        cin >> a >> c >> b;
        if(c == '?')break;
        else if(c == '+')
        {
            d = a+b;
        }
        else if(c == '-')
        {
            d = a - b;
        }
        else if(c == '*')
        {
            d = a * b;
        }
        else if(c == '/')
        {
            d = a / b;
        }
        cout << d << endl;
    }
    return 0;
}




Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

    int H, A;
    cin >> H >> A;

    int ans = 0;

    while(H > 0){
        H -= A;
        ans++;
    }

    cout << ans << endl;

    return 0;
}



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

using namespace std;

int main(){
    string x;
    int y;
    cin >> x >> y;
    for(int a = 0; a < (int)x.size(); a++){
        if(x[a] != '1' && y > a){
            cout << x[a] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}

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

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    char save;
    int count = 0;
    int doubl = 0;
    REP(i,S.size()){
        if(doubl == 1){
            count++;
            doubl = 2;
        }else if(doubl == 2){
            doubl = 0;
            count++;
        }else if(save != S[i]){
            doubl = 0;
            count++;
        }else{
            doubl = 1;
        }
        save = S[i];
    }
    cout << count << "\n";
}

Measured memory_bytes: 720
N = int(input())
As = list(map(int,input().split()))
dic = {}
array = []
x = As[0]
init = 1 - x
for i in range(1,N):
    v = init + i - 1 - As[i]
    array.append(v)
    if v not in dic:
        dic[v] = 1
    else:
        dic[v] += 1
if 0 in dic:
    ans = dic[0]
else:
    ans = 0

for i in range(1,N):
    y = As[i] + i - x
    z = array[i-1]
    dic[z] -= 1
    if y in dic:
        ans += dic[y]
print(ans)


Measured memory_bytes: 130336
a,s=map(int,input().split())
def ex_euclid(x, y):
    c0, c1 = x, y
    a0, a1 = 1, 0
    b0, b1 = 0, 1
    while c1 != 0:
        m = c0 % c1
        q = c0 // c1
        c0, c1 = c1, m
        a0, a1 = a1, (a0 - q * a1)
        b0, b1 = b1, (b0 - q * b1)
    return c0, a0, b0
print(*ex_euclid(a,s)[1:3],sep=" ")


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

#define int long long int

void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
#define fioe() fileioe()
#else
#define fioe() 1
#endif
//!
const int M = 1e9+7;
const int maxr = 1e5+5;
int fact[maxr];

int power(int a,int b){
	if(a == 0)
		return 0;
	if(b == 0)
		return 1;
	int small = power(a,b/2);
	int ans = (small*small)%M;
	if(b%2==0){
		return ans;
	}
	return (ans*a)%M;
}

void precompute(){
	fact[0] = 1;
	for(int i=1;i<maxr;i++){
		fact[i] = fact[i-1]*i;
		fact[i] = fact[i]%M;
	}
}

int inverse(int value){
	return power(value,M-2);
}

int ncr(int n,int r){
	int result = fact[n];
	int lower = (inverse(fact[n-r])*inverse(fact[r]))%M;
	result = (result*lower)%M;
	return result;
}


int dp[maxr];

int solve(int n,int a,int k){
	int ans = 0;
	ans += power(k/a,n);
	int value = 0;
	for(int i = 2*a;i <= k; i += a){
		value += dp[i];//power(k/i,n);
		value = value%M;
	}
	ans = (ans - value + 3*M)%M;
	dp[a] = ans;
	return ans;
}

int32_t main()
{
	GO
	//fioe();
	precompute();
	int n,k;
	cin>>n>>k;
	int ans = 0;
	for(int i=k;i>=1;i--){
		ans += i*solve(n,i,k);
		ans %= M;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5220
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  int x = 0, total = 0;
  for (int i = 0; i < N; ++i) {
    int A; cin >> A;
    if (x >= A) {
      x = A;
    } else {
      total += A - x;
      x = A;
    }
  }
  cout << total << endl;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    int f[102][11], p[102][11];

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> p[i][j];
        }
    }
    int ans;
    // bit := josino store time schedule
    for (int bit = 1; bit < (1<<10); bit++) {
        int prof = 0;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = 0; j < 10; j++) {
                if (f[i][j] && ((bit >> (9-j)) & 1)) {
                    cnt++;
                }
            }
            prof += p[i][cnt];
        }
        if (bit == 1) {
            ans = prof;
        } else {
            ans = max(ans, prof);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    in_arr(int, a, n);
    bool inc = a[0] <= a[1];
    int ans = 0;
    rep(i, n - 1){
        if((inc && a[i] <= a[i + 1]) || (!inc && a[i] >= a[i + 1])){
            continue;
        }
        //cout << a[i] << endl;
        ++ans;
        ++i;
        while(a[i] == a[i + 1])
            ++i;
        inc = a[i] < a[i + 1];
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int h[n + 1];
  h[0] = 0;
  int c = 0, max = 0;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    if (h[i] <= h[i - 1]) {
      c++;
    } else {
      c = 0;
    }
    if (max < c) {
      max = c;
    }
  }
  cout << max;
}

Measured memory_bytes: 640
#include<stdio.h>
	int main()
{
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	while(op != '?'){
		if(op == '+'){
			printf("%d\n", a + b);
		}else if(op == '-'){
			printf("%d\n", a - b);
		}else if(op == '*'){
			printf("%d\n", a * b);
		}else if(op == '/'){
			printf("%d\n", a / b);
		}
		scanf("%d %c %d", &a, &op, &b);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<stdio.h>
#include<cmath>

using namespace std;

#define PI 3.141592654

struct point{
	double x;
	double y;
};

struct input{
	double length;
	double theta;
};

double get_radian( double theta_deg );
ostream& operator << ( ostream& s , point& p );

int main(void)
{
	input data;
	point goal = { 0.0 , 0.0 };
	double theta = 90;

	while(1)
	{
		scanf("%lf , %lf" , &data.length , &data.theta );
		if( data.length == 0 && data.theta == 0 ) break;

		goal.x += data.length * cos( get_radian(theta) );
		goal.y += data.length * sin( get_radian(theta) );

		theta -= data.theta;
	}
	cout << goal;
}

double get_radian( double theta_deg )
{
	return theta_deg*PI/180;
}

ostream& operator << ( ostream& s , point& p )
{
	return s << int(p.x) << endl << int(p.y) << endl;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,1,0,-1};
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int N,M;cin>>N>>M;
    int ans=N*(N-1)+M*(M-1);
    cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   long A,B,K;
   scanf("%ld %ld %ld",&A,&B,&K);
   if(A>=K){
      A -=K;
   } else if(A+B<K) {
      A=0;
      B=0;
   } else {
      B -=K;
      B +=A;
      A=0;
   }
   printf("%ld %ld",A,B);
   return 0;
}


Measured memory_bytes: 1736
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
 
using namespace std;
 
int main(){
 int N;
 int K;
 int Q;
 cin >> N >> K >> Q;
 int A[Q];
 int B[N] = {};
 int i;
 for(i=0;i<Q;++i){
   cin >> A[i];}
 for(i=0;i<Q;++i){
 B[A[i]-1]++;
 }
 for(i=0;i<N;++i){
    if(K - Q + B[i] >0)cout << "Yes" << endl;
    else cout << "No" << endl;
 }
  return 0;
}

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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dbg(x) cerr << #x << ": " << (x) << endl;
#define dbgv(v) cerr << #v << ": "; _shv(v);
#define dbgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T> inline void prt(T x) { cout << x << endl; }
template<typename T, typename U>
inline void getv(T& v, U n) { v = T(n); rep(i, n) cin >> v[i]; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    int q;
    cin >> q;
    rep(i, q) {
        string a, b;
        cin >> a >> b;
        int la = siz(a), lb = siz(b);
        vvi dp(la + 1, vi(lb + 1, 0));
        rep(i, la) {
            rep(j, lb) {
                if (a[i] == b[j])
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                else
                    dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
        prt(dp[la][lb]);
    }

    return 0;
}



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

signed main() {
  int A, B, K;
  cin >> A >> B >> K;

  if (K >= A) {
    K -= A;
    A = 0;
  } else {
    A -= K;
    cout << A << " " << B << endl;
    return 0;
  }

  if (K >= B) {
    K -= B;
    B = 0;
  } else {
    B -= K;
    cout << A << " " << B << endl;
    return 0;
  }

  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    vector<ll> sa(n+1); sa[0] = 0;
    REP(i,n) sa[i+1] = sa[i]+a[i];
    int ans = n;
    for (int i = n-1; i >= 0; --i) {
        if (sa[i]*2 < a[i]) {
            ans = n-i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
    char buf, ch='a', str[1200]={'\0'};
    int i, num;

    i=0;
    while ((buf=getchar()) != EOF) {
        if (buf>=65 && buf<=90) buf+=32;
        str[i] = buf;
        i++;
    }
    while(ch!=123) {
        num=0;
        for (i=0;i<sizeof(str);i++) {
            if(str[i]==ch) num++;
        }
        printf("%c : %d\n", ch, num);
        ch++;
    }
    return 0;
}



Measured memory_bytes: 2104
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()

for i in range(N // 4 + 1):
    for j in range(N // 7 + 1):
        if i * 4 + j * 7 == N:
            print('Yes')
            import sys
            sys.exit()

print('No')


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

int main() {
  string S, T;
  cin >> S >> T;
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int a[] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = a + b;
  ans = max(ans, a - b);
  ans = max(ans, a * b);

  cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
f = sys.stdin

def take2(iterable):
    while True:
        yield next(iterable), next(iterable)

for line in f:
    p1,p2,pq = [x + y * 1j for x, y in take2(map(float, line.split(',')))]
    
    v21 = p2 - p1
    vq1 = pq - p1
    px = vq1* (v21.real - v21.imag * 1j)
    px = px.real - px.imag * 1j
    px /= abs(px)
    pp = p1 + (vq1) * px * px
    print('{:.6f} {:.6f}'.format(pp.real,pp.imag))
    

Measured memory_bytes: 6760
W,H,N = map(int, input().split())
x_M,x_m = 0,W
y_M,y_m = 0,H
for i in range(N):
    x,y,a  = map(int, input().split())
    # 白い部分
    if a == 1:
        x_M = max(x_M, x)
    elif a == 2:
        x_m = min(x_m, x)
    elif a == 3:
        y_M = max(y_M, y)
    else:
        y_m = min(y_m, y)

ans = max(0,x_m-x_M)*max(0,y_m-y_M)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	string s;cin>>s;
	string t;cin>>t;
	for(int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define double long double 
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,bool> PP;

const double EPS = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

vector<PP> convex_hull(vector<PP> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<PP> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++])
    while (k >= 2 && ccw(ch[k-2].first, ch[k-1].first, ps[i].first) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--])
    while (k >= t && ccw(ch[k-2].first, ch[k-1].first, ps[i].first) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

bool isIntersect(L s1, L s2){
  return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
           ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}

bool check(vector<PP> v,P s,P g){
  bool res=0;
  int n=v.size();
  for(int i=0;i<n;i++)res|=isIntersect(L(v[i%n].first,v[(i+1)%n].first),L(s,g));
  return res;
}

double ref(P a,P b,P s,P g){
  double l=0,r=abs(a-b);
  int cnt=100;
  b-=a,s-=a,g-=a,b/=abs(b);
  while(cnt--){
    double m=(l+r)/2;
    P p1=m*b,p2=(m+EPS)*b;
    if(abs(s-p1)+abs(g-p1)<abs(s-p2)+abs(g-p2))r=m;
    else l=m;
  }
  b*=l;
  return abs(b-s)+abs(b-g);
}

int main(){
  double x,y;
  P s,g;
  cin>>x>>y;
  s=P(x,y);
  cin>>x>>y;
  g=P(x,y);
  int n;
  cin>>n;
  vector<PP> v;
  for(int i=0;i<n;i++)cin>>x>>y,v.push_back(PP(P(x,y),0));
  double ans=1e9;
  if(check(v,s,g)){
    v.push_back(PP(s,1));
    v.push_back(PP(g,1));
    v=convex_hull(v);
    int n=v.size();
    double sum=1e9;
    for(int i=0;i<2*n;i++){
      if(v[i%n].second)ans=min(ans,sum),sum=0;
      sum+=abs(v[i%n].first-v[(i+1)%n].first);
    }
  }
  else{
    for(int i=0;i<n;i++)
      ans=min(ans,ref(v[i].first,v[(i+1)%n].first,s,g));
  }
  printf("%.8Lf\n",ans);
  return 0;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    double N;
    cin>>N;
    vector<double>v(N);
    for(int i=0;i<N;i++){
        cin>>v.at(i);
    }
    sort(v.begin(),v.end());

    for(int i=0;i<N-1;i++){
     
       v.at(i+1)=(v.at(i)+v.at(i+1))/2;
    }
  
    cout<<v.at(N-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

#administrasion nxt nas
nxt = 1
ans = 0

for i in range(N):
    if nxt == A[i]:
        nxt += 1
    else:
        ans += 1
if ans == N:
    print(-1)
else:
    print(ans)

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

//Constants
const long long INF = std::numeric_limits<long long>::max();
const long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793;

//MACROS
#define pb push_back
#define fi first
#define se second
#define rep(i, begin, end) for (int i = (begin); i < (end); i++)
#define per(i, begin, end) for (int i = (begin) - 1; i >= (end); i--)
typedef long long LL;
typedef pair <int,int> PII;


int main() {
    int a, b;
	cin >> a >> b;
    if (a > 0) cout << "Positive";
    else if (b >= 0) cout << "Zero";
    else {
        if ((b - a + 1) % 2 == 0) cout << "Positive";
        else cout << "Negative";
    }
}

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

int main() {

  int N;
  cin >> N;

  vector<int> count(100010);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    count[a]++;
  }

  int answer = 0;

  for (int i = 0; i < count.size() - 2; i++) {
    answer = max(count[i] + count[i+1] + count[i+2], answer);
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 640