akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int N,M,ans(0);
vector <int> connect[8];
int passed[8]={0},node(0);

int dfs(int n){
  passed[n]=1;
  node++;
  if (node==N) ans+=1;
  for (int i(0);i<connect[n].size();i++){
    if (passed[connect[n][i]]==0) dfs(connect[n][i]); // is not still path
  }
  passed[n]=0;
  node--;
  return 0;
}

int check(int n){
  passed[n]=1;
  node++;
  if(node==N){
    ans++;
  }
  for(int i=0;i<connect[n].size();i++){
    if(passed[connect[n][i]]==0){
      check(connect[n][i]);
    }
  }
  passed[n]=0;
  node--;
  return 0;
}

// int main() {
// 	cin>>N>>M;
// 	for (int i(0);i<N;i++) {
//     int a,b;
//     cin>>a>>b;
//     connect[b-1].push_back(a-1);
//     connect[a-1].push_back(b-1);
//   }
//   // dfs(0);
//   check(0);
//   cout<<ans<<endl;
//   return 0;
// }
int main(){
  
  cin>>N>>M;
  vector<int> a(M),b(M);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    connect[a[i]-1].push_back(b[i]-1);
    connect[b[i]-1].push_back(a[i]-1);
  }
  check(0);
  cout<<ans<<endl;
  
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N;
  map<ll, ll> L, R;
  cin >> N;
  REP(i, N) {
    ll tmp;
    cin >> tmp;
    if (L.count(i + tmp)) {
      L.at(i + tmp)++;
    } else {
      L[i + tmp] = 1;
    }
    if (R.count(i - tmp)) {
      R.at(i - tmp)++;
    } else {
      R[i - tmp] = 1;
    }
  }
  ll ans = 0;
  for (auto a : L) {
    if (R.count(a.first)) {
      ans += (a.second * R.at(a.first));
    }
  }

  cout << ans << endl;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    cout << N*N*N;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define pb push_back
#define tam 320000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef  double lld;
int val[tam];
bool vis[tam];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    forr(i,0,n)
    {
        cin>>val[i];
    }
    memset(vis,0,sizeof vis);
    sort(val,val+n);
    int c=0;
    forr(i,0,n)
    {   
        if (vis[val[i]]==0)
            vis[val[i]]=1;
        else
            c++;
    }
    cout<<n-c-(c%2)<<endl;

}

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

