akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut edges = vec![];
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        let x = sc.read::<u64>();
        edges.push((a, b, x));
    }

    for &modulo in [1e9 as u64 + 7, 1e9 as u64 + 9, 998244353].iter() {
        let mut graph = vec![vec![]; n];
        for &(a, b, x) in edges.iter() {
            graph[a].push((b, x));
            graph[b].push((a, mod_pow(x, modulo - 2, modulo)));
        }
        let mut vis = vec![false; n];
        let mut cost = vec![None; n];
        for i in 0..n {
            if !vis[i] {
                vis[i] = true;
                cost[i] = Some(1);
                if !solve(i, &graph, &mut vis, &mut cost, modulo) {
                    println!("No");
                    return;
                }
            }
        }
    }
    println!("Yes");
}

fn mod_pow(mut x: u64, mut e: u64, modulo: u64) -> u64 {
    let mut result = 1;
    while e > 0 {
        if e & 1 == 1 {
            result = (result * x) % modulo;
        }
        x = (x * x) % modulo;
        e >>= 1;
    }
    result
}

fn solve(
    v: usize,
    graph: &Vec<Vec<(usize, u64)>>,
    vis: &mut Vec<bool>,
    cost: &mut Vec<Option<u64>>,
    modulo: u64,
) -> bool {
    let cur = cost[v].unwrap();
    for &(next, x) in graph[v].iter() {
        let next_cost = (cur * x) % modulo;
        if vis[next] {
            if let Some(prev) = cost[next] {
                if prev != next_cost {
                    return false;
                }
            }
        } else {
            vis[next] = true;
            cost[next] = Some(next_cost);
            if !solve(next, graph, vis, cost, modulo) {
                return false;
            }
            cost[next] = None;
        }
    }
    true
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 21624
import heapq
def dijkstra_heap(N,s,edge):
    d = [float("inf")] * N #始点sから各頂点への最短距離
    used = [False] * N
    d[s] = 0
    used[s] = True
    edgelist = []
    #edgelist : [sからの暫定(未確定)最短距離,頂点]のリスト
    #edge[s] : sから出る枝の[重み,終点]のリスト
    for v,w in enumerate(edge[s]):
        heapq.heappush(edgelist,(w,v)) #sの隣の点は枝の重さがそのまま暫定最短距離となる
    while len(edgelist):
        #まだ使われてない頂点の中から最小の距離のものを探す→確定させる
        minedge = heapq.heappop(edgelist)
        #minedge : [sからの(確定)最短距離,頂点]
        v = minedge[1]
        if used[v]:
            continue
        d[v] = minedge[0]
        used[v] = True
        for u,w in enumerate(edge[v]):
            if not used[u]:
                heapq.heappush(edgelist,(d[v]+w,u))
    return d


################################
A, B, C, D = map(int, input().split())
N = int(input())

d = [[0]*(N+2) for _ in range(N+2)]

X = [0]*N
Y = [0]*N
R = [0]*N
for i in range(N):
    X[i],Y[i],R[i] = map(int, input().split())
d[0][-1] = ((C-A)**2+(D-B)**2)**0.5
d[-1][0] = ((C-A)**2+(D-B)**2)**0.5
for i in range(1,N+1):
    d_s = max(0,((X[i-1]-A)**2+(Y[i-1]-B)**2)**0.5-R[i-1])
    d_e = max(0,((X[i-1]-C)**2+(Y[i-1]-D)**2)**0.5-R[i-1])
    d[0][i],d[i][0] = d_s,d_s
    d[N+1][i],d[i][N+1] = d_e,d_e
    for j in range(1,N+1):
        d[i][j] = max(((X[i-1]-X[j-1])**2+(Y[i-1]-Y[j-1])**2)**0.5-R[i-1]-R[j-1],0)
s = 0 #始点
d = dijkstra_heap(N+2,s,d)
print(d[-1])

Measured memory_bytes: 129244
#include <bits/stdc++.h>
#define N 500003
#define MOD 1000000007
#define int long long
using namespace std;

int vis[100006];
vector<int> v[100006];
int dp[100006];
void dfs(int root){
    if(vis[root])return;
    vis[root]=1;
    for(auto it:v[root]){
        if(!vis[it])
        dfs(it);
        dp[root]=max(dp[root],dp[it]+1);
    }



}


signed main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        dfs(i);
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main(void)
{
    long long K, count = 0;
    cin >> K;
    while (K != 0)
    {
        if (K % 10 == 7)
        {
            cout << "Yes\n";
            return 0;
        }
        K /= 10;
    }
    cout << "No\n";
}

Measured memory_bytes: 3600
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var list = nextCharArray();
	var ch = "abcdefghijklmnopqrstuvwxyz";
	if(list.length != 26){
		for(var i = 0; i < 26; i++){
			if(list.indexOf(ch[i]) == -1){
				list.push(ch[i]);
				break;
			}
		}
	}else{
		var tmpList = [];
		while(list.length > 0){
			tmpList.push(list.pop());
			tmpList.sort();
			var isOK = false;
			for(var i = 0; i < tmpList.length; i++){
				if(list[list.length - 1] < tmpList[i]){
					list.pop();
					list.push(tmpList[i]);
					isOK = true;
					break;
				}
			}
			if(isOK){
				break;
			}
		}
	}
	if(list.length == 0){
		myout(-1);
	}else{
		myout(myconv(list,0));
	}
}

