akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <cctype>
#include <iostream>

using namespace std;

int toInt(char c){// m c x i
	switch(c){
	case 'm':
		return 1000;
	case 'c':
		return 100;
	case 'x':
		return 10;
	case 'i':
		return 1;
	}
	cout << "impossible" << endl;
	return 0;
}

int encode(string str){
	int ret=0;
	for(int i=0;i<str.size();i++){
		char c = str[i];
		int mul=1;
		if('0' <= c && c<='9'){
			mul=c-'0';
			i++;
			c = str[i];
		}
		ret += mul*toInt(c);
	}
	return ret;
}

string decode(int n){
	string ret;
	//m
	if(n>=1000){
		int d = n/1000;
		n = n%1000;
		if(d>1)ret.push_back('0'+d);
		ret.push_back('m');
	}
	//c
	if(n>=100){
		int d = n/100;
		n = n%100;
		if(d>1)ret.push_back('0'+d);
		ret.push_back('c');
	}
	//x
	if(n>=10){
		int d = n/10;
		n = n%10;
		if(d>1)ret.push_back('0'+d);
		ret.push_back('x');
	}
	// i
	if(n>=1){
		int d = n/1;
		//n = n%1;
		if(d>1)ret.push_back('0'+d);
		ret.push_back('i');
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0;i<n;i++){
		string a,b;
		cin >> a >> b;
		string ans = decode(encode(a)+encode(b));
		cout << ans << endl;
	}
}

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



int main()
{
int n,m;
cin>>n>>m;

int sum=0;
while(m--)
{
    int a;
    cin>>a;
    sum+=a;
}
if(sum<=n)
    cout<<n-sum<<endl;
else
    cout<<-1<<endl;


    return 0;
}


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

double len(auto &it,auto &it2){
	double len=0;
  	for(int i=0;i<it.size();i++){
      	len+=pow(it.at(i)-it2.at(i),2);
    	}
  	return len;
}

int main(){
//1604
  int N,D,x,cnt;
  double length2;
  cin>>N>>D;
  vector <vector<int>> X(N);
  for(int k=0;k<N;k++){
  	for(int i=0;i<D;i++){
    	cin>>x;
    	X.at(k).push_back(x);
		}
	}

 for(auto it=X.begin();it!=X.end();++it){
   for(auto it2=it+1;it2!=X.end();++it2){
     length2=pow(len(*it,*it2),0.5);
     if(length2==int(length2))cnt++;
   }
 }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
Module Program
Sub Main(args As String())
        Dim sInput As String() = Split(Console.ReadLine(), " ")

        Dim iInputA As Integer = sInput(0)
        Dim iInputB As Integer = sInput(1)
        Dim iInputC As Integer = sInput(2)
        Dim iInputK As Integer = sInput(3)

        If iInputA >= iInputK Then
            Console.WriteLine(iInputK * 1)
        ElseIf iInputA + iInputB >= iInputK Then
            Console.WriteLine(iInputA * 1)
        Else
            Console.WriteLine((iInputA * 1) + ((iInputK - iInputA - iInputB) * -1))
        End If

    End Sub
End Module

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

double pi = acos(-1);

struct ClockHands {
public:
  ClockHands (int length, double angle)
    : x(length * cos(angle)),
      y(length * sin(angle)) {}

  // The coordinate point of clock hands.
  double x;
  double y;

  // Return the distance to the other's coordinate point.
  double Distance (ClockHands other) {
    double dist_x = x - other.x;
    double dist_y = y - other.y;
    return sqrt(dist_x * dist_x + dist_y * dist_y);
  }
};

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  ClockHands hour(a, h * 2 * pi / 12.0 + m * 2 * pi / 720.0);
  ClockHands minute(b, m * 2 * pi / 60.0);

  cout << fixed << setprecision(15);
  cout << hour.Distance(minute) << endl;
}


Measured memory_bytes: 4148
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B, C; cin >> A >> B >> C;
    bool ka = false;
    if (A == B && A != C) ka = true;
    else if (A == C && A != B) ka = true;
    else if (B == C && A != C) ka = true;
    if (ka) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
# 初期入力
N = int(input())
X = list(map(int, input().split()))
X_max =max(X)
X_min = min(X)

tairyoku =[]
# Pで集会を開く
for P in range(X_min,X_max + 1): #住んでいるところで端から端まで確認
    tairyoku.append([(x_j - P)**2 for x_j in X ])