int main(){
	double w,h,x,y;
	cin >> w >> h >> x >> y;
	cout << fixed << setprecision(10) << w*h/2 << ' ';
	if (x == w/2 and h/2 == y) cout << 1;
	else cout << 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

typedef __int128_t Int;
signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int A,B,C,K;
  cin>>A>>B>>C>>K;

  if(K%2 == 0) cout<<A-B<<endl;
  else cout<<B - A<<endl;
  return 0;

  int flag = 0;
  Int ans = A - B;
  const int INF = 1e18;
  while(K-- && flag == 0){
    Int nA = B + C;
    Int nB = A + C;
    Int nC = A + B;
    ans = (B -A);
    if(nA > INF || nB > INF || nC > INF) flag = 1;
    A = nA;
    B = nB;
    C = nC; 
  }

  if(flag) cout<<"Unfair"<<endl;
  else cout<<A - B<<endl;

  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h,n;
    cin>>h>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	sum+=a[i];
    }
    if(sum>=h){
    	cout<<"Yes"<<endl;
    }
    else
    	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    unsigned long long N;
    unsigned long long ans = 0;
    cin >> N;
    map<unsigned long long, unsigned long long> count;
    for (unsigned long long i = 0; i < N; ++i)
    {
        unsigned long long a;
        cin >> a;
        ++count[a];
    }
    for (auto i = count.begin(); i != count.end(); ++i)
    {
        if (i->second % 2 == 1)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9732
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
  ll n,k;
  cin>>n>>k;
  vi v(n);
  rep(i,0,n) cin>>v[i];
  rep(i,k,n)
  {
    if(v[i]>v[i-k])
    cout<<"Yes";
    else
    cout<<"No";
    cout<<"\n";
  }
}
int main()       
{
  fastio
  ll tt=1;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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


int main(){
  int a,b; cin >> a >> b;
  int k; cin >> k;
  int now = a;
  for(int i = 0; i < k; ++i){
    if(now > b)break;
    cout << now << endl;
    now++;
  }
  now = max(b-k+1,now);
  for(int i = now; i <= b; ++i){
    cout << i << endl;
  }
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
    int a,b,c,i,min=1000,num;
    int flg[102];
    scanf("%d%d",&a,&b);
    for(i=0;i<=101;i++) flg[i]=0;
    for(i=0;i<b;i++){
        scanf("%d",&c);
        flg[c]=1;
    }
    for(i=0;i<=101;i++){
        if(flg[i]==0){
            if(i<a&&min>a-i){
                min=a-i;
                num=i;
            }
            if(i>=a&&min>i-a){
                min=i-a;
                num=i;
            }
        }
    }
    printf("%d\n",num);
    return 0;
}

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

char S[202020];
LL ans, B;

int main(){
    scanf("%s", S);
    for (int i=0; S[i]; i++){
        if (S[i] == 'B') B++;
        else ans += B;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,T=map(int,input().split())
ans=10000
for i in range(n):
    c,t=map(int,input().split())
    if t>T:
        continue
    if c<ans:
        ans=c
if ans==10000:
  print("TLE")
else:
  print(ans)

Measured memory_bytes: 66228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long sum = 0;
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			sum += a[i];
		}
		
		long count = 0;
		long mod = 1000000007;
//		for(int i = 0; i < n - 1; i++) {
//			for(int j = i + 1; j < n; j++) {
//				count += a[i] * a[j] % mod; 
//				if(count >= mod) count = count % mod;
//			}
//		}
		for(int i = 0; i < n - 1; i++) {
			sum -= a[i];
			count += ((a[i] % mod) * (sum % mod)) % mod; 
		}
		
		
//		long answer = count % mod;
		System.out.println(count % mod);
		
	}

}


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

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

  string ans = "";
  rep(i, s.length()) {
    if (i % 2 == 0)
      ans.push_back(s[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int w = ni();
        int h = ni();
        int n = ni();
        int maxX = w;
        int minX = 0;
        int maxY = h;
        int minY = 0;
        for (int i = 0; i < n; i++) {
            int x = ni();
            int y = ni();
            int a = ni();

            if (a == 1) {
                minX = Math.max(minX, x);
            } else if (a == 2) {
                maxX = Math.min(maxX, x);
            } else if (a == 3) {
                minY = Math.max(minY, y);
            } else if (a == 4) {
                maxY = Math.min(maxY, y);
            }
        }

        out.println((maxX <= minX || maxY <= minY) ? 0 : (maxX - minX) * (maxY - minY));
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8524
N, H, D = map(int, input().split())
MOD = 10 ** 9 + 7

fact = 1
s = 0
for i in range(1, N+1) :
    fact = fact * i % MOD
    s = (s + fact) % MOD

dp = [0] * H
dp[0] = 1
ret = 1

for i in range(1, H) :
    dp[i] = ret * s % MOD
    ret = (ret + ret * s) % MOD
    if i >= D : 
        ret = (ret - dp[i - D]) % MOD
        
print(ret * fact % MOD)

Measured memory_bytes: 47980
#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
int dp[MAX][3];
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i-1];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i-1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i-1];
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector <int> num(N+1);
  for(int i = 0;i<N;i++){
    cin >> num.at(i);
  }
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  int A = 0,B = 0;
  for(int i = 0;i <N;i+=2){
    A = A+num.at(i);
    B = B+num.at(i+1);
  }
  cout << A-B << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    let mut task: Vec<i32> = n.trim().split_whitespace()
        .map(|x| x.parse().unwrap()).collect();

    task.sort();

    let mut ans = 0;
    for i in 1..task.len() {
        ans += task[i] - task[i-1];
        
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;

	vector<string> a(H);
	for (int i = 0; i < H; i++)
		cin >> a.at(i);

	int count;
	vector<int> b(100);
	int bcou = 0;

	for (int i = 0; i < H; i++) {
		count = 0;
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '.')
				count++;
			if (count == W) {
				b.at(bcou) = i;
				bcou++;
			}
		}
	}

	for (int i = 0; i < W; i++) {
		count = 0;
		for (int j = 0; j < H; j++) {
			if (a[j][i] == '.')
				count++;
			if(count==H){
				for (int k = 0; k < H; k++) {
					a[k].at(i)='0';
				}
			}
		}
	}

	int j = 0;
	for (int i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (a[i].at(j) == '0')
				continue;
			for (int k = 0; k < bcou; k++) {
				if (i == b.at(k)) {
					j = W+1;
					break;
				}
			}
			if (j != W + 1)
				cout << a[i].at(j);
		}
		if (j == W)
			cout << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<list>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int inf=1e9+7;
