akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[][] ab = new int[2][m];
		for(int i=0;i<m;i++) {
			ab[0][i] = in.nextInt()-1;
			ab[1][i] = in.nextInt()-1;
		}
		int ans = 0;
		for(int i=0;i<m;i++) {
			int[] u = new int[n];
			for(int j=0;j<n;j++) {
				u[j] = j;
			}
			for(int j=0;j<m;j++) {
				if(i==j) continue;
				int a = ab[0][j];
				int b = ab[1][j];
				union(u,a,b);
			}
			int num = find(u,0);
			for(int j=1;j<n;j++) {
				if(find(u,j)!=num) {
					ans++;
					break;
				}
			}
		}
		System.out.println(ans);
		in.close();

	}
	
	public static void union(int[] u,int a,int b) {
		u[find(u,b)] = find(u,a);
	}
	
	public static int find(int[] u,int a) {
		if(a==u[a]) return a;
		else return u[a] = find(u,u[a]);
	}

}


Measured memory_bytes: 21844
import java.util.*;

class Main{
public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int a = sc.nextInt();
   int b = sc.nextInt();
   for (double price=0;price<200000;price++){
     int tax8 = (int)(price*0.08);
     int tax10 = (int)(price*0.1);
     if ((tax8 == a)&&(tax10 == b)){
        System.out.println((int)price);
        System.exit(0);
     }
   }
   System.out.println(-1);
}
}

Measured memory_bytes: 22996
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
using namespace std;
#define endl '\n'
#define M_PI 3.14159265358979323846

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long double x;
    cin >> x;
    cout <<  setprecision(10) <<x * M_PI * 2;
    return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define INF (1LL<<60)
typedef pair<int,int> P;

int main(){
    int h,w;
    cin >> h >> w;
    
    vector<string> s(h);

    rep(i,h){
        cin >> s[i];
    }
    h++;
    w++;
    vector<vector<int> > a(h,vector<int>(w,0));
    for(int i=0;i<h-2;i++){
        for(int j=0;j<w-2;j++){
            int b = 0;
            if(s[i][j]=='.'){
                b++;
            }
            if(s[i][j+1]=='.'){
                b++;
            }
            if(s[i+1][j]=='.'){
                b++;
            }
            if(s[i+1][j+1]=='.'){
                b++;
            }
            if(b%2==0){
                a[i+1][j+1] = 1;
            }
        }
    }
    vector<vector<int> > t(h,vector<int>(w+1,0));
	rep(i,w){
		t[0][i] = a[0][i];
    }
    for(int i = 1; i < h; i++){
		rep(j,w){
			if(a[i][j] == 1){
				t[i][j] = t[i-1][j] + 1;
			}else{
				t[i][j] = 0;
			}
    
        }
    }
    deque<P> deq;
	int ans = 0;
    rep(i,h){
		rep(j,w){
			if(deq.empty()){
				deq.push_back(P(t[i][j],j));
				continue;
			}
			P p = deq.back();
			if(p.first < t[i][j]){
				deq.push_back(P(t[i][j],j));
			}else if(p.first > t[i][j]){
				int pos;
				while(!deq.empty() && p.first > t[i][j]){
					ans = max(ans, (p.first+1) * (j - p.second+1));
                    pos = p.second;
					deq.pop_back();
					p = deq.back();
				}
				deq.push_back(P(t[i][j],pos));
			}
		}
	}

	cout << max(ans,max(h-1,w-1)) << "\n";
    return 0;
}

Measured memory_bytes: 43920
#include<iostream>

