akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = []
P = []
for i in range(N):
    s,p = input().split()
    S.append(s)
    P.append(int(p))
Sset = sorted(list(set(S)))

dict1 = {}
for i in range(N):
    dict1[P[i]] = S[i]

for k in Sset:
    U = [i for i, j in dict1.items() if j == k]
    V = sorted(U,reverse=True)
    for l in V:
        print(P.index(l) + 1)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
//#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

const int MAX = 2e5;
int n, m, a, b, ans, visited[MAX];
vvi graph(MAX);

int f(int x) {
	int ret = 1;
	if (visited[x]) return 0;
	visited[x] = 1;
	for (int y : graph[x]) {
		ret += f(y);
	}
	return ret;
}

signed main() {
	fastio;
	cin >> n >> m;
	FOR(i, m) {
		cin >> a >> b;
		a--; b--;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	FOR(i, n) {
		ans = max(ans, f(i));
	}
	cout << ans;
}

Measured memory_bytes: 21096
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int findsumofDigits(int n){
        int sum = 0;
        while(n >0){
            sum += n%10;
            n /= 10;
        }
        return sum;
    }

int main()
{
    int n,alice,bob;
    alice = 0;
    bob = 0;
    cin >> n;
    std::vector<int> vec(n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> vec[i];
    }
    
    sort(vec.begin(),vec.end(),greater<int>());

    
    for(int i = 0; i < n; i++)
    {
        if(i%2 == 0)alice += vec[i];
        else bob += vec[i];

    }

    cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n>=30)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    


    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A>=B && A>=C){
  cout << A*10+B+C << endl;
  }
  else if(B>A && B>=C){
  cout << B*10+A+C << endl;
  }
  else if(C>A && C>B){
  cout << C*10+B+A << endl;
  }
}


Measured memory_bytes: 256
#define MOD 1000000007
#define Rep(i,a,n)for(int i=a;i<n;i++)
typedef long long L;
L mp(L a,L n,L m){L x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define imp(b,p)mp(b,p-2,p)
main(){
  L s,f[2009]={1},a=0;
  scanf("%lld", &s);
  if(s>2){
    Rep(i,1,2009)f[i]=f[i-1]*i%MOD;
    Rep(n,1,1+s/3)a+=f[s-2*n-1]%MOD*imp(f[n-1],MOD)%MOD*imp(f[s-3*n],MOD)%MOD;
  }
  printf("%lld",a%MOD);
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)

int const N=1e5+5;
int const inf=1e9+5;
void solve(){
int n,k;
cin>>n>>k;
vector<int> dp(n,inf);
vector<int> v(n);
for(int i=0;i<n;i++)
    cin>>v[i];
    dp[0]=0;
for(int i=0;i<n;i++){
      for(int j=i+1;j<min(n,i+k+1);j++)
        dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
}
cout<<dp[n-1]<<endl;
}
int main(){
    fast;

solve();

return 0;}


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

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

	vector<int> h(n), dp(n, INT_MAX);
	for (auto& i : h)
		cin >> i;
	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		dp[i] = min({
			dp[i],
			dp[i - 1] + abs(h[i] - h[i - 1]),
			i > 1 ? dp[i - 2] + abs(h[i] - h[i - 2]) : INT_MAX
		});
	}
 	cout << dp.back() << endl;
}

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