tairyoku_sum = [sum(i) for i in tairyoku ]
# print(tairyoku)
#print(tairyoku_sum)
print(min(tairyoku_sum))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    string a, b;
    cin >> a >> b;
    if (a == b)puts("H");
    else puts("D");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  priority_queue<P> pq;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    pq.push(P(a, i + 1));
  }

  vector<vector<int>> ans(h, vector<int>(w));

  P cur = pq.top();
  pq.pop();

  int id = cur.second;
  int cnt = cur.first;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int y = i;
      int x = i % 2 ? j : w - 1 - j;
      ans[y][x] = id;
      cnt--;

      if (cnt == 0) {
        cur = pq.top();
        pq.pop();
        id = cur.second;
        cnt = cur.first;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << ans[i][j];
      if (j != w - 1) {
        cout << " ";
      }
    }
    cout << endl;
  }

  return 0;
}

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

int main()
{
	int n;
	while(cin >> n){
	int t = 0;
	for (int a = 0; a < 10; ++a)
	{
		for (int b = 0; b < 10; ++b)
		{
			for (int c = 0; c < 10; ++c)
			{
				if(n - (a + b + c ) <= 9 && 0 <= n - (a + b + c )){
					t++;
				}
			}
		}
	}
	cout << t << endl;
}
	return 0;
}

Measured memory_bytes: 1160
//Bismillahir Rahmanir Raheem
//In the name of Allah , Most Gracious , Most Merciful

/*

  * * * * * * *   * * * * * * *   *           *   * * *   * * * * * *
              *   *           *   *           *     *     *           *
              *   *           *   *           *     *     *             *
              *   *           *   *           *     *     *             *
              *   * * * * * * *   * * * * * * *     *     *             *
  *           *   *           *   *           *     *     *             *
  *           *   *           *   *           *     *     *             *
  *           *   *           *   *           *     *     *           *
  * * * * * * *   *           *   *           *   * * *   * * * * * *

*/



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


#define BOOST ios_base::sync_with_stdio(false) , cin.tie(NULL)


int main()
{
    BOOST;

    long long int a,b,n;
    cin>>a>>b>>n;
    if(n>=b)n=b-1;
    cout<<floor(a*n/b) - a*floor(n/b)<<endl;
    return 0;
}












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

using namespace std;

#define all(x) x.begin(), x.end()
#define inf (long long) 1e18

typedef long long ll;
typedef long double ld;

const int N = 123456;
const int M = 1234567;
const int P = 400004;
const int A = 256;

int a[102];

