akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    int t[h][w];
    rep(i,h)rep(j,w) cin>>t[i][j];
    queue<pair<int,int>> from,to;
    rep(i,h)rep(j,w-1){
        if(t[i][j]%2==1){
            t[i][j+1]++;
            from.push({i+1,j+1});
            to.push({i+1,j+2});
        }
    }
    rep(i,h-1){
        if(t[i][w-1]%2==1){
            t[i+1][w-1]++;
            from.push({i+1,w});
            to.push({i+2,w});
        }
    }
    int res=from.size();
    cout<<res<<endl;
    rep(i,res){
        auto p1=from.front(),p2=to.front();from.pop();to.pop();
        cout<<p1.first<<" "<<p1.second<<" "<<p2.first<<" "<<p2.second<<endl;
    }
}


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

#define ll long long
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define see(x) cout<<(#x)<<" -> "<<(x)<<"\n"
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fr1(i,b,a) for(int i=b;i>=a;i--)

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
long double infd=1.0/0.0;
const double pi=2*acos(0.0);
const int MOD=1e9+7;

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int> a(n);
        fr(i,0,n)
            cin>>a[i];
        int x=1;
        int f=0;
        for(int i=0;i<n;i++){
            if(a[i]==1){
                f=1;
            }
            if(a[i]==x){
                x++;
            }
        }
        if(f)
            cout<<n-x+1<<nl;
        else cout<<-1;
    }
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 100002

typedef long long ll;

ll max(ll a,ll b){
    if(a>b) return a;
    else return b;
}

ll min(ll a,ll b){
    if(a<b) return a;
    else return b;
}

/*qsort(array,num_of_index,sizeof(ll),compare_int); */
 ll compare_int(const void *a,const void *b){
     return *(ll*) a - *(ll *) b; 
 } 
 
ll b_search(ll* array,ll left,ll right,ll key){
    ll mid = left / 2 + right / 2;
     if( right - left == 1){
         if(array[mid]==key)
             return mid;
          else
               return -1;
     }
     if(array[mid]==key)
         return mid;
     else if(array[mid]>key)
         b_search(array,left,mid,key);
     else if(array[mid]<key)
         b_search(array,mid,right,key);
}

/*lower_bound(key以上のイテレータを返す)*/
 /*例えば,2,2,5,5,9でkey=2なら(2),2,5,5,9を返す*/
 ll lower_bound(ll  *array,ll left,ll right,ll key){
     if(right-left<=1)
         return left;
     ll mid = left + (right - left) / 2;
     if(array[mid]<key)
         return lower_bound(array,mid,right,key);
     else
         return lower_bound(array,left,mid,key);
 }
 ll upper_bound(ll  *array,ll left,ll right,ll key){
     if(right-left<=1)
         return left;
     ll mid = left + (right - left) / 2;
     if(array[mid]<=key)
         return upper_bound(array,mid,right,key);
     else
         return upper_bound(array,left,mid,key);
 }

ll main(){
    ll N;
    ll A[MAX],B[MAX],C[MAX];
    scanf("%lld",&N);
    for(ll i=1;i<=N;i++)
        scanf("%lld",A+i);
    for(ll i=1;i<=N;i++)
        scanf("%lld",B+i);
    for(ll i=1;i<=N;i++)
        scanf("%lld",C+i);
    A[0] = B[0] = C[0] = 0;
    qsort(A,N+1,sizeof(ll),compare_int);
    qsort(B,N+1,sizeof(ll),compare_int);
    qsort(C,N+1,sizeof(ll),compare_int);
    ll ans = 0;
    for(ll i=1;i<=N;i++)
        ans += lower_bound(A,0,N+1,B[i]) * (N - upper_bound(C,0,N+1,B[i]));
    printf("%lld",ans);
}


Measured memory_bytes: 4856
A,B,C=map(int,input().split())
l=[A,B,C]
l2=[A*B,A*C,B*C]
l2.sort()
c=0
for i in range(3):
    if l[i]%2==0:
        c=c+1
if c<1:
    print(l2[0])
else:
    print("0")

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

int w, h;
int dp[101][101][4];

int solve(int y, int x, int index) { 
  // 0：まっすぐ下から　1：まっすぐ左から　2：曲がって下から　3：曲がって左から
  if( y == h-1 && x == w-1 ) return 1;
  if( y >= h || x >= w ) return 0;
  if( dp[y][x][index] ) return dp[y][x][index];
  if( index == 0 ) {
    return dp[y][x][index] = (solve(y+1, x, 0) + solve(y, x+1, 3)) % 100000;
  }
  if( index == 1 ) {
    return dp[y][x][index] = (solve(y, x+1, 1) + solve(y+1, x, 2)) % 100000;
  }
  if( index == 2 ) {
    return dp[y][x][index] = solve(y+1, x, 0) % 100000;
  }
  if( index == 3 ) {
    return dp[y][x][index] = solve(y, x+1, 1) % 100000;
  }
}
 