int main() 
{
    long int n;
    cin>>n;
    long long int a[n],ans=0;
    for(long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long int i=0;i<n;i++)
    {
        for(long int j=i+1;j<n;j++)
        {
            for(long int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k])
                {
                    if(a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[k]+a[i]>a[j])
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a,b;
	cin >> a >> b;

	if(a+b == 15)
		cout << "+" << endl;
	else if(a*b == 15)
		cout << "*" << endl;
	else
		cout << "x" << endl;

	return 0;
}

Measured memory_bytes: 256
def saiki(N,M,A,MAX,queri,ans):
	
	if len(A) == N:
		ret = 0
		for q in queri:
			if (A[q[1]] - A[q[0]]) == q[2]:
				ret += q[3]
		if ret > ans[0]:
			ans[0] = ret

	else:
		for i in range(1,MAX+1):
			a = [i] + A[:]
			saiki(N,M,a,i,queri,ans)




if __name__ == '__main__':
	N,M,Q = map(int, input().split())

	queri = []
	for _ in range(Q):
		a,b,c,d = map(int, input().split())
		queri.append([a-1,b-1,c,d])

	ans = [0]
	saiki(N,M,[],M,queri,ans)

	print(ans[0])

Measured memory_bytes: 9072
n = int(input())
s = input()

r_count = s.count("R")
g_count = s.count("G")
b_count = s.count("B")
ans = r_count * g_count * b_count

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1

print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <queue>


#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;
struct stk {
	int y, x;
	stk(int y, int x) : y(y), x(x) { }
};

string bd[14];

void chil(int y, int x, char cl){
int	dx[]={1,-1,0,0};
int	dy[]={0,0,1,-1};
	queue< stk > que;
	que.push(stk(y,x));
	while(!que.empty()){
		stk cr = que.front();
		que.pop();
		if(bd[cr.y][cr.x] == '1') bd[cr.y][cr.x] = cl;
		rep(i,4){
			if(bd[cr.y+dy[i]][cr.x+dx[i]] == '1'){
				que.push(stk(cr.y+dy[i], cr.x+dx[i]));
			}
		}
	}
}
void showw(){
	rep(i,14){ rep(j,14) cout << bd[i][j];
					cout << endl; }

}	

int main(void){

string ws;


	while(!cin.eof()){
		int cnt=0;
		rep(i,12){
			getline(cin,ws);
			if(cin.eof()) break;
			if(ws=="") break;
			bd[i+1] = "0" + ws + "0";
		}
		
		if(ws=="") continue;
		rep(i,14) rep(j,14)
			if(bd[i][j] == '1'){
				cnt++;
				char cl= 'a' + cnt;
				chil(i,j,cl);
			}
		cout << cnt << endl;
//		showw();
	}		
	return 0;
	
}

Measured memory_bytes: 7076
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		System.out.println((N % 10 == 9 || N / 10 == 9) ? "Yes" : "No");
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    set<int> ac;
    vi pena(n,0);
    rep(i,m){
        int p; string s; cin>>p>>s;
        if (s=="AC") ac.ins(p);
        if (s=="WA" && !ac.count(p)){
            pena[p-1]++;
        }
    }
    int ans=0;
    rep(i,n){
        if (ac.count(i+1)) ans+=pena[i];
    }
    cout<<ac.size()<<" "<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}

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

using namespace std;

int H, W, n, a, b;

char chA[M], chB[M];

void change(char &x) {
	if(x == 'L') x = 'U';
	else if(x == 'R') x = 'D';
	else if(x == 'U') x = 'L';
	else if(x == 'D') x = 'R';
}

int main() {
	scanf("%d%d%d", &H, &W, &n);
	scanf("%d%d", &a, &b);
	scanf("%s%s", chA + 1, chB + 1);
	// seperate 2D
	int ans = 1, l = 0, r = W + 1;
	for(int i = n; i >= 1; i--) {
		if(chB[i] == 'L') {
			r = min(r + 1, W + 1);
		} else if(chB[i] == 'R') {
			l = max(l - 1, 0);
		}
		if(chA[i] == 'L') {
			if(++l == r - 1) break;
		} else if(chA[i] == 'R') {
			if(--r == l + 1) break;
		}
	}
	ans &= !(b <= l || b >= r);
	swap(H, W), swap(a, b);
	for(int i = 1; i <= n; i++) change(chA[i]), change(chB[i]);
	l = 0, r = W + 1;
	for(int i = n; i >= 1; i--) {
		if(chB[i] == 'L') {
			r = min(r + 1, W + 1);
		} else if(chB[i] == 'R') {
			l = max(l - 1, 0);
		}
		if(chA[i] == 'L') {
			if(++l == r - 1) break;
		} else if(chA[i] == 'R') {
			if(--r == l + 1) break;
		}
	}
	ans &= !(b <= l || b >= r);
	if(ans == 1) puts("YES"); else puts("NO");
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5];
int t;
int main()
{
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+4);
	int k=a[3]-a[2];
	a[1]+=k;
	if((a[3]-a[1])%2==0)
		k+=(a[3]-a[1])/2;
	else
		k+=(a[3]-a[1]+1)/2+1;
	printf("%d",k);
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		Map<Long, Integer> counts = new HashMap<>();
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			Long val = Long.parseLong(tokens[i]);
			if (!counts.containsKey(val)) {
				counts.put(val, 1);
			} else {
				counts.put(val, counts.get(val) + 1);
			}
		}
		List<Long> keys = new ArrayList<>(counts.size());
		keys.addAll(counts.keySet());
		Collections.sort(keys);
		int rmNum = 0;
		for (Long key : keys) {
			int num = counts.get(key);
			if (num != key) {
				if (num > key) {
					rmNum += num - key;
				} else {
					rmNum += num;
				}
			}
		}
		System.out.println(rmNum);
	}
}


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

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

    int ans[3] = {};
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    for(int i = 1; i < n; i++){
        int b[3], c[3] = {};
        cin >> b[0] >> b[1] >> b[2];
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k)  continue;
                c[k] = max(c[k], a[j]+b[k]);
            }
        }
        for(int j = 0; j < 3; j++)  a[j] = c[j];
    }

    cout << max({a[0], a[1], a[2]}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
///*X.find_by_order("index")
///X.order_of_key("key")
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
 
///----------------------------------------------------------------------------------

string s;
int n, jump[200005][26], DP[200005], nxt[200005], first[26];

int fun(int ind)
{
	if (ind >= n) return 1;
	if (DP[ind] != -1) return DP[ind];
	
	
	int res = MOD;
	rep(i,0,26)
	{
		
		int temp = 1 + fun(jump[ind][i]);
		if (temp < res)
		{
			res = temp;
			nxt[ind] = i;
		}
	}
	return DP[ind] = res;
}
void solve()
{
	cin >> s;
	rep(i,0,200005)rep(j,0,26) jump[i][j] = MOD;
	memset(DP, -1, sizeof DP);
	memset(nxt, -1, sizeof nxt);
	fill(first, first + 26, MOD);
	
	n = s.length();
	
	
	
	repD(i,n-1,-1)
	{
		rep(j,0,26)
			jump[i][j] = first[j];
		first[s[i] - 'a'] = i;
	}
	
	rep(i,0,n)rep(j,0,26)assert(jump[i][j] > i);
	int ans = n+1, who = -1;
	
	
	rep(i,0,26)
	{
		int len = fun(first[i]);
		if (len < ans)
		{
			ans = len;
			who = i;
		}
	}
	int cur = first[who];
	string res;
	res.pb('a' + who);
	while (1)
	{
		if (cur >= n || nxt[cur] == MOD) break;
		res.pb('a' + nxt[cur]);
		cur = jump[cur][nxt[cur]];
	}
	cout << res << "\n";

}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t qwertyuiop = clock();
	#endif
 
	int t = 1;
	//cin >> t;	
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
			cout << "\n";
		#endif

	}
	
	#ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 44692
