akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if ((a * b) % 2 == 0) System.out.println("Even");
    else System.out.println("Odd");
  }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N, S, ans = INT_MAX, b = 0, i = 0;
	cin >> N >> S;
	vector<int> a(N);
	for (int& j : a) cin >> j;
	for (int j = 0; j < N; ++j) {
		while (N > i && S > b) {
			b += a[i];
			++i;
		}
		if (S <= b) ans = min(ans, i - j);
		if (i == j) ++i;
		else b -= a[j];
	}
	if (INT_MAX == ans) cout << 0;
	else cout << ans;
	cout << endl;
}


Measured memory_bytes: 3120
from sys import stdin

gets = stdin.readline

#@profile
def main():
    n = int(gets())
    flag = False
    for h in range(3500, 1, -1):
        nh = n*h
        for w in range(1, h+1):
            y = (4 * h * w - nh - n*w)
            if y > 0 and (nh % y == 0 or w % y == 0):
                print(h, w, (nh*w)//y)
                flag = True
                break
        if flag:
            break
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstring>
#include<list>
 
using namespace std;
 
 
 
void test() {
    string s;
    cin >> s;
    int ans = 0, count = 0;
    for(char c : s) {
        if(c == 'R') {
            count++;
        }
        else {
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    cout << ans << endl;
}
 
int main () 
{
    // int t;
    // cin >> t;
    // while(t--) 
        test();
}
 

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

int main(){
    int a,b,k;
    cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }

    }
    cout <<"NG"<<endl;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void add_arc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void add_edge(Graph &g, int a, int b, Weight w = 1) {
	add_arc(g, a, b, w);
	add_arc(g, b, a, w);
}

//??????????????????????????????
//???????????????????????????????????????????????????1???????????????????????????????????????
void traveling_salesman_problem() {
	static const int MAX_V = 15;
	static int dp[1 << MAX_V][MAX_V];
	static int g[MAX_V][MAX_V]; //Matrix g(V, Array(V, INF));
	memset(dp, 0x3f, sizeof(dp));
	memset(g, 0x3f, sizeof(dp));
	int V, E; cin >> V >> E;
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		g[s][t] = d;
	}
	dp[0][0] = 0;
	for (int mask = 0; mask < (1 << V); mask++) {
		rep(i, 0, V) {
			rep(j, 0, V) {
				if (mask >> j & 1)continue;
				if (dp[mask][i] == INF || g[i][j] == INF)continue;
				chmin(dp[mask | (1 << j)][j], dp[mask][i] + g[i][j]);
			}
		}
	}
	cout << (dp[(1 << V) - 1][0] == INF ? -1 : dp[(1 << V) - 1][0]) << endl;
}

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

Measured memory_bytes: 5136
using System;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            Console.WriteLine((
                String.Format("{0} {1}",
                    a * b, 2*a + 2 * b
                )));
        }
    }
}

Measured memory_bytes: 9128
from math import sqrt
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

n = int(input())
fac = factorization(n)
s = 0
for i in fac:
    if i[0] != 1:
        s += (-1+sqrt(1+4*i[1]*2))//2
print(int(s))