Measured memory_bytes: 21320
s=input()
yy=int(s[:4])
mm=int(s[5:7])
dd=int(s[8:])
if yy<2019:
    print("Heisei")
elif yy==2019:
    if mm<4:
        print("Heisei")
    elif mm==4:
        if dd<=30:
            print("Heisei")
        else:
            print("TBD")
    else:
        print("TBD")
else:
    print("TBD")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define ull unsigned ll
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=n-1;i>=0;i--)
#define SZ(x) x.size()
#define ALL(x) x.begin(), x.end()
#define pb push_back 
#define pii pair<int, int>
#define SQ(x) (x)*(x)
#define ff first
#define ss second
#define endl '\n'
using namespace std;
main (){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n; cin>>n; cout<<SQ(n)*n<<endl;
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int L[500000 / 2 + 2], R[500000 / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  rep(i, n1) L[i] = A[left + i];
  rep(i, n2) R[i] = A[mid + i];
  //番兵の設定
  L[n1] = R[n2] = 2000000000;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if(L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[500000], n;
  cnt = 0;
  cin >> n;
  rep(i, n) cin >> A[i];
  mergeSort(A, n, 0, n);
  rep(i, n) {
    cout << A[i];
    if(i < n - 1) {
      cout << " ";
    }
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 6996
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

const int limit = 50;

int n,m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
  visited[v] = true;
  REP(i,n){
    if(graph[v][i] == false) continue;
    if(visited[i] == true) continue;
    dfs(i);
  }
}

int main(void){

  cin >> n >> m;
  
  REP(i,m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    // make adjacent matrix
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  int ans = 0;

  REP(i,m){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    REP(k,n){
      visited[k] = false;
    }
    dfs(0);
    bool bridge = false;
    REP(k,n){
      if(visited[k] == false) bridge = true;
    }
    if(bridge == true) ans++;

    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,cnt=0,k=11;
bool prime(int x){
    if(x<2)return false;
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0)return false;
    }
    return true;
}
signed main(){
    cin>>n;
    while(cnt<n){
        if(prime(k)){
            cout<<k;
            cnt++;
        }
        k+=10;
        if(cnt>=n)cout<<endl;
        else cout<<" ";
    }
    return 0;
}



Measured memory_bytes: 256
s=raw_input()
if s[0]==s[1] and s[0]!=s[2]:
  print "Yes"
elif s[0]==s[2] and s[0]!=s[1]:
  print "Yes"
elif s[1]==s[2] and s[1]!=s[0]:
  print "Yes"
elif s[1]==s[0] and s[1]!= s[2]:
  print "Yes"
elif s[2]==s[0] and s[2]!= s[1]:
  print "Yes"
elif s[2]==s[1] and s[2]!= s[0]:
  print "Yes"
else:
  print "No"

Measured memory_bytes: 2568
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define ld long double
    #define ss(x) scanf("%s",&x)
    #define sc(x) scanf("%c",&x)
    #define sd(x) scanf("%Lf",&x)
    #define si(x) scanf("%lld",&x)
    #define ps(x) printf("%s\n",x)
    #define pc(x) printf("%c\n",x)
    #define pd(x) printf("%Lf\n",x)
    #define pi(x) printf("%lld\n",x)
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    string s;
    void solve()
    {
        cin>>s;
        if(s=="ABC")
            cout<<"ARC";
        else
            cout<<"ABC";
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	int n, k;
	ll r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;

	ll ans = 0;
	rep(i, k) {
		if (t[i] == 'r') ans += p;
		else if (t[i] == 's') ans += r;
		else ans += s;
	}

	REP(i, k, n) {
		if (t[i - k] != t[i]) {
			if (t[i] == 'r') ans += p;
			else if (t[i] == 's') ans += r;
			else ans += s;
		}
		else {
			t[i] = '.';
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll dp[5001][5001];
vpi arr;
bool cmp(pii a,pii b)
{
	return a.fi+a.sec<b.fi+b.sec;
}
signed main()
{
    fast;
    ll n,i,j;
    cin>>n;
    arr.resize(n);
    fr(i,n)cin>>arr[i].fi>>arr[i].sec;
    sort(all(arr),cmp);
    fr(i,n+1)fr(j,n+1)dp[i][j]=1e18;
    fr(i,n+1)dp[i][0] = 0;
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=n;j++)
    	{
    		dp[i][j] = dp[i-1][j];
    		if(dp[i-1][j-1]<=arr[i-1].fi)
    			dp[i][j] = min(dp[i][j],dp[i-1][j-1]+arr[i-1].sec);
    	}
    }
    for(j=n;j>=0;j--)
    {
    	if(dp[n][j]<=1e15)
    	{
    		cout<<j;
    		return 0;
    	}
    }
}


Measured memory_bytes: 195712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(); int W = sc.nextInt();
		int h = sc.nextInt(); int w = sc.nextInt();

		System.out.println((H-h)*(W-w));

	}
}

Measured memory_bytes: 23636
n,k = map(int, input().split())
WL = [int(input()) for i in range(n)]


#P????????°??¨??????????????¬??§??????Wi????????°?????????????????¢??°
def howmany(P):
 ans = 0
 truck = 1
 i = 0
 while truck <= k and i <= n-1:
  rp = P
  while rp >= WL[i]:
   ans += 1
   rp -= WL[i]
   i += 1
   if i == n: break
  truck += 1
 return ans

low = 0
high = 100000 * 100000 # n * k????????§???
while low != high:
 mid = (low + high) // 2
 if howmany(mid) == n:
  high = mid
 else:
  low = mid + 1
print(str(low))

Measured memory_bytes: 11608
#include<stdio.h>
int main(void)
{
    int n, i, cc, t;
    scanf("%d", &n);
    int res = n;
    for(i = 0; i <= n; i++){
        cc = 0;
        t = i;
        while(t > 0){
            cc += t % 6;
            t /= 6;
        }
        t = n - i;
        while(t > 0){
            cc += t % 9;
            t /= 9;
        }
        if(res > cc)res = cc;
    }
    printf("%d\n", res);


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


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

    int n, m, t; cin >> n >> m >> t;
    vector <ll> dpR(n, 0), dpC(m, 0);
    set <pair<int,int>> s;
    vector <int> rows[n], cols[m];
    for (int i = 0, a, b; i < t; ++i) {
        cin >> a >> b; a--, b--;
        dpR[a]++;
        dpC[b]++;
        s.insert({a, b});
        rows[a].push_back(b);
        cols[b].push_back(a);
    }
    
    ll maxr = *max_element(all(dpR));
    ll maxc = *max_element(all(dpC));
    ll ans = maxr + maxc;
    set <int> r, c;
    for (int i = 0; i < n; ++i) {
        if (dpR[i] == maxr) r.insert(i); 
    }
    for (int i = 0; i < m; ++i) {
        if (dpC[i] == maxc) c.insert(i); 
    }
    // cout << endl;
    // for (int i: r) cout << i << ' '; cout << endl;
    // for (int j: c) cout << j << ' '; cout << endl;

    bool ok = true;
    // for (int i: r) {
    //     for (int j: rows[i]) {
    //         if (!c.count(j)) ok = false;
    //     }
    // }

    // for (int i: c) {
    //     for (int j: cols[i]) {
    //         if (!r.count(j)) ok = false;
    //     }
    // }

    for (int i : r) {
        for (int j: c) {
            if (!s.count({i, j})) {
                ok = false;
                break;
            }
        }
    }
    cout << (ans - ok);

    return 0;
}



Measured memory_bytes: 82776
#include <stdio.h>
#include <math.h>

#define M_PI 3.14159265358979323846
 
 
int main(void){
    double PI=M_PI;
    double p=PI*2/1000000;

    int N;
    double x[100],y[100];
    int kakuritu[100] ={};

    scanf("%d",&N);
    for(int i=0; i<N; i++)
        scanf("%lf %lf",&x[i],&y[i]);

    for(int i=0; i<1000000; i++) {
        double max = cos(i*p)*x[0]+sin(i*p)*y[0];
        int maxj=0;
        for(int j=0; j<N; j++) {
            if(max < cos(i*p)*x[j]+sin(i*p)*y[j]) {
                max = cos(i*p)*x[j] + sin(i*p)*y[j];
                maxj=j;
            }
        }
        kakuritu[maxj]++;
    }

    for(int i=0;i<N;i++) {
        printf("%.10f\n",(double)kakuritu[i]/1000000.0);
    }
    return 0;
}

Measured memory_bytes: 128
def main():
    from sys import stdin
    input = stdin.readline
    n = int(input())
    inlis = list(map(int, input().split()))
    if 0 in inlis:
        ans = 0
    else:
        ans = 1
        for i in inlis:
            ans *= i
            #print(ans)
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)
    
 
 
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 82836
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n,m,dis[2000007],u,v,c,cnt;
map < pair<int,int> , int > p;
priority_queue < pair<int,int> , vector < pair<int,int> > , greater < pair<int,int> > > pr;
vector < pair<int,int> > edge[2000007];
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	cnt=n;
	for(int i=1;i<=2000000;i++) dis[i]=1e9;
	for(int i=1;i<=m;i++){
		cin>>u>>v>>c;
		int edu=p[mp(u,c)];
		if(edu==0){
			cnt++;
			p[mp(u,c)]=cnt;
			edu=cnt;
		}
		int edv=p[mp(v,c)];
		if(edv==0){
			cnt++;
			p[mp(v,c)]=cnt;
			edv=cnt;
		}
		edge[edu].pb(mp(edv,0));
		edge[edv].pb(mp(edu,0));
		edge[u].pb(mp(edu,1));
		edge[edu].pb(mp(u,1));
		edge[v].pb(mp(edv,1));
		edge[edv].pb(mp(v,1));
	}
	pr.push(mp(0,1));
	dis[1]=0;
	while(!pr.empty()){
		int val=pr.top().fi;
		u=pr.top().se;
		pr.pop();
		if(dis[u]!=val) continue;
		for(int i=0;i<(int)edge[u].size();i++){
			v=edge[u][i].fi;
			c=edge[u][i].se;
			//cout<<v<<" "<<u<<endl;
			if(dis[v]>val+c){
				dis[v]=val+c;
				pr.push(mp(dis[v],v));
			}
		}
	}
	if(dis[n]==1e9) cout<<-1;
	else cout<<dis[n]/2;
}


Measured memory_bytes: 99196
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);

		int n=scanner.nextInt();

		int k=scanner.nextInt();
		
		Integer[] data=new Integer[n];
		
		for(int i=0;i<n;i++) {
			data[i]=scanner.nextInt();
		}
		
		Arrays.sort(data,Comparator.reverseOrder());
		
		int result=0;
		for(int i=0;i<k;i++) {
			result+=data[i];
		}
		
		System.out.println(result);



		scanner.close();

	}

	public static int getsumofkakuketa(int n) {

		int result=0;

		while(true) {

			result+=n%10;

			if(n/10!=0) {
				n/=10;
			}else {
				return result;
			}
		}



	}

	public static boolean isMacthed(int a,int b,int sum) {

		if(sum>=a && sum<=b) {
			return true;
		}else {
			return false;
		}

	}



}







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