n = int(input())
 
n_max = 1
cnt_max = 0
for i in range(1, n + 1):
  cnt = 0
  a = i
  while(a % 2 == 0):
    a /= 2
    cnt += 1
  if cnt > cnt_max:
    cnt_max = cnt
    n_max = i
 
print(n_max)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct edge{int to,cost;};
int V;
vector<edge> G[100010],G2[100010];
ll d[100010],d2[100010];
 
void dijkstra(int s){
  priority_queue<pint,vector<pint>,greater<pint>> que;
  fill(d,d+V,longinf);
  d[s]=0;
  que.push(pint(0,s));
  
  while(!que.empty()){
    pint p=que.top(); que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(pint(d[e.to],e.to));
      }
    }
  }
}

void dijkstra2(int s){
  priority_queue<pint,vector<pint>,greater<pint>> que;
  fill(d2,d2+V,longinf);
  d2[s]=0;
  que.push(pint(0,s));
  
  while(!que.empty()){
    pint p=que.top(); que.pop();
    int v=p.second;
    if(d2[v]<p.first)continue;
    rep(i,G2[v].size()){
      edge e=G2[v][i];
      if(d2[e.to]>d2[v]+e.cost){
        d2[e.to]=d2[v]+e.cost;
        que.push(pint(d2[e.to],e.to));
      }
    }
  }
}

int main(){
  ll n,m,s,t;
  cin >> n >> m >> s >> t;
  s--,t--;
  V=n;
  rep(i,m){
    ll x,y,z,w;
    cin >> x >> y >> z >> w;
    x--,y--;
    G[x].push_back({y,z});
    G[y].push_back({x,z});
    G2[x].push_back({y,w});
    G2[y].push_back({x,w});
  }
  dijkstra(s),dijkstra2(t);
  vector<ll> v(n+1,0);
  v[n]=longinf;
  for(int i=n-1;i>=0;i--){
    v[i]=min(v[i+1],d[i]+d2[i]);
  }
  rep(i,n)cout << 1000000000000000-v[i] << endl;
return 0;}