using namespace std;

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < n.size(); i++) {
    if (n[i] == '1') {
      n[i] = '9';
    } else if (n[i] == '9') {
      n[i] = '1';
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


void solve(string x, string y){
    int lx = x.length();
    int ly = y.length();
    int dp[1001][1001];
    for(int i = 0; i < 1001; i++){
        for(int j = 0; j < 1001; j++){
            dp[i][j] = 0;
        }
    }

    for(int i = 1; i <= lx; i++){
        for(int j = 1; j <= ly; j++){
            if(x[i-1] == y[j-1]){
                dp[i][j] = max(dp[i][j-1],dp[i-1][j-1]+1);
                dp[i][j] = max(dp[i][j],dp[i-1][j]);
            } else {
                dp[i][j] = max(dp[i][j-1],dp[i-1][j-1]);
                dp[i][j] = max(dp[i][j],dp[i-1][j]);
            }
        }
    }

    cout << dp[lx][ly] << endl;
}

int main(){
    int q;
    string x,y;
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> x >> y;
        solve(x,y);
    }

    return 0;

}


Measured memory_bytes: 7088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int st(int a,int b)
{
  return abs(a-b);
}
int cdt(int a,int b,int c)
{
  if (a<b&&b<c) return 0;
  if (a>b&&b>c) return 0;
  if (a<c&&c<b) return 2*(c-b);
  if (b<a&&a<c) return 2*(b-a);
  if (c<a&&a<b) return 2*(a-b);
  if (b<c&&c<a) return 2*(b-c);
  if (a==c) return -2*abs(b-a);
  return 0;
}
int N,A[100002],np,tc,dt;
int main()
{ 
  cin>>N;
  for (int i=1;i<=N;i++)
    cin>>A[i];
  for (int i=1;i<=N+1;i++)
  {
    tc+=st(np,A[i]);
    np=A[i];
  }
  for (int i=1;i<=N;i++)
  {
    cout<<tc+cdt(A[i-1],A[i],A[i+1])<<endl;
  }
  //system("pause");
  return 0;
}

Measured memory_bytes: 1664
import math

n, k = map(int, input().split())
res = 0

for i in range(1, n + 1):
    if i > k:
        res += 1 / n
    else:
        c = math.ceil(math.log(k / i, 2))
        res += (1 / n) * (0.5 ** c)

print(res)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int r;
    cin >> r;
    cout << r * 2 * M_PI << endl;


  
    return 0;
}



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

int main(){
    int n;
    cin>>n;
    int a,b;
    cin>>a;
    a--;
    for(int i=0;i<n-1;i++){
        cin>>b;
        if(a<b) b--;
        else if(a>b){
            cout<<"No";
            return 0;
        }
        a=b;
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s; cin >> s;
	vi dp(2);
	dp[0] = 1;
	rep(i, s.size()){
		vi next(2);
		rep(j, 2) rep(a, 2) rep(b, 2){
			if(a && b) continue;
			if(!j && a + b > s[i] - '0') continue;
			int nj = j || a + b < s[i] - '0';
			(next[nj] += dp[j]) %= mod;
		}
		dp = next;
	}
	cout << (dp[0] + dp[1]) % mod << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<char> s(n);
    rep(i, n) cin >> s[i];
    sort(all(s));
    s.erase(unique(all(s)), s.end());
    if (s.size() == 3) {
        put("Three");
    }
    else {
        put("Four");
    }
    
    return 0;
}

Measured memory_bytes: 3592
sx, sy, tx, ty = map(int, input().split())

xlen = tx - sx
ylen = ty - sy

ans1 = "U" * (ylen) + "R" * (xlen)
ans2 = "D" * (ylen) + "L" * (xlen)
ans3 = "L" + "U" * (ylen+1) + "R" * (xlen+1) + "D"
ans4 = "R" + "D" * (ylen+1) + "L" * (xlen+1) + "U"

print(ans1 + ans2 + ans3 + ans4)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}
int main() {
	int n,m; cin >> n >> m;
	vector<int> a(n),b(n),c(m),d(m);
	rep(i,n){
		cin >> a[i] >> b[i];
	}
	rep(i,m){
		cin >> c[i] >> d[i];
	}
	rep(i,n){
		int min;
		int index = 0;
		rep(j,m){
			int x = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if (j==0){
				min = x;
			}else{
				if (x < min){
					min = x;
					index = j;
				}
			}
		}
		cout << index+1 << endl;

	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
vi v1,v2;
ll dp[3001][3001]={};
string ks(string a, string b){

	string s="";
	rep(i,1,a.size()+1){
		rep(j,1,b.size()+1)
	if(a[i-1]==b[j-1]){
		//s+=a[i-1];
		dp[i][j]=1+dp[i-1][j-1];
	}
	else{
	 dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
	}
}//cout<<dp[a.size()][b.size()]<<" ";
ll i=a.size();
ll j=b.size();ll u=0;
while(i!=0 && j!=0){
if(dp[i][j]==dp[i-1][j-1]+1 && a[i-1]==b[j-1])	
{
s+=a[i-1];
u++;
i--;
j--;}
else if(dp[i][j]==dp[i][j-1])
j--;
else i--;
}
for(int i=s.size()-1;i>=0;i--)
cout<<s[i];
return s; 
}

int main(){
	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
      string s1,s2;
      
      cin>>s1>>s2;
      string h=ks(s1,s2);
      //cout<<h;
        return 0;}

Measured memory_bytes: 70656
var lines = [];
var  reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', function (line) {
    lines.push(line);
});