int main(int argc, char const *argv[])
{
	
	#ifdef Cyborg1o1
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	

	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	srand(time(0));

	int n;
	cin >> n;

	int mn = 10000;
	int tot = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		tot += a[i];
		if(a[i] % 10 && a[i] < mn)
			mn = a[i];

	}

	if(tot % 10 == 0){
		if(mn != 10000)
			tot -= mn; 
		else
			tot = 0;
	}

	cout << tot << endl;

	return 0;					
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()	{
  string a, b, c;
  cin >> a >> b >> c;
  int x = a.length(), y = b.length(), z = c.length();
  if (a[x - 1] == b[0] && b[y - 1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3628
main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  xs <- map read . words <$> getLine
  ys <- map read . words <$> getLine
  let
    f n (k, xk)=
      fromIntegral $ (k-1)*xk - (n-k)*xk
    xsum = sum . map (f n) $ zip [1..] xs
    ysum = sum . map (f m) $ zip [1..] ys
  print $ xsum * ysum `mod` 1000000007

Measured memory_bytes: 141564
N = int(input())

if N ==0:
    print('0')
    exit()
if N == 1:
    print('1')
    exit()
if N == -1:
    print('11')
    exit()
if N == -2:
    print('10')
    exit()

m = 400
length = 0
for i in range(3, m):
    posneg = 1 if i % 2 == 1 else -1
    if posneg == 1 and 4**((i+1)/2 - 1) / 3 <= N and N <= 4**((i+1)/2) / 3:
        length = i
        break
    elif posneg == -1 and -(4)**((i+1)/2 - 1)/ 3 >= N and N >= -(4)**((i+1) /2) / 3:
        length = i
        break
ans = ''
for i in range(length, 2, -1):
    posneg = 1 if i % 2 == 1 else -1
    if posneg == 1:
        if 4**((i+1)/2 - 1) / 3 <= N and N <= 4**((i+1)/2) / 3:
            N -= 2**(i - 1)
            ans += '1'
        else:
            ans += '0'
    elif posneg == -1:
        if posneg == -1 and -(4)**((i+1)/2 - 1)/ 3 >= N and N >= -(4)**((i+1) /2) / 3:
            N += 2**(i - 1)
            ans += '1'
        else:
            ans += '0'

if N ==	0:
    ans += '00'
if N == 1:
    ans += '01'
if N == -1:
    ans += '11'
if N == -2:
    ans += '10'


print(ans)



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define MOD 1000000007
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

struct modint{
  li num;

  modint(li a=0){
    num=(a%MOD+MOD)%MOD;
  }
  modint operator+(modint a) {return{(num+a.num)%MOD};} 
  modint operator-(modint a) {return{((num-a.num)%MOD+MOD)%MOD};}
  modint operator*(modint a) {return{num*a.num%MOD};}
  modint inv(const modint& a);
  modint operator/(modint a) {return (*this)*inv(a);}
  modint& operator+=(modint a) {
    (num += a.num)%=MOD;
    return *this;
  }
  modint& operator*=(modint a) {
    (num*=a.num)%=MOD;
    return *this;
  }
};

std::ostream& operator<<(std::ostream& os, const modint& m){
  // ここでストリームに obj を書き込みます。
  li a=m.num;
  a%=MOD;
  a+=MOD;
  a%=MOD;
  cout << a;
  return os;
}

std::istream& operator>>(std::istream& os,modint& m){
  // ここでストリームに obj を書き込みます。
  li a; cin >>a;
  m=a;
  return os;
}

modint pow(modint a,int r){
  modint b=a,ans=1;
  while(r){
    if(r%2) ans*=b;
    b*=b;
    r/=2;
  }
  return ans;
}
// modint inv(const modint& a){
//   // MOD: prime
//   return pow(a,MOD-2);
// }


modint binom(li n,int k){
  if(df)print(n,k);
  if((k<0) or (k>n)) return 0;
  if(k>n-k) k=n-k;
  if(n<MOD){
    modint den=1,num=1;
    rep(i,k){
      den*=i+1;
      num*=n-i;
    }
    if(df)print("binom=",num,"/",den);
    return num*pow(den,MOD-2);
  }
  while(1) print("too large");
}

int main() {
  li s; cin >>s;
  modint ans=0;
  for(int i=1;s-i*3>=0;i++){
    if(df)print(binom(s-2*i-1,i-1));
    ans+=binom(s-2*i-1,i-1);
  }
  print(ans);
}


Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n; vector<vector<int> >vec(n, vector<int>(n, 0));
	rep(i, 0, n) {
		int u, k; cin >> u >> k;
		u--;
		rep(j, 0, k) {
			int v; cin >> v; v--;
			vec[u][v] = 1;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, n) {
			if (j)cout << " ";
			cout << vec[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long int llint;

int n;
vector<llint> a;
deque<llint> b;

void input() {
  cin >> n;
  a = vector<llint>(n);
  //b = deque<llint>(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
}

void solve() {
  if (n & 1) {
    for (int i = 0; i < n; ++i) {
      if (i & 1) {
        b.push_back(a[i]);
      } else {
        b.push_front(a[i]);
      }
    }
  } else {
    for (int i = 0; i < n; ++i) {
      if (i & 1) {
        b.push_front(a[i]);
      } else {
        b.push_back(a[i]);
      }
    }
  }

  for (auto& it : b) {
    cout << it << " ";
  }
  cout << endl;
}

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

Measured memory_bytes: 5376
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_V 1100000

struct edge{
	int to;
	long long int cost;
    edge(int to_, long long int cost_){
        to = to_;
        cost = cost_;
    }
};

vector<edge> G[MAX_V];
long long int d[MAX_V];

// O(ElogV)

void shortest_path(int s, int V){
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

bool flag[MAX_V];

int main(){
	int n;
	cin >> n;
	int start = MAX_V - 2;
	int goal = MAX_V - 1;
	vector<string> v;
	for(int loop = 0; loop < n; loop++){
		string S;
		cin >> S;
		int sz = S.size();
		int pos = 0;
		for(char c : S){
			pos *= 2;
			pos += c - '0';
		}
		pos *= 16;
		pos += sz - 1;
		G[pos].push_back(edge(goal, 0));
		flag[pos] = true;
		for(int i = 1; i < sz; i++){
			int pos1 = 0, pos2 = 0;
			for(int j = 0; j < i; j++){
				pos1 *= 2;
				pos1 += S[j] - '0';
			}
			for(int j = i; j < sz; j++){
				pos2 *= 2;
				pos2 += S[j] - '0';
			}
			pos1 *= 16;
			pos2 *= 16;
			pos1 += i - 1;
			pos2 += sz - i - 1;
			G[pos1].push_back(edge(pos2, sz - i));
		}
		v.push_back(S);
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(v[i].size() < v[j].size() && v[j].substr(0, v[i].size()) == v[i]){
				int pos = 0;
				for(int k = v[i].size(); k < v[j].size(); k++){
					pos *= 2;
					pos += v[j][k] - '0';
				}
				pos *= 16;
				pos += v[j].size() - v[i].size() - 1;
				G[start].push_back(edge(pos, v[j].size()));
			}
		}
	}
	for(int i = 0; i < 65536; i++){
		for(int j = 1; j <= 16; j++){
			if(i >= (1 << j)){
				continue;
			}
			int num = 0;
			for(int k = j; k > 1; k--){
				num *= 2;
				if(i & (1 << (k - 1))){
					num += 1;
				}
				if(flag[num * 16 + j - k]){
					G[i * 16 + j - 1].push_back(edge((i - num * (1 << (k - 1))) * 16 + k - 2, 0));
				}
			}
		}
	}
	shortest_path(start, MAX_V);
	if(d[goal] == INF){
		cout << 0 << endl;
	}else{
		cout << d[goal] << endl;
	}
	return 0;
}



Measured memory_bytes: 41572
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		
		long N = scan.nextLong();
		
		
		
		System.out.println(kaijou(N));
		
	}
	
	
	
	public static long kaijou (long a ){
		if(a==0){
			return 1;
		}else{
			return a*kaijou(a-1)%((long)Math.pow(10, 9)+7);
		}
	}

}

Measured memory_bytes: 31316
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  string line;
  int a,b,c;
  vector<int> v;
  getline (cin,line);
  stringstream(line) >> a >> b >> c;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(), v.end());
  cout << v[0] << ' ' << v[1] << ' ' << v[2] << '\n';
  return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[123456];
ii pr[123456];
int dp[123456][2];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int k=0;
		while(a[i]>(1<<k)) k++;
		pr[i].se=k;
		if(a[i]==(1<<k))
		{
			pr[i].fi=k;
		}
		else
		{
			pr[i].fi=k-1;
		}
		ans+=pr[i].se;
	}
	dp[0][0]=dp[0][1]=0;
	for(int i=0;i+1<n;i++)
	{
		for(int j=0;j<2;j++)
		{
			int v=dp[i][j];
			int r=(j==0?pr[i].fi:pr[i].se);
			for(int k=0;k<2;k++)
			{
				int l=(k==0?pr[i+1].se:pr[i+1].fi);
				dp[i+1][k]=max(dp[i+1][k],v+min(l,r));
			}
		}
	}
	ans-=max(dp[n-1][0],dp[n-1][1]);
	cout<<ans<<'\n';
}


Measured memory_bytes: 2176
def merge(A, left, mid, right):
    global count
    L = A[left:mid] + [1000000001]
    R = A[mid:right] + [1000000001]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    count += right - left


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

N = int(input())
A = list(map(int, input().split()))
count = 0
merge_sort(A, 0, N)
print(*A)
print(count)

Measured memory_bytes: 63868
#include<stdio.h>
#define MM 3
int main(void){
 
int sum,t,d[MM],i,j;
 
for(i=0;i<MM;i++){
scanf("%d",&d[i]);
}
 
for(i=0;i<MM-1;i++){
for(j=i+1;j<MM;j++){
if(d[i]<d[j]){
t=d[j];
d[j]=d[i];
d[i]=t;
}}}
 
d[0] = d[0] * 10;
sum = d[0]+d[1]+d[2];
printf("%d\n",sum);
 
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	long a,b,x,y,g,l,buf;
	while(cin >> a >>b){
		if(a>b){
			x=a;
			y=b;
		}else{
			x=b;
			y=a;
		}
		while(x%y!=0){
			buf=x;
			x=y;
			y=buf%y;
		}
		cout << y << " " << (a*b/y) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int i=0,j;
  int co=0;
  int ma=0;
  for(i=0;i<s.size();i++)
  {
    if(s[i]=='R'){
    j = i;
      co=0;
      while(j<(s.size()) && s[j]=='R'){
      j++;
        co++;
      }
    if(co>ma){
    ma = co;}
      i = j;
    }
  }
  cout<<ma<<endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] d = new int[k];
		for (int i = 0; i < k; i++) {
			d[i] = sc.nextInt();
		}
		for (int i = n;; i++) {
			int x = i;
			outside: while (x != 0) {
				for (int j = 0; j < k; j++) {
					if (x % 10 == d[j])
						break outside;
				}
				x /= 10;
				if (x == 0) {
					System.out.println(i);
					return;
				}
			}
		}
	}
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, l;
  cin >> n >> l;
  ll ans = l*n + (n*(n-1))/2;
  if(l >= 0)ans -= l;
  else ans -= min(l+n-1, 0LL);
  cout << ans;
}


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

