akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int X = tx - sx;
	int Y = ty - sy;
	vector<string> vec(100000);
	for (int i = 1; i <= Y; i++) {
		vec.push_back("U");
	}
	for (int i = 1; i <= X; i++) {
		vec.push_back("R");
	}
	for (int i = 1; i <= Y; i++) {
		vec.push_back("D");
	}
	for (int i = 1; i <= X; i++) {
		vec.push_back("L");
	}
	vec.push_back("L");
	for (int i = 1; i <= Y + 1; i++) {
		vec.push_back("U");
	}
	for (int i = 1; i <= X + 1; i++) {
		vec.push_back("R");
	}
	vec.push_back("D");
	vec.push_back("R");
	for (int i = 1; i <= Y + 1; i++) {
		vec.push_back("D");
	}
	for (int i = 1; i <= X + 1; i++) {
		vec.push_back("L");
	}
	vec.push_back("U");
	for (auto itr = vec.begin(); itr != vec.end(); itr++) {
		cout << *itr;
	}
	return 0;
}

Measured memory_bytes: 1904
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x;
    char op;
    while(true){
        cin >> a >>op >>b;
        if(op =='?')break;
        if(op =='+')
            x=a+b;
        if(op =='-')
            x=a-b;
        if(op =='*')
            x=a*b;
        if(op =='/')
            x=a/b;
        cout << x << endl;
    }
}


Measured memory_bytes: 3084
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int x,y,z;
int main(){
	int ma=0;
	cin>>x>>y>>z;
	ma=max(x,max(y,z));
	int hoge=(ma-x)+(ma-y)+(ma-z);
	if(hoge%2==1)hoge+=3;
	cout<<hoge/2<<endl;
}

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

using namespace std;

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

const int mod = 1e9+7;
vector<ll> bit(2*(1e5)+1,0);

void insert(int index, ll val){

    for(int i = index; i <= 2*(1e5); i += (i&-i)){
        bit[i] = max(bit[i], val);
    }
}

ll query(int index){

    ll ans = 0;
    for(int i = index-1; i > 0; i -= (i&-i)){
        ans = max(bit[i], ans);
    }
    return ans;
}

int main(){

    int n; cin >> n;
    vector<int> h(n),v(n),ch; // ch --> compressed height

    for(int i = 0; i < n; i++) {
        int tmp; cin >> tmp;
        h[i] = tmp;
        ch.push_back(tmp);
    }
    for(int i = 0; i < n; i++) cin >> v[i];
    sort(ch.begin(),ch.end());

    vector<ll> dp(n,0);

    dp[0] = v[0];
    //cout << (lower_bound(ch.begin(),ch.end(),h[0]) - ch.begin()) + 1 << endl;
    insert((lower_bound(ch.begin(),ch.end(),h[0]) - ch.begin()) + 1,dp[0]);

    for(int i = 1; i < n; i++){
        dp[i] = v[i];
        int compressed_h = (lower_bound(ch.begin(),ch.end(),h[i]) - ch.begin()) + 1;
        //cout << compressed_h << endl;
        ll tmp = query(compressed_h);
        //cout << tmp << endl;
        dp[i] = max(dp[i],tmp+v[i]);
        insert(compressed_h,dp[i]);
    }
    
    ll mx = 0;
    for(int i = 0; i < n; i++) mx = max(mx,dp[i]);

    cout << mx << endl;
}

Measured memory_bytes: 5876
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

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

  vector<vector<int>> points(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> points[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int k = i + 1; k < N; k++) {
      int cur = 0;
      for (int j = 0; j < D; j++) {
        cur += pow(points[i][j] - points[k][j], 2);
      }

      double v = sqrt(cur);
      if (v - floor(v) == 0)
        ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


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


int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s,t;cin>>s>>t;
	
	bool isans=true;
	for(ll i=0;i<s.length();i++) if(s[i]!=t[i])isans=false;
	
	if(isans) cout<<"Yes"; else cout<<"No";
		
	
}


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){return Point(x+p.x,y+p.y);}
  Point operator-(Point p){return Point(x-p.x,y-p.y);}
  Point operator*(double k){return Point(x*k,y*k);}
  Point operator/(double k){return Point(x/k,y/k);}

  double abs(){return sqrt(norm());}

  double norm(){return (x*x+y*y);}
};
typedef Point Vector;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

double dot(Vector a,Vector b){return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){return (a.x*b.y-a.y*b.x);}

Point project(Segment s,Point p){
  Vector base=(s.p2-s.p1);
  double r=(dot(p-s.p1,base)/base.norm());
  return (s.p1+base*r);
}