int main()
{
  int n;
  int ans=0;
  cin >> n;
  for(int i=0;i<n;i++){
    int buf;
    cin >> buf;
    ans+=buf-1;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    rep(i,n){
        rep(j,n){
            cin >> e[i][j];
        }
    }
    long long sum = 0;
    rep(i,n){
        rep(j,i){
            sum += min(e[i][j],e[j][i]);
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3200
// amigos y no más
// dile a la jardinera que traigo flores
 
// += O(logn) ; + = O(n)
 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define MOD 998244353LL
#define MOD1 1000000009LL
#define LIM 262150
#define FORN(i,j,n) for(int i=j; i<n;i++) 
#define FOR(i,n) FORN(i,0,n)
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef tree<int,int,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

vector<ll> v;
map<ll,ll> m;
ll n;

int main() {
	fastio;
	cin>>n;
	for(ll i=0; i<n;i++){
		ll x; cin>>x; v.push_back(x);
		m[x]++;
	}
	
	ll total = 0;
	
	for(auto it= m.begin(); it!=m.end();it++){
		ll cont = it->second;
		total+= ((cont * (cont-1))/2);
	}
	
	for(ll i=0; i<n;i++){
		cout<< total - (m[v[i]]- 1) <<"\n";
	}
	return 0;
}

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

l_tmp = 0
r_tmp = n+1
for i in range(m):
  l, r = map(int, input().split())
  l_tmp = l if l > l_tmp else l_tmp
  r_tmp = r if r < r_tmp else r_tmp

if r_tmp-l_tmp >= 0:
  print(r_tmp-l_tmp+1)
else:
  print(0)

Measured memory_bytes: 3060
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define OUT2(n1,n2) cout << n1 << " " << n2 << endl
#define OUT3(n1,n2,n3) cout << n1 << " " << n2 << " " << n3 << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c; bool flg;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  ll a,b;
  IN2(a,b);
  OUT((a-1) * (b-1));
}


Measured memory_bytes: 256
from itertools import combinations as comb

def main():
  while True:
    n = int(input())
    if n ==0:break
    m = int(input())
    result = [[None] * n for _ in range(n)]
    for _ in range(m):
      x, y = map(int, input().split())
      x -= 1
      y -= 1
      result[x][y] = True
      result[y][x] = False

    t_count = [lst.count(True) for lst in result]
    
    empty_index = [[] for _ in range(n)]
    empty_nums = [0] * n
    for i in range(n):
      for j in range(i + 1, n):
        if result[i][j] == None:
          empty_index[i].append(j)
          empty_nums[i] += 1

    limit = n // 2
    def search(x, t_count):
      if x == n:return 1
      choice_num = limit - t_count[x]
      if choice_num < 0 or choice_num > empty_nums[x]:return 0
      rest_num = empty_nums[x] - choice_num
      ret = 0
      for inds in comb(empty_index[x], rest_num):
        new_count = t_count[:]
        for ind in inds:
          new_count[ind] += 1
        ret += search(x + 1, new_count)
 
      return ret

    print(search(0, t_count))

main()


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

int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		int d=1;
		int s=a+b;
		if(s==0)
		d=0;
		else
		while(s/10!=0)
		{
		d++;
		s/=10;
		}
		cout<<d<<endl;
	}
}

Measured memory_bytes: 3004
# -*- coding: utf-8 -*-

import sys

def readline():
	return sys.stdin.readline().rstrip()
def read(f=int):
	return f(readline())
def reads(f=int):
	return [f(s) for s in readline().split()]

S = read(str)
T = read(str)

print(sum([1 if s == t else 0 for s, t in zip(S, T)], 0))


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

int main() {
	ll sum = 0;
	ll now = 0;
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	now = a[0];
	for (ll i = 1; i < n; ++i) {
		if (now > a[i]) {
			sum += now - a[i];
		}
		else {
			now = a[i];
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=100005;
int n,a[N],pos;
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(&a[1],&a[n+1]); reverse(&a[1],&a[n+1]);
	for(int i=1;i<=n+1;i++){
		if(a[i+1]<=i){
			pos=i-1; break;
		}
	}
	int t1=a[pos+1]-pos,t2;
	for(int i=1;i<=n;i++)if(a[i+1]<=pos){t2=i-pos; break;}
	t1++; t2++;
	if((t1&1)|(t2&1))puts("First"); else puts("Second");
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int a[N],ans,n;
#define ok(x,y) (x<a[y])
int main(){
	read(n);re(i,0,n)read(a[i]);
	sort(a,a+n);reverse(a,a+n);
	int l=0,r=n-1,res=0,x=0,y=0;
	while(l<=r){
		int mid=(l+r)>>1;
		if(ok(mid,mid))res=mid,l=mid+1;else r=mid-1;
	}
	for(;;x++)if(!ok(res,res+x))break;
	for(;;y++)if(!ok(res+y,res))break;
	x&=1;y&=1;
	puts((!(x&&y))?"First":"Second");
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
        final int k = s.nextInt();
        int a = s.nextInt();
        final int b = s.nextInt();

        boolean okFlg = false;
        while (a <= b) {
            if (a % k == 0) {
                okFlg = true;
                break;
            }
            a++;
        }
        if (okFlg) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }
  }
}

Measured memory_bytes: 27080
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[102][100004];
int main()
{
	ll n,W;
	cin>>n>>W;
	ll w[n+1],v[n+1];
	ll sum=0;
	for (ll i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
		sum+=v[i];
	}
	for (ll i=0;i<=sum;i++)
	{
		if (i==0)
			dp[0][i]=0;
		else
			dp[0][i]=INT_MAX;
	}
	ll ans=INT_MIN;
	for (ll i=1;i<=n;i++)
	{
		for (ll j=1;j<=sum;j++)
		{
			if (v[i]<=j)
				dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
			else
				dp[i][j]=dp[i-1][j];
		//ans=max(ans,dp[i][j]);
		}
	}
	for (ll i=1;i<=sum;i++)
	{
		if (dp[n][i]<=W)
			ans=i;
	}
	cout<<ans;
	}


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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
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; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }

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

	string s1 = S.substr(2, 1);
	string s2 = S.substr(3, 1);
	string s3 = S.substr(4, 1);
	string s4 = S.substr(5, 1);
	
	string result = "No";
	if (s1 == s2 && s3 == s4) {
		result = "Yes";
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    bool ok = true;
    // true なら先手がかつ
    ll n = s.size();
    if(s[0] != s[n-1]){
        if(n%2)ok = true;
        else ok = false;
    }
    else{
        if(n%2)ok = false;
        else ok = true;
    }

    cout << (ok ? "First" : "Second") << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

using namespace std;
void trace(int *a, int n)
{
    for (int k = 0; k < n; k++)
    {
        if (k != 0)
            cout << ' ';
        cout << a[k];
    }
    cout << '\n';
}
int main() {
    int n;
    cin >> n;
    int *a = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int c = 0;
    for(int i=0; i<n; i++) {
        int minj = i;
        for(int j=i; j<n; j++) {
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        if(i != minj) {
            int t = a[i];
            a[i] = a[minj];
            a[minj] = t;
            c++;
        }
        
    }
    trace(a, n);
    cout << c << endl;
}   


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

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)4
#define INPUT(i, n, a) for(int i = 1 ; i <= n ; i++) cin >> a[i]
#define ll long long
const int INF = 1e9;

int n, W;
static int w[100010];
static int v[10000010];
static ll dp[110][100010];

int main() {
	cin >> n >> W;
	REP(i, n) cin >> w[i] >> v[i];
	REP(i, n) FOR(j, 1, W) w[i] <= j ? (dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])) :(dp[i + 1][j] = dp[i][j]);
	cout << dp[n][W];
}