reader.on('close', function () {
    if (lines.length === 1) {
        var date_int = lines[0].replace(/\//g, '');
        if (date_int <= 20190430) {
            console.log('Heisei');
            return;
        }
    }
    console.log('TBD');
});

Measured memory_bytes: 7628
def main():
    n,q = map(int, input().split())
    tl = []
    que = []
    d = dict()
    for _ in range(n):
        s,t,x = map(int, input().split())
        tl.append((s-x,1,x))
        tl.append((t-x,0,x))
    for _ in range(q):
        t = int(input())
        tl.append((t,2))
    tl.sort()
    wor = set()
    wcur = 0
    cur = -1
    flg = 0
    for x in tl:
        if x[1] == 1:
            wcur += 1
            wor.add(x[2])
            if cur < 0 or x[2] < cur:
                cur = x[2]
                flg = 0
        elif x[1] == 0:
            wcur -= 1 
            wor.remove(x[2])
            if x[2] == cur:
                flg = 1
            if not wcur:
                cur = -1
                flg = 0
        else:
            if flg:
                cur = min(wor)
                flg = 0
            print(cur)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 87280
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define pa pair<int,int>
const int N=1e6+10;
const int mod=1e9+7;
using namespace std;

int main()
{   
   int n; cin>>n;
   vector<int> a(n);
   for(int i=0;i<n;++i) cin>>a[i];
   vector<int> b;
   while(!a.empty())
   {
      int ff=0;
      for(int i=(int)a.size()-1;i>=0;i--)
      {
         if(a[i]==i+1) 
         {
            b.pb(i+1); a.erase(a.begin()+i); ff=1;
            break;
         }
      }
      if(!ff) return 0*puts("-1");
   }
   reverse(b.begin(),b.end());
   for(auto e:b) printf("%d\n",e);
return 0;
}
/*
*/

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC148E
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Cin.Long();
            var solver = new Solver(n);

            Console.WriteLine(solver.Solve());
        }
    }

    class Solver
    {
        private long N;

        public Solver(long n)
        {
            N = n;
        }

        public IConvertible Solve()
        {
            if (N % 2 == 1)
            {
                return 0;
            }

            long ans = 0;
            long five = 5;
            for (int i = 1; i <= 25; i++)
            {
                ans += N / five / 2;
                five *= 5;
            }
            
            return ans;
        }
    }

    internal static class Cin
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(String());
        }

        public static int[] IArr()
        {
            return Split().Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(String());
        }

        public static long[] LArr()
        {
            return Split().Select(long.Parse).ToArray();
        }

        public static double Double()
        {
            return double.Parse(String());
        }

        public static double[] DArr()
        {
            return Split().Select(double.Parse).ToArray();
        }

        private static IEnumerable<String> Split()
        {
            return String().Split(' ');
        }
    }
}

Measured memory_bytes: 11092
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(void){
  int N,Q;
  int c[100000];
  int txd[100000][3];
  cin>>N;
  int box[100000];
  REP(i,N){
    cin>>c[i];
  }
  cin>>Q;
  REP(i,Q){
    cin>>txd[i][0]>>txd[i][1]>>txd[i][2];
  }

  REP(i,Q){
    if(txd[i][0]==1){
      box[txd[i][1]]+=txd[i][2];
      //cout << box[txd[i][1]] << endl;
      if(box[txd[i][1]]>c[txd[i][1]-1]){
         cout<<txd[i][1]<< '\n';
         return 0;
      }
    }
    else{
      box[txd[i][1]]-=txd[i][2];
      if(box[txd[i][1]]<0){
        cout << txd[i][1] << '\n';
        return 0;
      }
    }
    //REP(i, N) cout << box[i] << " ";
    //cout << endl;
  }
  cout << 0 << '\n';
  return 0;


}



Measured memory_bytes: 4280
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
	return 0;
}