Measured memory_bytes: 17724
n= int(input())
b= list(map(int,input().split()))
getnum = []
while len(b)>0:
    tempmax=-1
    for i,c in enumerate(b):
        if i+1==c:tempmax=i
    if tempmax==-1:
        print(-1)
        break
    else:
        getnum.append(b[tempmax])
        del b[tempmax]
else:
    for t in getnum[::-1]:print(t)

Measured memory_bytes: 8888
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#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)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, m;
int rins[9][9];

int main(){
  cin >> n >> m;
  memset(rins, sizeof(rins), 0);
  int inp1,inp2;
  rep(i, m){
    cin >> inp1 >> inp2;
    rins[inp1][inp2] = 1;
    rins[inp2][inp1] = 1;
  }
  vi v;
  vi c;
  int ans = 0;
  bool flag;
  for(int i = 2; i <= n; i++) v.push_back(i);

  do{
    c.clear();
    c.push_back(1);
    rep(i, n-1) c.push_back(v[i]);

    flag = true;
    rep(i, n-1) if(rins[c[i]][c[i+1]] == 0) flag = false;
    if(flag) ans++;
  }while(next_permutation(v.begin(), v.end()));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long i,j,k,c,n,f[21]={0};
f[1]=j=1;
cin>>n;
for(k=1;k<=n;k++){
c=0;
for(i=1;i<=j+1;i++){
f[i]=f[i]*k+c;c=f[i]/10;
if(c){
f[i]%=10;if(i+1>j)j++;
}
}
}
while(j>0)cout<<f[j--];
cout<<endl;
return 0;
}

Measured memory_bytes: 1156
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def i(n: Int): Int = ints(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    val Seq(a, b) = readLine.ints
    val c: String = (a - b).signum match {
      case -1 => "<"
      case 1 => ">"
      case _ => "=="
    }
    println(s"a $c b")
  }
}

Measured memory_bytes: 43768
program RainFlowsintoDams
    implicit none
    integer(4):: n, i
    integer(8), allocatable:: a(:), ans(:)

    read*, n
    allocate(a(n), ans(n))
    read*, a(:)

    ans(:) = 0
    ans(1) = sum(a) - 2*sum(a(2:n:2))

    do i=2,n
        ans(i) = 2*a(i-1) - ans(i-1)
    end do

    print*, ans(:)

end program RainFlowsintoDams

Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n, a[100], s = 0, ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }
    double y = double(s) / n;
    if(int(y * 10) % 10 >= 5) y = int(y) + 1;
    else                 y = int(y);
    for(int i = 0; i < n; i++){
        ans += pow(a[i] - y, 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//      https://youtu.be/X_hMZYDMps4

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define all(x)              x.begin(),x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,ans=0,flag=0,mod=1000000007,odd=0,even=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        if(ll(s[i]-'0')==i%2) odd++;
        if(ll(s[i]-'0')!=i%2) even++;
    }
    cout<<min(odd,even);
}


Measured memory_bytes: 3772
n=int(input())
s=[input() for i in range(n)]
l=list(set(s))
o=[]
for x in range(len(s)):
    o.append(0)
dic=dict(zip(l,o))

for x in s:
   if x in dic:dic[x]+=1
d=sorted(dic.items(),key=lambda x:-x[1])
m=d[0][1]
p=[]
for r in d:
    if r[1]==m:p.append(r[0])
u=sorted(p)
for y in u:
    print(y)

Measured memory_bytes: 58764
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
using namespace std;
 
int main () {
  int r;
  cin >> r;
  double pi = 3.141592;
  cout << pi * 2 * r;
  
  

  return 0;
}

Measured memory_bytes: 3788
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
lens = len(s)
a = int(s[0])
b = s[1:]
t = '9'*(lens-1)
if b == t:
    print((lens-1)*9+a)
else:
    print((lens-1)*9+a-1)