const int mod=1e9+7;

//const int maxn=

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    int n;
    cin>>n;
    
    string str1,str2;
	
	cin>>str1>>str2;
	
	int N=(n<<1);
	
	string ans="";
	
	for(int i=0;i<N;i++)
	{
		if(i&1)
			ans+=str2[i>>1];
		else
			ans+=str1[i>>1];
	}
	
	cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
gets
ps = [0] + gets.split.map(&:to_i)
xys = $stdin.read.split

h = {}
xys.each_slice(2) do |xs,ys|
  x = xs.to_i
  y = ys.to_i
  h[x] ||= []
  h[x] << y
  h[y] ||= []
  h[y] << x
end

used = {}
ret = 0
h.each do |k,v|
  next if used[k]
  b = v
  lused = {}
  lused[k] = 1
  until b.empty?
    b.each do |n|
      lused[n] = 1
    end
    b = b.flat_map {|n| h[n] || []}.uniq.reject {|n| lused[n]}
  end
  used.merge!(lused)

  lused.each_key do |n|
    ret += 1 if lused[ps[n]]
  end
end

1.upto(ps.length-1) do |i|
  ret += 1 if !used[i] && ps[i] == i
end

p ret


Measured memory_bytes: 52468
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s,t;
  cin >> s >> t;
 
  cout << t << s << endl;

  
}

Measured memory_bytes: 3576
#include <iostream>
#include <complex>
#include <vector>

using namespace std;

const double EPS = 1e-7;
typedef complex<double> P;
typedef vector<P> G;
struct L { P p, q; L(P p, P q) : p(p), q(q) {} };
double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }

double distLP(L l, P p){
	if(dot(l.q-l.p,p-l.p)<-EPS) return abs(p-l.p);
	if(dot(l.p-l.q,p-l.q)<-EPS) return abs(p-l.q);
	return abs(cross(l.q-l.p,p-l.p))/abs(l.q-l.p);
}

double distLL(L l, L m){
	double res = distLP(l, m.p);
	res = min(res, distLP(l, m.q));
	res = min(res, distLP(m, l.p));
	res = min(res, distLP(m, l.q));
	return res;
}

double distCC(G g1, G g2){
	double res = 1e12;
	for(int i=0;i<g1.size();i++){
		for(int j=0;j<g2.size();j++){
			res = min(res, distLL(L(g1[i],g1[(i+1)%g1.size()]),L(g2[j],g2[(j+1)%g2.size()])));
		}
	}
	return res;
}

int main(){
	double d1[200], d2[200];
	double dist[200][200];
	int w, n;
	while(cin >> w >> n, w){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++) dist[i][j] = 1e12;
			dist[i][i] = 0.0;
		}
		vector<G> vg;
		G vd1, vd2;
		vd1.push_back(P(0,-100));
		vd1.push_back(P(0,20000));
		vd2.push_back(P(w,-100));
		vd2.push_back(P(w,20000));
		for(int i=0;i<n;i++){
			G g;
			int m; cin >> m;
			for(int j=0;j<m;j++){
				int x, y; cin >> x >> y;
				g.push_back(P(x,y));
			}
			vg.push_back(g);
		}
		for(int i=0;i<n;i++){
			d1[i] = distCC(vd1,vg[i]);
			d2[i] = distCC(vd2,vg[i]);
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				dist[i][j] = distCC(vg[i],vg[j]);
				dist[j][i] = dist[i][j];
			}
		}
		for(int j=0;j<n;j++)
			for(int i=0;i<n;i++)
				for(int k=0;k<n;k++)
					dist[i][k] = min(dist[i][k], dist[i][j]+dist[j][k]);
		double ans = w;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				ans = min(ans, d1[i]+dist[i][j]+d2[j]);
			}
		}
		printf("%.8lf\n", ans);
	}
}

Measured memory_bytes: 0
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

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

