akhauriyash/Code-Regression huggingface dataset:
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 3 "/workspaces/compro/lib/union_find.hpp"
#ifndef UNION_FIND
#define UNION_FIND
class UnionFind {
private:
  std::vector<int> parent;
  std::vector<int> _size;

public:
  UnionFind(const int s) {
    parent = std::vector<int>(s, -1);
    _size = std::vector<int>(s, 1);
  }

  void merge(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry)
      return;
    if (_size[rx] < _size[ry])
      std::swap(rx, ry);
    parent[ry] = rx;
    _size[rx] += _size[ry];
    _size[ry] = _size[rx];
  }

  int size(int x) { return _size[x]; }

  int root(int x) {
    if (parent[x] == -1)
      return x;
    return parent[x] = root(parent[x]);
  }

  bool isSame(int x, int y) { return root(x) == root(y); }
};
#endif
#line 3 "main.cpp"

long long solve(long long N, int M, const std::vector<long long> &A, const std::vector<long long> &B) {
  UnionFind uf(N);
  REP(i, M) { uf.merge(A[i], B[i]); }
  set<int> ans;
  REP(i, N) { ans.insert(uf.root(i)); }
  return ans.size() - 1;
}

// generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator)
int main() {
  int N;
  int M;
  std::cin >> N >> M;
  std::vector<long long> A(M), B(M);
  for (int i = 0; i < M; ++i) {
    std::cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  auto ans = solve(N, M, A, B);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 7916
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(t)            int t; cin>>t; while(t--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
void jaiswal_sahil()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
}

const int N = 1e5 + 5;
int dp[N][3];
int n;
int maxPoint(int i, int a[N][3], int p){

    if(i == n)
        return 0;

    if(dp[i][p] != -1)
        return dp[i][p];
    
    int q1 = -inf, q2 = -inf, q3 = -inf;
    if(p==1){
        q2 = a[i][1] + maxPoint(i+1, a, 2);
        q3 = a[i][2] + maxPoint(i+1, a, 3);
    }else if(p==2){
        q1 = a[i][0] + maxPoint(i+1, a, 1);
        q3 = a[i][2] + maxPoint(i+1, a, 3);
    }else if(p==3){
        q1 = a[i][0] + maxPoint(i+1, a, 1);
        q2 = a[i][1] + maxPoint(i+1, a, 2);
    }

    return dp[i][p] = max({q1, q2, q3});
}
 
int maxPointBU(int n, int *a, int *b, int *c){

    int dp1[N][2][2][2] = {};
    for(int i=1; i<=n; i++){
        dp1[i][1][0][0] = a[i] + max(dp1[i-1][0][1][0], dp1[i-1][0][0][1]);
        dp1[i][0][1][0] = b[i] + max(dp1[i-1][1][0][0], dp1[i-1][0][0][1]);
        dp1[i][0][0][1] = c[i] + max(dp1[i-1][1][0][0], dp1[i-1][0][1][0]);
    }

    return max({dp1[n][1][0][0], dp1[n][0][1][0], dp1[n][0][0][1]});
}

int32_t main()
{
    jaiswal_sahil();
    
    cin>>n;

    int a[n+1], b[n+1], c[n+1];
    for(int i=1; i<=n; i++)
        cin>>a[i]>>b[i]>>c[i];
    
    int ans = maxPointBU(n, a, b, c);
    cout<<ans<<endl;

    // cin>>n;
    
    // int a[N][3];
    // for(int i=0; i<n; i++){
    //     int x, y, z; cin>>x>>y>>z;
    //     a[i][0] = x, a[i][1] = y, a[i][2] = z;
    // }

    // memset(dp, -1, sizeof(dp));
    // int x = a[0][0] + maxPoint(1, a, 1);
    // int y = a[0][1] +  maxPoint(1, a, 2);
    // int z = a[0][2] +  maxPoint(1, a, 3);
    // int ans = max({x, y, z});

    // cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
#define pll pair<int,pair<int,int> >
const int M=1e5+5;
std::vector<pair<int,int>> vtr[M];
unordered_map<int,int> dst[M],dn[M];
unordered_map<int,vector<int> > adj[M];
bool vis[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v,c;
		cin>>u>>v>>c;
		vtr[u].pb({v,c});
		vtr[v].pb({u,c});
		adj[u][c].pb(v);
		adj[v][c].pb(u);
	}
	for(int i=1;i<=n;i++)
	{
		for(auto u:vtr[i])
		{
			dst[i][u.ss]=1e9;
		}
	}
	priority_queue<pll,vector<pll>,greater<pll>> pq;
	for(auto u:vtr[1])
	{
		dst[u.ff][u.ss]=1;
		pq.push({1,{u.ff,u.ss}});
	}
	while(!pq.empty())
	{
		auto u = pq.top();
		pq.pop();
		if(u.ss.ff==n)
		{
			cout<<u.ff<<"\n";
			return 0;
		}
		if(dn[u.ss.ff][u.ss.ss])
			continue;
		dn[u.ss.ff][u.ss.ss]=1;
		if(vis[u.ss.ff]==0)
		{
			for(auto v:vtr[u.ss.ff])
			{
				if(v.ss==u.ss.ss)
				{
					if(dst[v.ff][v.ss]>dst[u.ss.ff][u.ss.ss])
					{
						dst[v.ff][v.ss]=dst[u.ss.ff][u.ss.ss];
						pq.push({u.ff,{v.ff,v.ss}});
					}
				}
				else
				{
					if(dst[v.ff][v.ss]>1+u.ff)
					{
						dst[v.ff][v.ss]=1+u.ff;
						pq.push({1+u.ff,{v.ff,v.ss}});
					}
				}
			}
			vis[u.ss.ff]=1;
		}
		else
		{
			for(auto v:adj[u.ss.ff][u.ss.ss])
			{
				if(dst[v][u.ss.ss]>u.ff)
				{
					dst[v][u.ss.ss]=u.ff;
					pq.push({u.ff,{v,u.ss.ss}});
				}
			}
		}
	}
	cout<<"-1\n";
	return 0;
}

Measured memory_bytes: 96948
#-*-coding:utf-8-*-

def main():
    n = int(input())
    s_list = []
    for i in range(n):
        s_list.append(input())
    m = int(input())
    m_list = []
    for i in range(m):
        m_list.append(input())

    sen_set = set(s_list + m_list)
    max_money = 0
    for sen in sen_set:
        money = 0
        for i in s_list:
            if sen == i:
                money += 1
        for j in m_list:
            if sen == j:
                money -= 1
        if max_money < money:
            max_money = money
    
    print(max_money)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll W,H,N;
ll X1[1000],X2[5000],Y1[5000],Y2[5000];



ll compress(ll *x1,ll *x2,ll w){
	vector<ll> xs;
	rep(i,N){
		for(ll k=-1;k<=1;k++){
			if(0<=x1[i]+k&&x1[i]+k<w) xs.pb(x1[i]+k);
			if(0<=x2[i]+k&&x2[i]+k<w) xs.pb(x2[i]+k);
		}
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	rep(i,N){
		x1[i]=lower_bound(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=lower_bound(xs.begin(),xs.end(),x2[i])-xs.begin();
	}
	return xs.size();
}
bool grid[6000][6000];

ll vx[4]={1,0,-1,0};
ll vy[4]={0,1,0,-1};

bool ok(ll y,ll x){
	return 0<=y&&y<H&&0<=x&&x<W;
}
bool dfs(ll y,ll x){
	if(!grid[y][x]){
		grid[y][x]=1;
		rep(i,4){
			if(ok(y+vy[i],x+vx[i])) dfs(y+vy[i],x+vx[i]);
		}
		return 1;
	}
	else return 0;
}

int main()
{while(1){
	cin>>W>>H;
	if(!W) return 0;
	cin>>N;
	rep(i,N){
		cin>>X1[i]>>Y1[i]>>X2[i]>>Y2[i];
		X2[i]--;
		Y2[i]--;
	}
	W=compress(X1,X2,W);
	H=compress(Y1,Y2,H);
	rep(i,H) rep(j,W) grid[i][j]=0;
	rep(i,N){
		for(ll y=Y1[i];y<=Y2[i];y++){
			for(ll x=X1[i];x<=X2[i];x++){
				grid[y][x]=1;
			}
		}
	}
	ll ans=0;
	///rep(i,H){ rep(j,W){
	//	cout<<grid[i][j];
	//} cout<<endl;}
	rep(i,H) rep(j,W){
		if(dfs(i,j)) ans++;
	}
	cout<<ans<<endl;
}}

Measured memory_bytes: 24468
n = int(input())
s = input()
lst = [0] * 1000
for i in range(1000):
    if len(str(i)) == 1:
        tmp = '00' + str(i)
        lst[i] = tmp
    elif len(str(i)) == 2:
        tmp = '0' + str(i)
        lst[i] = tmp
    else:
        lst[i] = str(i)

cnt = 0
for v in lst:
    id_1 = s.find(v[0])
    if id_1 == -1:
        continue
    id_2 = s.find(v[1], id_1 + 1)
    if id_2 == -1:
        continue
    id_3 = s.find(v[2], id_2 + 1)
    if id_3 == -1:
        continue
    cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
using namespace std;
char s[12];
int main(){
	int i,l,cnt=0;
	scanf(" %s",s+1);
	l=strlen(s+1);
	if(s[1]!='A'){
		printf("WA");
		return 0;
	}
	for(i=3;i<=l-1;i++){
		if(s[i]=='C') cnt++;
	}
	if(cnt!=1){
		printf("WA");
		return 0;
	}
	for(i=1;i<=l;i++){
		if(s[i]!='A'&&s[i]!='C'&&!(s[i]>='a'&&s[i]<='z')){
			printf("WA");
			return 0;
		}
	}
	printf("AC");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define int long long int
#define repeat(n) for (int i = 0; i < n; ++i)
#define repeat2(n) for (int j = 0; j < n; ++j)
#define all(x) (x).begin(), (x).end()

#define MAX_SIZE (100001)

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

    int n = 1;
    int x = 0;
    int cnt = 0;
    int dp[2019];
    memset(dp, 0, sizeof(int) * 2019);
    ++dp[0];
    for (auto it = s.rbegin(); it != s.rend(); ++it) {
        x = (x + (*it - '0') * n) % 2019;
        n = n * 10 % 2019;
        ++dp[x];
    }

    int ans = 0;
    repeat(2019) {
        ans += (dp[i] - 1) * dp[i] / 2;
    }

    cout << ans;
    
    return 0;
}


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

int main()
{
    ll a,b,i,cnt=0;
    scanf("%lld %lld", &a, &b);
    while(a<=b){
        string s;
        s = to_string(a);
        if(s[0]==s[4] && s[1]==s[3]){
            cnt++;
        }
        a++;
    }
    printf("%lld\n", cnt);
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t a, b;
    cin >> a >> b;

    for (auto i : irange(1L, 20001L)) {
        if ((int64_t)(i * 0.08 + 1e-10) == a &&
            (int64_t)(i * 0.1 + 1e-10) == b) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 256
x_1, y_1, x_2, y_2 = map(int, input().split())
v_x = x_2 - x_1
v_y = y_2 - y_1

v2_x = -v_y
v2_y = v_x

x_3 = x_2 +v2_x
y_3 = y_2 +v2_y

x_4 = x_1 + v2_x
y_4 = y_1 + v2_y

print(x_3,y_3,x_4,y_4)


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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;
signed main(){
	char Koo, Noo;

	cin>>Noo;

	Koo='a';

	if((int) Koo <= (int) Noo) cout<<"a";
	else cout<<"A";

 return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
int main(){
  int n,p,cnt=0; 
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
	scanf("%d",&p);
    if(p!=i){
      cnt++;
    }
  }
  if(cnt==0||cnt==2){
  	printf("YES");
  }
  else{
  	printf("NO");
  }
return 0;
}

Measured memory_bytes: 128
sx,sy,tx,ty = map(int,input().split())
dx = tx - sx
dy = ty - sy
ans = []
ans.append('U'*dy)
ans.append('R'*dx)
ans.append('D'*dy)
ans.append('L'*(dx+1))

ans.append('U'*(dy+1))
ans.append('R'*(dx+1))
ans.append('D')
ans.append('R')
ans.append('D'*(dy+1))
ans.append('L'*(dx+1))
ans.append('U')

print(*ans,sep='')

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int n,ans;
bool ifis(int n){
	int f=n;
	int how=0;
	while(f){
		f/=10;
		how++;
	}
	how--;
	if(how%2) return false;
	return true;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		if(ifis(i)) ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
const int mod=998244353;
int n,m,q,x,y;
int k,a[N],tree[N<<2],tag[N<<2],s[N<<2];
void pushup(int i)
{
    tree[i]=(tree[i<<1]+tree[i<<1|1])%mod;
    s[i]=(s[i<<1]+s[i<<1|1])%mod;
}

void pushdown(int i){
    if(tag[i]){
        tag[i<<1]=tag[i<<1|1]=tag[i];
        tree[i<<1]=tag[i]*s[i<<1]%mod;
        tree[i<<1|1]=tag[i]*s[i<<1|1]%mod;
        tag[i]=0;
    }
}

void build(int i,int l,int r)
{
    tag[i]=0;
    if(l==r)
    {
        tree[i]=s[i]=a[l];
        return ;
    }
    int mid=l+(r-l)/2;
    build(i<<1,l,mid);
    build(i<<1|1,mid+1,r);
    pushup(i);
}

void update(int i,int l,int r,int m,int n,int k)
{
    if(m<=l&&r<=n)
    {
        tree[i]=s[i]*k%mod;
        tag[i]=k;
        return ;
    }
    pushdown(i);
    int mid=l+(r-l)/2;
    if(m<=mid) update(i<<1,l,mid,m,n,k);
    if(n>mid) update(i<<1|1,mid+1,r,m,n,k);
//    if(n<=mid) update(i<<1,l,mid,m,n,k);
//    else if(m>mid) update(i<<1|1,mid+1,r,m,n,k);
//    else update(i<<1,l,mid,m,mid,k),update(i<<1|1,mid+1,r,mid+1,n,k);
    tree[i]=(tree[i<<1]+tree[i<<1|1])%mod;
}

main(){
    scanf("%d%d",&n,&q);
    a[n]=1;
    for(int i=n-1;i>=1;i--) a[i]=a[i+1]*10%mod;
    build(1,1,n);
    //cout<<"fuck";
    while(q--){
        scanf("%d%d%d",&x,&y,&k);
        update(1,1,n,x,y,k);
        printf("%d\n",tree[1]);
    }
    return 0;
}

Measured memory_bytes: 17684
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a, b;
    char op;
    while(true){
        cin >> a >> op >> b;
        if( op == '?') break;
        switch(op){
            case '+':
                cout << a+b << endl;
                break;
            case '-':
                cout << a-b <<endl;
                break;
            case '*':
                cout << a*b << endl;
                break;
            case '/':
                cout << a/b << endl;
                break;
        }
    }
}


Measured memory_bytes: 3092
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int H,W,D,A[300][300];
int Q,L,R;
P p[90000];
vector<long long> imos[90000];

int main()
{
	int ans=0;
	cin>>H>>W>>D;
	rep(i,H){
		rep(j,W){
			cin>>A[i][j];
			A[i][j]--;
			p[A[i][j]]=P(i,j);
		}
	}
	rep(i,D){
		imos[i].pb(0);
		for(int j=1;i+j*D<H*W;j++){
			imos[i].pb( imos[i][j-1]+abs(p[i+j*D].fr-p[i+(j-1)*D].fr)+abs(p[i+j*D].sc-p[i+(j-1)*D].sc) );
		}
	}
	cin>>Q;
	rep(i,Q){
		ans=0;
		cin>>L>>R;
		L--;
		R--;
		int l=L/D;
		int r=R/D;
		int m=L%D;
		ans += imos[m][r]-imos[m][l];
		cout<<ans<<endl;
	}
	//cout<<ans<<endl;
}

Measured memory_bytes: 6400
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int main(){
	
	
	string line;
	vector<string> wordsblue(1000);
	vector<string> wordsred(1000);
	int N,M,i,j,k;
	int count,countdef;	
	
	countdef=0;
	cin >> N;
	
	for(i=0;i<N;i++){
		cin >> wordsblue[i];
		
	}
	
	cin >> M;
	
	for(i=0;i<M;i++){
		cin >> wordsred[i];
	
	}
	
	for(i=0;i<N;i++){
		count=0;
		
		for(j=0;j<N;j++){
			if(wordsblue[i]==wordsblue[j]){
			    count+=1; 
			    
			}
		}	
		for(k=0;k<M;k++){
			if(wordsblue[i]==wordsred[k]){
				count-=1;
							
			}
		}
		if (count>countdef){
			countdef=count;
		}	
	}
	printf("%d",countdef);
	
}

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 int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> cnt(9, 0);
    int x;
    cin >> x;
    int sum = 0;
    for(int i = 1; i <= 10000000; i++){
        sum += i;
        if(sum >= x){
            cout << i << endl;
            return 0;
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double e = a, g = b, f = e / g;
  cout << d << " ";
  cout << r << " ";
  printf("%.6lf", f);
  cout << endl;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
long long D[3010][3010];
long long dp[3010][3010][4];
int main(){
  long long R,C,K;
  cin>>R>>C>>K;
  long long r,c,v;
  for(int i=0;i<K;i++){
    cin>>r>>c>>v;
    r--;
    c--;
    D[r][c]=v;
  }
  dp[0][0][1]=D[0][0];
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      if(j+1<C){
        dp[i][j+1][3]=max({dp[i][j+1][3],dp[i][j][3],dp[i][j][2]+D[i][j+1]});
        dp[i][j+1][2]=max({dp[i][j+1][2],dp[i][j][2],dp[i][j][1]+D[i][j+1]});
        //cout<<i<<" "<<j<<"#"<<dp[i][j+1][2]<<endl;
        dp[i][j+1][1]=max({dp[i][j+1][1],dp[i][j][1],dp[i][j][0]+D[i][j+1]});
        dp[i][j+1][0]=max(dp[i][j+1][0],dp[i][j][0]);
      }
      if(i+1<R){
        for(int k=0;k<4;k++){
          dp[i+1][j][0]=max(dp[i][j][k],dp[i+1][j][0]); 
          dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+D[i+1][j]);
        }
      }
    }
  }
  long long ans=0;
  for(int i=0;i<4;i++){
    ans=max(ans,dp[R-1][C-1][i]);
  }
  cout<<ans<<endl;  
  return 0;
}

           
        
    
    
    

Measured memory_bytes: 356288
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
   // 	freopen("input.txt", "r", stdin);
   // 	freopen("output.txt", "w", stdout);
	//#endif
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u == t){
		cout<<a<<" "<<b-1;
	}
	else{
		cout<<a-1<<" "<<b;
	}

	return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, w = list(map(int, input().rstrip('\n').split()))
    dp = [10 ** 10] * (n * 10 ** 3 + 1)
    dp[0] = 0
    mv = 0
    for i in range(n):
        wv, vv = list(map(int, input().rstrip('\n').split()))
        for j in range(mv, -1, -1):
            dp[j+vv] = min(dp[j+vv], dp[j] + wv)
            mv = max(mv, j+vv if dp[j+vv] != 10 ** 10 else mv)
    mi = 0
    for i in range(len(dp)):
        if dp[i] <= w:
            mi = i
    print(mi)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define MOD (ll)(998244353)
#define INF (9e18)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	int x,y; cin>>x>>y;
	int a=x*2-y/2;
	int b=y/2-x;
	if(y%2!=0 || a<0 || b<0) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 3640
from collections import deque
K=int(input())
queue=deque(list(range(1,10)))
for i in range(K):
    k=queue.popleft()
    mod=k%10
    for diff in range(mod-1,mod+2):
        if diff<0 or 9<diff:
            continue
        queue.append(10*k+diff)
print(k)

Measured memory_bytes: 19664
N,K = map(int, input().split())
A_list = sorted(list(map(int, input().split())))

if K == 1:
    print(0)
    exit()

MOD = 10**9 + 7

fact = [0] * (N+1)
fact_inv = [0] * (N+1)
inv = [0] * (N+1)

fact[0] = fact[1]  = 1
fact_inv[0] = fact_inv[1] = 1
inv[1] = 1

for i in range(2, N):
    fact[i] = fact[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD # //で良いのかな?
    fact_inv[i] = fact_inv[i-1] * inv[i] % MOD

def combo(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * (fact_inv[k] * fact_inv[n-k] % MOD) % MOD

def main():
    min_sum = 0
    max_sum = 0

    for i in range(N-K+1):
        cmb = combo(N-i-1, K-1)
        min_sum -= A_list[i] * cmb
        max_sum += A_list[N-i-1] * cmb
        min_sum %= MOD
        max_sum %= MOD
    print((max_sum+min_sum + MOD )%MOD)
    


if __name__ == "__main__":
    main()



Measured memory_bytes: 24728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n = fr.nextInt();
		boolean flag = true;
		int i=0; 
		int tPrev = 0;
		int xPrev = 0;
		int yPrev = 0;
		while (i < n) {
			int curT = fr.nextInt();
			int curX = fr.nextInt();
			int curY = fr.nextInt();
			int timeDiff = curT - tPrev;
			int manhattanDist = Math.abs(curX - xPrev) + Math.abs(curY - yPrev);
			if ((manhattanDist > timeDiff) || (timeDiff - manhattanDist)%2 == 1) {
				flag = false;
			}
			xPrev = curX;
			yPrev = curY;
			tPrev = curT;
			i++;
		}
		System.out.println(flag ? "Yes" : "No");
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 44804
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a)) 

const int N=1e5+5;
int a[N];
int b[N];
int c[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int j=0;j<n;j++)cin>>b[j];
	for(int k=0;k<n;k++)cin>>c[k];
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	ll ans=0;
	
	for(int i=0;i<n;i++)
	{
		ans+=(ll)(lower_bound(a,a+n,b[i])-a)*(n-(upper_bound(c,c+n,b[i])-c));
	}
	cout<<ans<<endl;
	return  0;
}

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    int ans = 0;
    for(int i=1; i<=n; i++){
        int sum = 0;
        int x = i;
        while(x > 0){
            sum += x % 10;
            x /= 10;
        }
        if(a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
g = [[] for _ in range(0,n)]
x = [None] * n
ans = "Yes"
for i in range(0,m):
    L,R,D = map(int, input().split())
    g[L-1].append((R-1,D))
    g[R-1].append((L-1,-D))
for i in range(0,n):
    if x[i] is not None:
        continue
    x[i] = 0
    q = [i]
    while len(q) > 0:
        qq = q.pop()
        for r,d in g[qq]:
            if x[r] is None:
                q.append(r)
                x[r] = x[qq] + d
for i in range(0,n):
    for r,d in g[i]:
        if x[i] + d != x[r]:
            ans = "No"
            break
print(ans)


Measured memory_bytes: 65972
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string x; cin >> x;
	int c1 = 0, ans = 0;
	F0R(i,x.length()) {
	    if (x[i] == 'T' && c1 > 0) c1 --, ans++;
        else if (x[i] == 'S') c1++;
	}
	cout << x.length()-2*ans;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=1000000007;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  ll n,k;
  cin >> n >> k;
  vll h(n+1);
   h[0]=0;
  rep(i,1,n+1) cin >> h[i];
  
  vector<vll> dp(305,vll(305,inf));
  
  dp[0][0]=0;
   
  
  
       rep(y,1,n+1){
         rep(x,1,n+1) {
           if(x<y) continue;
      rep(i,0,x) dp[x][y]=min(dp[x][y],dp[i][y-1]+max(0ll,h[x]-h[i]));
   }
   }
  
  ll res=inf;
  rep(i,0,n+1) res=min(res,dp[i][n-k]);
  
  cout << res << endl;
}


Measured memory_bytes: 1024
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

vector<int>adj[100005];

int mx[100005];
int indegree[100005];
bool vis[100005];
void dfs(int s){
    vis[s]=true;
    for(int i=0;i<adj[s].size();i++){
        int u = adj[s][i];
        indegree[u]--;
        mx[u]= max(mx[u],mx[s]+1);
        if(indegree[u]==0){
            dfs(u);
        }
    }
}
int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    memset(vis,false,sizeof vis);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        indegree[v]++;
    }
    for(int i=1;i<=n;i++){
        if(vis[i]==false && indegree[i]==0){
            dfs(i);
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(ans,mx[i]);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll a[100005];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    ll f=1e9,tot=0,sum=0;
    bool flag=false;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<0) tot++;
        if(a[i]==0) flag=true;
        f=min(f,abs(a[i]));
        sum+=abs(a[i]);
    }
    if(tot%2&&!flag) sum-=2*f;
    printf("%lld\n",sum);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
vector <pair <string, pair <int, int> > > name_eff;
bool less_tmp (pair <string, pair <int, int> > &a, pair <string, pair <int, int> > &b){
    string a_L = a.first;
    int a_rev = a.second.first;
    int a_time = a.second.second;
    string b_L = b.first;
    int b_rev = b.second.first;
    int b_time = b.second.second;

    int left = a_rev * b_time;
    int right = b_rev * a_time;

    if(left != right){
      return left < right;
    }

    return a_L > b_L;
}

int main(){
  while(true){
    int N;
    cin >> N;
    if(N == 0){
      break;
    }
    name_eff.clear();
    for(int i = 0; i < N; i++){
      string L;
      int P;
      int A;
      int B;
      int C;
      int D;
      int E;
      int F;
      int S;
      int M;
      cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
      int sales = F * S * M;
      int revenue = sales - P;
      int total_time = A + B + C + (D + E) * M;
      name_eff.push_back(make_pair(L, make_pair(revenue, total_time)));
    }
    sort(name_eff.begin(), name_eff.end(), less_tmp);
    reverse(name_eff.begin(), name_eff.end());

    for(int i = 0; i < N; i++){
      cout << name_eff[i].first << endl;
    }
    cout << "#" << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;
int main() {
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i < n - 2; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>

#define MAX_N 200000

typedef int int32_t;
typedef long int64_t;

// ?????????bubble sort???????????????naive???merge sort??§merge?????????????????\?????????????????°??????????????????

long merge(int* a, int* t, int left, int mid, int right) {
    long c = 0;
    int p = left, q = mid + 2;

    for (int i = left; i <= mid; i++) {
        t[i] = a[i];
    }
    t[mid+1] = INT32_MAX; // sentinel
    for (int i = mid+1; i <= right; i++) {
        t[i+1] = a[i];
    }
    t[right+2] = INT32_MAX;

    for (int i = left; i <= right; i++) {
        if (t[p] < t[q]) {
            a[i] = t[p++];
        } else {
            a[i] = t[q++];
            c += mid - p + 1;
        }
    }
    return c;
}

long mergesort(int* a, int* t, int left, int right) {
    long c = 0;
    if (left < right) {
        int mid = (left + right) / 2;
        c += mergesort(a, t, left, mid);
        c += mergesort(a, t, mid+1, right);
        c += merge(a, t, left, mid, right);
    }

    return c;
}

int main(void) {
    int n;
    int a[MAX_N] = {0}, t[MAX_N] = {0};

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    // Attention: sum of 1..MAX_N > INT32_MAX
    long c = mergesort(a, t, 0, n-1);
    printf("%ld\n", c);

    return 0;
}

Measured memory_bytes: 4284
#include<stdio.h>
int main(void){
        int n,debt;
        debt=100000;
        scanf("%d",&n);
        int i;
        for(i=0;i<n;i++){
                debt*=1.05;
                if(debt-(int)(debt/1000.)*1000>0){
                        debt=(int)(debt/1000.+1)*1000;
                }
        }
        printf("%d\n",debt);
        return 0;
}

Measured memory_bytes: 592
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Reflection.Metadata;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var res = 0;

            for (int i = 0; i < num; i++)
                if ((i & 1) == 0 && (args[i] & 1) == 1)
                    res++;

            Console.WriteLine(res);

        }
    }

}

Measured memory_bytes: 28288
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;




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

	long long n, d, i, j, k, ans, x, y;
	cin >> n >> d;
	ans = 0;
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) ans++;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3196
n = int(input())
a = []
b = []
c = []
d = []

for i in range(n+1):
  if i%1 == 0:
    a.append(i)
    
for j in range(n+1):
  if j%3 == 0:
    b.append(j)
    
for k in range(n+1):
  if k%5 == 0:
    c.append(k)

for l in range(n+1):
  if l%3 == 0 and l%5 == 0:
    d.append(l)

print(sum(a)-sum(b)-sum(c)+sum(d))


Measured memory_bytes: 72184
#include <algorithm>
#include <cstdio>

using namespace std ;

int main ()
{
	int M , D , i , j , res=0 ;
	scanf("%d%d",&M,&D);
	for ( i=1 ; i<=M ; i++ )
		for ( j=1 ; j<=D ; j++ )
		{
			int a=j/10 , b=j%10 ;
			if ( j<10 || j>99 ) continue;
			if ( a>=2 && b>=2 && a*b==i ) res++;//,printf("%d %d\n",i,j);
		}
	printf("%d\n",res);
	return 0 ;
}


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



int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    int cnt = 0;
    if(a == b)
        cnt++;
    if(b == c)
        cnt++;
    if(c == a)
        cnt++;
    
    if(cnt == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    
    return 0;
}




Measured memory_bytes: 3592
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	var n = len(s)
	var minDif = 10000000
	for i := 0; i < n-2; i++ {
		var m, _ = strconv.Atoi(s[i : i+3])
		if minDif > int(math.Abs(float64(753-m))) {
			minDif = int(math.Abs(float64(753 - m)))
		}
	}
	fmt.Println(minDif)
}


Measured memory_bytes: 512
a = gets.to_i
b = gets.to_i if a != b
if a === 1 && b === 2
  puts 3
elsif a === 1 && b === 3
  puts 2
elsif a === 2 && b === 1
  puts 3
elsif a === 2 && b === 3
  puts 1
elsif a === 3 && b === 1
  puts 2
else a === 3 && b === 2
  puts 1
end



Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define LL long long
#define lson l,m
#define rson m+1,r
#define pii pair<LL,int>
using namespace std;
const double pi = 2*acos(0.0);
const int maxn = 1e5+10;
const int inf=2e9;
const int maxm = 1e4 + 10;
const int mod = 998244353;



int main()
{
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
    #endif
    LL a,b;
    cin >> a >>b;
    if(abs(a-b)<=1) printf("Brown\n");
    else printf("Alice\n");
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 200020;

int a[MAXN], b[MAXN];

int main ()
{
    int n, m;
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++)
    {
        scanf ("%d", &a[i]);
    }
    scanf ("%d", &m);
    for (int i = 1; i <= m; i ++)
    {
        scanf ("%d", &b[i]);
    }
    sort (a + 1, a + n + 1);
    sort (b + 1, b + m + 1);
    int j = 1;
    bool flag = true;
    for (int i = 1; i <= m; i ++)
    {
        while (a[j] < b[i])
        {
            j ++;
        }
        if (a[j] > b[i])
        {
            flag = false;
            break;
        }
        else
        {
            j ++;
        }
    }
    if (flag)
    {
        printf ("YES\n");
    }
    else
    {
        printf ("NO\n");
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    string s,t,u;
    ll a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(s==u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }


    return 0;

}


Measured memory_bytes: 256
import numpy as np

MOD = 998244353
 
n,s = map(int, input().split())
a = list(map(int,input().split()))


fac_inv2 = pow(2,MOD-2,MOD)

dp = np.zeros(s,"int64")

for i in range(n):
    
    newdp = dp.copy()
    if a[i]<s:
        newdp[a[i]:] += dp[:s-a[i]] * fac_inv2 % MOD
    if a[i]<=s:
        newdp[a[i]-1] += 1
    dp = newdp % MOD

ans = dp[-1]
ans *= pow(2,n-1,MOD)
ans %= MOD
print(ans)

Measured memory_bytes: 27568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N),B(N);
    vector<vector<ll>> v(M+1);
    rep(i,N){
        cin >> A[i] >> B[i];
        if(A[i] > M) continue;
        v[A[i]].push_back(B[i]);
    }
    priority_queue<ll> que;
    ll ans = 0;
    rep(i,M){
        ll d = i+1;
        for(auto& u:v[d]){
            que.push(u);
        }
        if(que.empty()) continue;
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 9900
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};

struct D21{
  int is,js;
  D21(int isize,int jsize){
    is = isize;
    js = jsize;
  }
  int operator()(int i,int j){
    return i*js+j;
  }
};


void Main(){
  int n;
  cin>>n;
  vvi a(n,vi(3,0));
  rep(i,n) rep(j,3) cin>>a[i][j];

  vvi dp(n+1,vi(3,0));

  rep(i,n) rep(j,3) rep(k,3) if(j!=k){
    chmax( dp[i+1][j] , dp[i][k] + a[i][j] );
  }
  cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;

} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=8e3+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

char str[N];
ll n, x, y;
vector<ll>dx, dy;
bool dp[N][2*N], memo[N][2*N], memo2[N][2*N], dp2[N][2*N];

bool solve(ll i, ll j)
{
    if(i==dx.size())
        return j==x+N;
    if(memo[i][j])
        return dp[i][j];
    dp[i][j]=false;
    memo[i][j]=true;
    if(i>0)
        dp[i][j]|=solve(i+1, j-dx[i]);
    else if(str[0]=='T')
        dp[i][j]|=solve(i+1, j-dx[i]);
    dp[i][j]|=solve(i+1, j+dx[i]);
    // printf("%lld %lld\n", i, j);
    return dp[i][j];
}

ll solve2(ll i, ll j)
{
    if(i==dy.size())
        return j==y+N;
    if(memo2[i][j])
        return dp2[i][j];
    memo2[i][j]=true;
    dp2[i][j]=false;
    dp2[i][j]|=solve2(i+1, j+dy[i]);
    dp2[i][j]|=solve2(i+1, j-dy[i]);
    return dp2[i][j];
}

int main() 
{
    cin>>str>>x>>y;
    n=strlen(str);
    ll cnt=0, dir=0;
    for(ll a=0; a<n; a++)
    {
        if(str[a]=='T')
        {
            if(dir==0)
            {
                if(cnt>0)
                    dx.pb(cnt);
                cnt=0;
                dir=1;
            }
            else
            {
                if(cnt>0)
                    dy.pb(cnt);
                dir=0;
                cnt=0;
            }
        }
        else
            cnt++;
    }
    if(cnt>0)
    {
        if(dir)
            dy.pb(cnt);
        else
            dx.pb(cnt);
    }
    // for(ll a=0; a<dx.size(); a++)
    //     printf("%lld ", dx[a]);
    // printf("\n");
    // for(ll a=0; a<dy.size(); a++)
    //     printf("%lld ", dy[a]);
    // printf("\n");
    for(ll a=0; a<N; a++)
        for(ll b=0; b<2*N; b++)
        {
            memo[a][b]=false;
            memo2[a][b]=false;
        }
    bool ans=solve(0, N);
    ans&=solve2(0,N);
    if(ans)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 314240