akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    string s; cin >> s;
    int n0=0, n1=0;
    rep(i, s.size()){
        if(s[i] == '0') n0++;
        else n1++;
    }

    cout << 2 * min(n0, n1) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4608
N = int(input())
A = list(map(int, input().split()))
count = 0
boolean = True

def bisect_array(array):
    for i in range(len(array)):
        array[i] = array[i] / 2
    return array

while boolean:
    for i in A:
        if i % 2 != 0:
            boolean = False
    if boolean == True:count += 1
    A = bisect_array(A)

print(count)
    

Measured memory_bytes: 3060
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Set<Integer> favorite = new HashSet<>();
		for(int i = 1; i < M + 1; i++) {
			favorite.add(i);
		}
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			Set<Integer> tmp = new HashSet<>();
			for(int j = 0; j < K; j++) {
				tmp.add(sc.nextInt());
			}
			favorite.retainAll(tmp);
		}
		System.out.println(favorite.size());
	}

}


Measured memory_bytes: 24532
n,m=map(int,input().split())

grid=[]
for i in range(n):
  x=list(input())
  grid.append(x)
  

dp=[[0 for i in range(m)] for j in range(n)]
dp[0][0]=1
for i in range(n):
  for j in range(m):
    if grid[i][j]!='#':
      if i>0:
        dp[i][j]+=dp[i-1][j]
      if j>0:
        dp[i][j]+=dp[i][j-1]
        
print(dp[n-1][m-1]%(10**9+7))        

Measured memory_bytes: 252508
#include<bits/stdc++.h>
using namespace std;
int main() {
    int A,B;cin>>A>>B;
    int tmpp,ans;ans=0;
    int k[5];
    for(int tmp=A;tmp<=B;tmp++){
        tmpp=tmp;
        k[0]=tmpp/10000;tmpp=tmpp-k[0]*10000;
        k[1]=tmpp/1000;tmpp=tmpp-k[1]*1000;
        k[2]=tmpp/100;tmpp=tmpp-k[2]*100;
        k[3]=tmpp/10;tmpp=tmpp-k[3]*10;
        k[4]=tmpp;
        if(k[0]==k[4]&&k[1]==k[3]){
            ans++;
        }
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
S=input()
if S == "SUN":
    print(7)
if S == "MON":
    print(6)
if S == "TUE":
    print(5)
if S == "WED":
    print(4)
if S == "THU":
    print(3)
if S == "FRI":
    print(2)
if S == "SAT":
    print(1)

Measured memory_bytes: 61584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=15;
int n,m,x,c[N],a[N][N];
int f[1<<N][N];
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	}
	int ans=0x3f3f3f3f;
	for(int i=1;i<(1<<n);i++)
	{
		int res[15];
		for(int j=1;j<=m;j++) res[j]=0;
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				for(int k=1;k<=m;k++)
					res[k]+=a[j+1][k];
			}
		}
		bool flag=1;
		int cnt=0;
		for(int j=1;j<=m;j++)
			if(res[j]<x)
			{
				flag=0;
				break;
			}
		if(flag)
		{
			for(int j=0;j<n;j++)
				if(i&(1<<j))
					cnt+=c[j+1];
			ans=min(ans,cnt);
		}
	}
	if(ans==0x3f3f3f3f) puts("-1");
	else
	cout<<ans;
	return 0;
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n,a;
  cin >> n >> a;
  vector<int64_t> dx(n);
  rep(i,n){
    int hoge;
    cin >> hoge;
    dx.at(i) = hoge - a;
  }
  vector<vector<int64_t>> dp(n+1,vector<int64_t>(10000)); // 5000を0とする。
  rep(i,10000){
    if(i != 5000){
      dp.at(0).at(i) = 0;
    }else{
      dp.at(0).at(5000) = 1;
    }
  }
  rep(i,n){
    rep(j,10000){
      if(j-dx.at(i)>=0 && j-dx.at(i) <= 9999){
        dp.at(i+1).at(j) += dp.at(i).at(j-dx.at(i));
      }
      dp.at(i+1).at(j) += dp.at(i).at(j);
    }
  } 
  cout << dp.at(n).at(5000)-1 << endl;
}

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