int main() {

  while( cin >> w >> h, w+h ) {
    fill_n(**dp, 101*101*4, 0);
    cout << (solve(1, 0, 0) + solve(0, 1, 1)) % 100000 << endl; 
  }
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

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

	int N; cin >> N;

	string str; cin >> str;

	int right = 0;
	int left = N - 1;

	int ans = 0;
	while(right <= left) {
		while(right < N and str[right] == 'R') {
			right++;	
		}
		while(left >= 0 and str[left] == 'W') {
			left--;	
		}
		str[right] = 'R';
		str[left] = 'W';
		ans++;
	}
	if (ans == 0) {
		cout << 0 << endl;		
	}else {
		cout << ans-1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3804
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N, M;
    cin >> N >> M;

    vector<bool> used(N + 1, false);
    used[0] = true;

    vector<int> e(M);
    for (int i = 0; i < M; i++) cin >> e[i];
    reverse(e.begin(), e.end());

    vector<int> ans;

    for (int i = 0; i < M; i++) {
        if (!used[e[i]]) {
            ans.push_back(e[i]);
            used[e[i]] = true;
        }
    }
    for (int i = 0; i <= N; i++) if (!used[i]) ans.push_back(i);


    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }

}














































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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    int a[BIG];
    int n,k,ans;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>n >>k;
    for (int i=0; i<k; i++) {
        int x;
        cin >>x;
        while (x--) {
            int y;
            cin >>y;
            a[y] = 1;
        }
    }
    for (int i=1; i<=n; i++)
        if (!a[i])
            ans++;
    cout <<ans;




    return 0;
}


Measured memory_bytes: 3652
//*******Abhijit Burman***********// 
//Jalpaiguri Government Engineering College/ 

#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back 
#define mk make_pair 
#define MAXX (1000000000000000000+7)
#define mod 1000000007
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) 

// ll powermod(ll base, ll exp, ll mod) 
// {
// 	ll result = 1;
// 	while (exp != 0) 
// 	{
// 		if ((exp % 2) == 1) 
// 		{
// 			result = (result * base) % mod;
// 		}
// 		base = (base * base) % mod;
// 		exp /= 2;
// 	}
// 	return result;
// }
map<ll,ll> visited;
// void bfs( vector<ll> adj[], ll node)
// {
//     map<ll,ll> mp;
//     queue<ll> q;
    
//     //strating node
//     q.push(node);
//     mp[node]=1;
//     while(!q.empty())
//     {
//         ll temp = q.front();
//         q.pop();
//         for(int i=0;i<adj[temp].size();i++)
//         {
//             if(mp[adj[temp][i]]==0)
//             {
//                 q.push(adj[temp][i]);
//                 mp[adj[temp][i]]=1;
//             }
//         }
//         cout<<temp<<" ";
        
//     }
//     cout<<endl;
// }
// void dfs(vector<ll> adj[],ll node)
// {
// 
//     visited[node] = 1;
//     for(int i=0;i<adj[node].size();i++)
//     {
//         if(visited[adj[node][i]]==0)
//         {
//             dfs(adj,adj[node][i]);
//         }
//     }
// }

ll firstDivisior(ll n){
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return i;
        }
    }
    return n;
    
}
bool isPallindrom(string s){
    ll i=0,j=s.size()-1;
    while(i<=j){
        if(s[i]==s[j]){
            i++;
            j--;
        }
        else{
            return false;
        }
    }
    return true;
}
void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    ll temp1,temp2;
    if(c%b==0){
        temp1 = c/b;
    }
    else{
        temp1=c/b;
        temp1++;
    }
    if(a%d==0){
        temp2 = a/d;
    }
    else{
        temp2=a/d;
        temp2++;
    }
    cout<<(temp1<=temp2?"Yes":"No")<<endl;
}

