akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;


class UnionFind{
    vector<int> par;
    int all = 0;
    vector<int> siz;
    int treenum;

    public:UnionFind(int N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par.eb(i);
        for(int i = 0; i < N; i++) siz.eb(1);
        all = N;
        treenum = N;
    }

    public:int root(int x){
        if(par[x]==x) return x;
        else{
            par[x]=root(par[x]);
            return par[x];
        }
    }

    public:bool same(int x, int y){
        return root(x)==root(y);
    }

    public:void unite(int x, int y){
        if(same(x,y)) return;
        else{
            int rx=root(x);
            int ry=root(y);
            par[ry]=rx;
            siz[rx]=siz[rx]+siz[ry];
            siz[ry]=siz[rx];
            treenum--;
            return;
        }
    }

    public:int size(int x){
        siz[x]=siz[root(x)];
        return siz[x];
    }

    public:void sizall(){
        rep(i,all){
            siz[i] = siz[root(i)];
        }
    }

    public:int treenumber(){
        return treenum;
    }

    public:void add(){
        par.eb(all);
        siz.eb(1);
        all++;
        treenum++;
    }

    public:void del(int x){
        //xを木から外して単一ノードの木に分離する
        //子の検索にO(n)かける. UF木の弱点なので使用は推奨されない
        //根であれば繋ぎ直し、素集合としてみなさない.
        bool isroot=false;
        //あるノードの根であるかどうか.
        rep(i,all){
            if(root(i)==x) isroot=true;
        }
        if(!isroot){
            rep(i,all){
                if(par[i]==x){
                    par[i]=par[x];
                }
            }
            par[x]=x;
            return;
        }

        if(isroot){
            sizall();
            if(size(x)==1) return;
            rep(i,all){
                if(par[i]==x){
                    treenum++;
                    par[i]=i;
                }
            }
            return;
        }

    }

};


void solve(){

    ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        uf.unite(a-1, b-1);
    }
    ll ans = 0;
    rep(i,n){
        ans = max(ll(uf.size(i)),ll(ans));
    }
    cout << ans << endl;

}

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


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