int main()
{
    int n,t,m;
    bool f = 1;
    cin >> n;
    vector<int> a;
    rep(i,n){
        cin >> t;
        if((t%2) == 0){
            a.push_back(t);
        }
    }
    m = a.size();
    rep(i,m){
        if((a[i] % 3) != 0){
            if((a[i] % 5) != 0){
                f = 0;
            }
        }
    }
    if(f){
        cout << "APPROVED";
    }else{
        cout << "DENIED";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define strep(it,v) for(it=v.begin();it!=v.end_();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 100031;
ll a,b;
int main()
{
   std::ios_base::sync_with_stdio(false); cin.tie(NULL);
   cin>>a>>b;
   cout<<a*a - b;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int x[N], y[N], t[N];

void fail() {
  puts("No");
  exit(0);
}

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &t[i], &x[i], &y[i]);
    int h = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if(t[i - 1] + h > t[i] || (t[i] - t[i - 1] - h) & 1)
      fail();
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

int main(){
  int H, W; cin >> H >> W;
  std::vector<string> S(H);
  for(int i = 0; i < H; i++) cin >> S[i];
  std::vector<string> T = S;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '#'){
        T[i][j] = '#';
        continue;
      }
      int tmp = 0;
      for(int x = -1; x <= 1; x++){
        for(int y = -1; y <= 1; y++){
          if(0 <= i + x && i + x < H && 0 <= j + y && j + y < W){
            if(S[i+x][j+y] == '#') tmp++;
          }
        }
      }
      T[i][j] = '0' + tmp;
    }
  }
  for(int i = 0; i < H; i++) cout << T[i] << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a,b,c = LI()
    ans = 10 ** 5
    ans = min(ans, a + b)
    ans = min(ans, a + c)
    ans = min(ans, c + b)
    print(ans)
    return

#B
def B():
    n = II()
    w = LI()
    ans = inf
    for i in range(n):
        ans = min(ans, abs(sum(w[:i]) - sum(w[i:])))
    print(ans)
    return

#C
def C():
    n, m = LI()
    a = IR(m)+[inf]
    dp = [0] * (n + 3)
    dp[0] = 1
    for i in range(n + 1):
        if a[bisect_left(a, i + 1)] != i + 1:
            dp[i + 1] += dp[i] % mod
        if a[bisect_left(a, i + 2)] != i + 2:
            dp[i + 2] += dp[i] % mod
    print(dp[n] % mod)
    return

#D
def D():
    h, w = LI()
    s = SR(h)
    dp = [[0] * w for _ in range(h)]
    for x in range(w):
        for y in range(h):
            if s[y][x] == ".":
                dp[y][x] += 1
    for y in range(h):
        x = 0
        q = 0
        while 0 <= x < w:
            if s[y][x] == ".":
                dp[y][x] += q
                q += 1
            else:
                q = 0
            x += 1
        x = w - 1
        q = 0
        while 0 <= x < w:
            if s[y][x] == ".":
                dp[y][x] += q
                q += 1
            else:
                q = 0
            x -= 1
    for x in range(w):
        y = 0
        q = 0
        while 0 <= y < h:
            if s[y][x] == ".":
                dp[y][x] += q
                q += 1
            else:
                q = 0
            y += 1
        y = h - 1
        q = 0
        while 0 <= y < h:
            if s[y][x] == ".":
                dp[y][x] += q
                q += 1
            else:
                q = 0
            y -= 1
    print(max(map(lambda x: max(x), dp)))
    return

# E
def E():
    l = S()
    dp = [1, 2]
    for i in range(1,len(l)):
        less = dp[0] % mod
        equal = dp[1] % mod
        if l[i] == "1":
            dp[0] = less * 3 + equal
            dp[1] = equal * 2
        else:
            dp[0] = less * 3
            dp[1] = equal
    print(sum(dp) % mod) 

#Solve
if __name__ == '__main__':
    E()


Measured memory_bytes: 53232
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] input = sc.next().split("");
		Map<String, Integer> left = new HashMap<>();
		Map<String, Integer> right = new HashMap<>();

		int res = 0;
		for (int i = 1; i < N; i++) {
			int tmpRes = 0;
			for (int j = 0; j < i; j++) {
				if (left.get(input[j]) == null) {
					left.put(input[j], 1);
				} else {
					left.put(input[j], left.get(input[j]) + 1);
				}
			}
			for (int j = i; j < N; j++) {
				if (right.get(input[j]) == null) {
					right.put(input[j], 1);
				} else {
					right.put(input[j], right.get(input[j]) + 1);
				}
			}
			for (Map.Entry<String, Integer> entry : left.entrySet()) {
				if (right.get(entry.getKey()) != null) {
					tmpRes++;
				}
			}
			if (tmpRes > res) {
				res = tmpRes;
			}
			left.clear();
			right.clear();
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 37364
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<pair<int,int>> v;
	for(int i=0;i<n;i++){
		int x,l; cin >> x >> l;
		v.push_back(make_pair(x+l,x-l));
	}
	sort(v.begin(),v.end());
	int ans=0;
	int last=-1e9-3;
	for(int i=0;i<n;i++){
		if(v[i].second>=last){
			ans++;
			last=v[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include<stdio.h>

int main()
{
    int a,b;
    long long int temp,lcm,a1,b1;

    while(scanf("%d%d",&a,&b)!=EOF)
    {
        a1=a;
        b1=b;
        while(a%b!=0)
        {
           temp=a%b;
           a=b;
           b=temp;
        }

        lcm=a1*b1/b;
        printf("%d ",b);
        printf("%lld\n",lcm);
    }
    return 0;
}



Measured memory_bytes: 2012
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int c = sc.nextInt();
			int [][] data = new int[c][c];
			for(int i = 0; i < c; i++){
				for(int j = 0; j < c; j++){
					data[i][j] = sc.nextInt();
				}
			}
			
			int [][] count = new int[3][c];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					int color = sc.nextInt()-1;
					count[(i + j) % 3][color]++;
				}
			}
			
			int ans = Integer.MAX_VALUE;
			for(int i = 0; i < c; i++){
				for(int j = 0; j < c; j++){
					if(i == j) continue;
					for(int k  = 0; k < c; k++){
						if(i == k || j == k) continue;
						int sum = 0;
						for(int cc = 0; cc < c; cc++){
							sum += data[cc][i] * count[0][cc];
						}
						for(int cc = 0; cc < c; cc++){
							sum += data[cc][j] * count[1][cc];
						}
						for(int cc = 0; cc < c; cc++){
							sum += data[cc][k] * count[2][cc];
						}
						ans = Math.min(ans, sum);
					}
				}
			}
			System.out.println(ans);
		}
	}
	
	private long calc(long n, long m, long l){
		long sum = 1;
		for(long i = n; i > m; i--){
			sum *= i;
		}
		for(long i = 2; i <= l; i++){
			sum /= i;
		}
		return sum;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 80336
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define REP(x,b) for(int x=0;x<b;x++)
#define FORSIZE(x,A) for(int x=0;x<A.size();x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define rsort(x,n) sort(x, x+n, greater<int>())
#define REV(x) reverse(x.begin(),x.end())
using namespace std;
typedef long long ll;
inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}