Measured memory_bytes: 63672
#include"bits/stdc++.h"
#include<cassert>
#define fr first
#define sc second
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P> PP;
string S[] = { "Sunny","Cloudy","Rainy","Sunny" };
signed main() {
	string s; cin >> s;
	rep(i, 3) {
		if (s == S[i])cout << S[i + 1] << endl;
	}
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

//Boring Commercials
public class Main{

	public static class R implements Comparable<R>{
		public int s;
		public int t;
		public R(int s, int t) {
			this.s = s;
			this.t = t;
		}
		public int compareTo(R o) {
			return s-o.s;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int p = sc.nextInt();
			int q = sc.nextInt();
			p = (p/100)*60 + p%100;
			q = (q/100)*60 + q%100;
			if(n==0&&p==0&&q==0)break;
			PriorityQueue<R> pq = new PriorityQueue<R>();
			for(int i=0;i<n;i++){
				int k = sc.nextInt();
				int last = 0;
				for(int j=0;j<k;j++){
					int s = sc.nextInt();
					int t = sc.nextInt();
					s = (s/100)*60+s%100;
					t = (t/100)*60+t%100;
					if(j==0){
						pq.add(new R(p, s));
						last = t;
					}
					else{
						pq.add(new R(last, s));
						last = t;
					}
					if(j==k-1){
						pq.add(new R(last, q));
					}
				}
			}
			int max = 0;
			R r = null;
			while(!pq.isEmpty()){
				R a = pq.poll();
				if(r==null){
					r = a;
				}
				else if(r.s <= a.s && a.s <= r.t){
					r.t = Math.max(r.t, a.t);
				}
				else{
					r = a;
				}
				max = Math.max(max, r.t-r.s);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

int main(int argc, char **argv)
{
  uint64_t N;
  std::cin >> N;
  
  std::string A, B, C;
  std::cin >> A >> B >> C;
  
  uint64_t count = 0;
  
  for (uint64_t n = 0; n < N; ++n) {
    if (A[n] == B[n] && B[n] == C[n]) {
      ; // nop
    } else if (A[n] == B[n] || B[n] == C[n] || C[n] == A[n]) {
      ++count;
    } else {
      count += 2;
    }
  }
  
  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


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

	if (A + B + C >= 22) co("bust");
	else co("win");

	Would you please return 0;
}

Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,x,ans=0;
map <int,int> mp;

int main()
{
	cin>>n;
	rep(i,n)
	{
		scanf("%d",&x);
		mp[x]++;
	}
	for(map <int,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		if((it->se)>=(it->fi)) ans+=(it->se)-(it->fi);
		else ans+=(it->se);
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 4736
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int lenA, lenB, m;
  scanf("%d%d%d", &lenA, &lenB, &m);
  vector<int64> a(lenA), b(lenB);
  for (int i = 0; i < lenA; ++i) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < lenB; ++i) {
    scanf("%lld", &b[i]);
  }
  while (m--) {
    int64 x;
    scanf("%lld", &x);
    int a2 = lower_bound(a.begin(), a.end(), x) - a.begin();
    int a1 = a2 - 1;
    int b2 = lower_bound(b.begin(), b.end(), x) - b.begin();
    int b1 = b2 - 1;
    int64 ret = 1LL << 60;
    if (a2 < lenA && b2 < lenB) {
      ret = min(ret, (a[a2] - x) + abs(a[a2] - b[b2]));
      ret = min(ret, (b[b2] - x) + abs(a[a2] - b[b2]));
    }
    if (a1 >= 0 && b1 >= 0) {
      ret = min(ret, (x - a[a1]) + abs(a[a1] - b[b1]));
      ret = min(ret, (x - b[b1]) + abs(a[a1] - b[b1]));
    }
    if (a2 < lenA && b1 >= 0) {
      ret = min(ret, (a[a2] - x) + abs(a[a2] - b[b1]));
      ret = min(ret, (x - b[b1]) + abs(a[a2] - b[b1]));
    }
    if (a1 >= 0 && b2 < lenB) {
      ret = min(ret, (x - a[a1]) + abs(a[a1] - b[b2]));
      ret = min(ret, (b[b2] - x) + abs(a[a1] - b[b2]));
    }
    printf("%lld\n", ret);
  }
  return 0;
}


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

template<typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    typename vector<T>::const_iterator it;
    for (it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "}";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
    os << "[";
    typename set<T>::const_iterator it;
    for (it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template<typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
    os << "[";
    typename map<F, S>::const_iterator it;
    for (it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) os << ", ";
        os << it->first << " = " << it->second;
    }
    return os << "]";
}

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

typedef long long int ll;
typedef long double ld;

#define endl "\n";
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(cont, it) for(decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c),x) != (c).end())
#define F first
#define S second

const ll mod = 1000000007;
const ll inf = (ll) 1e15;

ll power(ll a, ll b, ll m = mod) {if (b == 0) return 1; if (b == 1) return (a % m); ll x = power(a, b / 2, m); x = (x * x) % m; if (b % 2) x = (x * a) % m;return x;}
ll max(ll a, ll b) { return (a > b ? a : b); }
ll min(ll a, ll b) { return (a < b ? a : b); }


void solve() {

    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    int a1=0,a2=0,a3=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;
        if(x<=a)
            a1++;
        if(x>=a+1&&x<=b)
            a2++;
        if(x>=b+1)
            a3++;
    }
    cout << min(a1,min(a2,a3))<< endl;

}

int main() {
    IOS;
    int t = 1, num = 1;   ///// change this t for number of testcase globally
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}

object Main {
  val alist = List(1,3,5,7,9,11,15,17,19,21,23,25)
  val blist = 0 to 25
  val invs = for{
    i<-alist
    j<-1 to 25 by 2
    if (i*j) % 26 == 1
  } yield (i,j)
  def encode(c:Int,a:Int,b:Int) = (((a*(c-97)+b) % 26)+97).toChar
  def decode(c:Int,a:Int,b:Int) = ((a*(c-97-b+26) % 26)+97).toChar

  def main(args:Array[String]) = {
    val n = readInt
    (0 until n).foreach { _ =>
      val l = readLine
      val (a,b) = {for(i<-alist;j<-blist) yield (i,j)}.find{ case (i,j) =>
            l.contains("that".map{encode(_,i,j)}) || l.contains("this".map{encode(_,i,j)})
      }.get
      println( l.map { c=> if(c>=97 && c<=122) decode(c,invs.find(s => s._1 == a).get._2,b) else c })
    }
  }
}

Measured memory_bytes: 45136
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int A = one.get(0);
		int B = one.get(1);
		if(A % 2 != B % 2){
			myout("IMPOSSIBLE");
		}else{
			int tmp = (Math.max(A, B) - Math.min(A, B)) / 2;
			myout(Math.max(A, B) - tmp);
		}
	}
	//Method addition frame start




	//Method addition frame end
}


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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 multi_inv(i64 a, i64 md) {
    i64 x, y;
    extgcd(md, a, x, y);
    return (y > 0 ? y : md + y);
}