int main() {
  int n, i, j, l;
  string s, ans = "-1";
  cin >> n >> s;
  vector<string> t(4);
  t[0] = "SS";
  t[1] = "SW";
  t[2] = "WS";
  t[3] = "WW";
  for (i = 0; i < n - 2; ++i) {
    for (j = 0; j < 4; ++j) {
      if (s[i + 1] == 'o') {
        if (t[j][i] == t[j][i + 1]) {
          t[j].push_back('S');
        } else {
          t[j].push_back('W');
        }
      } else {
        if (t[j][i] != t[j][i + 1]) {
          t[j].push_back('S');
        } else {
          t[j].push_back('W');
        }
      }
    }
  }
  for (j = 0; j < 4; ++j) {
    if (s[0] == 'o' && s[n - 1] == 'o') {
      if ((t[j][0] == t[j][n - 1] && t[j][1] == 'S' && t[j][n - 2] == 'S') ||
          (t[j][0] != t[j][n - 1] && t[j][1] == 'W' && t[j][n - 2] == 'W')) {
        ans = t[j];
        break;
      }
    } else if (s[0] == 'o' && s[n - 1] == 'x') {
      if ((t[j][0] == t[j][n - 1] && t[j][1] == 'S' && t[j][n - 2] == 'W') ||
          (t[j][0] != t[j][n - 1] && t[j][1] == 'W' && t[j][n - 2] == 'S')) {
        ans = t[j];
        break;
      }
    } else if (s[0] == 'x' && s[n - 1] == 'o') {
      if ((t[j][0] == t[j][n - 1] && t[j][1] == 'W' && t[j][n - 2] == 'S') ||
          (t[j][0] != t[j][n - 1] && t[j][1] == 'S' && t[j][n - 2] == 'W')) {
        ans = t[j];
        break;
      }
    } else {
      if ((t[j][0] == t[j][n - 1] && t[j][1] == 'W' && t[j][n - 2] == 'W') ||
          (t[j][0] != t[j][n - 1] && t[j][1] == 'S' && t[j][n - 2] == 'S')) {
        ans = t[j];
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1152
<?php
fscanf(STDIN,'%d',$length);
$line = trim(fgets(STDIN));
$arr = explode(' ',$line);

$times=0;
for($i=0;$i<$length;$i++) {
  $min=$i;
  for($j=$i;$j<$length;$j++) {
    if($arr[$j]<$arr[$min]){
      $min=$j;
    }
  }
  if($min==$i){
    continue;
  }
  $temp=$arr[$i];
  $arr[$i]=$arr[$min];
  $arr[$min]= $temp;
  $times++;
}
echo implode(' ',$arr),PHP_EOL,$times,PHP_EOL;


Measured memory_bytes: 9252
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        // 変数宣言
        final int MAX = 10;
        int ratingDispray;
        int ratingInternal;
        int joinContestCount;

        // 標準入力
        Scanner sc = new Scanner(System.in);
        joinContestCount = sc.nextInt();
        ratingDispray = sc.nextInt();

        sc.close();

        // 演算処理
        if( joinContestCount >= MAX ){
            ratingInternal = ratingDispray;
        }else{
            ratingInternal = ratingDispray + (100 * (10 - joinContestCount ));
        }

        // 出力
        System.out.println( ratingInternal );
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=200005;
int n,q,tot,f[N],fa[N],ans,K;
struct node{
	int x,y,v;
	friend bool operator < (node A,node B){
		return A.v<B.v;
	}
}e[N<<3];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
int find(int x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
signed main(){
	n=read(),q=read();
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=q;i++){
		int A=read()+1,B=read()+1,C=read();
		e[++tot]=(node){A,B,C};
		f[A]=min(f[A],C+1);
		f[B]=min(f[B],C+2);
	}
	for(int i=1;i<=n;i++) f[i%n+1]=min(f[i%n+1],f[i]+2);
	for(int i=1;i<=n;i++) f[i%n+1]=min(f[i%n+1],f[i]+2);
	for(int i=1;i<=n;i++) e[++tot]=(node){i,i%n+1,f[i]};
	sort(e+1,e+tot+1);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=tot;i++){
		int tx=find(e[i].x),ty=find(e[i].y);
		if(tx!=ty){
			fa[tx]=ty;
			ans+=e[i].v;
			K++;
			if(K==n-1) break;
		}
	}
	write(ans);
    return 0;
}

Measured memory_bytes: 14464
#include<iostream>
#include<string>
using namespace std;
int N;
int A[210];

int main(){
    cin>>N;
    for (int i=0;i<N;i++) cin>>A[i];
    int res=0;

while(true){
    bool exist_odd = false;
    for(int i=0;i<N;i++){
        if (A[i]%2 != 0) exist_odd = true;
    }
    if (exist_odd) break;

    for(int i=0;i<N;i++){
        A[i] /= 2;
    }
    res++;
}


cout<<res<<endl;


}

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

string S;
int N, cnt;

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

    cin >> N >> S;
    for(int i = 0; i < 1000; i++){
        int c[3] = {i / 100, (i / 10) % 10, i % 10};
        int f = 0;
        for(int j = 0; j < N; j++){
            if(S[j] == ('0' + c[f])) f++;
            if(f == 3) break;
        }
        if(f == 3) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

#define INF 1<<13
#define MIN(a,b) ((a)<(b)?(a):(b))

int main(void){
    int h,w;
    scanf("%d %d",&h,&w);
    char grid[h][w];
    char tmp[w+1];
    for(int i = 0;i < h;i++){
        scanf("%s",tmp);
        for(int cp = 0;cp < w;cp++)grid[i][cp] = tmp[cp];
    }
    int dp[h+1][w+1];
    for(int i = 0;i <= w;i++)dp[0][i] = INF;
    for(int i = 0;i <= h;i++)dp[i][0] = INF;
    dp[1][1] = 0;

    char cp_grid[h+1][w+1];
    for(int i = 0;i <= w;i++)cp_grid[0][i]='.';
    for(int i = 0;i <= h;i++)cp_grid[i][0]='.';
    for(int i = 1;i <= h;i++)for(int j = 1;j <= w;j++)cp_grid[i][j]=grid[i-1][j-1];

    for(int i = 1;i <= h;i++)for(int j = 1;j <= w;j++){
        if(i==1&&j==1){dp[i][j]=0;continue;}
        dp[i][j] = MIN(dp[i-1][j]+(cp_grid[i][j]=='#' && cp_grid[i-1][j]=='.'?1:0),dp[i][j-1]+(cp_grid[i][j]=='#' && cp_grid[i][j-1]=='.'?1:0));
    }
    printf("%d",dp[h][w]+(grid[0][0]=='#'?1:0));
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define all(v) v.begin(),v.end()
#define SZ(x) (int)x.size()
#define endl "\n"
#define thunder ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(15);
using namespace std;
typedef long long int ll;
#ifdef ONLINE_JUDGE
#define debug(...)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif
void debug_out() { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
vector<pair<int,int>>vp;
unordered_map<pair<int,int>,ll,HASH>mp;
ll dp(int weight,int index)
{
    if(weight<0||index<0)return 0;
    if(mp[{weight,index}])return mp[{weight,index}];
    ll ans1=0;
    if(vp[index].first<=weight)
    {
        ans1+=(max(ll(vp[index].second)+dp(weight-vp[index].first,index-1),dp(weight,index-1)));
    }
    else
        ans1=dp(weight,index-1);
    mp[{weight,index}]=ans1;
    return ans1;


}
int main()
{
    thunder
    auto start = chrono::high_resolution_clock::now();
    int n,w;cin>>n>>w;
    vp.resize(n);
    for(int i=0;i<n;++i)
    {
        cin>>vp[i].first>>vp[i].second;
    }

   cout<<dp(w,n-1);
   





   auto end = chrono::high_resolution_clock::now(); 
   double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
   time_taken *= 1e-9;
   debug(time_taken);
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i,k;
    cin>>n>>k;
    ll a[n],ans;
    forn(i,n) cin>>a[i];
    for(i=k;i<n;i++){
        if(a[i]>a[i-k]) cout<<"Yes" el;
        else cout<<"No" el;
    }

}

main()
{
//    fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 5164
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var vowel = new List<string>(){
            "a","i","u","e","o"
        };
        var c = Console.ReadLine();
        Console.WriteLine(vowel.Contains(c) ? "vowel" : "consonant");
    }
}


Measured memory_bytes: 13024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class BRGBBoxes {
public:
        int R,G,B,N;
void solve(std::istream& cin, std::ostream& cout) {
    cin >> R >> G >> B >> N;
    int res = 0;
    rep(r,0,N/R+1)rep(g,0,(N-r*R)/G+1)if((N-r*R - g*G)%B == 0)res ++;
    cout << res << endl;
}
};


#undef int
int main() {
	BRGBBoxes solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    ll h;
    cin>>h;
    int last;
    rep(i,0,45)
    {
        if((1ll<<i)&h)last=i;
    }
    cout<<(1ll<<(last+1))-1;

    return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    int maxx = 1;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
        maxx = max(maxx, sz[a]);
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    };
};*/

/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/



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

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

    sort(a.begin(), a.end());

    if (a[n-1]-a[0]>1)
    {
        cout<<"No"; return 0;
    }

    if (a[0]==a[n-1])
    {
        if (a[0]==n-1 || a[0]<=n/2) cout<<"Yes";
        else cout<<"No";
        return 0;
    }

    int unique = 0;
    for (int i = 0; i<n; i++) if (a[i]==a[0]) unique++;

    if (unique + 1<=a[n-1] && a[n-1]<=unique + (n - unique)/2) cout<<"Yes";
    else cout<<"No";





}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int N = 0; int Y = 0;
    scanf("%d %d", &N, &Y);

    int x = -1; int y = -1; int z = -1;

    for(int i = N; i >= 0; i--){
        for(int j = N - i; j >= 0; j--){
            if(Y == 10000 * i + 5000 * j + 1000 * (N - i - j) && N - i - j >= 0){
                x = i; y = j; z = N - i - j;
            }
        }
    }
    printf("%d %d %d\n", x, y, z);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  int n;
  int h[100005];
  int dp[100005];
  cin >> n;
  for(int i=0; i<n; i++) cin >> h[i];

  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);

  for(int i=2; i<n; i++) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Formula solver = new Formula();
        solver.solve(1, in, out);
        out.close();
    }

    static class Formula {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int[] arr = new int[s.length];
            for (int i = 0; i < s.length; i++) {
                arr[i] = s[i] - '0';
            }
            int mask = 1 << 4;
            for (int i = 1; i < mask; i++) {
                int sum = arr[0];
                String vals = "";
                for (int j = 1; j < s.length; j++) {
                    if ((i & (1 << j)) == 0) {
                        sum += arr[j];
                        vals += "+";
                    } else {
                        sum -= arr[j];
                        vals += "-";
                    }
                }
                if (sum == 7) {
                    StringBuilder ans = new StringBuilder();
                    int j = 1, k = 0;
                    ans.append(arr[0]);
                    while (j < s.length) {
                        ans.append(vals.charAt(k++));
                        ans.append(arr[j++]);
                    }
                    out.println(ans.toString() + "=7");
                    return;
                }
            }
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 21588
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

signed main() {
	string s; cin >> s;
	int K; cin >> K;
	rep(i, 0, s.size()) {
		if (s[i] == 'a')continue;
		if ('z' + 1 - s[i] <= K) {
			K -= 'z' + 1 - s[i];
			s[i] = 'a';
		}
	}
	s[s.size() - 1] = 'a' + (s[s.size() - 1] + K - 'a') % 26;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 576
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<set>
#include<queue>
#include<vector>
#include<cstdio>
#include<map>
#include<iomanip>
using namespace std;
char a[55][55];
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
      cin>>a[i][j];
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
      if(a[i][j]=='#')
        if(a[i+1][j]!='#'&&a[i-1][j]!='#'&&a[i][j+1]!='#'&&a[i][j-1]!='#'){
          cout<<"No";
          return 0;
        }
  cout<<"Yes";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        sc.close();
        int ans = 100;
        int cnt = 0;
        while (true) {
            if (a % ans == 0 && b % ans == 0) {
                cnt++;
            }
            if (cnt == k) {
                System.out.println(ans);
                return;
            }
            ans--;
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <algorithm>

template <class T>
auto Input()
{
	T t;
	std::cin >> t;
	return t;
}

template <class T>
auto Input(int n)
{
	T v(n);
	for (auto &e : v) std::cin >> e;
	return v;
}

int main()
{
	auto n = Input<int>();
	auto v = Input<std::vector<int>>(n);
	
	std::sort(v.begin(), v.end());
	double value = v[0];
	for (int i = 1; i < n; i++) {
		value += v[i];
		value /= 2;
	}
	
	std::cout << value << std::endl;
	
	return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)
#define int long long

signed main(){
    int N,K;
    cin >> N >> K;
    vector<int> H(N+1);
    for(int i=1;i<=N;++i) cin >> H[i];
    int dp[100100];
    fill(dp,dp+100100,INF);
    dp[1] = 0;
    for(int i=1;i<=N;++i){
        for(int k=1;k<=K;++k){
            if(i+k > N) break;
            dp[i+k] = min(dp[i+k],dp[i]+abs(H[i+k]-H[i]));
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    char s1[4], s2[4];

    scanf("%s", s1);
    scanf("%s", s2);

    if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]){
        puts("YES");
    } else {
        puts("NO");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll;
#pragma GCC optimize("O3")
#define pb push_back

int32_t main()  {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int a , b ; 
	cin >> a >> b;
	cout << a * b ;
}


Measured memory_bytes: 3652
import Data.List (tails)

main :: IO ()
main = getLine >>= print . solve

solve :: String -> Int
solve = maximum . map length . allACGTs

allACGTs :: String -> [String]
allACGTs = map (takeWhile isACGT) . tails

isACGT :: Char -> Bool
isACGT = flip elem "ACGT"


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  long long num = 0,f = 0;
  char F = S.at(0);
  for(int i = 0;i < S.size() && S.at(i)==F;i++) {
    f++;
  }

  long long l = 0;
  if(f == S.size()) {
    cout << (long long)S.size() * K / 2<< endl;
    return 0;
  }else {
    for(int i = S.size()-1;i >= 0 && S.at(i)==F;i--) {
      l++;
    }
    num += l / 2;
  }

  long long t = f + l;
  num += (t/2)*(K-1);
  num += f/2;

  long long n = 1;
  for(int i = f;i < S.size()-l-1;i++) {
    if(S.at(i) == S.at(i+1)) n++;
    else {
      num += n/2*K;
      n = 1;
    }
  }
  num += n/2*K;
  //cout << f << " " << l << " " << t << endl;

  cout << num << endl;


}




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

int main(void)
{
    char t[200001], s[200001];
    int i,sizet,count = 0;
    scanf("%s", t);
    scanf("%s", s);

    sizet = strlen(t);

    for (i = 0; i < sizet; i++)
    {
        if (t[i] != s[i])
        {
            count++;
        
        }

    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 2120
#include<stdio.h>
#include<string.h>

int main(){
	char* str1=new char[1024];
	char* tmp1=new char[1024];
	int num1=0;
	int num2=0;


	while(1){
		memset(str1,'\0',1024);
		memset(tmp1,'\0',1024);
		scanf("%s",str1);
		if(strcmp(str1,"-")==0){
			break;
		}
		scanf("%d",&num1);
		for(int i=0; i<num1; i++){
			scanf("%d",&num2);
			int num3=0;
			for(int t=num2; t<(int)strlen(str1); t++){
				tmp1[num3]=str1[t];
				num3++;
			}
			for(int t=0; t<num2; t++){
				tmp1[num3]=str1[t];
				num3++;
			}
			for(int t=0; t<(int)strlen(str1); t++){
				str1[t]=tmp1[t];
			}
		}
		printf("%s\n",tmp1);
	}
		delete [] str1;
		delete [] tmp1;
}



Measured memory_bytes: 2604
#include <bits/stdc++.h>
using namespace std;
int main(){
char A;
cin>>A;
if(A=='a'){
cout<<"vowel"<<endl;
}
else if(A=='i'){
cout<<"vowel"<<endl;
}
else if(A=='u'){
cout<<"vowel"<<endl;
}
else if(A=='e'){
cout<<"vowel"<<endl;
}
else if(A=='o'){
cout<<"vowel"<<endl;
}
else{
cout<<"consonant"<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}



void test_case()
{
    int n;
    cin>>n;

    if(n%2 == 1) {
        cout<<0<<endl;
        return;
    }

    int ans = 0;

    int temp = 10;

    while(n/temp > 0)  {
        ans+= n/temp;
        temp= temp *5;
    } 
    

    cout<<ans<<endl;
    
    
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

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

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(10 ** 7)


class SegmentTree:
    """
    引数：
        N: 処理する区間の長さ
        operator: モノイド演算 (max, min, __add__,ラムダ式,関数定義など)
        UNIT: 単位元
        a: 長さNの配列 a で初期化（a を与えない場合、単位元で初期化）
    注意: 内部的には 1-indexed
    """

    def __init__(self, N, operator, unit, a=None):
        self.op = operator
        self.UNIT = unit

        self.N0 = 2**(N-1).bit_length()
        self.tree = [self.UNIT]*(2*self.N0)
        if a != None:
            self.tree[self.N0:self.N0+N] = a[:]
            for k in range(self.N0-1, 0, -1):
                self.tree[k] = self.op(self.tree[2*k], self.tree[2*k+1])

    # a_k の値を x に更新
    def update(self, k, x):
        k += self.N0
        self.tree[k] = x
        k //= 2
        while k:
            self.tree[k] = self.op(self.tree[2*k], self.tree[2*k+1])
            k //= 2

    # 区間[l,r)をopでまとめる
    def query(self, l, r):
        L = l + self.N0
        R = r + self.N0
        s = self.UNIT
        while L < R:
            if R & 1:
                R -= 1
                s = self.op(self.tree[R], s)
            if L & 1:
                s = self.op(s, self.tree[L])
                L += 1
            L >>= 1
            R >>= 1
        return s

    def get(self, k):  # k番目の値を取得。query[k,k]と同じ
        return self.tree[k + self.N0]

    def all(self):
        return self.tree[1]


N = int(input())
S = input()
S = list(S)


def ope(x, y):
    r = []
    if type(x) is str and type(y) is str:
        r = [x, y]
    elif type(x) is str:
        r = [x] + y
    elif type(y) is str:
        r = x + [y]
    else:
        r = x + y

    return list(set(r))


seg = SegmentTree(N, ope, '-', S)

Q = int(input())

ans = []
for _ in range(Q):
    q, a, b = input().split()

    if q == '1':
        seg.update(int(a) - 1, b)
    else:
        r = seg.query(int(a) - 1, int(b))
        ans.append(str(len(r)-1))


print("\n".join(ans))


Measured memory_bytes: 172640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C;
    cin>>A>>B>>C;

        if((A==B&&B!=C&&C!=A)||(B==C&&C!=A&&A!=B)||(C==A&&A!=B&&B!=C))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());
  int s = 0, t = 0;
  rep(i, n) {
    if (i & 1) t += a[i];
    else s += a[i];
  }
  cout << s - t << endl;



  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define nl "\n"
ll n;
ll a[3002];
ll dp[3002][3002][2];
ll f(ll l,ll r,ll turn)
{
	if(l==r)
	{
		if(turn==0)
		{
			dp[l][r][turn] = a[l];
			return a[l];
		}
		else
		{
			dp[l][r][turn] = -a[r];
			return -a[l];
		}
	}
	if(l>r)
		return 0;
	if(l+1==r)
	{
		if(turn == 0)
			dp[l][r][turn] = max(a[l]-a[r],a[r]-a[l]);
		else
			dp[l][r][turn] = min(a[r]-a[l],a[l]-a[r]);
	}
	if(dp[l][r][turn] == -1)
	{
		if(turn == 0)
			dp[l][r][turn] = max(a[l]+f(l+1,r,1),a[r]+f(l,r-1,1));
		else
			dp[l][r][turn] = min(f(l+1,r,0)-a[l],f(l,r-1,0)-a[r]);
	}
	return dp[l][r][turn];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	ll i,j,k;
	ll ans=0;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<3002;i++)
		for(j=0;j<3002;j++)
			for(k=0;k<2;k++)
				dp[i][j][k]=-1;
	f(0,n-1,0);
	cout<<dp[0][n-1][0]<<nl;
	return 0;
}

Measured memory_bytes: 141184
l = input().split()
w = int(l[0])
h = int(l[1])
x = int(l[2])
y = int(l[3])
r = int(l[4])

if (x-r) >= 0 and (x+r) <= w and (y-r) >= 0 and (y+r) <= h:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5596
using System;
using System.IO;
using System.Linq;

namespace AtCoder.R170.C
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        private static void WriteAnswer(TextWriter tw, int answer)
        {
            tw.WriteLine(answer);
        }

        private static int Parse(TextReader tr)
        {
            var w = tr.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            if (w[1] == 0)
                return w[0];
            var a = tr.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            return Calc(w[0], a);
        }

        public static int Calc(int x, int[] a)
        {
            var answer = x;

            for (int i = 0; ; ++i)
            {
                if (!a.Contains(answer - i))
                    return answer - i;
                if (!a.Contains(answer + i))
                    return answer + i;
            }
        }
    }
}


Measured memory_bytes: 28328
#include <iostream>
#include <set>

using namespace std;
typedef long long ll;

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

    set<ll> s;
    multiset<ll> ms;
    for(ll i = 0; i < n; i++){
        ll a;
        cin >> a;
        s.insert(a);
        ms.insert(a);
    }

    if(s.size() == 1){
        if(0 == *s.begin()){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(s.size() == 2){
        ll a1 = *s.begin();
        if(a1 != 0 || n % 3 != 0 || ms.count(0) != n / 3){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else if(s.size() == 3){
        auto it = s.begin();
        ll a1 = *it++;
        ll a2 = *it++;
        ll a3 = *it;
        if(((a1 ^ a2 ^ a3) != 0) || (n % 3 != 0) ||
           (ms.count(a1) != n / 3) || (ms.count(a2) != n / 3)){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
int main(){
  int N, S;
  cin >> N >> S;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> dp(S + 1, 0);
  long long total = 0;
  for (int i = 0; i < N; i++){
    for (int j = S; j > A[i]; j--){
      dp[j] = (dp[j] + dp[j - A[i]]) % MOD;
    }
    if (A[i] <= S){
      dp[A[i]] = (dp[A[i]] + dp[0] + i + 1) % MOD;
    }
    total += dp[S] * (N - i) % MOD;
    dp[S] = 0;
    /*
    for (int j = 0; j < S; j++){
      cout << dp[j] << ' ';
    }
    cout << endl;
    */
  }
  cout << total % MOD;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<10&&b<10){
    cout<<a*b<<endl;
  }
  else
  {
    cout<<"-1"<<endl;
  }
  
}

Measured memory_bytes: 3624
#include<cstdio>

using namespace std;

int main(){
    char s[4];

    scanf("%s", s);

    int a[] = {0,0,0};

    for(int i = 0; i < 3; i++){

        if (s[i] == 'a') a[0]++;
        else if (s[i] == 'b') a[1]++;
        else if (s[i] == 'c') a[2]++;
    }

    for(int i = 0; i < 3; i++){
        if (a[i] == 0){
            puts("No");
            return 0;
        }
    }
    puts("Yes");

}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	string text;
	int a[100] = {0};
	bool flg = true;

	cin >> text;
	int len = text.length();
	for(int i = 0; i < len; i++){
		//cout << text[i] - '0' << endl;
		a[text[i] - '0'] = 1;
	}
	for(int i = 49; i < 49+26; i++){
		if(a[i] == 0){
			cout << char(i + '0') << endl;
			flg = false;
			break;
		}
	}
	if(flg) cout << "None" << endl;
	return 0;
}


Measured memory_bytes: 512
b1,b2,b3=map(int,input().split())

if b1==1 and b2==0 and b3==0:
    print('Close')

    
if b1==0 and b2==1 and b3==0:
    print('Close')

    
if b1==1 and b2==1 and b3==0:
    print('Open')

    
if b1==0 and b2==0 and b3==1:
    print('Open')

    
if b1==0 and b2==0 and b3==0:
    print('Close')



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;

    long double res = 0;
    for(int i = 0; i < n; ++i) {
        long double a = 0;
        cin >> a;
        res += 1 / a;
    }

    cout << 1 / res << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
P = [int(input()) for _ in range(N)]
Q = [0 for i in range(N+1)]
res = 100000000000000
for i in range(N):
	Q[P[i]] = Q[P[i] - 1] + 1
	res = min(res, N-Q[P[i]])
	
print(res)

Measured memory_bytes: 18960
import math
x=int(input())

def f(n):
    if n<2:
        return False
    elif n==2:
        return True
    elif n%2==0:
        return False
    sqn=int(math.sqrt(n))
    for i in range(3,sqn+5):
        if n%i==0:
            return False
    return True

def ans():
    for i in range(x,x*2+1):
        if f(i):
            print(i)
            return
ans()
    

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int BORDER = 3200;
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.nextLine());
		String s = scan.nextLine();
		if (a < BORDER) {
			System.out.println("red");
		} else {
			System.out.println(s);
		}
		scan.close();
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

int main() {
    string s; cin >> s;
    ll ans = 0;
    ll c = 0;
    rep(i, 0, sz(s)){
        if(s[i] == 'R') c++;
        else{
            chmax(ans, c);
            c = 0;
        }
    }
    chmax(ans, c);
    co(ans);
    
    return 0;
}




Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY (1<<30)
int n,M[MAX][MAX];

void dijkstra()
{
  int minv;
  int d[MAX],color[MAX];
  
  for(int i=0;i<n;i++)
    {
      d[i]=INFTY;
      color[i]=WHITE;
    }
  d[0] = 0;
  color[0]=GRAY;
  while(1)
    {
      minv=INFTY;
      int u=-1;
      for(int i=0;i<n;i++)
	{
	  if(minv > d[i] && color[i] !=BLACK)
	    {
	      u=i;
	      minv = d[i];
	    }
	}
      if(u==-1) break;
      color[u]=BLACK;
      for(int v=0;v<n;v++)
	{
	  if(color[v] != BLACK && M[u][v] != INFTY)
	    {
	      if(d[v] > d[u] + M[u][v] )
		{
		  d[v] = d[u]+M[u][v];
		  color[v]=GRAY;
		}
	    }
	}
    }
  for( int i=0;i<n;i++)
    {
      cout << i << " " << (d[i]==INFTY ? -1: d[i] ) << endl;
    }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
	{
	  M[i][j]=INFTY;
	}
    }
  int k,c,u,v;
  for(int i=0; i<n; i++)
    {
      cin >> u >> k;
      for(int j=0;j<k;j++)
	{
	  cin >> v >> c;
	  M[u][v]=c;
	}
    }
  dijkstra();
  return 0;
}

Measured memory_bytes: 3092
import math
a, b, C = map(float,input().split())
r = math.pi*C / 180 

S = math.sin(r)* a * b / 2
L = a + b + math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(r))
h = b * math.sin(r)

print("{0:.8f}".format(S))
print("{0:.8f}".format(L))
print("{0:.8f}".format(h))



Measured memory_bytes: 5696
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>


using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	int n,k;
	int a[100001];


	while(cin >> n >> k && !(n==0&&k==0)){
	for(int i = 0; i < n; i++)
		cin >> a[i];

	int ub,lb;
	ub=lb=0;
	ll cSum=0;
	for(int i = 0; i < k; i++){
		cSum += a[i];
	}
	ll maxSum = cSum;
	for(int i = 1; i <= n - k; i++){
		cSum -= a[i-1];
		cSum += a[i+k-1];
		maxSum = max(maxSum,cSum);
	}

	cout << maxSum << endl;
	}

	return 0;
}

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

using namespace std;

#define pb push_back
#define nl '\n'
#define pi 2.0*acos(0.0)
#define mod 1e9+7
#define FOR(i,j,n)    for(ll i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

int main(){
    ll n,ans = 0,gcd,r = 0,g = 0,b = 0,leftp,rightp,fixp,exclude = 0;
    string s;
    scanf("%lld", &n);
    cin>>s;

    FOR(i,0,n){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }
    ans = r * g * b;
    if(ans == 0) cout<< 0 <<nl;
    else{
        FOR(i,0,n){
            fixp = i;
            leftp = fixp - 1;
            while(leftp >= 0){
                rightp = fixp + (fixp - leftp);
                //cout<<leftp<<" "<<rightp<<endl;
                if(rightp >= n) break;
                if(s[i] != s[leftp] && s[i] != s[rightp] && s[leftp] != s[rightp]) exclude++;
                leftp--;
            }
        }
        cout<< ans - exclude <<nl;
    }
}


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

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

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

int main(){
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '1') {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();

        int strLength = line.length();

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i<strLength; i++) {
        	sb.append('x');
        }


        System.out.println(sb.toString());

	}

}

Measured memory_bytes: 23892
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
#include <set>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	string a; int n;
	cin >> a;
	n = a.size();

	sort(a.begin(), a.end());
	vector<int> arr;
	arr.push_back(0);
	char tmp = a[0];
	for (char p : a) {
		if (tmp == p) {
			++arr.back();
		}
		else {
			arr.push_back(1);
			tmp = p;
		}
	}

	int ans = n * (n - 1) / 2 + 1;
	for (int p : arr) {
		ans -= p * (p - 1) / 2;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	int H = sc.nextInt();
      int W= sc.nextInt();
      int h= sc.nextInt();
      int w= sc.nextInt();
		System.out.println((H-h)*(W-w));
		
    }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

int dp[101][101][301];

signed main() {
  int n, maxw;
  cin >> n >> maxw;

  vi w(n), v(n);
  rep(i, 0, n) cin >> w[i] >> v[i];

  int w0 = w[0];
  rep(i, 0, n) w[i] -= w0;

  rep(i, 0, n) rep(j, 0, i+1) rep(k, 0, 301) {
    chmax(dp[i+1][j][k], dp[i][j][k]);

    int ww = w0*j + k;
    if(ww <= maxw) {
      chmax(dp[i+1][j+1][k+w[i]], dp[i][j][k]+v[i]);
    }
  }

  int ans = 0;
  rep(j, 0, 101) rep(k, 0, 301) {
    int ww = w0*j + k;
    if(ww <= maxw) {
      chmax(ans, dp[n][j][k]);
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 22272