using namespace std;


int main()
{
    string s;

    cin >> s;

    int sz = s.size();

        if(s[6] <= 52 && s[5] == 48 )
          cout << "Heisei" << endl;

        else
          cout << "TBD" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main(){
	double a,b,c;
	while(~scanf("%lf %lf %lf", &a, &b, &c)){
		if(a + b + c == 17){
			printf("YES\n");
		}else{
			printf("NO\n");
		}	
	}
	return 0;
}

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

template <class T> inline void chadd(T &a, const T &b, int mod) {
  a = (a + b) % mod;
}

int main() {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> a(H + 7, std::vector<char>(W + 7, '!'));
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      std::cin >> a[i][j];

  int mod = 1000000007;
  std::vector<std::vector<long long>> dp(H + 7,
                                         std::vector<long long>(W + 7, 0));

  dp[0][0] = 1;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (a[i][j] != '.')
        continue;
      if (a[i + 1][j] == '.')
        chadd(dp[i + 1][j], dp[i][j], mod);
      if (a[i][j + 1] == '.')
        chadd(dp[i][j + 1], dp[i][j], mod);
    }
  }
  std::cout << dp[H - 1][W - 1] << std::endl;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

void solve()
{
	int m;
	cin >> m;
	while(m--)
	{
		set<string> Set;
		string str;
		cin >> str;
		int n = str.size();
		for(int i = 1; i < n; ++i)
		{
			string str1;
			string str2;
			for(int j = 0; j < i; ++j)
			{
				str1.push_back(str[j]);
			}
			for(int j = i; j < n; ++j)
			{
				str2.push_back(str[j]);
			}
			Set.insert(str1 + str2);
			Set.insert(str2 + str1);
			string str2buf = str2;
			reverse(str2.begin(), str2.end());
			Set.insert(str1 + str2);
			Set.insert(str2 + str1);
			reverse(str1.begin(), str1.end());
			Set.insert(str1 + str2buf);
			Set.insert(str2buf + str1);
			Set.insert(str1 + str2);
			Set.insert(str2 + str1);
		}
		cout << Set.size() << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1000
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll a,b,c,k;
ll ans;
//string s;
signed main(){
	acc_io;
	ans=0;
	cin>>a>>b>>c>>k;
	if(k<=a){
		if(a) ans=k;
		else  ans=0;
	}
	else if(k<=(a+b)){
		if(a) ans=a;
		else  ans=0;
	}
	else{
		if((k-a-b)<c){
			if(a>0&&c>0){
				ans=a-(k-a-b);
			}
			else{
				if(a>0){
					ans=a;
				}
				else{
					ans=-(k-a-b);
				}
			}
		}
		else{
			if(a>0&&c>0){
				ans=a-c;
			}
			else{
				if(a>0){
					ans=a;
				}
				else{
					ans=-c;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};


int main() {
	char a;
	cin >> a;
	if ((int)a >= 97) {
		cout << "a";

	}
	else {
		cout << "A";
	}
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(){
  int i,sum,n,j,b,a,k;
  char m,m2,o;
  scanf("%d%c",&a,&o);
  for(i=0;i<a;i++){
    sum=0;
    while(1){
      if(scanf("%c",&m)==EOF)break;
      if(m=='\n')break;
      if('2'<=m&&m<='9'){
	scanf("%c",&m2);
	if(m2=='i')sum=sum+(m-'0');
	if(m2=='x')sum=sum+(m-'0')*10;
	if(m2=='c')sum=sum+(m-'0')*100;
	if(m2=='m')sum=sum+(m-'0')*1000;
      }else if(m=='i'||m=='x'||m=='c'||m=='m'){
	if(m=='i')sum=sum+1;
	if(m=='x')sum=sum+10;
	if(m=='c')sum=sum+100;
	if(m=='m')sum=sum+1000;
      }
    }
    if(sum>=1000){
      b=sum/1000;
      if(b!=1)printf("%dm",b);
      else printf("m");
      sum-=b*1000;
    }
    if(sum>=100){
      b=sum/100;
      if(b!=1)printf("%dc",b);
      else printf("c");
      sum-=b*100;
    }
    if(sum>=10){
      b=sum/10;
      if(b!=1)printf("%dx",b);
      else printf("x");
      sum-=b*10;
    }
    if(sum>=1){
      if(sum!=1)printf("%di",sum);
      else printf("i");
    }
    printf("\n");
  }
  return 0;
}
    

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 177, task a, 2020/08/29
//ms,
/*
*/

int main(void){
  int d, t, s;
  cin >>d >>t >>s;
  if(s*t >= d) cout <<"Yes"<<endl;
  else cout <<"No" <<endl;
  return 0;
}
/*
*/


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

int main(){
  int N;

  cin >> N;

  if(N % 10 == 3){
    cout << "bon" << endl;
  }else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define EL '\n'
#define el '\n'
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define large 1000000007
#define pb() push_back()
#define MAX 10e+7
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void solve()
{
ll n;
ll m;
cin>>n>>m;
char mat[n][m];
rep(i,0,n)
{
	rep(j,0,m)
	{
		cin>>mat[i][j];
	}
}
ll rohit[n+1][m+1]={0};

//rohit[1][1]=1;
rep(i,0,n+1)
{
	rep(j,0,m+1)
	{
		if(i==0||j==0)
		rohit[i][j]=0;
		else if(i==1&&j==1)
		rohit[i][j]=1;
        else if(mat[i-1][j-1]==35)
		{
			//cout<<"YEES"<<el;
		rohit[i][j]=0;
		//cout<<rohit[i][j]<<" ";
		}
		else if(mat[i-1][j-1]=='.')
		{
		//cout<<"YESSSSS"<<el;
		rohit[i][j]=(rohit[i-1][j]%large+rohit[i][j-1]%large)%large;
		//cout<<rohit[i][j]<<" ";
		}
		//cout<<el;
	}
}
cout<<rohit[n][m]%large;
}
int main()
{

FASTIO
 long long int t;
 solve();
  return 0;
}


Measured memory_bytes: 9088
mod = 2019
L, R = map(int, input().split())
if R // mod - (L - 1) // 2019 > 0:
	print(0)
else:
	x = 2019
	l = L % mod
	r = R % mod
	for i in range(l, r + 1):
		for j in range(i + 1, r + 1):
			x = min(x, (i * j) % mod)
	print(x)

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

int main(){
    string s,t;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        string tmp=t.substr(i)+t.substr(0,i);
        if(s==tmp){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int n;
    cin >> n;
    
    double ans = 0.0;
    for(int i = 0;i < n;i++){
        double x;
        string s;
        cin >> x >> s;
        if(s == "JPY") ans += x;
        else ans +=  380000.0*x;
    }
    cout << ans << endl;

}




int main() {

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



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

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for (int r = 0; r <= N; r += R) {
    for (int g = 0; g <= (N - r); g += G) {
      if ((N - r - g) % B == 0) {
        ans++;
      }
    }
  }

  cout << ans << endl;
}

signed main() {
  solve();
  return 0;
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int main() {
  int N; cin >> N;
  vector<int> A(N); rep(i, N) cin >> A[i];
  int ans=1;
  int d=0,tmp;
  reps(i, N-1) {
    tmp = A[i] - A[i-1];
    if(tmp==0) continue;
    tmp = tmp > 0? 1:-1;
    if (d==0) {
      d = tmp;
    } else if(d!=tmp) {
      d=0;
      ans++;
    }
  }
  dump(ans);
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	size_t ans = s.size();
	for (size_t i = 1; i < s.size(); i++) 
		if (s[i] != s[i - 1])ans = min(ans, max(i, s.size() - i));
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int n, l;
    vector<string> v;
    string s;
    cin >> n >> l;
    
    int i = 0;
    for(i = 0; i < n; i++){
        cin >> s;
        v.push_back(s);
    }
    
    sort(v.begin(), v.end());
    
    for(i = 0; i < n; i++){
        cout << v[i];
    }
    
    cout << endl;
}



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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 1e5;
ll N;
ll A[MAX_N], B[MAX_N];
int main(){
   cin >> N;
   vector<Pii> C(N);
   REP(i, N) {
      cin >> A[i] >> B[i];
      C[i] = mp(A[i] + B[i], i);
   }
   RSORT(C);
   ll ans = 0;
   REP(i, N){
      if (i % 2 == 0){
         ans += A[C[i].second];
      }
      else{
         ans -= B[C[i].second];
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;
void solve(){
    int a, b;
    cin >> a >> b;
    cout << b + a * (b % a == 0 ? 1 : -1);
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}




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

using namespace std;

#define pb			push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define hastr(s, c)		((s).find(c) != string::npos)

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    string s;
    cin >> s;
    if(hastr(s,'7'))
    	cout << "Yes";
    else
    	cout << "No";

    return 0;
}


Measured memory_bytes: 3588
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        String s = scanner.next();
        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                if (!"RUD".contains(String.valueOf(s.charAt(i)))) {
                    System.out.println("No");
                    return;
                }
            } else {
                if (!"LUD".contains(String.valueOf(s.charAt(i)))) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 23124
chomp($n=<>);
chomp($nn=<>);
@ary=split/ /,$nn;
@arya=sort{$a <=> $b}@ary;

foreach (@ary){
	if($_ <= $arya[$n/2-1]){
    	print "$arya[$n/2]"."\n";
    }else{
    	print "$arya[$n/2-1]"."\n";
    }
}

Measured memory_bytes: 46896
H,W,K=gets.split.map(&:to_i)

MOD=10**9+7

dp=Array.new(H+1){Array.new(W,0)}
dp[0][0]=1

oks=[]
[0,1].repeated_permutation(W-1).each do |f|
    valid_flag=true
    f.each_cons(2) do |i,j|
        valid_flag=false if i==1 && j==1
    end
    add=Array.new(W,0)
    W.times do |w|
        add[w]=1 if w<W-1 && f[w]==1
        add[w]=-1 if w>0 && f[w-1]==1
    end
    oks << add if valid_flag
end

H.times do |h|
    oks.each do |add|
        W.times do |w|
            ww=w+add[w]
            dp[h+1][ww]+=dp[h][w]
            dp[h+1][ww]-=MOD if dp[h+1][ww]>=MOD
        end
    end
end
p dp[H][K-1]

Measured memory_bytes: 1788
N = int(input())
s = []
for _ in [0]*N:
    x, y, h = map(int, input().split())
    s.append([x, y, h])

s.sort(key=lambda x:x[2], reverse=True)
ansH = 0
x0, y0, h0 = s[0]
for cx in range(0, 101):
    for cy in range(0, 101):
        H = h0 + abs(x0 - cx) + abs(y0 - cy)
        for x, y, h in s:
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                break
        else:
            print(cx, cy, H)

Measured memory_bytes: 3188
#include<iostream>
//#include<vector>
using namespace std;

int main(){
    long long n,T;
    cin >> n >> T;
    long long t[200000],ans = 0;
    for(int i = 0;i < n;i++){
        cin >> t[i];
        if(i > 0){
            ans += min(T,t[i] - t[i - 1]);
        }
    }

    cout << ans + T << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int main()
{
    string s; cin >> s;
    ll ans = 0;
    ll b_num = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'B') {
            b_num++;
        }
        else {
            ans += b_num;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
from math import degrees,atan2
a,b,x=map(int,input().split())
if a**2*b/2>=x:
    height=2*x/(a*b)
    print(degrees(atan2(b,height)))
else:
    height=2*(a**2*b-x)/a**2
    print(degrees(atan2(height,a)))

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

bool check_bingo(vector<vector<bool>> &check_sheet) {
    bool result = false;

    for(int i=0; i<3; ++i) {
        if(check_sheet[i][0] == true && check_sheet[i][1] == true && check_sheet[i][2] == true) {
            result = true;
            break;
        }

        if(check_sheet[0][i] == true && check_sheet[1][i] == true && check_sheet[2][i] == true) {
            result = true;
            break;
        }
    }

    if(result == false) {
        if(check_sheet[0][0] == true && check_sheet[1][1] == true && check_sheet[2][2] == true) {
            result = true;
        } else if (check_sheet[0][2] == true && check_sheet[1][1] == true && check_sheet[2][0] == true) {
            result = true;
        }
    }

    return result;
}

int main() {
    vector<vector<int>> bingo(3, vector<int>(3, 0));
    vector<vector<bool>> check_sheet(3, vector<bool>(3, false));

    for(int i=0; i<3; ++i) {
        for(int j=0; j<3; ++j) {
            cin >> bingo[i][j];
        }
    }

    int n;
    cin >> n;

    for(int i=0; i<n; ++i) {
        int b;
        cin >> b;

        for(int i=0; i<3; ++i) {
            for(int j=0; j<3; ++j) {
                if(b == bingo[i][j]) {
                    check_sheet[i][j] = true;
                }
            }
        }
    }

    bool is_bingo = check_bingo(check_sheet);

    if (is_bingo) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int n, x, a, g;
int f(int p, int q) {return q ? f(q, p%q) : p;}

int main() {
	cin>>n>>x;
	while(n--) scanf("%d", &a), g = f(g, abs(a-x));
	cout<<g;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAX = (int)1e7;
int gcd(int x, int y) {
	if (y == 0) {
		return x;
	}
	if (x >= y) {
		gcd(y, x%y);
	}
	else {
		gcd(x, y%x);
	}
}
int main() {
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;
}

Measured memory_bytes: 3052
N, M = map(int, input().split())

ac = [False] * N
wa = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

a = 0
b = 0
for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])


Measured memory_bytes: 75880
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  ll ans = 0, tot = 0;
  rep(i,N){
    ll A; cin >> A;
    tot += A; 
    if (A==0 || i==N-1) {
      ans += tot/2;
      tot = 0;
      continue;
    }

  }
  cout << ans << endl;

  


  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 3592
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var w = long.Parse(line[0]);
        var h = long.Parse(line[1]);
        var x = long.Parse(line[2]);
        var y = long.Parse(line[3]);
        getAns(w, h, x, y);
    }
    static void getAns(long w, long h, long x, long y)
    {
        if (x * 2 == w && y * 2 == h) Console.WriteLine("{0} 1", w / 2 * h);
        else Console.WriteLine("{0} 0", (double)w * h / 2d);
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
 
void solve()
{
    int n;
    cin >> n;
    vector<int> num(4, 0);

    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;

        if(s == "AC") num[0]++;
        else if(s == "WA") num[1]++;
        else if(s == "TLE") num[2]++;
        else num[3]++;
    }

    cout << "AC x " << num[0] << "\n";
    cout << "WA x " << num[1] << "\n";
    cout << "TLE x " << num[2] << "\n";
    cout << "RE x " << num[3] << "\n";
}
 
int main()
{
    fastio;
    solve();
}

Measured memory_bytes: 3600
s = gets.chomp

if s.index("S")
	unless s.index("N")
		puts "No"
		exit
	end
else
	if s.index("N")
		puts "No"
		exit
	end
end

if s.index("W")
	unless s.index("E")
		puts "No"
		exit
	end
else
	if s.index("E")
		puts "No"
		exit
	end
end

puts "Yes"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000

void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,d[3];
  string s;
  cin>>s;
  a = s[0] - '0';
  d[0] = s[1] - '0';
  d[1] = s[2] - '0';
  d[2] = s[3] - '0';
  rep(i,1<<3){
    // cout<<a<<endl;
    ll ans = a;
    rep(j,3){
      if(i>>j&1) ans += d[j];
      else ans -= d[j];
    }
    // cout<<ans<<endl;
    if(ans==7){
      cout<<a;
      rep(j,3){
        if(i>>j&1) cout<<"+"<<d[j];
        else cout<<"-"<<d[j];
      }
      cout<<"=7"<<endl;
      break;
    }
  }

}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

unordered_map<int, int> mp[100000];
void solve() {
	int n, m; cin >> n >> m;
	int t; cin >> t;
	set<int> st;
	vector<int> a(m), b(m), c(m);
	rep(i, m) {
		cin >> a[i] >> b[i] >> c[i]; b[i]--;
	}
	rep(i, m) {
		int le = i;
		while (i + 1 < m&&a[i] == a[i + 1]) {
			i++;
		}
		int len = t - a[i];
		Rep1(j, le, i) {
			if (c[j] == 0) {
				st.erase(b[j]);
				for (auto itr = st.begin(); itr != st.end(); itr++) {
					if (*itr < b[j]) {
						mp[*itr][b[j]] -= len;
					}
					else {
						mp[b[j]][*itr] -= len;
					}
				}
			}
			else {
				for (auto itr = st.begin(); itr != st.end();itr++) {
					if (*itr < b[j]) {
						mp[*itr][b[j]] += len;
					}
					else {
						mp[b[j]][*itr] += len;
					}
				}
				st.insert(b[j]);
			}
		}
	}
	vector<int> ma(n, 0);
	vector<int> ans(n, mod);
	rep(i, n) {
		for (auto itr = mp[i].begin(); itr != mp[i].end(); itr++) {
			int id = (*itr).first;
			int val = (*itr).second;
			if (ma[i] < val) {
				ma[i] = val; ans[i] = id;
			}
			else if (ma[i] == val)ans[i] = min(ans[i], id);
			if (ma[id] < val) {
				ma[id] = val; ans[id] = i;
			}
			else if (ma[id] == val)ans[id] = min(ans[id], i);
		}
	}
	rep(i, n) {
		if (ma[i] == 0)ans[i] = 0;
		if (i == 0 && ans[i] == 0)ans[i] = 1;
		cout << ans[i] + 1 << endl;
	}
}

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



Measured memory_bytes: 168316
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=2001;
int n;
vector<int> g[MAX_N];
int match[MAX_N];
int used[MAX_N];
void add_edge(int src,int dst){
    g[src].pb(dst);
    g[dst].pb(src);
}
bool dfs(int v){
    used[v]=true;
    rep(i,g[v].size()){
        int u=g[v][i],w=match[u];
        if(w<0||!used[w]&&dfs(w)){
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int res=0;
    memset(match,-1,sizeof(match));
    rep(i,n){
        if(match[i]<0){
            memset(used,0,sizeof(used));
            if(dfs(i)) ++res;
        }
    }
    return res;
}
int main(){
    int x,y,e;
    cin>>x>>y>>e;
    n=x+y;
    int xi,yi;
    rep(i,e){
        cin>>xi>>yi;
        add_edge(xi,x+yi);
    }
    cout<<bipartite_matching()<<endl;
    return 0;
}


Measured memory_bytes: 3264
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

vvi v;
pair<int,int> find(int n){
	rep(i,v.size())rep(j,v[i].size()){
		if(v[i][j]==n)return make_pair(i,j);
	}
	return make_pair(-1,-1);
}

int main(){
	int m;
	while(scanf("%d",&m) , m){
		int a,b;
		v.assign(m,{0});
		rep(i,m)v[i]={i+1};
		while(scanf("%d%d",&a,&b), a|b){
			auto ia=find(a), ib=find(b);
			vi &A=v[ia.first], &B=v[ib.first];
			if(b==0){
				if(ia.second==0) continue;
				while(1){
					int top=A.back();
					v.push_back({top});
					A.pop_back();
					if(top==a)break;
				}
			}else if(ia.first==ib.first){
				if(ia.second < ib.second){
					v.push_back({b,a});
					while(1){
						int top=A.back();
						if(top!=a && top!=b){
							v.push_back({top});
						}
						A.pop_back();
						if(top==a) break;
					}
				}
			}else{
				while(1){
					int top=A.back();
					A.pop_back();
					if(top==a){
						B.push_back(a);
						break;
					}else{
						v.push_back({top});
					}
				} 
			}
			v.erase(remove_if(v.begin(),v.end(),[](const vi& v){return v.size()==0; }),v.end());
		}
		vi ans;
		rep(i,v.size())ans.push_back(v[i].size());
		sort(ans.begin(),ans.end());
		rep(i,ans.size())printf("%d\n",ans[i]);
		puts("end");
	}
}

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

int main(void)
{
	vector<pair<int, int>> co(4);
	cin >> co[0].first >> co[0].second >> co[1].first >> co[1].second;
	pair<int, int> dire(co[1].first - co[0].first, co[1].second - co[0].second);

	co[2].first = co[1].first - dire.second;
	co[2].second = co[1].second + dire.first;
	co[3].first = co[2].first - dire.first;
	co[3].second = co[2].second - dire.second;

	printf("%d %d %d %d \n", co[2].first, co[2].second, co[3].first, co[3].second);
	
	return 0;
}

Measured memory_bytes: 256
#include       <set>
#include       <map>
#include     <queue>
#include     <cmath>
#include    <cstdio>
#include    <cctype>
#include    <vector>
#include   <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
const double eps = 1e-7;
const int maxn = 1e5+5;

ll fast_pow(ll a,ll b,ll mod){
    ll ans = 1;
    while(b){
        if(b&1)
            ans = ans*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ans;
}

int main(){
    ll n, m;
    ll a, x=0, y=0;
    scanf("%lld%lld",&n,&m);

    for(int i=1;i<=n;i++){
        scanf("%lld",&a);
        x = (x+(2*i-n-1)*a)%mod;
    }
    for(int i=1;i<=m;i++){
        scanf("%lld",&a);
        y = (y+(2*i-m-1)*a)%mod;
    }
    printf("%lld\n",x*y%mod);
    return 0;
}

/*

1592794101
989097785


232162543

*/


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a,b;
	top = 0;
	char s[100];

while(scanf("%s",s) != EOF){
	if(s[0] == '+'){
	a = pop();
	b = pop();
	push(a+b);
	}
	else if(s[0] == '-'){
		b = pop();
		a = pop();
		push(a-b);
	}
	else if(s[0] == '*'){
		a = pop();
			b = pop();
		push(a*b);
	}
	else{
		push(atoi(s));
	}
}
	printf("%d\n",pop());
	return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
//using ll=long long;

int main(){
    int N;
    cin >> N;
    for(int i = 0; i <= N; ++i){
        for(int j = 0; j <= N; ++j){
            int tmp = 4 * i + 7 * j;
            if(tmp == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;
using namespace atcoder;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using S = int;
S op(S a, S b){return max(a, b);}
S e(){ return 0;}

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

	int n, k;
	cin >> n >> k;

	int max_a = 303030;
	segtree<int, op, e> seg(max_a);

	rep(i, n){
		int a;
		cin >> a;
		int l = max(0, a - k);
		int r = min(max_a-1, a + k);
		seg.set(a, seg.prod(l, r+1) + 1);
	}

	cout << seg.all_prod() << endl;
}


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

int N;
int A[200010] = {};
string S;
int main(){
    cin >> N >> S;
    for(int i=1;i<=N;i++){
        if(S[i-1]=='#') A[i] = 1;
        A[i] += A[i-1];
    }
    int ans = min(N-A[N],A[N]);
    for(int i=1;i<=N;i++) ans = min(ans,A[i]+(N-i)-(A[N]-A[i-1]));
    cout << ans << endl;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

bool solve(int n, int x, vector<int> &ans){
    if(n == 1){
        ans[0] = x;
        return true;
    }
    if(x == n * 2 - 1 || x == 1){
        return false;
    }
    ans[n - 1] = x;
    if(n == 2){
        ans[0] = x - 1;
        ans[2] = x + 1;
    }else if(x == 2){
        ans[n - 3] = x + 2;
        ans[n - 2] = x - 1;
        ans[n] = x + 1;
        int now = 1;
        rep(i, n * 2 - 1){
            while(x - 1 <= now && now <= x + 2){
                ++now;
            }
            if(n - 3 <= i && i <= n){
                continue;
            }
            ans[i] = now;
            ++now;
        }
    }else{
        ans[n - 3] = x - 2;
        ans[n - 2] = x + 1;
        ans[n] = x - 1;
        int now = 1;
        rep(i, n * 2 - 1){
            while(x - 2 <= now && now <= x + 1){
                ++now;
            }
            if(n - 3 <= i && i <= n){
                continue;
            }
            ans[i] = now;
            ++now;
        }
    }
    return true;
}

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> ans(n * 2 - 1);
    if(solve(n, x, ans)){
        cout << "Yes" << endl;
        rep(i, n * 2 - 1){
            cout << ans[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
n, m = map(int, input().split())
p_list = []
for i in range(m):
    p_list.append(list(int(i) for i in input().split()))
a = sorted(p_list)
tmp = 0
b = {}
for (i,j) in a:
    if i != tmp:
        count = 1
        tmp = i
        b[(i,j)] = "0"*(6-len(str(i))) + str(i) + "0"*(6-len(str(count))) + str(count)
    else:
        count += 1
        b[(i,j)] = "0"*(6-len(str(i))) + str(i) + "0"*(6-len(str(count))) + str(count)
for (i,j) in p_list:
    print(b[(i,j)])

Measured memory_bytes: 48612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

#define SIZE 50
vector<vector<ll>> pascal_triangle(){
    ll dp[SIZE+2][SIZE+2];
    rep(i,SIZE+2)rep(j,SIZE+2)dp[i][j] = 0;
    dp[0][0] = 1;
    for(int i=0;i<=SIZE;i++){
        for(int j=0;j<=SIZE;j++){
            dp[i+1][j] += dp[i][j];
            dp[i][j+1] += dp[i][j];
        }
    }
    vector<vector<ll>> C(SIZE+1,vector<ll>(SIZE+1));
    rep(i,SIZE+1)rep(j,SIZE+1)C[i][j] = dp[i-j][j];
    return C;
}

int main(){
    vector<vector<ll>> C = pascal_triangle();
    int n,p;
    cin>>n>>p;
    
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    int odd = 0;
    rep(i,v.size())if(v[i]%2)odd++;
    
    ll ans = 0;
    for(;p<=odd;p+=2){
        ans += C[odd][p];
    }
    cout<<ans*(1LL<<(n-odd))<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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--)
typedef long long LL;
string s;
typedef pair<int,int>P;
vector<P>v;

int main(){
	cin>>s;

	if((s[0]!='1')||(s[s.size()-1]!='0')){
		cout<<-1<<endl;
		return 0;
	}
	REP(i,s.size()-1){
		if(s[i]!=s[s.size()-2-i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	int now=1;
	REP(i,s.size()/2){
		if(s[i]=='1'){
			for(int j=now+1;j<=i+2;j++){
				v.push_back(P(now,j));
			}
			now=i+2;
		}
	}
	for(int i=now+1;i<=s.size();i++){
		v.push_back(P(now,i));
	}
	REP(i,v.size()){
		cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	
	return 0;
}

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

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
#define fr first
#define sc second

using namespace std;

int pre[4040][3];
int main(){

    ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);

    int n; string s; cin >> n >> s;
    ll sum =  0;
    map<char,int>mm;
    mm['R'] = 0;
    mm['G'] = 1;
    mm['B'] = 2;

    for(int i = n - 1;i >= 0;i--){
        pre[i][0] += pre[i + 1][0];
        pre[i][1] += pre[i + 1][1];
        pre[i][2] += pre[i + 1][2];
        for(int j = i - 1;j >= 0;j--){
            if(s[i] == s[j])continue;
            int t = mm[s[i]] + mm[s[j]];
            sum += pre[i][3 - t];
            if(i + (i - j) < n){
                if(mm[s[i + (i - j)]] == 3 - t)
                    sum--;
            }
        }
        pre[i][mm[s[i]]]++;
    }
    cout << sum << '\n';



    return 0;
}


Measured memory_bytes: 3688