int main( int argc, const char* argv[] )
{
    int a[101];
    int tmp;
    int c = 0;
    int m = 0;
    fill(a, a+101, 0);
    while (cin >> tmp) {
        a[tmp] += 1;
        m = max(m, a[tmp]);
        c += 1;
    }
    FOR(i, 0, 101) {
        if (a[i] == m) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

bool get_line( double , double , double , double , double& );

int main(void)
{
	double x1, x2, x3, x4;
	double y1, y2, y3, y4;

	double a1, a2;

	bool result1 , result2;

	int num;

	cin >> num;

	for( int i = 0 ; i < num ; i++ )
	{
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		result1 = get_line( x1 , x2 , y1 , y2 , a1 );
		result2 = get_line( x3 , x4 , y3 , y4 , a2 );

		if( result1 == false && result2 == false )
		{
			cout << "YES" << endl;
		}
		else
		{
			if( a1 - a2 >= -1e-10 && a1 - a2 <= 1e-10 ) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}

	return 0;
}

bool get_line( double x1 , double x2 , double y1 , double y2 , double& a )
{
	if( x1 - x2 >= -1e-10 && x1 - x2 <= 1e-10 )
	{
		return false;
	}
	else
	{
		a = ( y1 - y2 ) / ( x1 - x2 );

		return true;
	}
}

Measured memory_bytes: 1228
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
           Scanner sc=new Scanner(System.in);
           int c=0;
           String str=sc.next();
           if(str.contains("RRR"))
        	   System.out.println("3");
           else if(str.contains("RR"))
        	   System.out.println("2");
           else if(str.contains("R"))
        	   System.out.println("1");
           else
        	   System.out.println("0");
	}

}


Measured memory_bytes: 35512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    int h[N];
    int cnt = 0;
    REP(i,N){
        cin >> h[i];
        if(h[i] >= K) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

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

int step[100][100];
const int INF = 1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h){
        cin>>s[i];
    }
    int w_cnt = 0;
    rep(i,h){
        rep(j,w){
            if(s[i][j] == '.') w_cnt++;
        }
    }

    rep(i,100){
        rep(j,100){
            step[i][j] = INF;
        }
    }
    // bfs
    queue<P> q;
    q.push({0,0});
    step[0][0] = 1;
    while(!q.empty()){
        P nw = q.front(); q.pop();
        rep(i,4){
            int x = dx[i], y = dy[i];
            int nx = nw.first  + x; 
            int ny = nw.second + y;
            if(step[ny][nx] != INF) continue;
            if(nx<0 || nx>=w || ny<0 || ny>=h) continue;
            if(s[ny][nx] == '.'){
                step[ny][nx] = step[nw.second][nw.first] + 1;
                q.push({nx, ny});
            }
        }
    }
    if(step[h-1][w-1] == INF){
        cout<<-1<<endl;
        return 0;
    }
    cout<<w_cnt-step[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main(void)
{
  int n, a[10], sum = 0;
  bool yes = true;
  std::cin >> n;
  for(int i = 0; i != n; i++){
    std::cin >> a[i];
    sum += a[i];
  }
  for(int i = 0; i != n; i++){
    if(2 * a[i] >= sum){
      yes = false;
      break;
    }
  }
  std::cout << (yes ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import*
n,c=map(int,input().split());d=[list(map(int,input().split()))for _ in range(c)];e=[c*[0]for _ in range(3)]
for i in range(n):
  s=list(map(int,input().split()))
  for j in range(n):e[(i+j)%3][s[j]-1]+=1
if n==1:print(0);exit()
print(min(sum(d[t][i]*e[0][t]+d[t][j]*e[1][t]+d[t][k]*e[2][t]for t in range(c))for i,j,k in permutations((i for i in range(c)),3)))

Measured memory_bytes: 3064
function main(input) {
  var c = input.trim();
  var alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
  var result = alphabet.indexOf(c);
  console.log(alphabet[result + 1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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 SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	int n, m;
	vector<vector<pii>> g;
	vi loc;
	int nul{ INTMAX };
public:
	D()
	{
		cin >> n >> m;
		g.resize(n + 1);
		loc.resize(n + 1, nul);

		REP(i, m)
		{
			int l, r, d;
			cin >> l >> r >> d;

			g[l].emplace_back(MP(r, d));
			g[r].emplace_back(MP(l, -d));
		}

	}

	void solve()
	{

		REP1C(i, n)
		{

			if (loc[i] == nul)
			{
				loc[i] = 0;
				deque<int> que;
				que.PB(i);

				while (!que.empty())
				{
					int v = que.front(); que.pop_front();

					REP(i, SZ(g[v]))
					{
						int nxt = g[v][i].first;
						int c = g[v][i].second;

						if (loc[nxt] == nul)
						{
							loc[nxt] = loc[v] + c;
							que.PB(nxt);
						}
						else if (loc[nxt] != loc[v] + c)
						{
							cout << "No" << endl;
							return;
						}
					}
				}
			}
		}

		cout << "Yes" << endl;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}


Measured memory_bytes: 9344
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>

#define MAX 100001
#define NIL -1

using namespace std;

vector<int> G[MAX];
int n,e;
int Type[MAX];
int tt = 0;

void DFS(int i,int type){
    if (Type[i] != 0) return;
    Type[i] = type;
    for (int j = 0; j < G[i].size(); j++) {
            DFS(G[i][j],type);
    }
}

void DFS_Man(){
    for (int i = 0; i < n; i++) {
        if (Type[i] == 0) {
            tt++;
            DFS(i,tt);
        }
    }
}

int main(){
    cin >> n >> e;
    for (int i = 0; i < n; i++) Type[i] = 0;
    for (int i = 0; i < e; i++) {
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    DFS_Man();
    
    int com;
    
    cin >> com;
    for (int i = 0; i < com; i++) {
        int a1,a2;
        cin >> a1 >> a2;
        if (Type[a1] == Type[a2]) {
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 10184
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){
    vector<pair<T,T>> out(input.size()-1);
    rep(i,input.size()-1){
        out[i].first =input[i  ];
        out[i].second=input[i+1];
    }
    return(out);
}
vector<char> String_to_vector_char(const string& input){
    vector<char> out(input.size());
    rep(i,input.size()){
        out[i]=input[i];
    }
    return out;
}
inline bool operator<(const pii &lhs,const pii &rhs){
    return(lhs.first<rhs.first);
}

ll n;
map<string,vector<pii>> m;
void input(){
    string s;ll p;
    cin>>n;
    rep(i,n){
        cin>>s>>p;
        m[s].push_back({p,i+1});
    }
}

void src(){
    for(auto i:m){
        sort(i.second.rbegin(),i.second.rend());
        for(auto j:i.second){
            cout<<j.second<<"\n";
        }
    }
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using ll=long long;



void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || abs(a-b)<=d&&abs(b-c)<=d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define lli long long int
using namespace std;
int main()
{
    lli N, D;
    cin >> N >> D;
    lli res = 0;
    for (lli i = 0; i < N; i++)
    {
        lli x, y;
        cin >> x >> y;
        double dis = sqrt(x * x + y * y);
        if (dis <= (double)D)
            res++;
    }
    cout<<res<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vll> vvll;

#define FOR(i,a,b) for(long i=a;i<b;++i)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tc(t) while(t--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007

vector<bool> isPrime(100009,true);//declare outside function

void sieve(long long N)//eratosthenes
{
    isPrime[0] = false;
    isPrime[1] = false;
    for(long long i=2;i*i<=N;++i)
    {
        if(isPrime[i]==true)
        {
            for(long long j=i*i;j<=N;j+=i)
                isPrime[j]=false;
        }
    }
}

int main()
{
	io;
	ll x;
  cin>> x;
  sieve(100009);
  FOR(i,x,100009)
  {
    if(isPrime[i])
    {
      cout<<i;
      return 0;
    }
  }
	return 0;
}


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

int main() {
  int64_t N;
  cin>>N;
  int64_t a=N,b=0,c=1,Z=0;
  
  while(a>0){
    b++;
    if(b>1){
      c*=2;
    }
    a/=10;
  }
  
  for(int64_t i=0;i<c;i++){
    int64_t k=i,q=1,d=c/2;
    a=N;
    Z+=a%10;
    a/=10;
    while(a>0){
      if(k>=d){
        q=1;
        k-=d;
        Z+=a%10;
        a/=10;
        d/=2;
      }
      else{
        q*=10;
        Z+=(a%10)*q;
        a/=10;
        d/=2;
      }
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define usll                    unordered_set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	string s;
	cin>>s;
	for(ll i=0;i<3;++i)
	{
		if(s[i]=='7')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
char s[105];
int main(){
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++){
		if(s[i]=='C'){
			for(int j=len-1;j>i;j--){
				if(s[j]=='F'){
					printf("Yes");
					return 0;}}}}
	printf("No");return 0;}

Measured memory_bytes: 256
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, k = LI()
    s = '0' + SI() + '0'

    L = []
    R = []
    if s[1] == '0':
        L.append(1)
        R.append(1)
    for i in range(n + 1):
        if s[i] == '1' and s[i + 1] == '0':
            R.append(i)
        if s[i] == '0' and s[i + 1] == '1':
            L.append(i + 1)

    if s[-2] == '0':
        L.append(n)
        R.append(n)

    res = R[0] - L[0] + 1
    k = min(len(R) - 1, k)
    for i in range(len(R) - k):
        res = max(res, R[i + k] - L[i] + 1)

    # print(R)
    # print(L)

    return res


print(main())


Measured memory_bytes: 7184
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>

#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int main() {
  string s;
  int n, k;
  while (cin >> n >> k >> s) {
    s[k-1] += 32;
    cout << s << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;



Int ans, n, l[2200];

Int cnt(Int a, Int b){
    Int bottom = abs(a-b) + 1;
    Int top = a + b - 1;
    Int ans = upper_bound(l, l + n, top) - lower_bound(l, l + n, bottom);
    if(bottom <= a && a <= top)ans--;
    if(bottom <= b && b <= top)ans--;
    return ans;
}

int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> l[i];
    }
    sort(l, l + n);

    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            ans += cnt(l[i],l[j]);
        }
    }

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

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


def num2alpha(num):
    if num <= 26:
        return chr(64 + num)
    elif num % 26 == 0:
        return num2alpha(num // 26 - 1) + chr(90)
    else:
        return num2alpha(num // 26) + chr(64 + num % 26)


def main():
    print(num2alpha(N).lower())


main()


Measured memory_bytes: 9180