Measured memory_bytes: 81408
N = int(input().rstrip())
As = map(int, input().rstrip().split())

data = {}
for i, num_student in enumerate(As):
    data[i + 1] = num_student
sorted_dict = sorted(data.items(), key=lambda x: x[1])
print(' '.join(map(str, [x[0] for x in sorted_dict])))


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

int main(){
    int h,w,m;
    cin >> h >> w >> m;
    //vector<vi> masu(h,vi(w,0));
    map<pair<int,int>,int> mp;
    vi tate_count(h,0);
    vi yoko_count(w,0);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        yoko_count[b]++;
        tate_count[a]++;
        pair<int,int> kani=make_pair(a,b);
        mp[kani]++;
    }
    int maxi_t=0;
    for(int i=0;i<h;i++){
        maxi_t=max(maxi_t,tate_count[i]);
    }
    int maxi_y=0;
    for(int i=0;i<w;i++){
        maxi_y=max(maxi_y,yoko_count[i]);
    }
    int ans=maxi_y+maxi_t;
    vi yoko,tate;
    for(int i=0;i<h;i++){
        if(maxi_t==tate_count[i]) tate.push_back(i);
    }
    for(int i=0;i<w;i++){
        if(maxi_y==yoko_count[i]) yoko.push_back(i);
    }
    bool flag=false;
    if(tate.size()*yoko.size()>1e9){
        cout << ans << endl;
        return 0;
    }
    for(auto x:yoko){
        for(auto y:tate){
            pair<int,int> ebi=make_pair(y,x);
            if(mp[ebi]==0) flag=true;
        }
    }
    if(!flag) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 28532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int q = sc.nextInt();
		long[] d = new long[k];
		for (int i=0;i<k;i++) {
			d[i]=sc.nextLong();
		}
		for (int i=0;i<q;i++) {
			long n = sc.nextLong();
			long x = sc.nextLong();
			long m= sc.nextLong();
			long[] dMod=new long[k];
			long[] sum = new long[k+1];
			long[] countZero = new long[k+1];
			for (int j=0;j<k;j++) {
				dMod[j]=d[j]%m;
				sum[j+1] = sum[j]+dMod[j];
				countZero[j+1] = countZero[j]+(dMod[j]==0 ? 1 : 0);
			}
			long fin = x + (sum[k]) * ((n-1)/k) + sum[(int)((n-1)%k)];
			long zeros = (countZero[k]) * ((n-1)/k) + countZero[(int)((n-1)%k)];
			
			System.out.println(n-1 - (fin/m - x/m) - zeros);
		}
		
	}
	
	
	
	
	
}