int main()
{
  Point A,B,C,D;
  int q;

  cin>>A.x>>A.y>>B.x>>B.y;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>C.x>>C.y;
    D=project(Segment(A,B),C);
    printf("%.10f %.10f\n",D.x,D.y);
  }
  return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	sort(ALL(a));
	
	int ans=0;
	int cnt=0;
	int now=a[0];
	REP(i,n){
		if(a[i]==now) cnt++;
		else{
			if(cnt>=now) ans+=cnt-now;
			else ans+=cnt;
			
			now=a[i];
			cnt=1;
		}
	}
	if(cnt>=now) ans+=cnt-now;
	else ans+=cnt;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);

char s[15];
int main(){
    cin>>s;
    int len = strlen(s);
    int cnt=0;
    char ans[15];
    rep(i,0,len){
        if(s[i]!='B')
            ans[cnt++]=s[i];
        else
            if(cnt>0) cnt--;
    }
    printf("%s\n",ans);
    return 0;
}

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

#define ll long long

using namespace std;

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ll n;
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000;
}

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

int main() {
    vector<vector<int>> c(3,vector<int>(3));
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> c.at(i).at(j);
        }
    }

    vector<vector<int>> d(3,vector<int>(2));

    bool ans1=true;
    bool ans2=true;
    
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3-1; j++){
            d[i][j]=c[i][j]-c[i][j+1];
        }
    }
    for (int j = 0; j < 3-1; j++){
        if(d[0][j]!=d[1][j] || d[1][j]!=d[2][j]){
            ans1=false;
        }
    }

    for (int j = 0; j < 3; j++){
        for (int i = 0; i < 3-1; i++){
            d[j][i]=c[i][j]-c[i+1][j];
        }
    }
    for (int j = 0; j < 3-1; j++){
        if(d[0][j]!=d[1][j] || d[1][j]!=d[2][j]){
            ans2=false;
        }
    }

    if(ans1&&ans2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    
}

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

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

long long dp[110][100100] = {0};