Measured memory_bytes: 3624
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 4e5 + 111;
     
using namespace std;
 
int n, m, a[82][82], b[82][82], dp[82][82][13000], k = 6500;

void solve(){   
	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++)
			cin >> b[i][j];

	dp[1][1][a[1][1] - b[1][1] + k] = 1;
	dp[1][1][b[1][1] - a[1][1] + k] = 1;

	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			for (int x = -k; x <= k; x++){
				if (dp[i][j][x + k]){
					dp[i + 1][j][x + a[i + 1][j] - b[i + 1][j] + k] = 1;
					dp[i + 1][j][x + b[i + 1][j] - a[i + 1][j] + k] = 1;
					dp[i][j + 1][x + a[i][j + 1] - b[i][j + 1] + k] = 1;
					dp[i][j + 1][x + b[i][j + 1] - a[i][j + 1] + k] = 1;
				}
			}
		}
	}

	int ans = inf;

	for (int i = -k; i <= k; i++)
		if (dp[n][m][i + k] > 0)
			ans = min(ans, abs(i));

	cout << ans;
}
 
main(){
	int q;
    boost;
	    
	q = 1;
 
	while (q--){
		solve();
	}
}

Measured memory_bytes: 674944
h, w = map(int, input().split())
grid = [['.' for j in range(w + 2)]for i in range(h + 2)]
for i in range(h):
    line = list(input())
    grid[i + 1][1:w + 1] = line
direction =[[0, 1], [1, 0], [0, -1], [-1, 0]]
for i, line in enumerate(grid[1:h + 1][1:w + 1]):
    for j, dot in enumerate(line):
        if grid[i][j] == '.':
            continue
        for dire in direction:
            x = i + dire[0]
            y = j + dire[1]
            if grid[x][y] == '#':
                break
        else:
            print('No')
            exit()
else:
    print('Yes')

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define printjudge(cond) {if(cond) printf("Yes\n"); else printf("No\n");}
#define printans(ans) {printf("%d\n",(ans));}
#define intscan(x) {scanf("%d", &x);}
#define Ntimes(N) for(int i=0; i<N; i++)
#define min(x,y) (((x)<(y)) ? (x) : (y))
#define max(x,y) (((x)>(y)) ? (x) : (y))
typedef int* intarray;
typedef char* string;

int main(){
    int s, i=1;
    intscan(s);
    while(1){
        if(s==1 || s==2 || s==4) break;
        s = (s%2) ? 3*s+1 : s/2;
        i++;
    }
    printans(i+3);
    return 0;
}

Measured memory_bytes: 128
def d_worst_case(Q, R):
    import math
    ans = []
    for a, b in R:
        a, b = min(a, b), max(a, b)
        if a == b:
            ans.append(str(2 * a - 2))
        elif a + 1 == b:
            ans.append(str(2 * a - 2))
        else:
            c = int((a * b)**0.5)
            if c == (a * b)**0.5:
                c -= 1
            if c * (c + 1) >= a * b:
                ans.append(str(2 * c - 2))
            else:
                ans.append(str(2 * c - 1))
    return '\n'.join(ans)