vector<i64> set_ncr(i64 n) {
    vector<i64> ncr(n+1);
    ncr[0] = 1;
    for (i64 i = 1; i <= n; i++) {
        i64 inv = multi_inv(i, MOD);
        ncr[i] = (n - i + 1) * ncr[i - 1] % MOD;
        ncr[i] = ncr[i] * inv % MOD;
    }
    return ncr;
}

int main(){
    i64 n;
    cin >> n;
    set<i64> st;
    vector<i64> v;
    i64 num = 0;
    for(int i=0;i<=n;++i){
        i64 a;
        cin >> a;
        if(st.count(a))num = a;
        st.insert(a);
        v.push_back(a);
    }

    i64 left = -1, right = -1;
    for(int i=0;i<=n;++i){
        if(v[i] == num){
            if(left >= 0)right = i;
            else left = i;
        }
    }

    i64 m = left + (n-right);
    auto n1cr = set_ncr(n+1), mcr = set_ncr(m);
    for(i64 k=1;k<=n+1;++k){
        i64 ans = n1cr[k];
        if(k-1 <= m){
            i64 tmp = mcr[k-1];
            ans -= tmp;
            if(ans < 0)ans += MOD;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 8308
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

struct T{
    int height;
    vector<int> o;
};

int main(){
    ll x;
    cin >> x;
    for (ll a = 0;1010; a++){
        for (ll b = 0;b<1020;b++){
            if (pow(a,5)+pow(b,5)==x){
                cout << a << ' ' << (-1)*b << endl;
                return 0;
            }
            else if (pow(a,5)-pow(b,5)==x){
                cout << a << ' ' << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4100
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string S=Console.ReadLine();
            string T=Console.ReadLine();

            string T2=T.Remove(S.Length,1);
            if(S==T2)
            {
                Console.WriteLine("Yes");
            }
            else{
                Console.WriteLine("No");
            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 25784
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

type pair struct {
	rn string
	p  int
	i  int
}

func main() {
	n := nextInt()
	s := make([]pair, n)
 // 入力とid付与
	for i := 0; i < n; i++ {
		s[i].rn = nextStr()
		s[i].p = nextInt()
		s[i].i = i + 1
	}
  // 同名ごとのソート
	sort.Slice(s, func(i, j int) bool {
		if s[i].rn == s[j].rn {
			return s[i].p > s[j].p
		}
		return s[i].rn < s[j].rn
	})

	for _, v := range s {
		fmt.Println(v.i)
	}
}

func init() {
	const max = 1024
	var buf = make([]byte, max)
	sc.Buffer(buf, max)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 17;
const int maxtot = 65536;

int n, v[maxn][maxn];
long long f[maxtot], g[maxtot];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> v[i][j];
        }
    }

    int tot = 1 << n;

    for (int i = 1; i < tot; ++i) {
        long long sum = 0;

        for (int j = 0; j < n; ++j)
            if (i & (1 << j))
                for (int k = j+1; k < n; ++k)
                    if (i & (1 << k))
                        sum += v[j][k];

        g[i] = sum;
    }

    for (int i = 1; i < tot; ++i) {
        int st = i & (-i);
        for (int j = st; j <= i; ++j)
            if ((j & i) == j) {
                f[i] = max(f[i], f[i-j] + g[j]);
            }
    }

    cout << f[tot-1] << endl;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    sort(all(p));
    ll ans = 0;
    rep(i, k) ans += p[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll n, a, b;
	scanf("%ld %ld %ld", &n, &a, &b);
	if(a%2==b%2) printf("%ld\n", labs((a+b)/2-a));
	else printf("%ld\n", std::min((a-1+b)/2, (n-a+1+n-b)/2));
	return 0;
}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int main(){
	int v[5];
	v[1]=6000;
	v[2]=4000;
	v[3]=3000;
	v[4]=2000;
	for(int i=0;i<4;i++){
		int t,n;
		cin>>t>>n;
		cout<<v[t]*n<<endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
 lint digit(lint);
 
int main(){
 
    string s;
    lint q;
    cin >> s >> q;
 
 
    lint revcnt = 0; 
    string sen, bac;
    for(lint i = 0; i < q; ++i){
        int t;
        cin >> t;
        if(t == 1)++revcnt;
        else {
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(revcnt%2) bac = bac+c;
                else sen = c+sen;
            }
            else {
                if(revcnt%2) sen = c+sen;
                else bac = bac+c;
            }
        }
    }
 
    s = sen+s+bac;

    if(revcnt%2)reverse(s.begin(), s.end());
 
    cout << s << endl;
 
}
lint digit(lint num){
    lint dig = 0;
    while(num){
        num /= 10;
        ++dig;
    }
    return dig;
}

Measured memory_bytes: 1512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
void fun(vb &vis,vv &e,ll u,vi &val,vi &add)
{
    val[u]+=add[u];
    vis[u]=true;
    for(ll i=0;i<e[u].size();i++)
    {
        if(!vis[e[u][i]])
        {
            add[e[u][i]]+=add[u];
            fun(vis,e,e[u][i],val,add);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,q;
    cin>>n>>q;
    vector <vector <ll> > e(n,vi ());
    vector <ll> val(n,0);
    vector <ll> add(n,0);
    for(ll i=0;i<n-1;i++)
    {
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        e[x].pb(y);
        e[y].pb(x);
    }
    for(ll i=0;i<q;i++)
    {
        ll p,x;
        cin>>p>>x;
        p--;
        add[p]+=x;
    }
    vector <bool> vis(n,false);
    fun(vis,e,0,val,add);
    for(ll i=0;i<n;i++)
    {
        cout<<val[i]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 32128
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<string>
#include<sstream>
using namespace std;
//char moji[26]={'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'};
int main(){
	//while(1){
		int w,a,b;cin>>w>>a>>b;
		if(abs(a-b)<=w){cout<<0<<endl;}
		else cout<<abs(a-b)-w<<endl;
		
	}//mainwhile

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<int> G[100005];
int ans=0;
bool flag[100005];
int d[100005];
int ct[100005];
bool leaf[100005];
int pl[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<100005;i++){
		ct[i]=G[i].size();
	}
	queue<int> que;
	for(int i=0;i<n;i++){
		int v=G[i][0];
		flag[i]=true;
		if(G[i].size()==1 && G[v].size()==2){
			que.push(i);
		}
	}
	while(que.size()){
		int v=que.front();
		que.pop();
		int nv=G[v][0];
		for(int i=0;i<G[v].size();i++){
			if(flag[G[v][i]])nv=G[v][i];
		}
		if(ct[v]==1 && ct[nv]==2){
			ct[v]--;
			ct[nv]--;
			flag[v]=false;
			que.push(nv);
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(flag[i])cnt++;
	}
	if(cnt<=2){
		printf("%d\n",1);
		return 0;
	}
	for(int i=0;i<n;i++){
		if(flag[i]){
			if(ct[i]==1){
				//printf("%d\n",i);
				for(int j=0;j<G[i].size();j++){
					pl[G[i][j]]++;
				}
			}
		}
	}
	vector<int> vec;
	for(int i=0;i<n;i++){
		if(flag[i] && pl[i]>0){
			vec.push_back(pl[i]);
		}
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	for(int i=0;i<vec.size();i++){
		//printf("%d\n",vec[i]);
		if(vec[i]>1){
			ans+=vec[i]-1;
		}else{
			if(i==0)ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

#define PI 3.141592653589

double r;

int main() {
    cin >> r;
    cout << setprecision(15) << r * r * PI << " " << r * 2 * PI << endl; // setprecisionは桁数指定
    return 0;

}





Measured memory_bytes: 3236
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int n1 = n * 2;
	vi div;
	for(int i = 1; (i * i) <= n1; i++){
		if(n1 % i == 0){
			div.pb(i);
			if((n1 / i) != i) div.pb(n1 / i);
		}
	}
	rep(i, div.size()){
		int cur = 0, num = 1, cur1 = cur + 1;
		vi res[div[i]];
		int f = 1;
		while(num <= n1 && cur < div[i]){
			if(cur >= div[i]){
				f = 0;
				break;
			}
			if(res[cur].size() == (n1 / div[i])){
				if(cur1 < (div[i] - 1)){
					f = 0;
					break;
				}
				cur++;
				cur1 = cur + 1;
				continue;
			}
			if(cur1 == div[i]){
				f = 0;
				break;
			}
			res[cur].pb(num);
			res[cur1].pb(num);
			cur1++;
			num++;
		}
		if(f){
			cout << "Yes" << endl;
			cout << div[i] << endl;
			rep(j, div[i]){
				cout << res[j].size() << " ";
				rep(k, res[j].size()) cout << res[j][k] << " ";
				cout << endl;
			}
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())
a = int(a)
b = int(b)
c = int(c)
x = int(x)
y = int(y)

z = min(x,y)
w = abs(x - y)
count = 0

if 2 * c > a + b:
    count += (a + b) * z
else:
    count += 2 * c * z

if x > y:
    if 2 * c < a:
        count += 2 * c * w
    else:
        count += a * w
elif x < y:
    if 2 * c < b:
        count += 2 * c * w
    else:
        count += b * w

print(count)

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

const int MAX_N = 2 * 1e4 + 2;

int R[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, P;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> P;
        R[P] = i + 1;
    }
    for (int i = 1; i <= N; i++) cout << 30000 * i << ' ';
    cout << endl;
    for (int i = 1; i <= N; i++) cout << 30000 * (N - i) + R[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }

    ll ans = 0;
    ll tmp = INF;
    rep(i,n){
        if(i == 0){
            ans++;
            tmp = vec.at(i);
            continue;
        }

        if(vec.at(i) < tmp){
            ans++;
        }

        if(tmp > vec.at(i)){
            tmp = vec.at(i);
        }
    }

    cout << ans << endl;

}


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

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;
using vd = vector<ld>;

template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class TIn, class TOut = null_type>
using order_tree = tree<TIn, TOut, less<TIn>, rb_tree_tag,
	tree_order_statistics_node_update>;
// .find_by_order(int r) and .order_of_key(TIn v)

constexpr int INF = 2000000010;
constexpr ll LLINF = 9000000000000000010LL;
constexpr ld PI = acos(-1);

constexpr ll MOD = 998244353LL;

ll mpw(ll a, ll b) {
	if (b == 0LL) return 1LL;
	ll r = mpw(a*a%MOD, b/2);
	if (b&1) r = r*a%MOD;
	return r;
}

ll invert(ll x) {
	return mpw(x, MOD-2);
}

void brinc(int &x, int k) {
	int i = k - 1, s = 1 << i;
	x ^= s;
	if ((x & s) != s) {
		--i; s >>= 1;
		while (i >= 0 && ((x & s) == s))
			x = x &~ s, --i, s >>= 1;
		if (i >= 0) x |= s;
	}
}
void fft(vi &A, int p, bool inv = false) {
	int N = 1<<p;
	for(int i = 0, r = 0; i < N; ++i, brinc(r, p))
		if (i < r) swap(A[i], A[r]);
	for (int m = 2; m <= N; m <<= 1) {
		for (int k = 0; k < N; k += m) {
			for (int j = 0; j < m/2; ++j) {
				ll t = A[k + j + m/2];
				A[k + j + m/2] = (MOD+A[k + j] - t)%MOD;
				A[k + j] = (A[k + j] + t)%MOD;
			}
		}
	}
	if(inv){ ll inverse = invert(N); for(auto &x : A) x = x*inverse%MOD; }
}

void solve() {
	int N, M[3];
	cin >> N;

	constexpr ll e18 = 1'000'000'000'000'000'000LL % MOD;

	vi p10(N+1, 1LL);
	for (ll n = 1; n <= N; ++n)
		p10[n] = e18*p10[n-1]%MOD;

	vvi ltr[3];
	for (int r = 0; r < 3; ++r) {
		cin >> M[r];
		ltr[r].resize(N);
		for (int e = 0; e < M[r]; ++e) {
			int a, b;
			cin >> a >> b;
			--a, --b;
			if (a > b) swap(a, b);
			ltr[r][a].push_back(b);
		}
	}

	// Color graphs 1 and 2.
	vi col[3];
	for (int r = 0; r < 2; ++r) {
		col[r].assign(N, -1);
		for (int i = N-1; i >= 0; --i) {
			unordered_set<int> nbs;
			for (int j : ltr[r][i]) nbs.insert(col[r][j]);
			do col[r][i]++; while (nbs.find(col[r][i]) != nbs.end());
		}
	}

	// Color and cost graph 3.
	col[2].assign(2*N, -1);
	vi prof(2*N, 0);
	for (int i = N-1; i >= 0; --i) {
		unordered_set<int> nbs;
		for (int j : ltr[2][i]) nbs.insert(col[2][j]);
		do col[2][i]++; while (nbs.find(col[2][i]) != nbs.end());
		prof[col[2][i]] = (prof[col[2][i]] + p10[i+1]) % MOD;
	}

	int k = 0;
	while ((1<<k) <= N) ++k;

	vi g0(1<<k, 0LL);
	vi g1(1<<k, 0LL);
	for (int i = 0; i < N; ++i) {
		g0[col[0][i]] = (g0[col[0][i]] + p10[i+1]) % MOD;
		g1[col[1][i]] = (g1[col[1][i]] + p10[i+1]) % MOD;
	}
	fft(g0, k, false);
	fft(g1, k, false);
	vi rev(1<<k);
	for (int i = 0; i < (1<<k); ++i) rev[i] = (g0[i]*g1[i])%MOD;
	fft(rev, k, true);

	ll ans = 0LL;
	for (ll ij = 0; ij < 2*N && ij < (1<<k); ++ij) {
		ans = (ans + prof[ij] * rev[ij]) % MOD;
	}
	cout << ans << endl;
}

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

	solve();
	
	return 0;
}


Measured memory_bytes: 21760
def floor_sum(n, m, a, b):
    res = 0
    while True:
        if a >= m:
            res += a//m * n * (n-1) // 2
            a %= m
        if b >= m:
            res += b//m * n
            b %= m
        Y = (a*n+b) // m
        X = Y*m-b
        if Y == 0:
            return res
        res += (n-(X+a-1)//a) * Y
        n, m, a, b = Y, a, m, -X%a

import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
    n, m, a, b = map(int, input().split())
    print(floor_sum(n, m, a, b))

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

using namespace std;

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

const ll INF=1e9+7;

int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	string s;
	cin>>s;
	int l=s.size();
	rep0(i,l-1){
		if(s[i]==s[i+1]){
			cout<<i+1<<' '<<i+2;
			return 0;
		}
		if(s[i]==s[i+2]){
			cout<<i+1<<' '<<i+3;
			return 0;
		}
	}
	cout<<-1<<' '<<-1;
	return 0;
}

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

int main()
{
    string o, e;
    cin >> o ;
    cin >> e;

    string ans = "";
    for (int i = 0; i < o.size() + e.size(); i++)
    {
        if (i % 2 == 0)
            ans += o[i / 2];
        else
            ans += e[i / 2];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

struct Q{int a;int b;int c;int d;};

signed main(){

  int H,W;cin>>H>>W;
  vector<string> maze(H);
  REP(i,0,H)cin>>maze[i];
  vector<vector<int>> visited(H,vector<int>(W,INF));

  queue<Q> que;
  if(maze[0][0]=='#'){
    visited[0][0]=1;
    que.push({0,0,1,1});
  } else {
    visited[0][0]=0;
    que.push({0,0,0,0});
  }

  while(que.size()){
    Q q = que.front();que.pop();
    each(dxy,vector<vector<int>> {{1,0},{0,1}}){
      int nx=q.b+dxy[0],ny=q.a+dxy[1],nz=q.c, ns=q.d;
      if(nx<0||W-1<nx||ny<0||H-1<ny)continue;
      if((maze[ny][nx]=='#')&&(ns==0)){
        nz++;
        ns=1;
      } else if(maze[ny][nx]=='.'){
        ns=0;
      }
      if(visited[ny][nx]<=nz){continue;}
      visited[ny][nx]=nz;
      que.push({ny,nx,nz,ns});
    }
  }
  // debug(visited);
  print(visited[H-1][W-1]);



}


Measured memory_bytes: 512
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int j = 1;
    if (b<=a){
      for (int i=1;i<=a;i++){
        j*=10;
      }
        System.out.println(b*(j-1)/9);}
    else {
      for(int i=1;i<=b;i++){
        j*=10;
      }
      System.out.println(a*(j-1)/9);};
  }
}
          


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

int a[200010];
int b[200010];
int n;

int check(int mid){
	for (int i = 0; i < 2 * n - 1; i++){
		b[i] = a[i] >= mid;
	}
	for (int i = n - 1; i >= 1; i--){
		int j = 2 * (n - 1) - i;
		if (b[i] == b[i - 1] || b[j] == b[j + 1]) return b[i];
	}
	return b[0];
}

int main(){
	scanf("%d", &n);
	for (int i = 0; i < 2 * n - 1; i++){
		scanf("%d", &a[i]);
	}
	int l = 1, r = 2 * n - 1;
	while (l < r){
		int mid = l + r + 1 >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	printf("%d\n", l);
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct HopcroftKarp {
    int sizeL, sizeR;
    vector<vector<int>> candy;      // candy[l] = R
    vector<bool> matched, seen;
    vector<int> matching, dist;
    HopcroftKarp(int l, int r) : sizeL(l), sizeR(r), candy(l) { }
    void add_edge(int u, int v) { candy[u].emplace_back(v); }
    void bfs() {
        dist.assign(sizeL, -1);
        queue<int> que;
        for (int left = 0; left < sizeL; left++) if (!matched[left]) {
            dist[left] = 0; que.emplace(left);
        }
        while (!que.empty()) {
            int left = que.front(); que.pop();
            for (auto right: candy[left]) {
                int nxt = matching[right];
                if (nxt >= 0 && dist[nxt] == -1) {
                    dist[nxt] = dist[left] + 1;
                    que.emplace(nxt);
                }
            }
        }
    }
    bool dfs(int left) {
        seen[left] = true;
        for (auto &right: candy[left]) {
            int nxt = matching[right];
            if (nxt < 0 || (!seen[nxt] && dist[nxt] == dist[left] + 1 && dfs(nxt))) {
                matching[right] = left;
                return matched[left] = true;
            }
        }
        return false;
    }
    int solve() {
        matched.assign(sizeL, false);
        matching.assign(sizeR, -1), dist.assign(sizeL, -1);
        int res = 0;
        while (true) {
            bfs();
            seen.assign(sizeL, false);
            int flow = 0;
            for (int i = 0; i < sizeL; i++) {
                if (!matched[i] && dfs(i)) flow++;
            }
            if (flow == 0) return res;
            res += flow;
        }
    }
    friend ostream& operator<<(ostream& os, HopcroftKarp& bm) {
        for (int i = 0; i < bm.matching.size(); i++) if (~bm.matching[i]) {
            os << bm.matching[i] << " - " << i << endl;
        }
        return os;
    }
};

int main() {
    int X, Y, E; cin >> X >> Y >> E;
    HopcroftKarp bm(X, Y);
    while (E--) {
        int a, b; cin >> a >> b;
        bm.add_edge(a, b);
    }
    cout << bm.solve() << endl;
    return 0;
}


Measured memory_bytes: 3216
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N, D = LI()

X = LIR(N)

ans = 0
for xd1 in X:
    for xd2 in X:
        ret = 0
        for x1, x2 in zip(xd1, xd2):
            ret += (x2-x1)**2
        ret = math.sqrt(ret)
        ans += ret.is_integer()

print((ans-N)//2)

Measured memory_bytes: 39152
// https://atcoder.jp/contests/arc069/tasks/arc069_a
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll n,m;cin>>n>>m;
    ll x = min(n,m/2);
    x += (m - x*2) / 4;
    cout<<x<<"\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;
const int N = 100005;
struct edge {
	int to, nxt, cap;
} graph[N * 6];
int n, p[N], q[N], col1[N], col2[N], cnt1 = 0, cnt2 = 0, ans = 0;
int head[N * 2], cur[N * 2], dep[N * 2], s, t, cnt = 0;
bool vis1[N], vis2[N];
queue<int> Q;
void addedge (int u, int v, int cap) {
	edge x = {v, head[u], cap};
	graph[head[u] = cnt++] = x;
}
bool bfs () {
	for (int i = s; i <= t; i++) cur[i] = head[i], dep[i] = -1;
	dep[s] = 0, Q.push(s);
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		for (int i = head[u]; ~i; i = graph[i].nxt) {
			int v = graph[i].to;
			if (graph[i].cap && dep[v] < 0) {
				dep[v] = dep[u] + 1;
				Q.push(v);
			}
		}
	}
	return dep[t] > 0;
}
int dfs (int u, int rest) {
	if (u == t || !rest) return rest;
	int flow = 0;
	for (int &i = cur[u]; ~i; i = graph[i].nxt) {
		int v = graph[i].to;
		if (graph[i].cap && dep[v] == dep[u] + 1) {
			int go = dfs(v, min(rest, graph[i].cap));
			graph[i].cap -= go, graph[i ^ 1].cap += go;
			rest -= go, flow += go;
			if (!rest) break;
		}
	}
	return flow;
}
int maxflow () {
	int res = 0;
	while (bfs()) res += dfs(s, N);
	return res;
}
int main () {
	scanf("%d", &n), ans = n;
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]), p[i]++, vis1[i] = false;
	for (int i = 1; i <= n; i++) scanf("%d", &q[i]), q[i]++, vis2[i] = false;
	for (int i = 1; i <= n; i++) {
		if (p[i] != i && !vis1[i]) {
			cnt1++;
			for (int j = i; !vis1[j]; j = p[j]) vis1[j] = true, col1[j] = cnt1;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (q[i] != i && !vis2[i]) {
			cnt2++;
			for (int j = i; !vis2[j]; j = q[j]) vis2[j] = true, col2[j] = cnt2;
		}
	}
	debug(cnt1), debug(cnt2);
	for (int i = 1; i <= n; i++) debug(i), debug(col1[i]), debug(col2[i]);
	s = 0, t = cnt1 + cnt2 + 1;
	for (int i = s; i <= t; i++) head[i] = -1;
	for (int i = 1; i <= n; i++) {
		if (p[i] != i) {
			if (q[i] != i) {
				addedge(col1[i], cnt1 + col2[i], 1), addedge(cnt1 + col2[i], col1[i], 0);
				if (p[i] == q[i]) addedge(cnt1 + col2[i], col1[i], 1), addedge(col1[i], cnt1 + col2[i], 0);
			}
			else addedge(col1[i], t, 1), addedge(t, col1[i], 0);
		}
		else if (q[i] != i) addedge(s, cnt1 + col2[i], 1), addedge(cnt1 + col2[i], s, 0);
		else ans--;
	}
	ans -= maxflow();
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9472