int n,w;
int mp[1001][1001];
int dx[4]= {0,1,0};
int dy[4]= {0,0,1};
bool flag;
struct pos {
	int x,y,xx,yy;
} pp[1000001];
int cnt=0;

int main() {
	cin>>n>>w;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=w; j++)
			cin>>mp[i][j];
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=w; j++) {
			if(mp[i][j]%2==1) {
				flag=false;
				for(int k=1; k<=2; k++) {
					int ii=i+dx[k];
					int jj=j+dy[k];
					if(ii<1||jj<1||ii>n||jj>w) continue;
					else {
						if(mp[ii][jj]%2==0) continue;
						mp[ii][jj]++;
						mp[i][j]--;
						flag=true;
						pp[++cnt].x=i;
						pp[cnt].y=j;
						pp[cnt].xx=ii;
						pp[cnt].yy=jj;
						break;
					}
				}
				if(!flag) {
					if(j<w) {
						mp[i][j+1]++;
						mp[i][j]--;
						pp[++cnt].x=i;
						pp[cnt].y=j;
						pp[cnt].xx=i;
						pp[cnt].yy=j+1;
						continue;
					}
					if(i<n){
						mp[i+1][j]++;
						mp[i][j]--;
						pp[++cnt].x=i;
						pp[cnt].y=j;
						pp[cnt].xx=i+1;
						pp[cnt].yy=j;
					}
				}
			} else continue;
		}
	}
	cout<<cnt<<endl;
	for(int i=1; i<=cnt; i++) cout<<pp[i].x<<' '<<pp[i].y<<' '<<pp[i].xx<<' '<<pp[i].yy<<endl;
	return 0;
}