Q = int(input())
R = [[int(i) for i in input().split()] for j in range(Q)]
print(d_worst_case(Q, R))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace  std;
const int N=1e9+7;
typedef long long ll;
int main()
{
      int n,k,m;
      cin>>n>>k>>m;
      if(k*m>=n)
         cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
int main(){
	cin>>n>>m;
	if(n>m) swap(n,m);
	if(n==1){
		if(m!=1) cout<<m-2<<endl;
		else cout<<1<<endl;
	}
	else{
		cout<<1LL*(n-2)*(m-2)<<endl;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }


void solveF() {

}

void solveE() {

}

void solveD() {

}

void solveC() {

}

void solveB() {

}

void solveA() {
	ll h, w;
	cin >> h >> w;
	cout << (h == 1 or w == 1 ? 1 : (h*w+1)/2)<< endl;
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) {
		solveA();
		//solveB();
		//solveC();
		//solveD();
		//solveE();
		//solveF();
	}


	return 0;
}


Measured memory_bytes: 3628
//lover~ crazy~
#include<bits/stdc++.h>
using namespace std;
struct request{
	int a,b;
}r[100005];
bool book[100005];
int n,m,ans;
bool cmp(request x,request y) {
	return x.b<y.b;
}
int main() {
    cin>>n>>m;
    for(int i=0;i<m;i++) cin>>r[i].a>>r[i].b;
    sort(r,r+m,cmp);
    for(int i=0;i<m;i++) {
    	bool k=0;
        for(int j=r[i].a;j<r[i].b;j++) 
        	if(book[j]) {k=1;break;}
        if(k==0) {
        	book[r[i].b-1]=1;
        	ans++;
 //       	cout<<r[i].b-1<<" "<<ans<<endl; 
		}
	}
	cout<<ans;
	return 0; 
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

Measured memory_bytes: 1152
from collections import Counter
from itertools import permutations
import sys
input = sys.stdin.buffer.readline
N, C = map(int, input().split())
D = [[int(x) for x in input().split()] for _ in range(C)]

cnt = [Counter() for _ in range(3)]

for i in range(N):
    c = [int(x)-1 for x in input().split()]
    for j in range(3):
        cnt[j].update(c[(3-(i+2)+j)%3::3])

ans = 1000*500*500+5
for p in permutations(range(C), 3):
    s = 0
    for j in range(3):
        for k, v in cnt[j].items():
            s += D[k][p[j]] * v
    ans = min(ans, s)

print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int r, d;
	array <long int, 15> x;
	cin >> r >> d>>x[0];
	for (int i = 1; i <= 10;i++) {
		x[i] = r * x[i - 1] - d;
		cout << x[i] << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();
    
    long ans = 0;
    for (int i = 1; i < n; i++) {
      ans += i;
    }
    
    System.out.println(ans);
  }
}


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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int x, y;
	int temp = 0;
	while (cin >> x >> y, x != 0 || y != 0) {
		if (x > y) {
			temp = y;
			y = x;
			x = temp;
		}
		cout << x <<" "<< y << endl;
	}
}