int main() {
  int N;
  long long W, w[110], v[100100];
  cin >> N >> W;

  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j - w[i] >= 0) {
        chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
      }
        chmax(dp[i + 1][j], dp[i][j]);
    }
  }

  cout << dp[N][W] << endl;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    int sharp = 0;
    for(int i = 0; i < h*w; i++){
        char t;
        cin >> t;
        if(t=='#'){sharp++;}
    }
    if(sharp == h+w-1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class UnionFindTree{
public:
    std::vector<int> parent;
    std::vector<int> rank;
 
    UnionFindTree(int n){
        parent.resize(n, 0);
        rank.resize(n, 0);
 
        for(int i = 0; i < n; i++){
            parent[i] = i;
        }
        return;
    }
    ~UnionFindTree(){
        return;
    }
 
    int find(int x){
        if(parent[x] == x){
            return x;
        }
        else{
            return parent[x] = find(parent[x]);
        }
    }
 
    void unite(int x, int y){
        x = find(x);
        y = find(y);
 
        if(x == y){
            return;
        }
 
        if(rank[x] < rank[y]){
            parent[x] = y;
        }
        else{
            parent[y] = x;
            if(rank[x] == rank[y]){
                rank[x]++;
            }
        }
    }
 
    bool is_same(int x, int y){
        return find(x) == find(y);
    }
};

int main(int argc, char **argv){
	int n, q, com, x, y;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> n >> q;
#else
	std::cin >> n >> q;
#endif
	UnionFindTree uft(n);

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> com >> x >> y;
#else
		std::cin >> com >> x >> y;
#endif
		if(com == 0){
			uft.unite(x, y);
		}
		else{
			if(uft.is_same(x, y)){
				std::cout << "1" << std::endl;
			}
			else{
				std::cout << "0" << std::endl;
			}
		}
	}

 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int N = 303;
const int mod = 998244353;

int dp[N][N][N];

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

int main() {
	string s;
	cin >> s;
	int k = nxt();
	int n = s.length();

	s += '0';
	vector<int> cnts;
	for (int i = 0, c = 0; i < n + 1; ++i) {
		if (s[i] == '1') {
			++c;
		} else {
			cnts.push_back(c);
			c = 0;
		}
	}

	const int total = accumulate(all(cnts), 0);
	reverse(all(cnts));

	dp[0][0][0] = 1;
	for (int i = 0; i < (int)cnts.size(); ++i) {
		for (int bal = 0; bal <= total; ++bal) {
			for (int used = 0; used <= total; ++used) {
				if (!dp[i][bal][used]) {
					continue;
				}
				for (int here = 0; here <= total; ++here) {
					if (bal + cnts[i] - here < 0) {
						break;
					}
					add(dp[i + 1][bal + cnts[i] - here][used + max(0, here - cnts[i])], dp[i][bal][used]);
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i <= min(k, total); ++i) {
		add(ans, dp[(int)cnts.size()][0][i]);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 30468
#include<stdio.h>
int main()
{
    char n;
    scanf("%c",&n);
    if(n=='A')
        printf("T");
    else if(n=='T')
        printf("A");
    else if(n=='G')
        printf("C");
    else if(n=='C')
        printf("G");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,x;
    cin>>n;
    vector<pair<int,int>> list(n);
    for(i=1;i<=n;i++){
        cin>>x;
        list[i-1]=make_pair(x,i);
    }
    sort(all(list));
    rep(i,n){
        if(i!=0)cout<<" ";
        cout<<list[i].second;
    }
    cout<<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n;
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    Cout(a[n - 1] - a[0]);
    return 0;
}


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

int main(){
  string s,t;
  cin >> s >> t;

  int a= s.length();
   char c[a] ;
   char d[a] ;

   for(int i=0; i<a; i++){
     c[i] = s[i];
     d[i] = t[i];
   }

   int e=0;

   for(int i=0; i<a; i++){
     if(c[i] != d[i]){
       e++;
     }
   }

   cout << e << endl;
   return 0;
}

Measured memory_bytes: 4132
s = input()

aidx_list = []
zidx_list = []

for i in range(len(s)):
    if (s[i]  == 'A'):
        aidx_list.append(i)
    if (s[i] == 'Z'):
        zidx_list.append(i)

print(len(s[aidx_list[0]:zidx_list[-1]+1]))


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

int main(){
    long long n;
    cin>>n;
    long long d;
    cin>>d;
    d=(d*d);
    long long ans=0;
    for(int i=0; i<n; i++){
        long long x, y;
        cin>>x>>y;
        if(((x*x)+(y*y))<=d){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>

std::vector<int> dx{1, 1, 0, -1, -1, -1, 0, 1};
std::vector<int> dy{0, 1, 1, 1, 0, -1, -1, -1};

void dfs(std::vector<std::vector<bool>> &seen, std::vector<std::vector<int>> &map, int x, int y){
//    std::cout << x << ", " << y << std::endl;
    seen.at(y).at(x) = true;
    for(int i = 0; i < 8; ++i){
        int nextX = x + dx.at(i), nextY = y + dy.at(i);
        if(!seen.at(nextY).at(nextX) && 1 == map.at(nextY).at(nextX)){
            dfs(seen, map, nextX, nextY);
        }
    }
}

int main(){
    int w, h;
    while(std::cin >> w >> h){
        if(0 == w && 0 == h){
            break;
        }

        std::vector<std::vector<int>> map(h + 2, std::vector<int>(w + 2, 0));
        for(int i = 1; i <= h; ++i){
            for(int j = 1; j <= w; ++j){
                std::cin >> map.at(i).at(j); 
            }
        }

        std::vector<std::vector<bool>> seen(h + 2, std::vector<bool>(w + 2, false));
        int count = 0;
        for(int i = 1; i <= h; ++i){
            for(int j = 1; j <= w; ++j){
                if(!seen.at(i).at(j) && 1 == map.at(i).at(j)){
                    dfs(seen, map, j, i);
                    ++count;
                } 
            }
        }
    
        std::cout << count << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3320
using System;

namespace ABC130
{
    class A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);
            int A = int.Parse(input[1]);

            if (X < A) { Console.WriteLine(0); } else { Console.WriteLine(10); }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct SegmentTree {
private:
    int n;
    vector<T> node;
    T def;
    function<T(T,T)> out;
    
public:
    SegmentTree() {}
    SegmentTree(const vector<T> &v, T _def, function<T(T,T)> _out) {
        int vl = (int)v.size();
        n = 1;
        while(n < vl) n *= 2;
        def = _def; out = _out;
        node = vector<T>(2 * n - 1, def);
        for(int i = 0; i < vl; i++) node[i + n - 1] = v[i];
        for(int i = n - 2; i >= 0; i--) node[i] = out(node[i * 2 + 1], node[i * 2 + 2]);
    }
    
    void update(int idx, T val) {
        idx += (n - 1);
        node[idx] = val;
        while(idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = out(node[idx * 2 + 1], node[idx * 2 + 2]);
        }
    }
    
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if ((r <= a) || (b <= l)) return def;
        if ((a <= l) && (r <= b)) return node[k];
        return out(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll chars = 'z' - 'a' + 1;
    ll n;
    string s;
    cin >> n >> s;
    vector<SegmentTree<ll>> st(chars, SegmentTree<ll>(vector<ll>(n, 0), 0, [](ll a, ll b){ return a + b; }));
    rep(i, n) {
        st[s[i] - 'a'].update(i, 1);
    }
    ll q;
    cin >> q;
    rep(i, q) {
        ll t;
        cin >> t;
        if (t == 1) {
            ll idx;
            char c;
            cin >> idx >> c;
            idx--;
            st[s[idx] - 'a'].update(idx, 0);
            st[c - 'a'].update(idx, 1);
            s[idx] = c;
        }
        else {
            ll l, r;
            cin >> l >> r;
            l--;
            ll ans = 0;
            rep(j, chars) {
                if (st[j].query(l, r) > 0) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 226076
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();

  println!("{}", if a % 3 == 0 || b % 3 == 0 || (a + b) %3 == 0 {
    "Possible"
  } else {
    "Impossible"
  });
}



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

#define ll long long
#define pll pair<ll,ll>
#define MAX 1000005
#define MOD 1073741824

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

	if(a>=13)
	{
		cout << b << endl;
	}
	else if(a>=6 and a<=12)
	{
		cout << b/2 << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "homework"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 200000;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int n;
struct Matrix {
	int a[50][50];

	Matrix () {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = 0;
			}
		}
	}

	Matrix operator *(const Matrix &other) {
		Matrix product;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					product.a[i][k] += a[i][j] * other.a[j][k];
					product.a[i][k] %= MOD;
				}
			}
		}

		return product;
	}

	void print() {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cout << a[i][j] << ' ';
			}
			cout << endl;
		}
		cout << endl;
	}
};

Matrix bp(Matrix a, int k) {
	Matrix result;
	for (int i = 0; i < n; i++) {
		result.a[i][i] = 1;
	}
	while (k) {	
		if (k & 1) result = result * a;
		k >>= 1;
		a = a * a;
	}	
	return result;
}

int32_t main() {
	FAST;
	
	cin >> n;
	int k;
	cin >> k;
	Matrix a;

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

	Matrix res = bp(a, k);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans = (ans + res.a[i][j]) % MOD;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int solve(int y,int m,int d){
	int res=0;
	if(y%3==0){
		res+=(10-m)*20+20-d;
	}else{
		if(m%2==0){
			res+=(19-d);
		}else{
			res+=(20-d);
		}
		m++;
		for(;m<11;m++){
			if(m%2==0){
				res+=19;
			}else{
				res+=20;
			}
		}
	}
	y++;
	for(;y<1000;y++){
		if(y%3==0){//allbig
			res+=20*10;
		}else{//big and small
			res+=20*5+19*5;
		}
	}
	res++;
	return res;
}


int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int y,m,d,ans;
		cin>>y>>m>>d;
		ans=solve(y,m,d);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
void main() {
  problem();
}

void problem() {
  auto L = scan!long;
  auto R = scan!long;
  auto d = scan!long;

  long solve() {
    long ans;
    foreach(i; L..R+1) {
      if (i % d == 0) ans++;
    }

    return ans;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 2704
from heapq import heappush, heappop
V, E, r = map(int, input().split())
inf = 10**10
edges = [[] for _ in [None]*V]
vertices = [inf]*V
vertices[r] = 0

for _ in [None]*E:
    s, t, d = map(int, input().split())
    edges[s].append((t, d))

q = [(0, r)]
rem = V-1
while q and rem > 0:
    cost, v = heappop(q)
    if vertices[v] < cost:
        continue
    rem -= 1
    for dest, _cost in edges[v]:
        newcost = cost + _cost
        if vertices[dest] > newcost:
            vertices[dest] = newcost
            heappush(q, (newcost, dest))

print("\n".join([str(n) if n!=inf else "INF" for n in vertices]))

Measured memory_bytes: 97916
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#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) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(A);CIN(B);CIN(C);
    if(A==B){
        COUT(C);
    }
    if(A==C){
        COUT(B);
    }
    if(B==C){
        COUT(A);
    }
    return 0;
}


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

int main(){
	while(true){
		string s1;
		cin>>s1;

		if(s1=="."){
			break;
		}

		string s2;
		cin>>s2;

		if(s1==s2){
			cout<<"IDENTICAL"<<endl;
			continue;
		}

		string t1=s1;
		string t2=s2;
 	
		while(true){
			size_t d1b =t1.find('\"');
			if(d1b==string::npos)
				break;
			t1.replace(d1b,1,"@");

			size_t d1e =t1.find('\"');
			t1.replace(d1e,1,"@");

			size_t d2b=t2.find('\"');
			if(d2b==string::npos)
				break;
			t2.replace(d2b,1,"@");

			size_t d2e =t2.find('\"');
			t2.replace(d2e,1,"@");
			
			string u1=s1;
			u1.replace(d1b+1,d1e-d1b-1, "");
			string u2=s2;
			u2.replace(d2b+1,d2e-d2b-1, "");

			if(u1==u2){
				t1=u1;
				t2=u2;
				break;
			}
		}
		if(t1==t2){
			cout<<"CLOSE"<<endl;
		}else{
			cout<<"DIFFERENT"<<endl;
		}
	}
return 0;
}






			

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

int main()
{
    int n;
    int x, y, b, p;

    cin >> n;
    for (int i = 0; i < n; i++) {
        int kanade, hayami;
        cin >> x >> y >> b >> p;

        if (b >= 5 && p >= 2) {
            kanade = (x * b + y * p) * 0.8;
        } else {
            kanade = x * b + y * p;
        }
        
        if (b < 5) {
            hayami = x * 5 * 0.8;
        } else {
            hayami = x * b * 0.8;
        }
        if (p < 2) {
            hayami += y * 2 * 0.8;
        } else {
            hayami += y * p * 0.8;
        }

        cout << min(hayami, kanade) << endl;
    }

    return (0);
}

Measured memory_bytes: 3100
N=int(input())
A=[int(i) for i in input().split()]
if A==[0]*N:
  print(N*(N+1)//2)
  exit()
S_xor=[A[0]]
ans=0
left=1
for i in range(1,N):
  S_xor.append(S_xor[i-1]^A[i])
  
S_xor.append(2**31-1)
A.append(2**31-1)

for i in range(N):
  if i==0:
    while S_xor[left-1]&A[left]==0 and left<=N:
      left+=1
  else:
    while (S_xor[left-1]^S_xor[i-1])&A[left]==0 and left<=N-1:
      left+=1
  ans+=left-i
print(ans)

Measured memory_bytes: 86732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int sum=0;
  cin >> n;
  int tmp=n;
  while(tmp){
    sum+=tmp%10;
    tmp/=10;
  }
  if(n%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, K;
    cin >> A >> B >> K;
    int cnt = 0;
    for (int i = 100; i > 0; i--) {
        if (A % i == 0 && B % i == 0) {
            cnt++;
        }
        if (cnt == K) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

static const int MAX = 100005;
static const int INFTY = (1 << 28);

int N;

vector<int> M[100005];

int dist1[MAX];
int distN[MAX];

void CalcDist1() {//頂点1から他の頂点への距離をDFSする
	int color[MAX];
	REP(i, N + 1) color[i] = 0;//1-indexed

	REP(i, N + 1) dist1[i] = INFTY;
	
	stack<int> S;

	S.push(1);
	dist1[1] = 0;

	int now, nex;
	while (!S.empty()) {
		now = S.top(); S.pop();
		color[now] = 1;//訪問済み
		REP(i, M[now].size()) {
			nex = M[now][i];
			if (color[nex] == 0) {
				S.push(nex);
			}
			if (dist1[nex] == INFTY) {
				dist1[nex] = dist1[now] + 1;
			}
		}
	}

}

void CalcDistN() {//頂点Nから他の頂点への距離をDFSする
	int color[MAX];
	REP(i, N + 1) color[i] = 0;//1-indexed

	REP(i, N + 1) distN[i] = INFTY;

	stack<int> S;

	S.push(N);
	distN[N] = 0;

	int now, nex;
	while (!S.empty()) {
		now = S.top(); S.pop();
		color[now] = 1;
		REP(i, M[now].size()) {
			nex = M[now][i];
			if (color[nex] == 0) {
				S.push(nex);
			}
			if (distN[nex] == INFTY) {
				distN[nex] = distN[now] + 1;
			}
		}
	}

}

int main() {
	int a, b;
	cin >> N;
	REP(i, N - 1) {
		cin >> a >> b;
		M[a].push_back(b);//1-indexed
		M[b].push_back(a);
	}

	CalcDist1();
	CalcDistN();

	int sum1 = 0, sumN = 0;
	for (int i = 1;i <= N;i++) {
		if (dist1[i] <= distN[i]) sum1++;
		else sumN++;
	}

	/*for (int i = 1;i <= N;i++) {
		cout << dist1[i] << " " << distN[i] << endl;
	}*/

	cout << (sum1 > sumN ? "Fennec" : "Snuke") << endl;
	return 0;
}

Measured memory_bytes: 6912
import math
if __name__ == '__main__':
    #s = input().rstrip().split(' ')
    K = int(input())
    k = 0
    for a in range(1,K+1):
        for b in range(a,K+1):
            for c in range(b,K+1):
                val = math.gcd(math.gcd(a,b),c)
                if a==b or b==c or a==c:
                    if a==b and b==c:
                        val = val
                    else:
                        val = val * 3
                else:
                    val = val * 6

                k = k + val
    print(k)


Measured memory_bytes: 9136
#include<string>
#include<iostream>
using namespace std;
int main(){
  int a,b,A,B,cnt = 0;
  char mas[100][100];
  cin >> a >>b;
  A=1 + (a/50);
  B=1 + (b/50);
  for(int i=0;i<(2*A+1);i++){
    for(int j=0;j<100;j++){
      if(i%2 == 1 && j%2 == 1 && cnt < a-1){
        mas[i][j]='.';
        cnt++;
      }
      else mas[i][j] ='#';
    }
  }
  cnt = 0;
  for(int i=2*A+1;i<(2*(A+B+1));i++){
    for(int j=0;j<100;j++){
      if((i-2*A-1)%2 == 1 && j%2 == 1 && cnt < b-1){
        mas[i][j]='#';
        cnt++;
      }
      else mas[i][j] ='.';
    }
  }
  cout << 2*(A+B+1) << " " << 100 <<endl;
  for(int i=0;i<2*(A+B+1);i++){
    for(int j=0;j<100;j++){
      cout << mas[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

cnt = {}
for ai in a:
    if ai in cnt:
        cnt[ai] += 1
    else:
        cnt[ai] = 1

ans = 0
for ai in cnt.keys():
    tmp = cnt[ai]
    tmp += cnt[ai - 1] if (ai - 1) in cnt else 0
    tmp += cnt[ai + 1] if (ai + 1) in cnt else 0
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 56044
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main(void){
    int X;

    cin >> X;

    int ans = 1;
    int tmp;
    for(int i=1;i<=1000;i++){
        for(int j=2;j<=10;j++){
            if(pow(i, j)<=X){
                tmp = pow(i, j);
                ans = max(tmp, ans);
            }
        }
    }
   cout << ans << endl;
   return 0; 
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d %d', $r, $c);

$colSum = array_fill(0, $c + 1, 0);

for ($i = 0; $i < $r; $i++) {
    $row   = explode(' ', trim(fgets(STDIN)));
    $row[] = array_sum($row);

    foreach ($row as $k => $v) {
        $colSum[$k] += $v;
    }

    $view[$i] = implode(' ', $row);
}

$view[] = implode(' ', $colSum);

echo implode(PHP_EOL, $view), PHP_EOL;

Measured memory_bytes: 6744
def resolve():
    '''
    code here
    '''
    S = input()

    memo = 1
    new_list = []
    
    prev = S[0]
    cnt = 0

    for i in range(len(S)-1):
        if S[i+1] == prev:
            memo += 1
        else:
            new_list.append(memo)
            memo = 1
        prev = S[i+1]
    else:
        new_list.append(memo)

    # print(new_list)

    res = []
    for i in range(len(new_list)//2):

        a = new_list[i*2]
        b = new_list[i*2 +1]

        if (a+b)%2 == 1:
            res += [0 for _ in range(new_list[i*2])]
            res[-1] = (a+1)//2 + b//2
            res += [a//2 + (b+1)//2]
            res += [0 for _ in range(new_list[i*2+1]-1)]
        else:
            res += [0 for _ in range(new_list[i*2])]
            res[-1] = (a + b) // 2
            res += [(a + b ) // 2]
            res += [0 for _ in range(new_list[i*2+1]-1)]
    print(*res)




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 7280
// #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;
 
using ull = unsigned long long int;
using ll = long long int;
using du = double;
using ld = long du;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vdu = vector<du>;
using vs = vector<string>;
using vc = vector<char>;
using si = set<int>;
using sll = set<ll>;
using sdu = set<du>;
using sld = set<ld>;
using pii = pair<int, int>;
using pll = pair<ll,ll>;
using pdu = pair<du,du>;
using pld = pair<ld,ld>;
using pis = pair<int,string>;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define sp(x) setprecision(x)<<fixed
#define loop(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pi acos(-1)
#define meme(a,x) memset(a,x,sizeof(a))
#define all(a) a.begin(),a.end()
 
//debugger
 
#ifdef KAIZER
#include "debug.h"
#else
#define debug(x...)
#endif
//debugger
 
//functions
bool check_pow(ll a)
{
    if((a&(a-1))==0) return true;
    else return false;
}
ld my_pow(ld a,int b)
{
    ld ans=1;
    for(int i=0;i<b;i++) ans*=a;
    return ans;
}
ll digits(ll a)
{
    string line=to_string(a);
    return line.size();
}
bool prime_check(ll a)
{
    bool flag=true;
    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0) {flag=false; break;}
    }
    return flag;
}
bool comp(const pair<int,int> &a , const pair<int,int> &b)
{
    if(a.ff!=b.ff) return a.ff>b.ff;
    else return a.ss<b.ss;
}
bool comp2(const ll &a, const ll &b)
{
     return a>b;
}
 
//functions

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FASTIO;
    ll x,y,a,b,c,d;
    cin>>x>>y;
    c=x/2;
    d=y/2;
    a=c;
    b=d;
    if(x%2) a++;
    if(y%2) b++;
    ll ans=a*b+c*d;
    if(x==1 || y==1) ans=1;
    cout<<ans<<endl;
}


Measured memory_bytes: 3704
def resolve():
    N, M = list(map(int, input().split()))
    LRD = [list(map(int, input().split())) for _ in range(M)]
    adj_list = [[] for _ in range(N)]
    for lrd in LRD:
        l, r, d = lrd
        adj_list[l-1].append((l-1, r-1, d))
        adj_list[r-1].append((r-1, l-1, -d))
    
    X = [None]*N
    import collections

    for i in range(N):
        if X[i] is not None:
            continue
        q = collections.deque(adj_list[i])
        X[i] = 0
        while q:
            src, nxt, d = q.pop()
            if X[nxt] is not None:
                if X[nxt] != X[src] + d:
                    print("No")
                    return
            else:
                X[nxt] = X[src] + d
                q.extend(adj_list[nxt])
    print("Yes")

    


if '__main__' == __name__:
    resolve()


Measured memory_bytes: 118852
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
double dp[100][100],g[100][100];
int main(){
  int n, m;
  while(cin >> n >> m , n){
    for(int i = 0 ; i < n ; i ++ ){
      for(int j = 0 ; j < n ; j++ ){
	cin >> g[i][j];
      }
    }
    fill_n( dp[0], n, 1.0);
    fill_n( dp[1], 9900, 0);
    for(int i = 1 ; i < m ; i++ ){ //回数
      for(int prev = 0 ; prev < n ; prev++ ){ // prev
	for(int now = 0 ; now < n ; now++ ){ // now
	  dp[i][now] = max( dp[i][now], dp[i - 1][prev] * g[prev][now]);
	}
      }
    }
    cout << fixed << setprecision(2) << *max_element( dp[m - 1], dp[m - 1] + n ) << endl;
  }
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    set<char> cnt1, cnt2;
    for (int j = 0; j < s.size(); j++) {
      if (j > i) {
        cnt2.insert(s[j]);
      } else {
        cnt1.insert(s[j]);
      }
    }

    int cnt = 0;
    for (auto it = cnt1.begin(); it != cnt1.end(); it++) {
      if (cnt2.count(*it) > 0) {
        cnt++;
      }
    }

    ans = max(ans, cnt);
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,l,r) for(ll i=l; i<(ll)(r); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;

/////Union Find(for C)/////
int par[201010];   //par:-1*(size of set), chi:par
void UF(int n) {
    for (int i = 0; i < n; i++){
        par[i] = -1;
    }
}
int root(int x) {
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
}
void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    if(par[rx] > par[ry]) swap(rx,ry);
    par[rx] += par[ry];
    par[ry] = rx;
}
int same(int x, int y) {
    return (root(x) == root(y)?1:0);
}
int size(int x) {
    return (-par[root(x)]);
}
/////----------/////

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    UF(n);
    rep(i,q){
        int t, a, b;
        scanf("%d%d%d", &t, &a, &b);
        //a--; b--;
        if(t == 0) unite(a,b);
        else printf("%d\n",same(a,b));
    }
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll A,B,ans;
    scanf("%lld %lld", &A, &B);
    ans = A - 2 * B;
    if ( ans < 0 ) ans = 0;
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  
  long long X;
  cin >> X;
  
  for (int i=2; i<=360; i++) {
    if (i * X % 360 == 0) {
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
		ll a;
		cin>>a;
		ll b;
		cin>>b;
		ll p;
		p=a*b;
		cout<<p<<'\n';
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int n, m, x;

	cin >> n >> m >> x;

	int a;
	int cnt = 0;

	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a < x)
			cnt++;
	}

	cout << min(cnt, m - cnt) << endl;

	return 0;

}


Measured memory_bytes: 256
#include <map>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
	int N = 0, L = 0;
	cin >> N >> L;
	string s[N];
	vector<string> v;
	for(int i = 0; i < N; i++){
		cin >> s[i];
		v.push_back(s[i]);
	}
	sort(v.begin(), v.end());
	for(int i = 0; i < N; i++){
		cout << v[i];
	}
}


Measured memory_bytes: 256
# coding: utf-8
import math
import bisect

def calc():
    n = int(input())
    tops = list(map(int, input().split()))
    middles = list(map(int, input().split()))
    lowers = list(map(int, input().split()))
 
    tops = sorted(tops)
    lowers = sorted(lowers)
 
    counter = 0
 
    for i in range(n):
        # A < B
        top_num = bisect.bisect_left(tops, middles[i])
        
        # B < C
        lower_num = n - bisect.bisect_right(lowers, middles[i])
        
        counter += top_num * lower_num
    
    return counter
 
print(calc())

Measured memory_bytes: 23372
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

ll dp[405][405];
ll sum[405][405];

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

    int n, c;
    cin >> n >> c;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    for(int i = 0; i < n; ++i)  cin >> b[i];

    int maxe = max(*max_element(a.begin(), a.end()), *max_element(b.begin(), b.end()));
    for(int i = 0; i <= maxe; ++i)  sum[i][0] = 1;
    for(int i = 1; i <= maxe; ++i){
        for(int j = 0; j < c; ++j){
            sum[i][j+1] = sum[i][j] * i % mod;
        }
    }
    for(int i = 0; i < maxe; ++i){
        for(int j = 0; j <= c; ++j){
            chadd(sum[i+1][j], sum[i][j]);
        }
    }

    dp[0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= c; ++j){
            for(int k = 0; k <= j; ++k){
                // a_i^k + (a_i + 1)^k + ... + b[i]^k
                ll mul = (sum[b[i]][k] - sum[a[i]-1][k]) % mod;
                if(mul < 0) mul += mod;
                ll add = dp[i][j-k] * mul % mod;
                chadd(dp[i+1][j], add);
            }
        }
    }

    cout << dp[n][c] << endl;
}

Measured memory_bytes: 2816
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
  Comb(){
    fac = new ll[1000001];
    finv = new ll[1000001];
    inv = new ll[1000001];
    fac[0] = 1;
    for(int i=1;i<1000001;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000001;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000001;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string n;
  cin >> n;
  ll dp[n.length()][2];
  dp[0][0] = n[0]-'0';
  dp[0][1] = 10-(n[0]-'0');
  for(int i=1;i<n.length();i++){
    int temp = n[i]-'0';
    dp[i][0] = min(dp[i-1][0]+temp,dp[i-1][1]+temp+1);
    dp[i][1] = min(dp[i-1][0]+10-temp,dp[i-1][1]+9-temp);
  }
  cout << min(dp[n.length()-1][0],dp[n.length()-1][1]+1) << endl;
  return 0;
}


Measured memory_bytes: 17028
import java.math.*

fun main(args: Array<String>) {
    val (W, H, N) = readInputLine().split(" ").map { it.toInt() }
    
    var l = 0
    var r = W
    var b = 0
    var t = H
    
    for (i in 1..N) {
        val (x, y, a) = readInputLine().split(" ").map { it.toInt() }
        when (a) {
            1 -> l = Math.max(l, x)
            2 -> r = Math.min(r, x)
            3 -> b = Math.max(b, y)
            4 -> t = Math.min(t, y)
        }
    }

    if ((t - b) > 0 && (r - l) > 0) {
        println((t - b) * (r - l))
    } else {
        println(0)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 35992
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;

    cin >> N;
    
    vector<int> C(N), S(N), F(N), T(N, 0);
    for (int i = 0; i < N-1; i++){
        cin >> C[i] >> S[i] >> F[i];

        for (int j = 0; j <i+1; j++){
            T[j] = max(S[i], F[i]*((T[j]+F[i]-1)/F[i])) + C[i];
        }
    }

    for (int i = 0; i < N; i++){
        cout << T[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
n,w_lim = map(int,input().split())
dp = [[0 for i in range(w_lim+1)] for i in range(n)]

w,v = [],[]
for i in range(n):
    ww,vv = map(int,input().split())
    w.append(ww)
    v.append(vv)

#初期条件
for ww in range(w_lim+1): dp[0][ww] = v[0] if ww>=w[0] else 0

#漸化式
for i in range(n-1):
    for ww in range(w_lim+1):
        dp[i+1][ww] = dp[i][ww] if w[i+1]>ww else max(dp[i][ww], dp[i][ww-w[i+1]]+v[i+1])

ans = dp[n-1][w_lim]
print(ans)


Measured memory_bytes: 171272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;
	cin>>S;
	int N = S.size();
	rep(i,N){
		if(2*i<N)cout<<S[2*i];
	}
	cout<<endl;
}

Measured memory_bytes: 512