Measured memory_bytes: 8192
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int h, w;
    cin >> h >> w;

    vector<string> input(h);
    rep(i, h) cin >> input[i];

    vector<string> r, b;
    r = input;
    b = input;
    rep(i, h){
        for(int j = 1; j < w - 1; j++){
            if(i % 2 == 0){
                r[i][j] = '#';
            }else{
                b[i][j] = '#';
            }
        }
    }

    rep(i, h - 1){
        r[i][w-1] = '#';
        b[i+1][0] = '#';
    }

    rep(i, h){
        cout << r[i] << endl;
    }
    cout << endl;
    rep(i, h){
        cout << b[i] << endl;
    }

    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int x,y; cin>>x>>y;
  int ans;
  if(y>x&&x>=0) ans=y-x;
  else if(x>y&&y>0) ans=2+x-y;
  else if(abs(x)==abs(y)) ans=1;
  else if(x>=0) ans=1+abs(abs(x)-abs(y));
  else if(x<y) ans=min(y-x,abs(abs(x)-abs(y))+1);
  else ans=2+x-y;
  cout<<ans<<endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)

template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
const ll MAXN = 1e18;
const ll SIZE = 6e6 + 6;
const ll MOD  = 1e9 + 7;

ll a, b, c, k, res;

int main() { speedhack()

	cin >> a >> b >> c >> k;

	ll step = min (a, k);
	k -= step;
	res += step;

	step = min (b, k);
	k -= step;

	step = min (c, k);
	res -= step;
	cout << res;

	return 0;
}


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

int ans = 0;
int h, w;
vector<string> mp;
vector<string> flag1, flag2;

void dfs1(int x, int y) {
    if(x == 0 && y == 0 && mp[y][x] == '#') {
        ans++;
        flag1[y][x] = '#';
        return;
    }

    if(mp[y][x] == '.') {
        return;
    }
    if(mp[y][x] == '#') {
        flag1[y][x] = '#';
    }
    if(x-1 >= 0) dfs1(x-1, y);
    if(y-1 >= 0) dfs1(x, y-1);
    /*
    if(y-1 > -1) {
        if(mp[y-1][x] == '#') {
            ans = 2;
        }
    }
    if(x-1 > -1) {
        if(mp[y][x-1] == '#') {
            ans = 2;
        }
    }
    */
}