Measured memory_bytes: 2992
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <set>

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> H(N+1);
  vector<set<int> > G(N+1);
  for(int i=1; i<=N; i++) cin >> H[i];
  for(int i=1; i<=M; i++){
    int a,b;
    cin >> a >> b;
    G[a].insert(b);
    G[b].insert(a);
  }

  int ans = 0;
  for(int i=1; i<=N; i++){
    if(G[i].size() == 0){
      ans++;
      continue;
    }
    bool ok = true;
    for(auto &j: G[i]){
      if(H[i] <= H[j]) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
  
}


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

int main() {
  int a, b, c; cin >> a >> b >> c;
  int num = 0;
  num += a * 100;
  num += b * 10;
  num += c;
  if (num % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
# ABC088D - Grid Repainting
import sys
input = sys.stdin.readline

from collections import deque

def bfs() -> None:
    q = deque([(0, 0)])
    while q:
        x, y = q.popleft()
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy  # next x, y
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and dist[nx][ny] == 0:
                q.append((nx, ny))
                dist[nx][ny] = dist[x][y] + 1


def main():
    global H, W, S, dist, dxy
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    dist = [[0] * W for _ in range(H)]  # distance from (0, 0) to (x, y)
    dist[0][0] = 1
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    bfs()
    white, x = sum(s.count(".") for s in S), dist[-1][-1]
    ans = white - x if x else -1
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
  int d, n;
  cin >> d >> n;
  
  if(d == 0){
    if(n == 100) cout << 101 << endl;
    else cout << n << endl;
  }
  else if(d == 1){
    if(n == 100) cout << 10100 << endl;
    else cout << 100 * n << endl;
  }
  else{
    if(n == 100) cout << 1010000 << endl;
    else cout << 10000 * n << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

int main() {
  
    int k;
    cin >> k;
    for (int i=0;i<k;i++) {
        cout << "ACL";
    }
    cout << endl;

    return 0;
}


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

void solve(int n, int k) {
    vector<string> deck(n);
    for (int i = 0; i < n; ++i) {
        cin >> deck[i];
    }
    set<string> save;
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<string> p;
        for (int j = 0; j < n; ++j) {
            if (bit >> j & 1) p.push_back(deck[j]);
        }
        if (p.size() != k) continue;
        sort(p.begin(), p.end());
        do {
            string ans;
            for (int i = 0; i < k; ++i) {
                ans += p[i];
            }
            save.insert(ans);
        } while(next_permutation(p.begin(), p.end()));
    }
    cout << save.size() << endl;
}

int main() {
    while(true) {
        int n, k;
        cin >> n >> k;
        if (n == 0 && k == 0) break;
        else solve(n, k);
    }
    return 0;
}



Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  string S;
  cin >> S;
  if(S=="AAA"||S=="BBB")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <regex>
#include <math.h>
typedef long long ll;
using namespace std;


int main(void){
  int n,m;
  cin >> n >> m;
  ll ans = (n - m) * 100;
  ll bin = 1;
  for(ll i = 1;i <= m;i++){
    bin *= 2;
  }
  const ll s = 1900;
  ans += s * m;
  ans *= bin;
  cout << ans << endl;
}

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

int main()
{
    ll N;
    cin >> N ;
    ll A[N];
    ll count[N+1];
    ll others[N+1];
    ll all_num=0;
    for(int i=0;i<N;i++)cin >> A[i];
    for(int i=1;i<=N;i++){
        count[i]=0;
        others[i]=0;
    }
    for(int i=0;i<N;i++){
        count[A[i]]++;
    }

    for(int i=1;i<=N;i++){
        others[i]=(count[i])*(count[i]-1)/2;
        all_num+=others[i];
    }

    for(int i=1;i<=N;i++){
        count[i]=(count[i]-1)*(count[i]-2)/2;
    }

    
    for(int i=0;i<N;i++){
        cout << count[A[i]]+all_num-others[A[i]] << endl;
    }

    
}


Measured memory_bytes: 7296
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i64,
        b: i64,
    }
    if (a + b) % 2 == 0 {
        println!("{}", (a +  b) / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 1e9
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int dp[1000010]={};
  int dp2[1000010]={};
  for(int i=1;i<=1000000;i++){dp[i]=INF;dp2[i]=INF;}
  vector<ll> gu;
  vector<ll> ki;
  ll cnt=1;
  while(1){
    if((cnt*(cnt+1)*(cnt+2)/6)>1000000)break;
    if(((cnt*(cnt+1)*(cnt+2))/6)%2){ki.pb(cnt*(cnt+1)*(cnt+2)/6);dp[ki[ki.size()-1]]=1;dp2[ki[ki.size()-1]]=1;}
    else {gu.pb(cnt*(cnt+1)*(cnt+2)/6);dp[gu[gu.size()-1]]=1;}
    cnt++;
  }
  dp[1]=1;
  dp2[1]=1;
  for(int i=1;i<1000000;i++){
    for(int j=0;j<gu.size();j++){
      if(i+gu[j]>1000000)break;
      dp[i+gu[j]]=min(dp[i+gu[j]],(dp[i]+1));
    }
    for(int j=0;j<ki.size();j++){
      if(i+ki[j]>1000000)break;
      dp[i+ki[j]]=min(dp[i+ki[j]],(dp[i]+1));
      dp2[i+ki[j]]=min(dp2[i+ki[j]],(dp2[i]+1));
    }
  }
  int n;
  while(cin>>n,n){
    cout<<dp[n]<<" "<<dp2[n]<<endl;
  }
  return 0;
}



Measured memory_bytes: 10980
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>
#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++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
ll GCD(ll x, ll y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
ll LCM(ll x, ll y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}


int main(void) {

	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll lcm = LCM(c, d);
	ll  x = (b / c) - ((a - 1) / c),
		y = (b / d) - ((a - 1) / d),
		z = (b / lcm) - ((a - 1) / lcm);

	cout << (b - a + 1) - (x + y - z) << endl;

	return 0;

}

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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ld long double

#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)
#define Fit(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define Fitd(i,v) for(__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))

using namespace std;

#include <bits/stdc++.h>

using namespace std;

const int nm = 20;

int n;
int l[nm], a[nm][nm], b[nm][nm];

bool ok(int mask) {
	for (int i = 1; i <= n; ++i) {
		if (((mask >> (i - 1)) & 1) == 0) {
			continue;
		}
		for (int j = 1; j <= l[i]; ++j) {
			int u = a[i][j], v = b[i][j];
			int v2 = ((mask >> (u - 1)) & 1);
			if (v != v2) {
				return 0;
			}
		}
	}
	return 1;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &l[i]);
    	for (int j = 1; j <= l[i]; ++j) {
    		scanf("%d%d", &a[i][j], &b[i][j]);
    	}
    }

    int res = 0;
    for (int mask = 1; mask < (1 << n); ++mask) {
    	if (__builtin_popcount(mask) > res && ok(mask)) {
    		res = __builtin_popcount(mask);
    	}
    }
    printf("%d\n", res);
#ifdef LOCAL
    cout << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  ll X = 1;
  ll Y = 1;
  rep(i, N) {
    if(S.at(i) == 'a' && X <= A + B) {
      X++;
      cout << "Yes" << endl;
    }
    else if(S.at(i) == 'b' && (X <= A + B && Y <= B)) {
      X++;
      Y++;
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

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

using namespace std;
using ll = long long;

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll ans = 0;
  ans = min(a, k);
  k -= a;
  if (k > 0) {
    k -= b;
  }
  if (k > 0) {
    ans -= min(c, k);
  }
  
  cout << ans << endl;

  return 0;
}



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

int main(){
    string a,b;
    cin >> a >> b;
    string c = a+b;
    int n = atoi(c.c_str());
    for(int i=1;i*i<=n;i++){
        if(i*i == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		List<Integer> suraimu = new ArrayList<>();
		int sum = sc.nextInt();
		int count = 0;
		for(int i = 0; i < sum; i++){
			int color = sc.nextInt();
			if(!suraimu.contains(color)){
				suraimu.add(color);
			}else if(color == suraimu.get(i - 1)){
				suraimu.add(0);
				count += 1;
			}else{
				suraimu.add(color);
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
b = []
for key,val in Counter(a).items():
    if val >= 2:
        b.append(key)
        if val >= 4:
            b.append(key)

b.sort()

if len(b)>=2:
    x = b.pop()
    y = b.pop()
    ans = x*y
else:
    ans = 0

print(ans)


Measured memory_bytes: 18600
N=int(raw_input())

array=[]

judge = 'Yes'

for i in range(N):
    word = list(raw_input())
    if word in array:
        judge = 'No'
        break
    if len(array) != 0:
        last = array[-1]
        if word[0] != last[-1]:
            judge = 'No'
            break

    array.append(word)

#print N
#print array

print judge


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 1e5 + 10;
ll inf = 1e18;
ll n, W, w[N], v[N], ans, d[N];
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);

    cin >> n >> W;
    for(int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
    }
    for(int i = 1; i <= 1e5; i++)
    {
        d[i] = inf;
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1e5; j >= 0; j--)
        {
            if(d[j] + w[i] <= W && d[j] != inf)
            {
                d[j + v[i]] = min(d[j + v[i]], d[j] + w[i]);
                ans = max(ans, j + v[i]);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    string ans = "Good";
    rep(i, 3) {
        if(s[i] == s[i + 1]) {
            ans = "Bad";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int rgb = 0;
			rgb += sc.nextInt() * 100;
			rgb += sc.nextInt() * 10;
			rgb += sc.nextInt();

			if (rgb % 4 == 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	h := getNextInt(scanner)
	w := getNextInt(scanner)

	ans := 1 << 30

	whole := w * h

	mm := make([]int, 3)
	for i := 1; i < h; i++ {
		mm[0] = i * w
		mm[1] = (h - i) * (w >> 1)
		mm[2] = whole - mm[0] - mm[1]
		sort.Ints(mm)
		if ans > mm[2]-mm[0] {
			ans = mm[2] - mm[0]
		}
		mm[0] = i * w
		mm[1] = (h - i) / 2 * w
		mm[2] = whole - mm[0] - mm[1]
		sort.Ints(mm)
		if ans > mm[2]-mm[0] {
			ans = mm[2] - mm[0]
		}
	}
	for i := 1; i < w; i++ {
		mm[0] = i * h
		mm[1] = (w - i) * (h >> 1)
		mm[2] = whole - mm[0] - mm[1]
		sort.Ints(mm)
		if ans > mm[2]-mm[0] {
			ans = mm[2] - mm[0]
		}
		mm[0] = i * h
		mm[1] = (w - i) / 2 * h
		mm[2] = whole - mm[0] - mm[1]
		sort.Ints(mm)
		if ans > mm[2]-mm[0] {
			ans = mm[2] - mm[0]
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 5504
function main()
    a, b, h, m = parse.(Int, split(readline()))

    t = 60*60*h + 60*m
    ta = t*2*pi/43200
    tb = m*2*pi/60
    theta = abs(ta-tb)
    ans = a^2 + b^2 - 2*a*b*cos(theta)
    ans = sqrt(ans)
    println(ans)
end

main()


Measured memory_bytes: 212380
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char s;
	int k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(s>='0'&&s<='9')
	{
		k=k*10+(s^'0');
		s=getchar();
	}
	return k*base;
}
const int maxn=2e4+10;
const int maxm=5e5+10;
int n,X,Y,m,l,r,ans;
struct node
{
	int id,p,oth;
} a[maxn];
int Map[maxn];
int dfs_time,low[maxn],dfn[maxn],scc[maxn];
int to[maxm],ne[maxm],id,po[maxn],sccid;
stack<int> S;
bool cmp(node aa,node bb)
{
	if (aa.p==bb.p) return aa.id<bb.id;
	return aa.p<bb.p;
}
inline int qmax(int x,int y)
{
	return x>y?x:y;
}
inline int qmin(int x,int y)
{
	return x<y?x:y;
}
bool flag;
void tarjan(int x)
{
	S.push(x);
	dfn[x]=low[x]=++dfs_time;
	for (int i=po[x];i;i=ne[i])
	{
		if (dfn[to[i]]==0) 
		{
			tarjan(to[i]);
			if (!flag) return;
			low[x]=qmin(low[x],low[to[i]]);
		} else
		if (scc[to[i]]==0)
		{
			low[x]=qmin(low[x],dfn[to[i]]);
		}
	}
	if (dfn[x]==low[x])
	{
		++sccid;
		while (!S.empty())
		{
			scc[S.top()]=sccid;
			if (scc[a[S.top()].oth]==sccid)
			{
				flag=false;
				return;
			}
			if (S.top()==x) {S.pop();break;}
			S.pop();
		}
	}
}
inline void add(int x,int y)
{
	id++;to[id]=y;ne[id]=po[x];po[x]=id;
}
bool check(int x)
{
	id=0;sccid=0;
	dfs_time=0;
	memset(po,0,sizeof(po));
	memset(low,0,sizeof(low));
	memset(scc,0,sizeof(scc));
	memset(dfn,0,sizeof(dfn));
	for (int i=1;i<m;i++)
	{
		int last=min(m,i+9);
		for (int j=i+1;j<=last;j++)
		{
			if (a[j].p-a[i].p<x)
			{
				add(i,a[j].oth);
				add(j,a[i].oth);
			} else break;
		}
	}
	flag=true;
	tarjan(1);
	for (int i=1;i<=m;i++) 
	{
		if (!dfn[i]) tarjan(i);
		if (flag==false) return false;
	}
	return true;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	{
		X=read();Y=read();
		if (X>Y) swap(X,Y);
		a[i].id=i,    a[i].p=X,  a[i].oth=i+n;
		a[i+n].id=i+n,a[i+n].p=Y,a[i+n].oth=i;
	}
	m=n+n;
	r=qmax(abs(a[n+1].p-a[2].p),abs(a[n+2].p-a[1].p));
	r=qmax(r,qmax(abs(a[2].p-a[1].p),abs(a[n+2].p-a[n+1].p)));
	sort(a+1,a+n+1,cmp);
	l=a[2].p-a[1].p;
	for (int i=3;i<=n;i++) l=min(l,a[i].p-a[i-1].p);

	sort(a+1,a+m+1,cmp);
	for (int i=1;i<=m;i++) Map[a[i].id]=i;
	for (int i=1;i<=m;i++) a[i].oth=Map[a[i].oth];
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (check(mid)) {ans=max(ans,mid);l=mid+1;} else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6784
class Counter(dict):
    def __missing__(self, i):
        return 0

n = int(input())
a = list(map(int, input().split()))
q = int(input())

#print(n, a, q)
total = sum(a)
#print("total", total)

bucket = Counter()

for item in a:
    bucket[item] += 1

#print("bucket", bucket)

for i in range(q):
    b, c = map(int, input().split())
    taken = bucket[b]
    total -= bucket[b]*b
    bucket[c] += bucket[b]
    bucket[b] = 0
    total += taken*c
    #print(bucket)
    #print(b, c)
    print(total)


Measured memory_bytes: 23844