akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Satoshi
{
	class Node
	{
		public int id = -1;
		public int left = -1;
		public int right = -1;
		public int parent = -1;
		public int sibling = -1;
		public int degree = 0;
		public int depth = 0;
		public int height = 0;
		public string type = "internal node";
		public Node(int id, int left, int right)
		{
			this.id = id; this.left = left; this.right = right;
		}

	}

	class Program
	{
		public static Queue<Node> q1 = new Queue<Node>();
		public static Queue<Node> q2 = new Queue<Node>();
		public static Node[] nodes;
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			nodes = new Node[n];
			for (int i = 0; i < n; i++)
			{
				string[] s = Console.ReadLine().Split(' ');
				nodes[i] = new Node(int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]));
			}
			Array.Sort(nodes, (x, y) => x.id - y.id);
			foreach(Node x in nodes)
			{
				if (x.left != -1)
				{
					nodes[x.left].parent = x.id;
					x.degree++;
				}
				if (x.right != -1)
				{
					nodes[x.right].parent = x.id;
					x.degree++;
				}
				if (x.left != -1 && x.right != -1)
				{
					nodes[x.left].sibling = nodes[x.right].id;
					nodes[x.right].sibling = nodes[x.left].id;
				}
			}
			foreach (Node x in nodes)
			{
				if (x.left == -1 && x.right == -1)
				{
					x.type = "leaf";
					x.height = 0;
					q1.Enqueue(x);
				}
				if (x.parent == -1)
				{
					x.type = "root";
					x.depth = 0;
					q2.Enqueue(x);
				}
			}
			while (q2.Count != 0)
			{
				finddepth(q2.Dequeue());
			}
			while (q1.Count != 0)
			{
				findheight(q1.Dequeue());
			}
			foreach(Node x in nodes)
			{
				Console.WriteLine("node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}",
				                  x.id, x.parent,x.sibling,x.degree,x.depth,x.height,x.type);
			}
		}
		public static void findheight(Node x)
		{
			if (x.left != -1 && x.right != -1)
			{
				x.height = Math.Max(nodes[x.left].height, nodes[x.right].height) + 1;
			}
			else if (x.left != -1)
			{
				x.height = nodes[x.left].height + 1;
			}
			else if (x.right != -1)
			{
				x.height = nodes[x.right].height + 1;
			}
			if (x.parent != -1)
				q1.Enqueue(nodes[x.parent]);
		}
		public static void finddepth(Node x)
		{
			if (x.left != -1)
			{
				nodes[x.left].depth = x.depth + 1;
				q2.Enqueue(nodes[x.left]);
			}
			if (x.right != -1)
			{
				nodes[x.right].depth = x.depth + 1;
				q2.Enqueue(nodes[x.right]);
			}
		}
	}
}

Measured memory_bytes: 10108
H,W = map(int,input().split())
S = [0]*H
for i in range(H):
    S[i] = list(input())

#print(S)