int main()
{
    fio;
    int tt=1;
    // cin>>tt;
    while(tt--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cmath>

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

typedef double D;
const D EPS = 1e-8;
const D INF = 1e10;
const D PI = M_PI;

struct P {
    D x, y;
    P(D xs, D ys) : x(xs), y(ys) { }
    P() { }
};
P operator +(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
P operator *(P p, D s) { return P(p.x * s, p.y * s); }

D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }
D norm(P p) { return inp(p, p); }
D abs(P p) { return sqrt(norm(p)); }
bool eq(P a, P b) { return abs(a - b) < EPS; }
D arg(P p) { return atan2(p.y, p.x); }
P rot90(P p) {
    return P(-p.y, p.x);
}
P rot(P p, D radian) {
    P q;
    q.x = cos(radian)*p.x - sin(radian)*p.y;
    q.y = sin(radian)*p.x + cos(radian)*p.y;
    return q;
}
struct L : vector<P> {
    P a, b;
    L(P as, P bs) : a(as), b(bs) { }
};
P projection(L l, P p) { // ??卒???l???????????????p?????????
    P a = l.b - l.a;
    P b = p - l.a;
    D t = inp(b, a) / norm(a);
    return l.a + a * t;
}
P reflection(L l, P p) { // ??卒???l???????????????p???????属?
    return p + (projection(l, p) - p) * 2;
}
int ccw(P a, P b, P c) {
    b = b - a; c = c - a;

    // a - b - c ????????????????????即???
    if(outp(b, c) > EPS)  return +1; // ???????即???????
    if(outp(b, c) < -EPS) return -1; // ????即???????

    // a - b - c ?????卒??????????????其??即???
    if(inp(b, c) < 0)     return +2; // c - a - b
    if(norm(b) < norm(c)) return -2; // a - b - c
    return 0;                        // a - c - b
}
bool iSS(L s, L t) { // ????????????
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
        ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
bool iSP(L s, P p) {
    return ccw(s.a, s.b, p) == 0;
}
D dSP(L s, P p) {
    P r = projection(s, p);
    if(iSP(s, r)) return abs(r - p);
    return min(abs(s.a - p), abs(s.b - p));
}
D dSS(L s, L t) {
    if(iSS(s, t)) return 0;
    return min(min(dSP(s, t.a), dSP(s, t.b)),
            min(dSP(t, s.a), dSP(t, s.b)));
}
/* ?????????????????即??????iSS(s,t)????蔵???????????????即 */
P cLL(L l, L m) {
    D d = outp(m.b - m.a, l.b - l.a);
    return l.a + (l.b - l.a) * outp(m.b - m.a, m.b - l.a) * (1.0 / d);
}

typedef vector<P> Poly;
P at(const Poly &ps, int i) { return ps[i % ps.size()]; }
D polyArea(const Poly &ps) {
    D res = 0.0;
    for(int i = 0; i < (int)ps.size(); i++) {
        res += outp(at(ps, i), at(ps, i + 1));
    }
    return res / 2.0;
}
struct C {
    P p; D r;
    C(P ps, D rs) : p(ps), r(rs) { }
    C() { }
};

int main() {
    int N; scanf(" %d", &N);
    Poly ps(N);
    for(int i = 0; i < N; i++) {
        scanf(" %lf %lf", &ps[i].x, &ps[i].y);
    }
    int k = 0;
    int f = 1;
    for(int i = 0; i < N; i++) {
        int ks = ccw(at(ps, i), at(ps, i + 1), at(ps, i + 2));
        if(ks == 1 || ks == -1) {
            if(k == 0) k = ks;
            else if(k != ks) f = 0;
        }
    }
    cout << f << endl;
}

Measured memory_bytes: 1240
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;

	auto is_palindrome = [](string s) {
		int n = s.length();
		
		for(int i = 0; i < n / 2; i++) {
			if(s[i] != s[n - 1 - i]) return false;
		}
		return true;
	};

	int n = s.length();

	if(is_palindrome(s) && is_palindrome(s.substr(0, (n-3)/2 + 1)) && is_palindrome(s.substr((n+1)/2, n-(n+1)/2)) ) cout << "Yes";
	else cout << "No";


	


	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
        const int MAX = 10;
        int l[MAX];
        int v1, v2;
        int sumL;

        while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
                                 &l[0], &l[1], &l[2], &l[3],
                                 &l[4], &l[5], &l[6], &l[7],
                                 &l[8], &l[9], &v1, &v2) != EOF) {
                sumL = 0;
                for (int i = 0; i < MAX; i++) {
                        sumL += l[i];
                }
                float l1 = v1 * ((float)sumL / (v1 + v2));
                for (int i = 0; i < MAX; i++) {
                        l1 -= l[i];
                        if (l1 <= 0.0) {
                                printf("%d\n", i+1);
                                break;
                        }
                }
        }

        return 0;
}

Measured memory_bytes: 2580
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string s; cin >> s;
    for(int i = 0; i < 3; i++) {
        if(s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
from collections import deque

n, q = map(int, input().split())
name = deque()
time = deque()
for i in range(n):
    p, t = input().split(" ")
    name.append(p)
    time.append(int(t))

fin_time = 0
while (time):
    temp_time = time.popleft()
    temp_name = name.popleft()
    fin_time += min(q, temp_time)
    if q >= temp_time:
        print(temp_name + ' ' + str(fin_time))
    else:
        temp_time -= q
        time.append(temp_time)
        name.append(temp_name)


Measured memory_bytes: 9724
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a;
    cin >> a ;
    //*/
    
    //*
    vector<int> vec(4);
    //cin >> a.at(0) >> a.at(1) >> a.at(2) ;
    
    vec.at(0) = a / 1 % 10 ;
    vec.at(1) = a / 10 % 10 ;
    vec.at(2) = a / 100 % 10 ;
    vec.at(3) = a / 1000 % 10 ;
    
    //sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( ( vec.at(0) == vec.at(1) && vec.at(1) == vec.at(2) ) || ( vec.at(3) == vec.at(2) && vec.at(1) == vec.at(2) ) ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //*/
    
    //cout << b * 2 - a << endl;

    return 0; 
}


Measured memory_bytes: 3612
function watering(h)
    if length(h) == 1 return h[1] end
    if length(h) == 0 return 0 end
    m, idx = findmin(h)
    cnt = m
    cnt += watering(h[1:idx-1] .-= m)
    cnt += watering(h[idx+1:length(h)] .-= m)
    return cnt
end

function solve()
    N = parse(Int, readline())
    h = parse.(Int, split(readline()))
    println(watering(h))
end

solve()


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll t1, t2; cin >> t1 >> t2;
  ll a1, a2; cin >> a1 >> a2;
  ll b1, b2; cin >> b1 >> b2;
  if(a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2) {
    cout << "infinity" << endl;
    return 0;
  }

  ll diff1 = t1 * a1 - t1 * b1;
  ll diff2 = t1 * a1 + t2 * a2 - t1 * b1 - t2 * b2;
  ll cnt = 0;
  if(diff1 > 0 == diff2 > 0) {
    cout << 0 << endl;
    return 0;
  } else {
    cnt = 1;
  }

  if(diff1 < 0) {
    if((-diff1) % diff2 == 0) {
      cnt--;
    }
    cnt += (-diff1) / diff2 * 2;
  } else if(diff1 > 0) {
    if(diff1 % (-diff2) == 0) {
      cnt--;
    }
    cnt += diff1 / (-diff2) * 2;
  }
  cout << cnt << endl;
}


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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    string str;
    int k;
    in >> str;
    in >> k;
    for (int i = 0; i < str.size(); i++) {
      char c = str[i] - 'a';
      if (i + 1 == str.size()) {
        c += k % 26;
      } else {
        if (!c) continue;
        int add = min(k, 26 - c);
        if((c + add) % 26 > c) {
          continue;
        }
        k -= add;
        c += add;
      }
      c %= 26;
      str[i] = c + 'a';
    }
    out << str;
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll X, Y;
    cin >> X >> Y;
    if(X % Y == 0) {
        cout << -1 << endl;
        return 0;
    }
    for(ll i = X; i <= 1e18; i += X) {
        if(i % Y != 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
// import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      int d = scanner.nextInt();
      int n = scanner.nextInt();
      int ans = solve(d, n);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
  
  private static int solve(int d, int n) {
    // n = 100がコーナーケース（罠）
    // d = 0の時を考える。ちょうど0回割り切れる＝割り切れないだが、
    // 100で割り切れない100番目に小さい数は101
    if (n == 100) n++;
    for (int i = 0; i < d; i++) n *= 100;
    return n;
  }
}


Measured memory_bytes: 35676
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)