Measured memory_bytes: 27132
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	
    public static void main(String[] args) {
        Scanner sc = new Scanner (System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        long [] s = new long[n];
        long ans = 0;
        for(int i=0;i<n;i++) {
        	a[i] = sc.nextLong();
        	b[i] = sc.nextLong();
        	s[i] = a[i] + b[i];
        	ans -= b[i];
        }
        
        Arrays.sort(s);
        
        for(int i=n-1;i>=0;i-=2) {
        	ans += s[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 93532
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {

	int N, R;
	cin >> N >> R;

	if (N <= 10) {
		cout << 100 * (10 - N) + R << endl;
	}
	else {
		cout << R << endl;
	}
	
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  char ss[101];
  cin>>ss;
  int n=strlen(ss);
  int count=0;
  for(int i=0;i<n/2;i++){
    if(ss[i]!=ss[n-1-i])count++;
  }
  cout<<count;
}

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

struct Point{
    long double x, y;
    long double theta;
    int stat;
    Point(int _x = 0, int _y = 0, int _stat = 0): x(_x), y(_y), stat(_stat) {
        theta = atan2(_y, _x) + acos(-1) * _stat;
    };
    bool operator < (const Point &rhs) {
        if (theta == rhs.theta)
            return stat < rhs.stat;
        return theta < rhs.theta;
    }
};

int main() {
    int n;
    cin >> n;
    vector<Point> V;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        for (int j = 0; j < 4; j++)
            V.push_back(Point(x, y, j));
    }
    sort(V.begin(), V.end());
    long double X = 0, Y = 0;
    long double ans = 0;
    for (auto p : V) {
        X += p.x * (2 * (p.stat % 2) - 1);
        Y += p.y * (2 * (p.stat % 2) - 1);
        ans = max(ans, sqrt(X * X + Y * Y));
    }
    cout << fixed << setprecision(12) << ans << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vvi dp(N, vi(3, 0));
	REP(i, N) {
		int a, b, c;
		cin >> a >> b >> c;
		if (i == 0) {
			dp[i][0] = a;
			dp[i][1] = b;
			dp[i][2] = c;
		}
		else {
			dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
			dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
			dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c;
		}
	}
	int ans = 0;
	REP(i, 3) {
		ans = max(ans, dp[N - 1][i]);
	}
	cout << ans << endl;
	PAU;
	return 0;
}


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

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

  int N, D;
  cin >> N >> D;
  vector<vector<int>> dot(N, vector<int>(D));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> dot.at(i).at(j);
    }
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      long double distance = 0;
      for(int t = 0; t < D; t++){
        distance += pow((dot.at(i).at(t) - dot.at(j).at(t)), 2);
      }
      distance = sqrt(distance);
      if(distance == floor(distance)){
        count++;
      }
    }
  }
  cout << count <<endl;
}

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

#define MAX 10000
int num[MAX];

void unite(int x, int y, int n){
	int sma=0, big=0;
	if(x < y){
		big=num[y];
		sma = num[x];
		num[y] = num[x];
	} else{
		big=num[x];
		sma = num[y];
		num[x] = num[y];
	}
	for(int i=0; i<n; i++){
		if(num[i] == big){ num[i] = sma; }
	}
}

void same(int x, int y){
	if(num[x] == num[y]){ cout << 1 << endl;
	} else{ cout << 0 << endl; }
}

int main(){
	int n, q;
	cin >> n >> q;
	int com[q], x[q], y[q];
	for(int i=0; i<n; i++){ num[i] = i; }

	for(int i=0; i<q; i++){ cin >> com[i] >> x[i] >> y[i]; }
	
	for(int i=0; i<q; i++){
		if(com[i]==0){ unite(x[i], y[i], n); }
		else if(com[i]==1){ same(x[i], y[i]); }
	}

	return 0;
}


Measured memory_bytes: 4280
from collections import Counter
n,d,m,t,ans=int(input()),Counter(map(int,input().split())),int(input()),Counter(map(int,input().split())),"YES"
for i in t.keys():
  if i in d.keys():
    if d[i]<t[i]:ans="NO"
  else:ans="NO"
print(ans)

Measured memory_bytes: 67680
local n, q = io.read("*n", "*n")
local parent = {}
for i = 1, n do parent[i] = i end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

for i = 1, q do
  local t, u, v = io.read("*n", "*n", "*n")
  u, v = u + 1, v + 1
  local ru, rv = uf_findroot(u), uf_findroot(v)
  if t == 0 then
    parent[rv], parent[v] = ru, ru
  else
    print(ru == rv and 1 or 0)
  end
end