void dfs2(int x, int y) {
    if(x == w-1 && y == h-1 && mp[y][x] == '#') {
        ans++;
        flag2[y][x] = '#';
        return;
    }

    if(mp[y][x] == '.') {
        return;
    }
    if(mp[y][x] == '#') {
        flag2[y][x] = '#';
    }
    if(x+1 < w) dfs2(x+1, y);
    if(y+1 < h) dfs2(x, y+1);
}

int main() {
    cin >> h >> w;
    //vector<string> mp(h);
    string t = "";
    rep(i, 0, w) {
        t += '.';
    }
    rep(i, 0, h) {
        string s;
        cin >> s;
        mp.push_back(s);
        flag1.push_back(t);
        flag2.push_back(t);
    }
    dfs1(w-1, h-1);
    dfs2(0, 0);
    rep(i, 0, h) {
        rep(j, 0, w) {
            //cout << flag[i][j];
            if(flag1[i][j] != flag2[i][j]) {
                cout << "Impossible" << endl;
                return 0;
            }
        }
        //cout << endl;
    }
    if(ans == 2) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

a,b = rli()
if(a % 3 == 0 or b % 3 == 0 or (a+b)%3 == 0):
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3060
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


"""def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)"""

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    n=int(input())
    ar=[]
    while(n>0):
        n-=1
        ar.append(n%26)
        n//=26
    ar=ar[::-1]
    for i in ar:
        v=97+i
        print(chr(v),end='')
















BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


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

int n;
int cnt;
int p[10000];
int d1, d2;
int p_sum[10000];
int p_max = 0;
int m_sum;
int p_i;

int main(){
	while(true){
		cin >> n;
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin >> p[i] >> d1 >> d2;
			p_sum[i] = d1 + d2;
		}
		
		p_max = p_sum[0];
		for(int i = 0; i < n; i++){
			if(p_max < p_sum[i]){
				p_max = p_sum[i];
				p_i = i;
			}	
		}
		cout << p[p_i] << " " << p_max << endl;	
		p_i = 0;
	}
}

Measured memory_bytes: 1236
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h>>w;
    vector<string> a(h);
    ll dp[h+1][w+1];
    for (int i = 0; i < h; i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            dp[i][j]=0;
        }
    }
    dp[0][1]=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(a[i-1][j-1]=='#') continue;
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=MOD;
        }
    }
    cout << dp[h][w] << "\n";
}



Measured memory_bytes: 9088
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int max_S = 1e5 + 10;
char buff[max_S];

bool ends_with(char *str, int len, const string &B);