int main() {
  int h, w;
  char s = 'A';
  cin >> h >> w;
  FOR(i, 0, h) {
    FOR(k, 0, w) {
      string in;
      cin >> in;
      if (in == "snuke")
        cout << (char)(s + k) << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 256
# coding :utf-8
N=int(input())

F=[]
P=[]

table = [2**i for i in range(10)]
#print(table)

for i in range(N):
    lis = list(map(int, input().split()))
    F.append(lis)
#print(F)
for i in range(N):
    lis = list(map(int, input().split()))
    P.append(lis)
#print(P)

maxx=-1000000000001

for i in range(1,1024):
    total=0
    for j in range(N):
        n=0
        for k in range(10):
            n +=(1 if i&table[k] !=0 else 0)*F[j][k]
        total += P[j][n]
    if total >maxx:
        maxx= total
print(maxx)

Measured memory_bytes: 3064
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline


n,k=map(int,input().split())
x=[int(i) for i in input().split()]
ans=10**9
# 7 3
# -20 -10 -5 1 12 20 30
for left in range(n-k+1):
    if x[left+k-1]<=0:
        ans=min(ans,abs(0-x[left+k-1])+abs(x[left+k-1]-x[left]))
    elif x[left]<0<x[left+k-1]:
        dis1=min(abs(x[left]),abs(x[left+k-1]))
        dis2=max(abs(x[left]),abs(x[left+k-1]))
        ans=min(ans,dis1*2+dis2)
    else:
        ans=min(ans,x[left]+abs(x[left+k-1]-x[left]))
print(ans)

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

int main() {
  
  int n;
  cin >> n;
  int total = 0;
  
  total = total + (n -(n/2));
  
  int ans = 0;
  int b = n - 1;
  
  for(int i = 1; i < b; i++){
    ans = ans + (n - 1) / i;
  }
  
  cout << ans + 1 << endl;

}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main(){
	ll n, k;
	cin >> n >> k;
	vll v(n);
	vin(v);
	ll ans = 0;
	rep(i, 0, min(n, k) + 1)rep(j, 0, i + 1){
		priority_queue<ll, vll, greater<ll>> que;
		rep(l, 0, j) que.push(v.at(l));
		rep(l, 0, i - j) que.push(v.at(n - 1 - l));
		rep(l, 0, k - i) if(que.size() && que.top() < 0) que.pop();
		ll sum = 0;
		while(que.size()){
			sum += que.top();
			que.pop();
		}
		chmax(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())

ans = [0]*(n-1)

for i in range(n):
  for j in range(i+1, n):
    res = min(j-i, abs(x-1-i)+1+abs(y-1-j))
    ans[res-1] += 1

for i in ans:
  print(i)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll a, b;
        cin >> a >> b;
      	cout << (b + a - 3) / (a - 1); 
    }
    return 0;
}


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


int main() {
    /*ll S; cin >> S;
    ll h = 1;
    ll w = S;
    if(S > 1000000000){
        for(ll i = 5000000000; i > 0; i--){
            //cout << i << endl;
            if(S % i == 0) {h = i; w = S/i; break;}
        }
    }
    cout << 0 << " " << 0 << " " << w << " " << 0 << " " << 0 << " " <<  h << endl;
    */
    double W, H, x, y; cin >> W >> H >> x >> y;
    cout << (W*H)/2 << " ";
    if(x == W/2 && y == H/2) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string.h>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int main()
{
  char s[1000];
  int n = 0;
  int w = 0;
  std::cin >> s >> w;
  while(n<strlen(s)){
     std::cout << s[n];
     n = n + w;
  }
  std::cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
ll block=1300;
void fastio()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
struct Query
{
	ll l;
	ll r;
	ll i;
};
Query Q[500005];
ll ar[500005];
ll check[500005];
ll ans[500005];
ll cnt=0;
bool comp(Query a,Query b){
    if(a.l/block!=b.l/block)
        return a.l<b.l;
    return a.l/block % 2 ? a.r<b.r:a.r>b.r;
}
void add(ll pos)
{
	check[ar[pos]]++;
	if(check[ar[pos]]==1)
	cnt++;
}
void remove(ll pos)
{
	check[ar[pos]]--;
	if(check[ar[pos]]==0)
	cnt--;
}
int main() {
	fastio();
	ll n,x,y,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	cin>>ar[i];
	
	for(int i=0;i<m;i++){
		cin>>x>>y;
		Q[i].i=i;
		Q[i].l=--x;
		Q[i].r=--y;
	}

	sort(Q,Q+m,comp);
	ll cur_l=0;
	ll cur_r=-1;
	for(int i=0;i<m;i++)
	{
	ll L=Q[i].l;
	ll R=Q[i].r;
	while(cur_l>L)
	add(cur_l-1),cur_l--;
	
	while(cur_r<R)
	add(cur_r+1),cur_r++;
	
	while(cur_l<L)
	remove(cur_l),cur_l++;
	
	while(cur_r>R)
	remove(cur_r),cur_r--;
	
	ans[Q[i].i]=cnt;
	}
	for(int i=0;i<m;i++)
	cout<<ans[i]<<'\n';

	
	return 0;
}

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

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

int main()
{
    int A, B;
    cin >> A >> B;
    if(A < 1 || 9 < A || B < 1 || 9 < B){
        cout << "-1" << endl;
    }else{
        cout << A * B << endl;
    }
}

Measured memory_bytes: 256
/*input
5
5 3 2 4 1
*/
fn main() {
    let mut input = format!("");
    std::io::stdin().read_line(&mut input).expect("");
    input = format!("");
    std::io::stdin().read_line(&mut input).expect("");
    let mut v: Vec<u8> = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    let mut temp: u8;
    let mut step: u16 = 0;
    let mut sorted: bool;
    let mut first: bool = true;
    loop {
        sorted = true;
        for i in 0..v.len() - 1 {
            if v[i] > v[i + 1] {
                sorted = false;
                temp = v[i + 1];
                v[i + 1] = v[i];
                v[i] = temp;
                step = step + 1;
            }
        }
        if sorted {
            break;
        }
    }
    println!(
        "{}",
        v.iter().fold(format!(""), |a, &b| a.to_string()
            + if !first {
                " "
            } else {
                first = false;
                ""
            }
            + &b.to_string())
    );
    println!("{}", step);
}



Measured memory_bytes: 5032
# coding: utf-8
# Your code here!

from collections import deque

N = int(input())
a = deque(list(map(int,input().split())))
tmp = 0
tmp_a = []
length = -1
max_len = 0

for i in range(len(a)):
    tmp = a.popleft()
    if tmp_a == [] or tmp_a[-1] >= tmp:
        length += 1
    else:
        length = 0
    if length > max_len:
            max_len = length
    tmp_a.append(tmp)
print(max_len)


Measured memory_bytes: 14636
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int no; char delim; string blood;
    int A = 0, B = 0, AB = 0, O = 0;
    while (cin >> no >> delim >> blood) {
        if (blood == "A")  A++;  else
        if (blood == "B")  B++;  else
        if (blood == "AB") AB++; else
        if (blood == "O")  O++;
    }
    cout << A << endl << B << endl << AB << endl << O << endl;
    return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner stdIn=new Scanner(System.in);
        int x=stdIn.nextInt();
        int y=stdIn.nextInt();
        if(x>y){
            System.out.println("a > b");
        }
        else if(x<y){
            System.out.println("a < b");
        }
        else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26412
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<numeric>
#include<cmath>
#include<stdio.h>

using std::cout;
using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::sin;

#define INF 999999999
#define MOD 1000000007
#define PI 3.141592653589793

using ulli = unsigned long long int;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int a, b, n;
pair<int, int> s;
int grid[17][17];

int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
    while(1){
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        for(int i = 0; i <= a; i++){
            for(int j = 0; j <= b; j++){
                grid[i][j]=0;
            }
        }
        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> s.first >> s.second;
            grid[s.first][s.second] = -1;
        }
        for(int i = 1; i <= a; i++){
            for(int j = 1; j <= b; j++){
                if(grid[i][j] == -1){
                    dbug(i)dbug(j)dbug(grid[i][j])dbugln;
                    continue;
                }
                if(i == 1 && j == 1){
                    grid[i][j] = 1;
                    dbug(i)dbug(j)dbug(grid[i][j])dbugln;
                    continue;
                }
                if(grid[i-1][j] == -1 && grid[i][j-1] == -1){
                    grid[i][j] = 0;
                }else if(grid[i-1][j] == -1){
                    grid[i][j] = grid[i][j-1];
                }else if(grid[i][j-1] == -1){
                    grid[i][j] = grid[i-1][j];
                }else{
                    grid[i][j] = grid[i][j-1] + grid[i-1][j];
                }
                dbug(i)dbug(j)dbug(grid[i][j])dbugln;
            }
        }
        cout << grid[a][b] << '\n';
    }
    return 0;
}
/*
5 4
3
2 2
2 3
4 2
5 4
3
2 2
2 3
4 2
0 0

*/


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using i64 = long long int;

using P = pair<i64, i64>;

i64 gcd(i64 a, i64 b){
    //
    // Euclidean Algorithm (かっこいい) O(logN)
    // i64 a, b: GCDを求める数 a > b を仮定している
    //
    if(a % b == 0) return b;
    else return gcd(b, a % b);
}

map<i64, i64> prime_factorize(i64 n){
    // 
    // ひたすら割るやつ O(n^(1/2))
    // i64 n : 素因数を求める数
    // map<i64, i64> は range-based for を使うと楽(C++11~?)
    //
    map<i64, i64> mp;
    for(i64 i = 2;  i * i <= n; ++i){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

int main(){
    i64 a, b;
    cin >> a >> b;
    i64 g = gcd(a, b);
    auto factors = prime_factorize(g);
    cout << factors.size() + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct edge {
  int a;
  int b;
  int weight;
};
int *ufp, *ufr;
struct edge *ed;

void qsort1(int, int);
int UF_find(int);
void UF_union(int, int);
int Kruskal(int, int);

int main(void)
{
  int i, j, v, e, s, t, w, cost;
  scanf("%d %d", &v, &e);
  ufp = (int*)malloc(sizeof(int) * v);
  ufr = (int*)malloc(sizeof(int) * v);
  ed = (struct edge*)malloc(sizeof(struct edge) * e);
  for (i = 0; i < v; i++) {
    ufp[i] = i;
    ufr[i] = 0;
  }
  for (i = 0; i < e; i++) {
    scanf("%d %d %d", &s, &t, &w);
    ed[i].weight = w;
    ed[i].a = s;
    ed[i].b = t;
  }
  cost = Kruskal(v, e);
  printf("%d\n", cost);
  free(ufp);
  free(ufr);
  free(ed);
}

void qsort1(int left, int right)
{
  int pivot = ed[(left + right) / 2].weight, i = left, j = right;
  if (i >= j) return;
  do {
    while (ed[i].weight < pivot) i++;
    while (ed[j].weight > pivot) j--;
    if (i <= j) {
      struct edge temp = ed[i];
      ed[i] = ed[j];
      ed[j] = temp;
      i++;
      j--;
    }
  } while (i <= j);
  qsort1(left, j);
  qsort1(i, right);
}

int UF_find(int a)
{
  if (ufp[a] == a) return a;
  else {
    ufp[a] = UF_find(ufp[a]);
    return ufp[a];
  }
}

void UF_union(int a, int b)
{
  if (ufr[a] < ufr[b]) ufp[a] = b;
  else {
    ufp[b] = a;
    if (ufr[a] == ufr[b]) ufr[a]++;
  }
}

int Kruskal(int size, int esize)
{
  int i, cost = 0;
  qsort1(0, esize - 1);
  for (i = 0; i < esize; i++) {
    int ea = UF_find(ed[i].a), eb = UF_find(ed[i].b);
    if (ea != eb) {
      UF_union(ea, eb);
      cost += ed[i].weight;
    }

  }
  return cost;
}


Measured memory_bytes: 2872
var
i,t,x:longint;
s:ansistring;
begin
readln(s);
t:=length(s);
x:=0;
for i:=1 to length(s) do
  if s[i]='S' then inc(x)
    else if x>=1 then
      begin
        x:=x-1;
        t:=t-2;
      end;
writeln(t);
end.

Measured memory_bytes: 384
n, x, y = map(int, input().split()) 

ans = [0] * n
for i in range(1,n):
    for j in range(i+1, n+1):
        r1 = j-i
        r2 = abs(x-i) + 1 + abs(j-y)
        r3 = abs(y-i) + 1 + abs(j-x)
        ans[min(r1,r2,r3)] += 1

for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 3444
object Main {
  def main(args: Array[String]): Unit = {
    val numbers = io.StdIn.readLine().split(" ")
    val dice = io.StdIn.readLine().foldLeft(Dice()) { case (d, c) => d.rotate(Direction(c)) }
    println(numbers(dice.upSide.index))
  }

  sealed trait Sides {
    def index: Int = this match {
      case Sides.One   => 0
      case Sides.Two   => 1
      case Sides.Three => 2
      case Sides.Four  => 3
      case Sides.Five  => 4
      case Sides.Six   => 5
    }

    def unary_! : Sides = this match {
      case Sides.One   => Sides.Six
      case Sides.Two   => Sides.Five
      case Sides.Three => Sides.Four
      case Sides.Four  => Sides.Three
      case Sides.Five  => Sides.Two
      case Sides.Six   => Sides.One
    }
  }
  object Sides {
    case object One extends Sides
    case object Two extends Sides
    case object Three extends Sides
    case object Four extends Sides
    case object Five extends Sides
    case object Six extends Sides
  }

  case class Dice(upSide: Sides, northSide: Sides, eastSide: Sides) {
    def downSide: Sides = !upSide
    def southSide: Sides = !northSide
    def westSide: Sides = !eastSide

    def rotate(direction: Direction): Dice = direction match {
      case Direction.North => Dice(southSide, upSide, eastSide)
      case Direction.South => Dice(northSide, downSide, eastSide)
      case Direction.East => Dice(westSide, northSide, upSide)
      case Direction.West => Dice(eastSide, northSide, downSide)
    }
  }
  object Dice {
    import Sides._
    def apply(): Dice = Dice(One, Five, Three)
  }

  sealed trait Direction
  object Direction {
    case object North extends Direction
    case object South extends Direction
    case object East extends Direction
    case object West extends Direction

    def apply(c: Char): Direction = c match {
      case 'N' => North
      case 'S' => South
      case 'E' => East
      case 'W' => West
      case _ => throw new Exception
    }
  }
}

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

int main(){
  ll n,y;
  cin >>n >>y;
  rep(i,n+1){
    rep(j,n-i+1){
      int k = n-i-j;
      if(i*10000+j*5000+k*1000==y){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0; 
}

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

#define ll long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define viit vector<int>::iterator
#define MOD 1000000007
#define endl "\n"
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define repd(i, a, b) for (int i = (a); i >= (b); i--)
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int c[n+1][m+1];
    repe(i, 0, n) {
        c[i][0] = 0;
    }
    repe(i, 0, m) {
        c[0][i] = 0;
    }
    repe(i, 1, n) {
        repe(j, 1, m) {
            if (s[i-1] == t[j-1])
                c[i][j] = c[i-1][j-1] + 1;
            else
                c[i][j] = max(c[i-1][j], c[i][j-1]);
        }
    }
    string com = "";
    int i=n, j=m;
    while(i && j) {
        if (s[i-1] == t[j-1]) {
            com.push_back(s[i-1]);
            i--;j--;
        } else if (c[i][j-1] > c[i-1][j]) {
            j--;
        } else {
            i--;
        }
    }
    reverse(com.begin(), com.end());
    cout<<com;
    return 0;
}


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

namespace my {
/*汎用*/
template <typename T>
void input_vec(vector<T> &a, ll n) {
  if (!a.empty()) {
    cout << "error in input_vec" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  if (!a.empty()) {
    cout << "error in input_set" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

/*整数*/
ll gcd(ll a, ll b) {  // O( log(max(a,b)) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(max(a,b)) )
ll modinv(ll n, ll mod) {                               // O( log(max(n,mod)) )
  if (mod < 0 || my::gcd(n, mod) != 1) {
    cout << "error in modinv" << endl;
    exit(1);
  }
  n %= mod;
  if (n < 0) n += mod;
  ll a = mod, b = n, x = 1, y = 0;
  while (b != 0) {
    ll q = a / b, r = a % b;
    a = b;
    b = r;
    y -= q * x;
    swap(x, y);
  }
  y %= mod;
  if (y < 0) y += mod;
  return y;
}

bool is_prime(ll n) {  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
vector<pair<ll, ll>> prime_factorize(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}

/*union find*/
class unionfind {
 private:
  /*根のparの値は「-(その木の要素数)」とする*/
  ll n_;
  vector<ll> par;

  ll root(ll a) {  // O( log(n) )
    if (par.at(a) < 0)
      return a;
    else {
      par.at(a) = root(par.at(a));  //経路圧縮
      return par.at(a);
    }
  }

 public:
  unionfind(ll n) : n_(n), par(n, -1) {}  // O(n)

  void unite(ll a, ll b) {  // O( log(n) )
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    if (root(a) == root(b))
      return;
    else {
      ll ra = root(a), rb = root(b);
      if (-par.at(ra) < -par.at(rb)) swap(ra, rb);  //サイズによる併合
      par.at(ra) += par.at(rb);
      par.at(rb) = ra;
    }
  }

  bool is_same(ll a, ll b) {  // O( log(n) )
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    return root(a) == root(b);
  }

  ll size(ll a) {  // O( log(n) )
    assert(0 <= a && a < n_);
    return -par.at(root(a));
  }
};
}  // namespace my
////////////////////////////////////////////////

int main() {
  int n, m;
  cin >> n >> m;
  my::unionfind uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    uf.unite(--a, --b);
  }

  ll sizemax = 0;
  for (int i = 0; i < n; i++) {
    sizemax = max(sizemax, uf.size(i));
  }
  cout << sizemax << endl;
}

Measured memory_bytes: 4800
#include"bits/stdc++.h"
using namespace std;
int p[100001],parent[100001];
int findparent(int x)
{
	if(parent[x]!=x)
		parent[x]=findparent(parent[x]);
	return parent[x];
}
void unionset(int a,int b)
{
	if((a=findparent(a))==(b=findparent(b)))
		return ;
	parent[a]=b;
}
int main()
{
	int x,y;
	int i,j;
	int n,m;
	int ans=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&p[i+1]);
		parent[i+1]=i+1;
	}
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&x,&y);
		unionset(p[x],p[y]);
	}
	for(i=0;i<n;i++)
	{
		if(findparent(p[i+1])==findparent(i+1))
			ans++;
	}
	printf("%d",ans);
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<ll> a(n);
  int ma=0;
  rep(i,n){
    int A; cin>>A;
    a[i]=A;
    ma=max(ma,A);
  }
  int ng=0, ok=ma;
  while(ok-ng>1){
    ll mid=(ok+ng)/2;
    ll cnt=0;
    rep(i,n){
      cnt+=(a[i]+mid-1)/mid-1;
    }
    if(cnt<=k) ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
}


Measured memory_bytes: 4744
import sys


def main():
    n, m = map(int, sys.stdin.readline().split())
    g = [[] for i in range(n)]
    for i in range(m):
        l, r, d = map(int, sys.stdin.readline().split())
        g[l - 1].append((r - 1, d))
        g[r - 1].append((l - 1, -d))
    dis = [0] * n
    visited = [False] * n
    for i in range(n):
        if visited[i]:
            continue
        stack = list([i])
        visited[i] = True
        while len(stack):
            v = stack[-1]
            stack.pop()
            for u, d in g[v]:
                if not visited[u]:
                    dis[u] = dis[v] + d
                    stack.append(u)
                    visited[u] = True
    for v in range(n):
        for u, d in g[v]:
            if dis[v] + d != dis[u]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 66692
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
ll multiply(ll x,ll y){
    return ((x%mod)*(y%mod))%mod;
}
ll sum(ll x,ll y){
    return (x%mod+y%mod)%mod;
}
void solve(){
    int n;
    cin>>n;
    cout<<(n?0:1);
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) 
	    solve();
	return 0; 
	
}


Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if( c >=a && c <=b ){
            System.out.print("Yes"); 
        }else{
            System.out.print("No");
        } 
    }
}



Measured memory_bytes: 23636
#include<bits/stdc++.h>
        #define ll long long
        #define f   first
        #define s   second
        #define pb          push_back
        #define mod        1000000007
        #define mod1       1000000009
        #define hell        998244353
        #define inf         1000000000000000000LL
        #define pi          3.14159265358979323
        #define N           1000005
        using namespace std;
        ll n,k,sum,q,res,m,val,ans;
        ll x,y;
        ll xx[]={1,0,-1,0};
        ll yy[]={0,1,0,-1};
        void solve()    
        {   ll a,b;
            cin>>n;
            vector<ll> v(n);
            for(int i=0;i<n;i++) cin>>v[i];
            sort(v.begin(), v.end(),greater<ll>());
            ll ans=v[0];
            int i=1;
            int j=1;
            ll cnt=0;
            for(int i=2;i<n;i++)
            {
                ans+=v[j];
                cnt++;
                if(cnt==2)
                {
                    cnt=0;
                    j++;
                }
            }
            cout<<ans; 

        }
        int main()
        {   ios_base::sync_with_stdio(false);
            cin.tie(0);cout.tie(0);
            ll t=1;
            //cin>>t;
            while(t--)
                solve();
            

        }            

Measured memory_bytes: 4736
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<complex>//real().imag().
#include<cctype>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<string>
#include<utility>
#include<iterator>
#define pii pair<int,int>
#define make_pair mp
using namespace std;
typedef long long ll;
const int mode=1e9+7;
ll n;
map<ll,ll> mp;
ll dp(ll a)
{
    if(mp[a]) return mp[a];
    else
        return mp[a]=(dp(a/2)+dp((a-1)/2)+dp((a-2)/2))%mode;
}
int main()
{
    mp[0]=1;
    mp[1]=2;
    cin>>n;
    cout<<dp(n)<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		s string
	)
	fmt.Scan(&s)

	for i := 0; i < len(s); i++ {
		si := s[i : i+1]
		if i%2 == 0 {
			if si == "L" {
				fmt.Println("No")
				return
			}
		} else {
			if si == "R" {
				fmt.Println("No")
				return
			}
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 1772
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include<math.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	int ans = 0, sum = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			sum++;
			if (sum > ans)ans = sum;
		}
		else sum = 0;
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  double T, A;
  cin >> T >> A;
  
  vector<double> H(N);
  double kion = 10000;
  int basho;
  for( int i = 0; i < N; i++ ){
    cin >> H.at(i);
    H.at(i) = T - ( H.at(i) * 0.006 );
    if( kion > abs( A - H.at(i) ) ){
      kion = abs( A - H.at(i) );
      basho = i+1;
    }
  }
  cout << basho << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, a, b) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << '\n';

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> cnt(n + 1);
  FI(i,1,q) {
    int x;
    scanf("%d", &x);
    ++cnt[x];
  }
  FI(i,1,n) {
    int x = q - cnt[i];
    if (x >= k) puts("No");
    else puts("Yes");
  }
}


Measured memory_bytes: 1024
#include <iostream>

int main(){
    int n;
    std::string s;
    std::cin >> n >> s;

    int count = 0;
    for(int i = 0; i <= n - 3; ++i){
        if("ABC" == s.substr(i, 3)){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 632