Measured memory_bytes: 162052
class Dice:
    def __init__(self):
        self.front = '1'
        self.back = '6'
        self.top = '5'
        self.bottom = '2'
        self. right = '3'
        self.left = '4'
    def turnRight(self):
        temp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = temp
        return self.top
    def turnLeft(self):
        temp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = temp
        return self.top
    def turnFront(self):
        temp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = temp
        return self.top
    def turnBack(self):
        temp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = temp
        return self.top
 
mydice = Dice()
mydice.top, mydice.front, mydice.right, mydice.left, mydice.back, mydice.bottom = input().split()
 
n = int(input())
for q in range(n):
    top, front = input().split()
 
    for rotate in range(3):
        mydice.turnFront()
        if mydice.top == front:
            break
        mydice.turnRight()
        if mydice.top == front:
            break
    mydice.turnFront()
    while top != mydice.top:
        mydice.turnRight()
    print(mydice.right)

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

long long inf = LLONG_MAX;
vector <long long> id;

long long find(long long i){
	if (id[i] <= 0) return i;
	return id[i] = find(id[i]);
}

long long unio(long long i, long long j){
	long long u = find(i);
	long long k = find(j);
	if (find(i) == find(j)) return 0;
	if (id[u] > id[k])swap(u,k);
	id[u] += id[k];
	id[k] = u;
	return id[u];
}