sta_l1 = [[] for i in range(H)]
goa_l1 = [[] for i in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            if j == 0 or S[i][j-1] == "#":
                start = j
                sta_l1[i].append(start)
            if j == W-1:
                goal = j
                goa_l1[i].append(goal)

        else:
            if j-1 >= 0 and S[i][j-1] == ".":
                goal = j-1
                goa_l1[i].append(goal)
#print(sta_l1)
#print(goa_l1)

sta_l2 = [[] for i in range(W)]
goa_l2 = [[] for i in range(W)]

v1 = [[0]*W for i in range(H)]
for i in range(len(sta_l1)):
    for j in range(len(sta_l1[i])):
        for k in range(sta_l1[i][j],goa_l1[i][j]+1):
            v1[i][k] = goa_l1[i][j] - sta_l1[i][j] +1
#print(v1)

for i in range(W):
    for j in range(H):
        if S[j][i] == ".":
            if j == 0 or S[j-1][i] == "#":
                start = j
                sta_l2[i].append(start)
            if j == H-1:
                goal = j
                goa_l2[i].append(goal)

        else:
            if j-1 >= 0 and S[j-1][i] == ".":
                goal = j-1
                goa_l2[i].append(goal)
#print(sta_l2)
#print(goa_l2)

v2 = [[0]*W for i in range(H)]
for i in range(len(sta_l2)):
    for j in range(len(sta_l2[i])):
        for k in range(sta_l2[i][j],goa_l2[i][j]+1):
            v2[k][i] = goa_l2[i][j] - sta_l2[i][j] +1
#print(v2)

ans = 0
v = [[0]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        v[i][j] = v1[i][j] + v2[i][j] -1
        ans = max(ans,v1[i][j] + v2[i][j] -1)

#print(v)
print(ans)

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

using namespace std;

string n2m(int n) {
    string s = "";
    string p = "mcxi";
    string ns = "0123456789";
    int d;
    int e = 1000;
    for (int i=0; i<4; i++) {
        d = n/e;
        switch (d) {
            case 0:
                break;
            case 1:
                s += p.substr(i, 1);
                break;
            default:
                s += ns.substr(d, 1)+p.substr(i, 1);
                break;
        }
        n = n-d*e;
        e /= 10;
    }
    return s;
}

int m2n(string s) {
    int d = 1;
    int n = 0;
    for (int i=0; i<(int)s.length(); i++) {
        switch (s[i]) {
            case 'm':
                n += 1000*d;
                d = 1;
                break;
            case 'c':
                n += 100*d;
                d = 1;
                break;
            case 'x':
                n += 10*d;
                d = 1;
                break;
            case 'i':
                n += d;
                d = 1;
                break;
            default:
                d = s[i]-'0';
                break;
        }
    }
    return n;
}

int main() {
    int n, n1, n2;
    string s1, s2;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> s1 >> s2;
        n1 = m2n(s1);
        n2 = m2n(s2);
        cout << n2m(n1+n2) << endl;
    }
    return 0;
}

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

int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.size() <= k){
    std::cout << s << '\n';
  }
  else{
    rep(i, k){
      std::cout << s.at(i);
    }
    std::cout << "..." << '\n';
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;

int main() {
	u32 N;
	string S;
    
	cin >> N >> S;
	set<int> setpos[26];
    
	for (int i=0; i<N; i++) setpos[S[i] - 'a'].insert(i + 1);
    
	int idx, iq, lq, rq;
	
    char cq;
    
	u32 q;
	cin >> q;
    
	while (q--) {
        cin >> idx;
        if (idx == 1) {    // 1 iq cq
            cin >> iq >> cq;
            if (S[iq - 1] != cq) {
                setpos[S[iq - 1] - 'a'].erase(iq);
                setpos[cq - 'a'].insert(iq);
                S[iq - 1] = cq;
            }
        } else {    // 2 lq rq
            cin >> lq >> rq;
            int cnt = 0;
            for (int c = 0; c < 26; c++) {
                auto it = setpos[c].lower_bound(lq);
                if (it != setpos[c].end() && *it <= rq) cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

/* 
int main() {
	u32 N;
	cin >> N;
	
	string S;
	cin >> S;
	
	u32 Q;
	cin >> Q;
	
	set<u32> cm[26];
	for(u32 i=0; i<N; i++) cm[S[i] - 'a'].insert(i);

	for(u32 q=0; q<Q; q++) {
		u32 t;
		cin >> t;
		
		if(t & 1) {
			u32 i;
			char c;
			cin >> i >> c;
	
			if(S[i-1] == c) continue;
			
			cm[c - 'a'].insert(i-1);
			cm[S[i-1] - 'a'].erase(i-1);
			
			S[i-1] = c;
			
		} else {
			u32 l, r;
			cin >> l >> r;
			
			u32 ans = 0;
			
			for(const auto cs : cm) {
				auto itr = cs.lower_bound(l - 1);
				if(itr != cs.end() && *itr <= r - 1) ans++;
			}
			
			cout << ans << endl;
		}
	}
	
	return 0;
} */

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

#define int long long

int F[100][15];
int P[100][15];

signed main() {
    int n;
    cin >> n;
    for(int i=0; i<n; ++i) {
        for(int j=0; j<10; ++j) cin >> F[i][j];
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<11; ++j) cin >> P[i][j];
    }
    int res = -(1<<30);
    for(int b=1; b<(1<<10); ++b) {
        int c = 0;
        for(int i=0; i<n; ++i) {
            int x = 0;
            for(int j=0; j<10; ++j) if((b>>j&1)&&F[i][j]) x++;
            c+=P[i][x];
        }
        res = max(res, c);
    }
    cout <<res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long cc;
typedef pair <int, int> pii;
map <int, int> m;
int n;
set <int> s;
int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    while (n--) {
        int x; cin >> x;
        m[x]++;
        s.insert(x);
    }
    int res = 0;
    for (auto x: s) {
        if (m[x] > x) res += m[x] - x;
        else
        if (m[x] < x) res += m[x];
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 9344
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String S = br.readLine();
        if (N%2==1) {
            System.out.println("No");
        } else {
            int counter1 = 0;
            int counter2 = (N/2);
            for (int i=0; i<N/2; i++) {
                if (S.charAt(counter1)!=S.charAt(counter2)) {
                    System.out.println("No");
                    return;
                }
                counter1++;
                counter2++;
            }
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int ans=0;
  rep(i, a+1)rep(j, b+1)rep(k, c+1)if(i*500+j*100+k*50==x)ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

int main(void) {

  for(;;) {
    int N;
    std::cin >> N;
    if( N == 0 ) break;

    int W, H;
    std::cin >> W >> H;

    bool map[128][128] = {{}};
    for(int i = 0; i < N; ++i) {
      int x, y;
      std::cin >> x >> y;
      map[x][y] = true;
    }

    int S, T;
    std::cin >> S >> T;

    int res = 0;
    for(int i = 1; i <= W - S + 1; ++i) {
      for(int j = 1; j <= H - T + 1; ++j) {
        int count = 0;
        for(int x = i; x <= i + S - 1; ++x) {
          for(int y = j; y <= j + T - 1; ++y) {
            if( map[x][y] ) count += 1;
          }
        }
        res = std::max(res, count);
      }
    }

    std::cout << res << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
#include<cmath>

using namespace std;
int main(){
    double x1,x2,y1,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%lf\n",sqrt(pow(x2-x1,2)+pow(y2-y1,2)));
    return 0;
}



Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


ll n,m,k;

int t[1024][1024];

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

    rep(i,n+1) rep(j,m+1){
        ll cnt = m*i + n*j - 2*i*j;
        if(cnt==k){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

long long gcd(long long a, long long b) {
	if(b == 0) {
		return a;
	} else {
		return gcd(b, a % b);
	}
}

long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}

int main(void) {
	using namespace std;
	int N;
	cin >> N;
	long long l = 1;
	for(int i = 0; i < N; ++i) {
		long long T;
		cin >> T;
		l = lcm(l, T);
	}
	cout << l << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string enki;
    cin>>enki;
    if (enki=="A") 
    {
        cout<<"T";
    }
    if (enki=="C") 
    {
        cout<<"G";
    }
    if (enki=="G") 
    {
        cout<<"C";
    }
    if (enki=="T") 
    {
        cout<<"A";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll fun(ll x){
    return x*(x+1)/2;
}
int main (){
    ll n;cin >> n;

    ll sum = fun(n);
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0||i%15==0)sum-=i;
    }
    cout<<sum<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int mod = 1e9+7;
int expo(int b, int p) {
    if (p == 0) return 1;
    if (p == 1) return b;

    int x = expo(b, p/2);
    x = (int) ((ll)x*x % mod);
    if (p&1) x = (int) ((ll)x*b % mod);
    return x;
}

const int MAXA = (1<<20);

ii f[MAXA];

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    int a[n+1], b[n+1], z[n+1]; b[0] = z[0] = 0;
    FOR(i,1,n){
        cin >> a[i];
        b[i] = b[i-1] ^ a[i];
        z[i] = z[i-1] + (b[i] == 0);
    }

    if (b[n] != 0) {
        int dp[n+1];

        int x = 0, y = 1;
        RFOR(i,n,0) {
            if (b[i] == 0) {
                dp[i] = y;
                x = (x + dp[i]) % mod;
            } else if (b[i] == b[n]) {
                dp[i] = x;
                y = (y + dp[i]) % mod;
            }
        }
        cout << dp[0] << '\n';
    } else {
        int dp[n+1];

        int ans = expo(2, z[n]-1);
        RFOR(i,n,0) {
            if (b[i] != 0) {
                //dp[i] = sum(dp[j]*diffZeroes for all b[j] == b[i]) + 1;
                dp[i] = 1;
                //FOR(j,i+1,n) if (b[i] == b[j]) {
                //    //dp[i] = (int) (((ll)dp[i] + (ll)dp[j]*(z[j]-z[i]) % mod) % mod);
                //    //dp[i] += (ll)dp[j]*(z[j]-z[i]);
                //    dp[i] += (ll)dp[j]*z[j] - dp[j]*z[i];
                //}
                dp[i] = (dp[i] + f[b[i]].fi) % mod;
                dp[i] = (dp[i] - ((ll)f[b[i]].sc * z[i] % mod) + mod) % mod;

                f[b[i]].fi = (f[b[i]].fi + ((ll)dp[i] * z[i] % mod)) % mod;
                f[b[i]].sc = (f[b[i]].sc + dp[i]) % mod;

                ans = (ans + dp[i]) % mod;
            }
        }

        cout << ans << '\n';
    }
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int h, w; cin >> h >> w;
  vector<vector<int>> c(10, vector<int>(10));
  rep(i, 10) rep(j, 10) cin >> c[i][j];
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(k, 10) rep(i, 10) rep(j, 10) chmin(c[i][j], c[i][k]+c[k][j]);
  int ans = 0;
  rep(i, h) rep(j, w) {
    if(a[i][j] == -1) continue;
    ans += c[a[i][j]][1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3760
#include <stdio.h>

int main(){
  int n, p;  scanf("%d %d", &n, &p);

  int kisu = 0;
  for(int i=0; i<n; i++){
    int a;  scanf("%d", &a);
    if(a % 2)  kisu++;
  }
  
  long ans = ((long)1 << (n-kisu));
  long plus;
  if(kisu){
    plus = ((long)1 << (kisu-1));
  }else if(p == 1){
    plus = 0;
  }else{
    plus = 1;
  }
  printf("%ld\n", ans*plus);

  return 0;
}


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

static int Par[200000], Rank[200000];

void init(int X) {
	for (int i = 0; i < X; i++) {
		Par[i] = i;
		Rank[i] = 0;
	}
}

int root(int X) {
	if (Par[X] == X) return X;
	else return Par[X] = root(Par[X]);
}

bool same(int X, int Y) {
	return root(X) == root(Y);
}

void unite(int X, int Y) {
	if (same(X, Y)) return;
	X = root(X), Y = root(Y);
	if (Rank[X] < Rank[Y]) Par[X] = Y;
	else {
		Par[Y] = X;
		if (Rank[X] == Rank[Y]) Rank[X]++;
	}
	return;
}

int main() {
	bool ans = true;
	int N, M;
	cin >> N >> M;
	init(N + M);
	for (int i = 0; i < N; i++) {
		int K, L;
		cin >> K;
		for (int j = 0; j < K; j++) {
			cin >> L;
			unite(i, N + L - 1);
		}
	}
	for (int i = 0; i < N - 1; i++) {
		if (!same(i, i + 1)) ans = false;
	}
	if (ans) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 1792
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val inputs = List.tabulate(N)(i => (i + 1, sc.next, sc.nextInt))
    sc.close()

    val sorted = inputs.sortBy{ case (_, x,y) => (x, -y) }
    sorted.foreach(p => println(p._1))
  }
}

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


typedef pair<int,int> P;
#define MAX 100005
  
int V,E;
vector<int> G[MAX];
  
int depth[MAX];
int cnt[MAX];
int visited[MAX];
  
vector<P> ans;
  
void dfs(int pos,int prev){
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(!visited[to]){
      depth[to]=depth[pos]+1;
      dfs(to,pos);
      cnt[pos]+=cnt[to];
      if(cnt[to]==0)ans.push_back( P( min(pos,to) , max(pos,to) ) );
    }else if(depth[to]<depth[pos]){
      cnt[pos]++;
      cnt[to]--;
    }
  }
}
  
int main(){
  scanf("%d %d",&V,&E);
  for(int i=0;i<E;i++){
    int a,b;
    scanf("%d %d",&a,&b);
  	a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0,-1);
    
	cout << ans.size() << endl;
  return 0;
}

Measured memory_bytes: 2560
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        h: usize, n: usize,
        ab: [(usize, usize); n],
    }
    const INF: usize = 1 << 40;
    let mut dp = vec![INF; h + 1];
    dp[0] = 0;
    for &(a, b) in &ab {
        for i in 0..h {
            let to = min(h, i + a);
            dp[to] = min(dp[to], dp[i] + b);
        }
    }
    puts!("{}\n", dp[h]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll N=2e5+1;

ll solve(ll t,vector<ll>& a,ll n)
{
  ll ans=0;
  for(int i=1;i<=n;i++)
    ans+=(a[i]-t)*(a[i]-t);

  return ans;

}


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

ll n;cin>>n;

vl a(n+1);
ll sum=0;

for(int i=1;i<=n;i++)
{
  cin>>a[i];
  sum+=a[i];
}

sum/=n;

ll x=solve(sum,a,n);

if(solve(sum+1,a,n)<x)x=solve(sum+1,a,n);

cout<<x<<"\n";


}

Measured memory_bytes: 256
import sys,fractions
input = sys.stdin.readline

mod = 10**9+7

n = int(input())
lst_a = list(map(int, input().split()))

lcm = 1
for a in lst_a:
    lcm = a*lcm//fractions.gcd(a,lcm)
lcm %= mod
ans = 0
for a in lst_a:
	ans += lcm*pow(a,mod-2,mod)
	ans %= mod

print(ans)

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

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;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
  int w=0;
  int h=0;
  int x=0;
  int y=0;
  int r=0;

  scanf("%d %d %d%d %d\n", &w, &h, &x, &y, &r);
  if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}



Measured memory_bytes: 2672
N, M, X, Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

x.append(X)
y.append(Y)

xx = max(x)
yy = min(y)

if xx < yy:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let () = 
        (let lst = Str.split (Str.regexp "[B|D|E|F|H|I|J|K|L|M|N|O|P|Q|R|S|U|V|W|X|Y|Z]") (read_line ()) in
                 if lst = [] then
                         0
                 else
                         List.sort (fun a b ->
                                 let alen = String.length a in
                                 let blen = String.length b in
                                         if alen = blen then
                                                 0
                                         else 
                                         if alen < blen then
                                                 1
                                         else
                                                 -1
                         ) lst
                         |> List.hd
                         |> String.length
        )
        |> Printf.printf "%d\n"


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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for ( int i = 0; i < n; ++ i){
        cin >> a.at(i);
        sum += a.at(i);
    }
    int count = 0;
    double sum1 = sum / (4.0 * m);
    for ( int i = 0; i < n; ++i)
    {
        if ( a.at(i) >= sum1 )
            count++;
    }
    if ( count >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
    
}

Measured memory_bytes: 3612
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
typedef long long ll;
const int maxn = 210000;
int a[maxn],b[maxn];
int main()
{
	int n,max1=0,max2=0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
	{
		if (b[i] == a[n])printf("%d\n", a[n-1]);
		else printf("%d\n", a[n]);
	}
}

Measured memory_bytes: 3200
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(' ').map { it.toInt() }

    if (x * 2 <= y && y <= x * 4) {
        if (y % 2 == 0) {
            println("Yes")
        } else {
            println("No")
        }
    } else {
        println("No")
    }
}

Measured memory_bytes: 36336
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
P dp[110][50010];
const int INF=1e7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(;;){
        int n;
        cin>>n;
        if(!n) return 0;
        vector<int> p(n);
        rep(i,0,n) cin>>p[i];
        rep(i,0,n){
            fill(dp[i], dp[i]+50010, P(INF,INF));
        }
        rep(i,0,n) dp[i][0]=P(0,0);
        if(p[0]%1000!=0){
            if(p[0]%1000<=500) dp[0][500-p[0]%1000]=P(-1, p[0]);
            else dp[0][1000-p[0]%1000]=P(0, p[0]);
        }
        rep(i,0,n-1){
            if(p[i+1]%1000==0){
                rep(j,0,50010){
                    if(dp[i][j]!=P(INF,INF)){
                        dp[i+1][j]=min(dp[i+1][j], dp[i][j]);
                        dp[i+1][(j>=500?j-500:j)]=min(dp[i+1][(j>=500?j-500:j)],P(dp[i][j].fr-(j>=500?1:0), dp[i][j].sc+p[i+1]));
                    }
                }
                continue;
            }
            rep(j,0,50010){
                dp[i+1][j]=dp[i][j];
            }
            if(p[i+1]%1000<=500) dp[i+1][500-p[i+1]%1000]=min(dp[i+1][500-p[i+1]%1000],P(-1, p[i+1]));
            else dp[i+1][1000-p[i+1]%1000]=min(dp[i+1][1000-p[i+1]%1000], P(0, p[i+1]));
            rep(j,0,50010){
                if(dp[i][j]!=P(INF,INF)){
                    if(p[i+1]%1000<=500){
                        int x=j+500-p[i+1]%1000;
                        dp[i+1][x]=min(dp[i+1][x], P(dp[i][j].fr-1, dp[i][j].sc+p[i+1]));
                    }
                    else{
                        if(j>=p[i+1]%500){
                            int x=j-p[i+1]%500;
                            dp[i+1][x]=min(dp[i+1][x], P(dp[i][j].fr-1, dp[i][j].sc+p[i+1]));
                        }
                        int x=j+1000-p[i+1]%1000;
                        if(x>=500){
                            dp[i+1][x-500]=min(dp[i+1][x-500], P(dp[i][j].fr-1, dp[i][j].sc+p[i+1]));
                        }
                        else{
                            dp[i+1][x]=min(dp[i+1][x], P(dp[i][j].fr, dp[i][j].sc+p[i+1]));
                        }
                    }
                }
            }
        }
        int ans=500;
        rep(i,0,50010){
            if(dp[n-1][i]!=P(INF,INF)){
                ans=min(ans, dp[n-1][i].fr);
            }
        }
        int res=1e8;
        rep(i,0,50010){
            if(dp[n-1][i]!=P(INF,INF)){
                if(dp[n-1][i].fr==ans) res=min(res, dp[n-1][i].sc);
            }
        }
        cout<<-ans<<" "<<res<<"\n";
    }
}


Measured memory_bytes: 46104
#include <cstdio>

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a <= b && b <= c){
        printf("%d %d %d",a,b,c);
    }else if(a <= b && b >= c){
        if(a <= c){
            printf("%d %d %d",a,c,b);
        }else{
            printf("%d %d %d",c,a,b);
        }
    }else if(a >= b && b <= c){
        if(a <= c){
            printf("%d %d %d",b,a,c);
        }else{
            printf("%d %d %d",b,c,a);
        }
    }else if(a >= b && b >=c){
        printf("%d %d %d",c,b,a);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2728
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

long long int keta(long long int n) {
	long long int c = 0;
	while (n > 0) {
		c++;
		n /= 10;
	}
	return c;
}

int main() {
	long long int n;
	cin >> n;
	long long int MIN = n;
	for (long long int i = 1; i*i <= n; i++) {
		if (n % i == 0) {
			MIN = min(MIN, max(keta(i), keta(n / i)));
		}
	}
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int c;
if(b/10==0)
c=10*a+b;
if(b/10!=10 && b/10!=0)
c=100*a+b;
if(b/100==1)
c=1000*a+b;
for(int i=1;i*i<=c;i++)
if(i*i==c){
cout<<"Yes";
return 0;
}
cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main() {
	
	int a, b;
	cin >> a >> b;
	
	int ans = (a - 1)*(b - 1);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
cnt = 0 
while True:
  pre = False
  for i in range(N):
    if h[i] > 0:
      if pre:
        h[i] -= 1
      else:
        h[i] -= 1
        pre = True
        cnt += 1
    else:
      pre = False
  if sum(h) == 0:
    break
print(cnt)


Measured memory_bytes: 40336
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n)
  cin >> a[i];
  vector<ll> left(n);
  vector<ll> right(n);
  left[0] = a[0];
  right[0] = a[n - 1];
  for (ll i = 1; i < n; i++)
  {
    left[i] = max(left[i - 1], a[i]);
    right[i] = max(right[i - 1], a[n - i - 1]);
  }
  REP(i, n)
  {
    if (i == 0)
    {
      cout << right[n - 2] << endl;
    }
    else if (i == n - 1)
    {
      cout << left[n - 2] << endl;
    }
    else
    {
      cout << max(left[i - 1], right[n - 2 - i]) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)998244353) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

class Tree{
public:
	int n;
	vector<int> p;
	vector<int> l;
	vector<int> r;
	vector<int> d;
	vector<int> h;

	Tree(int N){
		n=N;
		p.resize(N, -1);
		l.resize(N, -1);
		r.resize(N, -1);
		d.resize(N, -1);
		h.resize(N, -1);
	}

	void add(int pa, int left, int right){
		if(left>=0){
			l[pa]=left;
			p[left]=pa;
		}
		if(right>=0){
			r[pa]=right;
			p[right]=pa;
		}
	}

	int get_brother(int id){
		if(p[id]==-1)return -1;
		int ll = l[p[id]];
		if(ll>=0&&ll!=id)return ll;
		int rr = r[p[id]];
		if(rr>=0&&rr!=id)return rr;
		return -1;
	}
	
	int get_depth(int id){
		if(p[id] == -1)return 0;
		if(d[id] >= 0)return d[id];
		return d[id] = get_depth(p[id]) + 1;
	}

	int get_height(int id){
		if(h[id]>=0)return h[id];
		int res = 0;
		if(r[id]>=0)res=max(res, get_height(r[id])+1);
		if(l[id]>=0)res=max(res, get_height(l[id])+1);
		return h[id]=res;
	}

	int get_degree(int id){
		int res = 0;
		if(r[id]>=0)++res;
		if(l[id]>=0)++res;
		return res;
	}

	int get_parent(int id){
		return p[id];
	}

	int get_root(int id){
		if(p[id]==-1)return id;
		return get_root(p[id]);
	}

	vector<int> get_preorder(int id){
		if(id==-1)return vector<int>(0);
		vector<int> res;
		res.push_back(id);
		vector<int> d;
		d = get_preorder(l[id]);
		res.insert(res.end(), ALL(d));
		d = get_preorder(r[id]);
		res.insert(res.end(), ALL(d));
		return res;
	}
	
	vector<int> get_inorder(int id){
		if(id==-1)return vector<int>(0);
		vector<int> res;
		vector<int> d;
		d = get_inorder(l[id]);
		res.insert(res.end(), ALL(d));
		res.push_back(id);
		d = get_inorder(r[id]);
		res.insert(res.end(), ALL(d));
		return res;
	}
	vector<int> get_postorder(int id){
		if(id==-1)return vector<int>(0);
		vector<int> res;
		vector<int> d;
		d = get_postorder(l[id]);
		res.insert(res.end(), ALL(d));
		d = get_postorder(r[id]);
		res.insert(res.end(), ALL(d));
		res.push_back(id);
		return res;
	}
};

void output(int d){
	static bool used = false;
	if(used)cout << " ";
	cout << d;
	used=true;
}

vector<int> pr;
vector<int> in;
int p = -1;

void func(int l, int r){
	if(l==r)return;
	int j;
	++p;
	int tmp = pr[p];
	for(j=l;j<r;++j){
		if(pr[p]==in[j]){
			func(l, j);
			func(j+1, r);
			break;
		}
	}
	output(tmp);
}

int main(){
	int N;
	cin >> N;
	pr.resize(N);
	in.resize(N);
	foreach(i, pr)cin>>i;
	foreach(i, in)cin>>i;
	func(0, N);
	cout << endl;
	return 0;
}



Measured memory_bytes: 3124
#include<iostream>

using namespace std;

int main()
{
	int n,m,i,j,sum=0;
	char a[51][51];
	cin>>n>>m;
	string str[51];
	string s;
	for(i=0;i<n;++i){
		cin>>s;
		str[i]=s;
	}
	for(i=0;i<50;++i){
		for(j=0;j<50;++j){
			sum=0;
			if(str[i][j]=='.'){
				if((i-1)>=0&&(j-1)>=0&&str[i-1][j-1]=='#')sum++;
				if((i-1)>=0&&str[i-1][j]=='#')sum++;
				if((i-1)>=0&&(j+1)<m&&str[i-1][j+1]=='#')sum++;
				if((j-1)>=0&&str[i][j-1]=='#')sum++;
				if((j+1)<m&&str[i][j+1]=='#')sum++;
				if((i+1)<n&&(j-1)>=0&&str[i+1][j-1]=='#')sum++;
				if((i+1)<n&&str[i+1][j]=='#')sum++;
				if((i+1)<n&&(j+1)<m&&str[i+1][j+1]=='#')sum++;
				a[i][j]='0'+sum;	
			}
			else if(str[i][j]=='#')a[i][j]='#';
		}
	}
	for(i=0;i<n;++i){
		for(j=0;j<m;++j){
			cout<<a[i][j];
		}
		cout<<endl;
	}
	
	return 0;
 } 

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N = int(input())
arr = list(map(int, input().split()))
ctr = 0

while True:
    for i in range(N):
        if arr[i] % 2 != 0:
            print(ctr)
            exit()
        else:
            continue
    else:
        arr = list(map(lambda x: x // 2, arr))
        ctr += 1

Measured memory_bytes: 3060
A,B = [int(i) for i in input().split()] 

Flag = False

price1 = int(A // 0.08) + 1
price2 = int(B // 0.1) + 1

if price1 < price2:
  start = price1
  end = price2
else:
  start = price2
  end = price1

for i in range(start,end+1):
  if int(i * 0.08) == A and int(i *0.1) == B:
    Flag = True
    price = i
    break

if Flag == True:
  print(price)
else:
  print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
  #endif

    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;
    bool is = false;
    rep(i, 0, 3) {
        if (s[i] == '7')
            is = true;
    }
    if (is)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
use std::str::FromStr;

fn parse()-> (u8, u8) {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();

    let mut it = line.split_whitespace();
    let a = u8::from_str(it.next().unwrap()).unwrap();
    let b = u8::from_str(it.next().unwrap()).unwrap();

    (a, b)
}

fn main() {
    let (a, b) = parse();

    if a < b {
        println!("{}", b + b - 1);
    } else if a == b {
        println!("{}", a + a);
    } else {
        println!("{}", a + a - 1);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
ll mod_pow(ll a,ll n) {
    if(n==0) return 1;
    if(n%2==0) {
        ll t=mod_pow(a,n/2);
        return (t*t)%MOD;
    }
    return (a*mod_pow(a,n-1))%MOD;
}
ll fact[201],inv_fact[201];
ll comb(ll n,ll k) {
    if(n<k) return 0;
    ll ret=fact[n];
    (ret*=inv_fact[k])%=MOD;
    (ret*=inv_fact[n-k])%=MOD;
    return ret;
}
int main() {
    int N;
    cin>>N;
    fact[0]=inv_fact[0]=1;
    for(int i=1;i<=N;i++) {
        fact[i]=(fact[i-1]*i)%MOD;
        inv_fact[i]=(inv_fact[i-1]*mod_pow(i,MOD-2))%MOD;
    }
    vector<ll> x(N);
    vector<ll> y(N);
    for(int i=0;i<N;i++) {
        cin>>x[i]>>y[i];
    }
    ll ans=0;
    for(int i=0;i<N;i++) {
        for(int j=i+1;j<N;j++) {
            int n=0;
            for(int k=i+1;k<j;k++) {
                int area = (x[j]-x[i])*(y[k]-y[i])-(x[k]-x[i])*(y[j]-y[i]);
                if(area) n++;
            }
            for(int k=1;k<=n;k++) {
                ll t = comb(n, k);
                (t *= mod_pow(2, j - i - 1 - n)) %= MOD;
                (ans+=t)%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;


int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    vector<vector<int>> matrix;
    for(int i = 0; i < n; ++i){
        matrix.push_back(vector<int>());
        for(int j = 0; j < m; j++){
            int v;
            scanf("%d", &v);
            matrix[i].push_back(v);
        }
    }
    
    vector<int> vect;
    for(int i = 0; i < m; i++){
        int v;
        scanf("%d", &v);
        vect.push_back(v);
    }
    
    for(auto row: matrix){
        int sum = 0;
        for(int i = 0; i < m; ++i){
            sum += row[i] * vect[i];
        }
        printf("%d\n", sum);
    }
    
    
}







Measured memory_bytes: 2792
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e3+10,mod=1e9+7 ;


int main ()
{
    FASTIO;
    ll n , m ;
    cin >> n >> m ;
    cout << n * m << endl;
    return 0;
}
/**


*/


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll x;
  cin>>x;
  if(x==1) {
cout<<0<<endl;
  }
  else {
cout<<1<<endl;
  }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string O,E; cin >> O >> E;
    REP(i,E.size()){
        cout << O[i] << E[i];
    }
    if(O.size()-E.size() == 1) cout << O[O.size()-1];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3580
// DFSを用いたトポロジカルソート
// 計算量 O(V + E) 
// reference Programming Contest Challenge Book Second Edition
// verify https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_4_B

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

template<typename T> struct edge {
  int to;
  edge(int to_) : to(to_) {}
};

template<typename T,template <typename ELEM> class C> struct AdListGraph {
  vector<vector<C<T>>> G;
  vector<bool> used;
  vector<bool> is_ancetor;
  int V;//0,...,|V|-1

  AdListGraph (int V_) {
    Init(V_);
  }

  void Init(int V_) {
    V = V_;

    G.clear();
    G.resize(V);
  }

  // https://faithandbrave.hateblo.jp/entry/20080310/1205149207
  template <typename FROM, class... Args>
  void AddEdge(FROM from, Args&&... arg) {
    G[from].emplace_back(arg...);
  }

  bool DFSForTopologicalSort (int i, vector<int>& sorted) {
    if (is_ancetor[i]) return false;
    if (used[i]) return true;

    used[i] = true;
    is_ancetor[i] = true;

    for(const auto& v : G[i]) {
      if(!DFSForTopologicalSort(v.to, sorted)) return false;
    }

    is_ancetor[i] = false;
    sorted.emplace_back(i);//dfsの帰りがけの順

    return true;
  }

  template<typename ID_TYPE>
  bool TopologicalSort (vector<ID_TYPE>& sorted) { // 成功ならtrue 失敗(DAG出ない)ならfalseを返す
    used.clear();
    used.resize(V,false);
    is_ancetor.clear();
    is_ancetor.resize(V, false);

    sorted.clear();

    rep (i,V) {
      if(!DFSForTopologicalSort(i, sorted)) {
        return false;
      }
    }

    reverse(sorted.begin(),sorted.end());

    return true;
  }

};

using ll = long long;

int main() {
  ll V,E;
  cin >> V >> E;
  AdListGraph<ll,edge> G(V);
  rep(i,E) {
    ll s,t;
    cin >> s >> t;
    G.AddEdge(s,t);
  }

  vector<int> ans;

  G.TopologicalSort(ans);

  for (auto v : ans) {
    cout << v << endl;
  }
  return 0;
}



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

int main()
{
    vector<int> A(5);
    for (int i = 0; i < 5; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int K = 0;
    cin >> K;
    
    if (A[4] - A[0] <= K) {
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc124/tasks/abc124_c

import itertools
from collections import Counter
import bisect

def main():
    S = list(input())

    even_black = 0
    even_white = 0
    for i in range(len(S)):
        if i % 2 == 0:
            if S[i] == '0':  # black
                even_white += 1
            else:  # white
                even_black += 1
        else: # odd
            if S[i] == '0':  # black
                even_black += 1
            else:  # white
                even_white += 1

    print(min(even_black, even_white))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4340
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;

int N;
int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d\n", &N);
    printf("%d\n", N*800-(N/15)*200);
    //system("pause");
}


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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007

typedef long long ll;
int main() {
  int n, height;
  int count = 0;
  int in;
  cin >> n >> height;
  for(int i = 0; i < n; i++) {
    scanf("%d", &in);
    if(in >= height) count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 256