int main()
{
	cin >> buff;
	int len = strlen(buff);
	for (int i = len; i > 0;) {
		int ok = 0;
		set<string> cand = {"dream", "dreamer", "erase", "eraser"};
		for (auto &x : cand) {
			if (ends_with(buff, i, x)) {
				ok = 1;
				i -= x.length();
				break;
			}
		}
		if (!ok) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

bool ends_with(char *str, int len, const string &B)
{
	if (B.length() <= len) {
		for (int i = 0; i < B.length(); ++i) {
			if (str[len - B.length() + i] != B[i]) {
				return 0;
			}
		}
		return 1;
	}
	return 0;
}


Measured memory_bytes: 384
import fractions
a,b=map(int,input().split())
k=fractions.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    
    return arr

 
print(len(factorization(k))+1)

Measured memory_bytes: 5304
// Written By NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 100003, mod = 1e9 + 7;
int arr[maxN];

int main() {
    int n = read(), k = read(), i, j, ans = 0, tmp = 0;
    for (i = 1; i <= n; ++i)
        arr[i] = read();
    for (i = 1; i <= n; ++i)
        for (j = 1; j < i; ++j)
            ans += arr[j] > arr[i];
    ans = 1ll * ans * k % mod;
    for (i = 1; i <= n; ++i)
        for (j = 1; j <= n; ++j)
            tmp += arr[j] != arr[i];
    ans = ((__int128) k * (k - 1) * tmp / 4 + ans) % mod;
    printf("%d\n", ans);
    return 0;
}


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

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

    VLL x(m); 
    VLL di(m-1);
    //firstには座標間の距離,secondには2点間の座標の最初のもの
    for(int i=0; i<m ; ++i){
        cin >> x[i];
    }
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }

    sort(x.begin(),x.end());
    ll length = x[m-1] - x[0];//先頭から最後尾までの長さ

    for(int i=0; i<m-1; ++i){
        di[i] = x[i+1] - x[i];
    }

    sort(di.begin(),di.end());
    ll distance=0,j=m-2;
    //必要な数の座標間の距離を足していく
    for(int i=0; i<n-1; ++i){
        distance += di[j];
        --j;
    }
    
    cout << length - distance << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<string>

int main() {
	int n;
	int a[200001];
	std::cin >> n;
	for (int i = 0; i < 200001; i++) {
		a[i] = -1;
	}
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	int count = 0;
	int ima = 0;
	bool flug = false;
	for (int i = 0; i < n && ima < n;) {
		/*std::cout << ima << std::endl;
		std::cout << a[ima] << std::endl;
		std::cout << i << std::endl;*/
		if (a[ima] == i+1) {
			ima++;
			i++;
			flug = true;
		}
		else {
			ima++;
			count++;
		}
	}
	if (flug) {
		std::cout << count << std::endl;
	}
	else {
		std::cout << -1 << std::endl;
	}
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,ans;
  cin>>a>>b>>c;
  if(a>=b&&a>=c) ans=a*10+b+c;
  if(b>=a&&b>=c) ans=b*10+a+c;
  if(c>=a&&c>=b) ans=c*10+a+b;
  cout<<ans<<endl;
  return(0);
}


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

multiset<long long> A, B;
long long bs, as, q, sz;

void lax() {
	while (A.size() > (sz + 1) / 2) {
		multiset<long long>::iterator it = A.end();
		it--;
		as += 2 * (*it);
		B.insert(*it);
		A.erase(it);
	}
	while (!B.empty()) {
		multiset<long long>::iterator it = A.end();
		it--;
		if (*it > *B.begin()) {
			long long a = *it, b = *B.begin();
			A.erase(it);
			B.erase(B.begin());
			as += 2 * a;
			as -= 2 * b;
			A.insert(b);
			B.insert(a);
		}
		else
			break;
	}
}
long long geten() {
	multiset<long long>::iterator it = A.end();
	it--;
	return *it;
}

int main() {
	cin >> q;
	for (int i = 0; i < q; i++) {
		int t, a, b;
		cin >> t;
		if (t == 1) {
			cin >> a >> b;
			sz++;
			A.insert(a);
			as -= a;
			bs += b;
			lax();
		}
		else
			cout << geten() << ' ' << + geten() * (sz % 2) + as + bs << '\n';
	}
}

Measured memory_bytes: 9600
import java.util.*;

public class Main {

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

        int N = sc.nextInt();
        int Y = sc.nextInt();

        for (int x = 0; x <= N; x++) {
            for (int y = 0; y <= N - x; y++) {
                int z = N - x - y;
                if (x * 10000 + y * 5000 + z * 1000 == Y) {
                    System.out.printf("%d %d %d", x, y, z);
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int gcd(int a,int b){
	return a%b==0? b:gcd(b,a%b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll q,h,s,d,n;cin >> q >> h >> s >> d >> n;
	q*=4;
	h*=2;
	int mi=min(q,min(h,s));
	if(mi*2<=d) cout << mi*n << endl;
	else{
		if(n%2==0) cout << n/2*d << endl;
		else cout << n/2*d+mi << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int sum = 0;
		for(int i = 0 ; i < n - 1 ; i++) {
			if(s.charAt(i + 1) == 'E') sum++;
		}
		int ans = sum;
		for(int i = 0 ; i < n - 1 ; i++) {
			if(s.charAt(i) != s.charAt(i + 1));
			else if(s.charAt(i) == s.charAt(i + 1) && s.charAt(i) == 'E') sum--;
			else if(s.charAt(i) == s.charAt(i + 1) && s.charAt(i) == 'W') sum++;
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 29284
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  cin >> n;
  k=0;
  while(1){
    k++;
    if((n*k)%360==0) break;
  }
  cout << k << endl;
  
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  vector<int> idx(n);
  iota(idx.begin(), idx.end(), 0);
  long double ans = 0;
  do {
    rep(i, n-1)
      ans += sqrt(pow(x[idx[i+1]]-x[idx[i]], 2)+pow(y[idx[i+1]]-y[idx[i]], 2));
  } while(next_permutation(idx.begin(), idx.end()));
  for (int i = 1; i <= n; i++)
    ans /= i;
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}

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

int main(void) {
  int n;cin>>n;
  
  Fr(i,50000) {
    if(n == (int)((double)i*1.08)) {cout << i << endl;return 0;}
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
s = list(input())
exist = 'abcdefghijklmnopqrstuvwxyz'

j = 0
s = set(s)
s = sorted(s)
if len(s) == 26:
    print('None')
    exit()
for i in range(len(s)+1):
    try:
        if s[i] == exist[j]:
            pass    
        elif s[i] != exist[j]:
            print(exist[j])
            break
        j += 1
    except:
        print('z')



Measured memory_bytes: 3956
#include <iostream>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
int main(){
    long long a,b,n;
    cin>>n>>a>>b;
    if(a==0 ){
        cout<<"0\n";
    }
    else if(b==0){
        cout<<n<<"\n";
    }
    else{
        long long ss,tt= n/(a+b);
        long long p = n%(a+b);
        ss=tt*a;
        if(p>=a){
            ss+=a;
        }
        else{
            ss+=p;
        }
        
        cout<<ss<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    for(ll i=0;i<k;i++)
    ans+=a[i];
    cout<<ans<<endl;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  int cnt=0;
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    if (i == n-1) {
      if ((x - vec.at(i)) == 0) {
        cnt++;
      }
      else {
        break;
      }
    }
    else if ((x - vec.at(i)) >= 0) {
      x -= vec.at(i);
      cnt++;
    }
    else {
      break;
    }
  }
  
  cout << cnt << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

struct union_find {
	vector<int> data;
	union_find(int n) : data(n, -1) {}
	int find(int a) {
		return data[a] < 0 ? a : data[a] = find(data[a]);
	}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (data[a] > data[b]) swap(a, b);
		data[a] += data[b];
		data[b] = a;
	}
};

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	while (cin >> n, n) {
		vector<int> x(n), y(n);
		vector<char> d(n);
		map<pii, pii> pos;
		for (int i = 0; i < n; i++) {
			cin >> x[i] >> y[i] >> d[i];
			pos[make_pair(x[i], y[i])] = make_pair(i, 0);
			(d[i] == 'x' ? pos[make_pair(x[i] + 1, y[i])] : pos[make_pair(x[i], y[i] + 1)]) = make_pair(i, 1);
		}
		bool ok = true;
		union_find uf(n * 2);
		for (int i = 0; i < n; i++) {
			int nx = x[i], ny = y[i];
			for (int a = 0; a < 2; a++) {
				for (int j = 0; j < 4; j++) {
					int tx = nx + dx[j], ty = ny + dy[j];
					pii tp(tx, ty);
					if (pos.count(tp) && pos[tp].first != i) {
						if (a == pos[tp].second) {
							int u = i, v = pos[tp].first;
							uf.unite(u, v);
							uf.unite(n + u, n + v);
							if (uf.same(u, n + u) || uf.same(v, n + v)) {
								ok = false;
							}
						}
						else {
							int u = i, v = pos[tp].first;
							uf.unite(u, n + v);
							uf.unite(n + u, v);
							if (uf.same(u, n + u) || uf.same(v, n + v)) {
								ok = false;
							}
						}
					}
				}
				(d[i] == 'x' ? nx : ny) += 1;
			}
		}
		puts(ok ? "Yes" : "No");
	}
	return 0;
}



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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = unsigned long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        if(a.at(i) == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    ll INF = 1e18;
    for(i = 0;i < n;++i){
        double ansd = ans;
        double ad = a.at(i);
        double tmpd = ansd*ad;
        if(tmpd > 2e18){
            cout << -1 << endl;
            return 0;
        }else{
            ans *= a.at(i);
            if(ans > INF){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3964
#include<cstdio>
using namespace std;
int n;double ans,a,d;
int main(){
	scanf("%d%lf%lf",&n,&a,&d);
	for (;n;n--){
		ans+=1.0*(a*2+(2*n-1)*d)/2;
		a=(a*(2*n+2)+d*5)/(2.0*n);
		d=d*(n+2)/n;
	}
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long int how(long long int a,long long int b,long long int c)
{
    if (a%c==0)
        a=a;
    else a=(a/c)*c+c;
    if(b%c==0) b=b;
    else b=b-(b%c);
    //cout<<(((b-a)/c)+1)<<endl;
    return (((b-a)/c)+1);
}
long int gcd(long long int a,long long int b)
{

    if (a == 0)
       return b;
    if (b == 0)
       return a;


    if (a == b)
        return a;


    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}

int main(){
	unsigned long long int a,b,c,d;
	//cin>>a>>b>>c>>d;unsigned long long int
	scanf("%llu %llu %llu %llu",&a,&b,&c,&d);
	unsigned long long int p=(b-a)+1, q=how(a,b,c), r=how(a,b,d),s=(c*d)/gcd(c,d),t=how(a,b,s);
	printf("%llu",p-q-r+t);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

int main() {
  int x, a;
  scanf("%d %d", &x, &a);

  cout << ((x < a) ? 0 : 10) << endl;
}


Measured memory_bytes: 256