ll nCr(ll n, ll r) 
{ 
    return n*(n-1)/2;
} 
 

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,m;
    cin >> n >> m;
    id.resize(n+1,-1);
    vector <pair<ll,ll>> arr(m);
    for (int z=0;z<m;z++){
    	ll a,b;
    	cin >> a >> b;
    	arr[z] = make_pair(a,b);
    }
    vector <ll> answer(m+1);
    answer[m] = nCr(n,2);
    for (int z=m-1;z>0;z--){
    	ll a = id[find(arr[z].first)];
    	ll b = id[find(arr[z].second)];
    	ll c = unio(arr[z].first,arr[z].second);
    	if (c == 0){
    		answer[z] = answer[z+1];
    	}
    	else{
    		answer[z] = answer[z+1]+nCr((-a),2)+nCr((-b),2)-nCr((-c),2);
    	}
    }
    for (int z=1;z<=m;z++){
    	cout << answer[z] << endl;
    }
    cin >> n;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(multiset<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<int> v(n);
    rep(i, n) cin >> v[i];

    multiset<int> s;
    for (int i : v) s.insert(i);

    auto check = [&](int i) {
        for (int j = 1; j * j <= i; j++) {
            if (i % j != 0) continue;
            if (contain(s, j)) return false;
            if (contain(s, i / j)) return false;
        }
        return true;
    };

    int ans = 0;
    for (int i : v) {
        s.erase(s.find(i));
        bool ok = check(i);
        s.insert(i);
        if (ok) ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 13552
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    
    cin>>a>>b>>c;
    
    if(a<=c && c<=b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int[] l = new int[n];
        for(int i = 0; i < n; i++){
            l[i] = Integer.parseInt(sc.next());
        }
        
        int min = 10000;
        int mp;
        int lengthA, lengthB, lengthC;
        int mask;
        for(int i = 0; i < Math.pow(4, n); i++){
            mp = 0;
            lengthA = 0;
            lengthB = 0;
            lengthC = 0;
            for(int j = 0; j < n; j++){
                mask = 0b11 << j*2;
                if((i & mask) == 0){
                    
                    if(lengthA != 0){
                        mp += 10;
                    }
                    lengthA += l[j];
                    
                }else if((i & mask) == 0b01 << j*2){
                    if(lengthB != 0){
                        mp += 10;
                    }
                    lengthB += l[j];
                    
                }else if((i & mask) == 0b10 << j*2){
                    if(lengthC != 0){
                        mp += 10;
                    }
                    lengthC += l[j];
                }
            }
            if(lengthA == 0 || lengthB == 0 || lengthC == 0){
                continue;
            }
            mp += Math.abs(a - lengthA) + Math.abs(b - lengthB) + Math.abs(c - lengthC);
            if(mp < min){
                min = mp;
            }
        }
        
        System.out.println(min);
    }
}

Measured memory_bytes: 22612
#include<stdio.h>
int time[24][60];
int main(void)
{
	int i, j, h, m, f;
	for (i=0; i<2; ++i) {
		scanf("%d", &j);
			for (; j>0; --j) {
				scanf("%d %d", &h, &m);
				time[h][m] = 1;
				}
			}
			f = 1;
			for (i=0; i<24; ++i)
				for (j=0; j<60; ++j)
					if ( time[i][j] ){
						if ( !f ) printf(" ");
						else f = 0;
						printf("%d:%02d", i, j);
						}
					printf("\n");
					return 0;
}

Measured memory_bytes: 620