Measured memory_bytes: 6264
#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 int long long
#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; }

ll GCD(ll A, ll b) { return b ? GCD(b, A%b) : A; }
ll LCM(ll A, ll b) { return A / GCD(A, b)* b; }

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 h,w,n; cin>>h>>w>>n;
  vi A(n);
  rep(i,n) {
    cin>>A[i]; A[i];
  }
  
  int k=0,cnt=A[0];
  rep(i,h){
    if(i%2==0) rep(j,w){
      if(cnt==0){
        cnt=A[++k];
      }
      cnt--;
      cout<<k+1;
      if(j!=w-1) cout<<" ";
    }
    
    if(i%2==1){
      deque<int> q;
      for(int j=w-1; j>=0; j--){
        if(cnt==0){
          cnt=A[++k];
        }
        cnt--;
        q.push_front(k);
      }
      rep(j,w){
        cout<<(q.front()+1);
        q.pop_front();
        if(j!=w-1) cout<<" ";
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, K, R, S, P;
string T;

int main() {
    cin >> N >> K >> R >> S >> P >> T;

    int ans = 0;
    for (int i = 0; i < K; i++) {
        vvi DP(N / K + 1, vi(3, 0));  // r,s,p
        int k = 0;
        for (int j = i; j < N; j += K) {
            if (k == 0) {
                if (T[j] == 'r') {
                    DP[k][2] = P;
                } else if (T[j] == 's') {
                    DP[k][0] = R;
                } else {
                    DP[k][1] = S;
                }
            } else {
                if (T[j] == 'r') {
                    DP[k][0] = max(DP[k - 1][1], DP[k - 1][2]);
                    DP[k][1] = max(DP[k - 1][0], DP[k - 1][2]);
                    DP[k][2] = max(DP[k - 1][0], DP[k - 1][1]) + P;
                } else if (T[j] == 's') {
                    DP[k][0] = max(DP[k - 1][1], DP[k - 1][2]) + R;
                    DP[k][1] = max(DP[k - 1][0], DP[k - 1][2]);
                    DP[k][2] = max(DP[k - 1][0], DP[k - 1][1]);
                } else {
                    DP[k][0] = max(DP[k - 1][1], DP[k - 1][2]);
                    DP[k][1] = max(DP[k - 1][0], DP[k - 1][2]) + S;
                    DP[k][2] = max(DP[k - 1][0], DP[k - 1][1]);
                }
            }
            k++;
        }
        ans += max(max(DP[k - 1][0], DP[k - 1][1]), DP[k - 1][2]);
        // cout << max(max(DP[k - 1][0], DP[k - 1][1]), DP[k - 1][2]) << endl;
    }

    cout << ans << endl;
    return 0;
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

int main()
{
    ll i,j,k,n,x,m;

    cin >> n>> x;
    ll ar[n+10];

    ll cnt = 0;
    for(i=0; i<n; i++)
    {
        cin >> ar[i];
    }

    for(i=1; i<n; i++)
    {
        m = ar[i]+ar[i-1];
        if(m>x)
        {
            ll baki = m-x,f1,f2;
             cnt += baki;

            f1 = min(ar[i],baki);

            ar[i] -= f1;
            baki -= f1;

            f1 = min(ar[i-1],baki);

            ar[i-1] -= f1;



        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 4384
n = int(input())
L = list(map(int, input().split()))

prev = float('inf')
memo = 0
for elm in L:
    if memo == 0 and elm < prev:
        memo = elm
    else:
        memo = max(elm, memo)
        if elm <= memo - 2:
            print("No")
            break
    
    prev = elm
else:
    print("Yes")


Measured memory_bytes: 15020
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	int a[4]; char s[4];
	rep(i,4){
		cin>>s[i]; a[i]=s[i]-'0';
		s[i]='+';
	}
	if(a[0]+a[1]+a[2]-a[3]==7) s[2]='-';
	else if(a[0]+a[1]-a[2]+a[3]==7) s[1]='-';
	else if(a[0]+a[1]-a[2]-a[3]==7){s[1]='-'; s[2]='-';}
	else if(a[0]-a[1]+a[2]+a[3]==7) s[0]='-';
	else if(a[0]-a[1]+a[2]-a[3]==7){s[0]='-'; s[2]='-';}
	else if(a[0]-a[1]-a[2]+a[3]==7){s[0]='-'; s[1]='-';}
	else if(a[0]-a[1]-a[2]-a[3]==7){s[0]='-'; s[1]='-'; s[2]='-';}

	cout<<a[0]<<s[0]<<a[1]<<s[1]<<a[2]<<s[2]<<a[3]<<"=7"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i,j,k,b[1000001],c[1000001],a[200],n;
  for(i=0;a[i-1]<1000000;i++)a[i]=i*(i+1)*(i+2)/6;
  for(j=0;j<=1000000;j++)b[j]=c[j]=j;
  for(j=2;j<i;j++){
    for(k=a[j];k<=1000000;k++){
      b[k]=min(b[k],b[k-a[j]]+1);
      if(a[j]%2){
        c[k]=min(c[k],c[k-a[j]]+1);
      }
    }
  }
while(cin>>n,n){
cout<<b[n]<<' '<<c[n]<<endl;
}
return 0;
}

Measured memory_bytes: 10888
n = int(input())
d, x = list(map(int, input().split()))
a_list = []
for i in range(n):
  a_list.append(int(input()))

count = 0
for i in a_list:
  j = 0
  while i * j + 1 <=d:
    count += 1
    j += 1

print(count + x)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> b[m];
    for (int i=0; i<n; i++) {
        int ai, bi;
        cin >> ai >> bi;
        if (ai <= m)
            b[ai - 1].push_back(bi);
    }
    priority_queue<int> pq;
    int sum = 0;
    for (auto &bi:b) {
        for (auto &bij:bi) pq.push(bij);
        if (!pq.empty()) {
            sum += pq.top();
            pq.pop();
        }
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (1LL * i * j >= n) break;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n, t;
    int minc = 10000;

    cin >> n >> t;

    int c[101], ti[10001];

    for (int i = 0; i < n; i++) cin >> c[i] >> ti[i];

    for (int i = 0; i < n; i++) {
        if (minc > c[i]) {
            if (ti[i] <= t) {
                minc = c[i];
            }
        }
    }

    if (minc == 10000) {
        cout << "TLE" << endl;
    }
    else {
        cout << minc << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve();
signed main(){
#ifdef Sprinkle
   clock_t clock_start=clock();assert(freopen("test.txt","r",stdin));
#else
   ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#endif
   solve();
#ifdef Sprinkle
   cerr<<"Running Time: "<<((clock()-clock_start) *1.0 / CLOCKS_PER_SEC)<<"s\n";
#endif
}
#ifdef Sprinkle
void err(){cerr<<"\n";}template<typename T,typename...U>void err(const T&hd,const U&...tl){cerr<<hd<<(sizeof...(tl)?", ":"");err(tl...);}
#define debug(x...) cerr<<""#x" = ";err(x)
#else
#define debug(...) 0
#endif
int a[55];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;++i)cin>>a[i];
    int sum=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            if(i!=j){
                sum+=a[i]*a[j];
            }
        }
    }
    cout<<sum/2<<endl;
}

Measured memory_bytes: 256
import sys
import decimal
from decimal import Decimal

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    A, B = input().split()
    A = Decimal(A)
    B = Decimal(B)
    ans = A * B
    ans = ans.quantize(decimal.Decimal("1"), rounding=decimal.ROUND_FLOOR)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9936
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,50){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double eps=1e-7;
const int N=3e5+10;
int a[110];
int main()
{
//    freopen("D:\\untitled3\\in","r",stdin);
    sync;
    int n;
    cin>>n;
    fup(i,1,n)
    {
        cin>>a[i];
    }
    ll ans=1e18;
    fup(i,1,100)
    {
        ll tmp=0;
        fup(j,1,n)
        {
            tmp+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
rating = int(input())
if rating < 600:
    print(8)
elif rating < 800:
    print(7)
elif rating < 1000:
    print(6)
elif rating < 1200:
    print(5)
elif rating < 1400:
    print(4)
elif rating < 1600:
    print(3)
elif rating < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 61692
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if (u == NIL) {
    return;
  }
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u) {
  if (u == NIL) {
    return;
  }
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main() {
  int i, v, l, r, root;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    T[i].p = NIL;
  }

  for(i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i = 0; i < n; i++) if(T[i].p == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2040
# Aizu Problem ITP_1_9_C: String Game
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


taro, hanako = 0, 0
n = int(input())
for _ in range(n):
    s1, s2 = input().split()
    if s1 == s2:
        taro += 1
        hanako += 1
    elif s1 > s2:
        taro += 3
    else:
        hanako += 3

print(taro, hanako)

Measured memory_bytes: 7640
n = int(input())
a = 0
b = 0
c = 0
d = 0
for i in range(n):
    e = input()
    if e == "AC":
        a += 1
    if e == "WA":
        b += 1
    if e == "TLE":
        c += 1
    if e == "RE":
        d += 1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

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

int main() {
  
  int N; cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  int Alice = 0, Bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) Alice += A[i];
    else            Bob   += A[i];
  }
  
  cout << Alice - Bob << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
    unsigned short *A, *B;

    int C[VMAX+1];
    int n, i, j;
    scanf("%d,",&n);

    A = malloc(sizeof(short)*n+1);
    B = malloc(sizeof(short)*n+1);

    for(i=0; i<=VMAX; i++) C[i]=0;

    for(i=0; i<n; i++){
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }

    for (i=1; i<= VMAX; i++ )C[i]=C[i]+C[i-1];

    for (j=1; j<=n; j++){
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }
    for (i=1; i<=n; i++){
        if(i>1)printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}


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

  int N;
  int K;
  cin >> N >> K;
  
  int R;
  int S;
  int P;
  cin >> R >> S >> P;
  
  string T;
  cin >> T;
  
  for(int i = K;i < N;++i){
    if(T[i] == T[i - K]){
      T[i] = 'w';
    }
  }
  
  
  int num = 0;
  
  for(int i = 0;i < N;++i){
    if(T[i] == 'r'){
      num = P + num;
    }
    else if(T[i] == 's'){
      num = R + num;
    }
    else if(T[i] == 'p'){
      num = S + num;
    }
    else{
      num = 0 + num;
    }
  }
  
  cout << num << endl;
    
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long

int main() {
    ll n;
    cin >> n;
    ll num = 0;
    for(int i = 1; i <= n; i++) {
        num = i+i*(i-1)/2;
        if(n <= num) {
            break;
        }
    }
    int sum = 0;
    for(int i = 1; i <= n; i++) {
        if(num-n == i) {
            //
        }
        else {
            cout << i << endl;
            sum += i;
        }
        if(sum == n) {
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int a = N / 1000;
    int b = (N % 1000 ) / 100;
    int c = (N % 100 )  / 10;
    int d = N % 10;

    String msg = "No";
    if (a == b & a == c )
      msg = "Yes";
    else if (d == b & d == c)
      msg = "Yes";

    System.out.println(msg);

  }
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i))
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(x,v) for(const auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義 #define int long long
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; }
//lambda: [&](int x, int y){return x<y;}

signed main(void){
    string s;cin>>s;
    vsort(s);
    if(s!="abc")cout << "No" << endl;
    else cout << "Yes" << endl;

}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int a,b;
int mi=INF;

void bfs(int idx,int sum) {
	if(idx==a) {
		mi=min(mi,sum);
		return;
	}
	bfs(idx+1,sum+b);
	bfs(idx+1,sum*2);
}

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

	cin>>a>>b;
	bfs(0,1);
	cout<<mi<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


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

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

int main() {
  int X;
  cin >> X;
  
  for (int i=0; i<179; i++) {
    int a = (i + 1) * 360;
    int b = a % X;
    
    if (b == 0) {
      int c = a / X;
      cout << c << endl;
      break;
    }
  }
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int n;
int memo[31], ans[31];
int main(){
  while(cin>>n){
    if(!n)
      return 0;
    memo[0]=1;
    memo[1]=1;
    memo[2]=2;
    for(int i=3;i<=n;i++){
      if(!memo[i]){
	memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
      }
    }
      if(memo[n]%3650)
      ans[n]+=1;
      ans[n]+=memo[n]/3650;
      cout<<ans[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
A, B = map(int, input().split())


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


Ps = primes(1000001)
Plen = len(Ps)
As = [0] * Plen
Bs = [0] * Plen
for i, p in enumerate(Ps):
    while A % p == 0:
        A = A // p
        As[i] += 1
    while B % p == 0:
        B = B // p
        Bs[i] += 1
ans = 1
if A > 1000001 and B > 1000001 and A == B:
    ans += 1
for _ in range(Plen):
    if As[_] != 0 and Bs[_] != 0:
        ans += 1
print(str(ans))

Measured memory_bytes: 14060