akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

const MOD = 1000000007
const MAX = 2000001

func comb(n, k int) int {
	fac  := make([]int, MAX)
	finv := make([]int, MAX)
	inv  := make([]int, MAX)
	fac[0], fac[1] = 1, 1;
	finv[0], finv[1] = 1, 1;
	inv[1] = 1;
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
	
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

func main() {
	var X, Y, ans int
	fmt.Scan(&X, &Y)
	n := (2 * Y - X) / 3
	m := (2 * X - Y) / 3;
	if (X + Y) % 3 == 0 && n >= 0 && m >= 0 {
		ans = comb(n + m, n);
	}
	fmt.Println(ans)
}

Measured memory_bytes: 48896
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int a[25][25];
int n;
ll  dp[1 << 21];
const ll MOD = 1e9 + 7;

void add(ll &a, ll b) {
	a = (a + b) % MOD;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> a[i][j];
		}
	}
	dp[0] = 1;
	for (int i = 0; i < (1 << n) - 1; ++i) {
		int x = __builtin_popcount(i);
		for (int j = 0; j < n; ++j) {
			if (a[x][j] && !((i >> j) & 1))
				add(dp[i | (1 << j)], dp[i]);
		}
	}
	cout << dp[(1 << n) - 1] << "\n";
	return 0;
}




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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int visited[200001];
int a[200001];
int cnt = 0;
int l = -1;

void dfs(int curr, int parent){
    cnt++;
    if(!visited[curr]){
        visited[curr] = cnt;
        dfs(a[curr], curr);
    }
    else
        l = parent;
}

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

    int n;
    ll k;
    cin >> n >> k;
    
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dfs(1, 0);
    int s = visited[l] - visited[a[l]] + 1;
    vi topo;
    topo.push_back(a[l]);
    for(int i = 1; i < s; i++){
        topo.push_back(a[topo[i - 1]]);
    }
    ll k2 = k - visited[a[l]] + 1;
    if(k2 < 0){
        int tmp = 1;
        while(k--){
            tmp = a[tmp];
        }
        cout << tmp;
    }
    else
        cout << topo[k2 % s];
    
}

Measured memory_bytes: 5776
import java.util.*;
/*行列の積
１行目に ｎｍｌ が空白区切りで与えられます。続く行にｎｘｍの行列Aと
ｍｘｌの行列Bが与えられます。ｎｘｌの行列Cの要素を出力する。
*/
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        
        int [][] a = new int[n][m];//ｎｘｍを入れる箱
        int [][] b = new int[m][l];//ｍｘｌを入れる箱
        long [][] c = new long[n][l];//answerのｎｘｌを入れる箱

        int i;//n
        int j;//m
        int k;//l
        
        
//      System.out.println(n+" "+m+" "+l);
//ｎｘｍとｍｘｌの読込
        for( i = 0; i < n; i++){
          for( j = 0; j < m; j++){
              a[i][j] = sc.nextInt();
//              System.out.print(a[i][j]);
          }
//          System.out.println();
        }
        
        for(i = 0;i<m;i++){
            for(j = 0;j<l;j++){
                b[i][j] = sc.nextInt();
//              System.out.print(b[i][j]);
                
            }
//            System.out.println();
        }
        
        //ここから
        for ( i = 0; i < n; i++){
            for ( j = 0; j < l; j++){
                for ( k = 0; k < m; k++){
                      
             //      c[i][j] = a[i][k] * b[k][j];
                   c[i][j] += ( a[i][k]*b[k][j]);
                }
            }
        }
        
        for( i = 0; i < n; i++){
            for( j = 0; j < l; j++){
                if(!(j==l-1)){
                System.out.print(c[i][j] +" ");
                }else if(j == l-1){
                    System.out.println(c[i][j]);
                }
            }
        }
    }
}



Measured memory_bytes: 53632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h := intScanner()
	w := intScanner()
	k := intScanner()
	k--
	if w > 1 {
		x := make([]int, w)
		x[0] = 1
		list := make([][]int, 0)
		st := [][]int{[]int{}}
		for len(st) != 0 {
			y := st[len(st)-1]
			st = st[:len(st)-1]
			if len(y) == w-1 {
				z := make([]int, w-1)
				copy(z, y)
				list = append(list, z)
			} else {
				z := make([]int, len(y))
				copy(z, y)
				st = append(st, append(z, 0))
				if len(y) == 0 {
					a := make([]int, len(y))
					copy(a, y)
					st = append(st, append(a, 1))
				} else if y[len(y)-1] == 0 {
					a := make([]int, len(y))
					copy(a, y)
					st = append(st, append(a, 1))
				}
			}
		}
		for i := 0; i < h; i++ {
			y := make([]int, w)
			for _, l := range list {
				for i := 0; i < w-1; i++ {
					if l[i] == 1 {
						y[i+1] += x[i]
						y[i] += x[i+1]
					}
					y[i] %= mod
				}
				for i := 0; i < w; i++ {
					if l[larger(i-1, 0)] == 0 && l[smaller(i, w-2)] == 0 {
						y[i] += x[i]
						y[i] %= mod
					}
				}
			}
			copy(x, y)
		}
		fmt.Println(x[k])
	} else {
		fmt.Println(1)
	}
}
func larger(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.lang.Math;

public class Main{
	Main(){
		Scanner sc = new Scanner(System.in);
		int iff = Integer.decode("0xff");
		int[][] a = new int[8][];
		
		for(int i = 0; i < 8; i++){
			a[i] = new int[3];
		}
		a[1][2] = a[2][1] = a[3][1] = a[3][2] = a[4][0] = a[5][0] = iff;
		a[5][2] = a[6][0] = a[6][1] = a[7][0] = a[7][1] = a[7][2] = iff;
		
		while(true){
			String str = sc.next();
			if(str.equals("0")){
				break;
			}
			int r = Integer.decode("0x"+str.substring(1, 3));
			int g = Integer.decode("0x"+str.substring(3, 5));
			int b = Integer.decode("0x"+str.substring(5, 7));
			
			double mind = Math.sqrt((double)(r*r+g*g+b*b));
			int p = 0;
			
			for(int i = 1; i < 8; i++){
				double d = Math.sqrt((double)((r-a[i][0])*(r-a[i][0])+(g-a[i][1])*(g-a[i][1])+(b-a[i][2])*(b-a[i][2])));
				if(d < mind){
					mind = d;
					p = i;
				}
			}
			
			if(p == 0){
				str = "black";
			} else if(p == 1){
				str = "blue";
			} else if(p == 2){
				str = "lime";
			} else if(p == 3){
				str = "aqua";
			} else if(p == 4){
				str = "red";
			} else if(p == 5){
				str = "fuchsia";
			} else if(p == 6){
				str = "yellow";
			} else {
				str = "white";
			}
			
			System.out.println(str);
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    long x = in.nl();
    long result = 1000 * (x / 500);
    x %= 500;
    result += (x / 5) * 5;
    out.println(result);
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 23252
import java.util.Scanner;
import java.util.Arrays;

class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) {
			System.out.println("YES");
		} else {

			System.out.println("NO");
		}
		in.close();

	}

}

Measured memory_bytes: 10060
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>

#define mod 1000000007
using namespace std;

int main() {
    int m, n;
    cin >> n >> m;
    cin.ignore();
    vector<string> matrix(n);
    string s;
    for (int i = 0; i < n; i++) {
        getline(cin, s);
        matrix[i] = s;
    }
    int grid[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            grid[i][j] = (matrix[i][j] == '#') ? -1 : 0;
        }
    }
    grid[0][0] = 1;
    for (int i = 1; i < n && grid[i][0] != -1; i++) {
        grid[i][0] = 1;
    }
    for (int j = 1; j < m && grid[0][j] != -1; j++) {
        grid[0][j] = 1;
    }
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < m; j++) {
            if (grid[i][j] != -1) {
                grid[i][j] = (grid[i - 1][j] == -1 ? 0 : grid[i - 1][j]) % mod + (grid[i][j - 1] == -1 ? 0 : grid[i][j - 1]) % mod;
                grid[i][j] = grid[i][j] % mod;
            }
        }
    }
    cout << grid[n - 1][m- 1] % mod << endl;
    return 0;
}

Measured memory_bytes: 5248
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005

int main()
{
    fastread;
    int n;
    cin>>n;
    vector<long long> cnt(n + 1, 0);
    for(int i = 1; i <= 100; i++) {
    	for(int j = 1; j <= 100; j++) {
    		for(int k = 1; k <= 100;k++) {
    			int res = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (i * k);
    			if(res <= n) {
    				cnt[res]++;
    			}
    		}
    	}
    }
    for(int i = 1; i <= n; i++) {
    	cout<<cnt[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3692
N = int(input())
A = list(map(int,input().split()))

#各要素が何個あるか
num_list = [0]*(N+1)
for i in A:
    num_list[i] += 1

#全体の組み合わせ
total = 0
for j in num_list:
    total += j*(j-1)//2

for k in A:
    print(total+1-num_list[k])

Measured memory_bytes: 24996
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, B, C): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if A == B { C } else if B == C { A } else { B };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    int lens = s.size();
    int lent = t.size();

    if (lens < lent) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    string ans;
    rep(i, 0, 50) ans += 'x';

    bool flag = false;
    for (int i = 0; i <= lens - lent; i++) {
        bool match = true;
        for (int j = 0; j <= lent - 1; j++) {
            if (s[j + i] != '?' && s[j + i] != t[j]) {
                match = false;
            }
        }
        if (match) {
            flag = true;
            string tmp = s;
            for (int j = 0; j <= lent - 1; j++) {
                tmp[j + i] = t[j];
            }
            for (int j = 0; j <= lens - 1; j++) {
                if (tmp[j] == '?') tmp[j] = 'a';
            }
            ans = min(ans, tmp);
        }
    }

    if (flag) cout << ans << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define F first
#define S second
#define M 1000000007
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll n,t,a;
	cin>>n>>t>>a;
	double mn=DBL_MAX;
	double h[n];
	for(int i=0;i<n;i++){
	cin>>h[i];
	h[i]*=0.006;
	h[i]=t-h[i];
	}
	ll ans=-1;
	for(int i=0;i<n;i++){
		if(abs(h[i]-a)<mn){
			mn=abs(h[i]-a);
			ans=i+1;
		}
	}
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int N,M;
  cin>>N;
  vector<string>S(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>S[i];
  }
  cin>>M;
  vector<string>T(M);
  for(int i=0;i<=M-1;i++){
  
    cin>>T[i];
  }
  int countplus=0;
  int countminus=0;
  int ans=0;
  for(int i=0;i<=N-1;i++){
  
    countplus=0;
    for(int j=0;j<=N-1;j++){
    
      if(S[i]==S[j])countplus++;   
    }
    countminus=0;
    for(int j=0;j<=M-1;j++){
    
      if(S[i]==T[j])countminus++;
    }
    ans=max(ans,countplus-countminus);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long int k[200000];
  k[0]=2;
  k[1]=1;
  if(n==1) cout<<"1"<<endl;
  for(int i=2;i<=n;i++){
    k[i]=k[i-1]+k[i-2];
    if(i==n) cout<<k[i]<<endl;
  }
}

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

#define N 101
#define E 200001

int main(){
  int i, j, min;
  int p, q, r, n;
  int W[N][N];
  int dij[N], d[N];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    dij[i] = 0;
    d[i] = E;
    for(j = 0; j < n; j++){
      W[i][j] = -1;
    }
  }
  for(i = 0; i < n; i++){
    scanf("%d %d", &p, &q);
    for(j = 0; j < q; j++){
      scanf("%d", &r);
      scanf("%d", &W[p][r]);
    }
  }
  d[0] = 0;
  while(1){
    min = E;
    for(i = 0; i < n; i++){
      if(dij[i]!=1 && d[i]<min){
        min = d[i];
        p = i;
      }
    }
    if(min == E){
      break;
    }
    for(i = 0; i < n; i++){
      if(W[p][i]!=-1 && dij[i]!=1 && d[p]+W[p][i]<d[i])
        d[i] = d[p] + W[p][i];
    }
    dij[p] = 1;
  }
  for(i = 0; i < n; i++){
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.ReadInt;
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                var lr = IO.ReadSplitInt;
                sum += lr[1] - lr[0] + 1;
            }
            WriteLine(sum);
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 11348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int A, B, C, X, Y;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            A = in.nextInt();
            B = in.nextInt();
            C = in.nextInt();
            X = in.nextInt();
            Y = in.nextInt();

            int ans = INF;
            int cnt_ab = Math.max(X, Y) * 2;
            while (cnt_ab >= 0) {
                int cnt = cnt_ab / 2;
                int cnt_a = X > cnt ? X - cnt : 0;
                int cnt_b = Y > cnt ? Y - cnt : 0;
                ans = Math.min(ans, A * cnt_a + B * cnt_b + C * cnt_ab);
                cnt_ab--;
            }
            out.println(ans);
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 23508
s1, *sn = input()
L = len(sn)
SUM = 0
for bits in range(1 << L):
    formula = s1
    for op, s in enumerate(sn):
        if bits >> op & 1:
            formula += '+'
        formula += s
    value = sum(map(int, formula.split('+')))
    # print(formula, value, sep=' => ')
    # print(SUM, SUM + value, sep=' => ')
    SUM += value
print(SUM)


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

typedef string::const_iterator state;
class ParseError {};

unordered_map<string,int> table;

bool is_capital_letter(char ch){
    return 'A'<=ch and ch<='Z';
}

bool is_small_letter(char ch){
    return 'a'<=ch and ch<='z';
}

bool is_number(char ch){
    return '0'<=ch and ch<='9';
}

int atom(state &begin){
    string atom_name;
    atom_name+=*begin;
    ++begin;
    while(is_small_letter(*begin)){
        atom_name+=*begin;
        ++begin;
    }
    if(table.find(atom_name)!=table.end()) return table[atom_name];
    else throw ParseError();
}

int number(state &begin){
    int res=0;
    while(is_number(*begin)){
        res*=10;
        res+=*begin-'0';
        ++begin;
    }
    return res;
}

int molecule(state &begin){
    int res=0;
    while(true){
        if(is_capital_letter(*begin)){
            try{
                int tmp=atom(begin);
                if(is_number(*begin)) res+=tmp*number(begin);
                else res+=tmp;
            }catch(...){
                throw ParseError();
            }
        }else if(*begin=='('){
            ++begin;
            int tmp=molecule(begin);
            ++begin;
            res+=tmp*number(begin);
        }else break;
    }
    return res;
}

void solve(){
    while(true){
        string a;
        cin >> a;
        if(a=="END_OF_FIRST_PART") break;
        int w;
        cin >> w;
        table[a]=w;
    }

    while(true){
        string mole;
        cin >> mole;
        if(mole=="0") break;
        try{
            state begin=mole.begin();
            cout << molecule(begin) << endl;
        }catch(...){
            cout << "UNKNOWN" << endl;
        }
    }
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

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

using namespace std;

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

    int x[N], y[N];
    for(int i=0; i<N; i++){
        cin >>x[i] >> y[i];
    }

    int a[N];
    for(int i=0; i<N; i++){
        a[i] = i;
    }

    double ave = 0;
    do{
        for(int i=1; i<N; i++){
            int p = x[a[i]] - x[a[i-1]];
            p = p*p;
            int q = y[a[i]] - y[a[i-1]];
            q = q*q;
            ave += pow(p+q, 0.5);
        }
    }while(next_permutation(a, a+N));

    for(int i=1; i<=N; i++){
        ave /= (double)i;
    }

    printf("%.12lf\n", ave);

    return 0;
}

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

int checker(vector<int> a, vector<int> b){
  int k=a.size();
  int count=0;
  for(int i=0;i<k;i++){
    count+=(a.at(i)-b.at(i))*(a.at(i)-b.at(i));
  }
  for(int i=1;i<127;i++){
    if(count==i*i){
      return 1;
    }
  }
  return 0;
}
  
int main(){
  int N, D; cin >> N >> D;
  vector<vector<int>> MY(N, vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> MY.at(i).at(j);
    }
  }
  int ans=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      ans+=checker(MY.at(i), MY.at(j));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
l = input()
dp = [1, 0]
mod = 10**9+7
for i in l:
    newdp = dp[:]
    if i=='0':
        newdp[0] = dp[0]
        newdp[1] = dp[1]*3%mod
    else:
        newdp[0] = dp[0]*2%mod
        newdp[1] = (dp[0]+dp[1]*3)%mod
    dp = newdp
print(sum(dp)%mod)

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

string s;
lol k;

int main() {
    cin >> s >> k;
    
    int poi = 0;
    while (k > 1 && s[poi] == '1' && poi < s.length()) {
        k--;
        poi++;
    }

    cout << s[poi] << '\n';
    return 0;
}

Measured memory_bytes: 384
int main()
{
  int no1,no2;
  scanf("%d",&no1);
  scanf("%d",&no2);
  if (no1>no2){
    printf("a > b\n");
  }else if (no1<no2){
    printf("a < b\n");
  }else if (no1==no2){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> vv) {
    REP(i, SIZE(vv)) {
        REP(j, SIZE(vv[i])) {
            cerr << vv[i][j] << " ";
        }
        cerr << endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}
 
inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}
 
template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}
 
template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        } 
    }
    if(n != 1) ret[n]++;
    return ret;
}
 
int main(void) {
    int n, d;
    cin >> n >> d;
    cout << (n-1) / (2 * d + 1) + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

vector<ll> len;
vector<ll> np;

ll solve(ll n, ll x){
    if(n == 0){
        return (ll)(x > 0);
    }

    if(x < len.at(n - 1) + 2){
        return solve(n - 1, x - 1);
    }else{ // x < len.at(n) - 1
        return np.at(n - 1) + 1 +
            solve(n - 1, x - len.at(n - 1) - 2);
    }
}

int main(){
    ll n, x;
    cin >> n >> x;

    len.resize(n + 1, 0);
    np.resize(n + 1, 0);
    len.at(0) = 1;
    np.at(0) = 1;
    for(int i = 1; i <= n; ++i){
        len.at(i) = 2 * len.at(i - 1) + 3;
        np.at(i) = 2 * np.at(i - 1) + 1;
    }

    cout << solve(n, x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
long long max(long long a,long long b){
	if(a>b)
	return a;
	return b;
}
int main() {
long long n;
cin>>n;
long long a[n],b[n],c[n];

for(long long i=0;i<n;i++){
	cin>>a[i]>>b[i]>>c[i];
}

long long dp[n][3];

dp[0][0]=a[0];
dp[0][1]=b[0];
dp[0][2]=c[0];

for(long long i=1;i<n;i++){
			
	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
	dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
	dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	
}

long long max1=0;

for(int j=0;j<3;j++){
	max1=max(max1,dp[n-1][j]);
}
cout<<max1;
return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

struct SegTree { //0indexed
	vector<int> nod;
	int size;
	SegTree(int x) {
		size = 1;
		while (x > size) {
			size *= 2;
		}
		nod = vector<int>(size * 2 - 1, INT_MIN);
	}
	void update(int k, int a) {
		k += size - 1;
		nod[k] = a;//最下の処理
		while (k > 0) {
			k = (k - 1) / 2;
			nod[k] = max(nod[k], a); //下から上へ 
		}
	}
	int query(int a, int b, int k, int l, int r) {
		//[a,b)について
		//kは節点の番号,[l,r)はその節点がカバーする範囲
		if (r <= a || b <= l) { //[a,b)と[l,r)が重なって無いとき
			return INT_MIN;
		}
		if (a <= l && r <= b) { //[a,b)が[l,r)を完全に含んでいるとき
			return nod[k];
		}
		else {
			return max(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
		}
	}
};

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> da(n);
	rip(i, n, 0) {
		cin >> da[i];
	}
	SegTree ma(n), mi(n);
	rip(i, n, 0) {
		ma.update(i, da[i]);
		mi.update(i, -da[i]);
	}vector<bool> up(n - 1);
	rip(i, n, 1) {
		up[i - 1] = (da[i] < da[i - 1]);
	}
	int co = 0;
	rip(i, k - 1, 0) {
		if (up[i]) {
			co++;
		}
	}
	bool ju = (co==0);
	int ans = n - k + 1;
	rip(i, n, k) {
		//printf("%d %d %d %d\n",da[i], ma.query(i - k, i, 0, 0, ma.size),-da[i-k], mi.query(i - k, i, 0, 0, ma.size));
		if (up[i-1]) {
			co++;
		}
		if (up[i-k]) {
			co--;
		}
		//printf("%d\n", co);
		if ((ma.query(i - k, i, 0, 0, ma.size) < da[i] && mi.query(i - k, i, 0, 0, ma.size) == -da[i - k]) || (ju&&(co==0))) {
			ans--;
		}
		if (co == 0) {
			ju = true;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5212
function main(arg) {
	arg = arg.split("\n")[0].split(" ").map(Number)
	var a = arg[0]
	var b = arg[1]
	var k = arg[2]

	var result = []
	var max = (a > b) ? b : a

	for (var i = 0; i <= max; i++) {
		if (a % i === 0 && b % i === 0) {
			result.push(i)
		}
	}
	result = result.sort((a,b) => b - a)
	console.log(result[k - 1])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if (flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
ll ta, tb, sz = 262144;
complex<double> XX[262155], YZZ[262155], ZZ[262155];
void dft(complex<double>* x, bool inv) {
    for (ll i = sz >> 1; i >= 1; i >>= 1) {
        complex<double> bs = polar(1.0, 2.0 * acos(-1) * i / sz *
            (inv ? -1.0 : 1.0)),
            w = 1;
        for (ll j = 0; 2 * j < sz; j += i) {
            for (ll k = 0; k < i; k++) {
                ZZ[j + k] = x[2 * j + k] + w * x[2 * j + i + k];
                ZZ[j + k + (sz >> 1)] = x[2 * j + k] - w * x[2 * j + i + k];
            }
            w *= bs;
        }
        for (ll j = 0; j < sz; j++)
            x[j] = ZZ[j];
    }
    if (inv)
        for (ll i = 0; i < sz; i++)
            x[i] /= sz;
}
vl FFT(vl A, vl B) {
    for (ll i = 0; i <= n - 1; i++)
        XX[i] = A[i], YZZ[i] = B[i];
    dft(XX, false);
    dft(YZZ, false);
    for (ll i = 0; i < sz; i++)
        XX[i] *= YZZ[i];
    dft(XX, true);
    vl C;
    for (ll i = 0; i <= 2 * n; i++)
        C.push_back((ll)(XX[i].real() + 0.5));
    return C;
}

int main() {
    cin >> n >> m;
    vl A(100010,0),B;
    rep(i, n) {
        cin >> x;
        A[x]++;
    }
    n = 100010;
    B = A;
    
    vl C = FFT(A, B);
  
    a = 200000;
    while (m>0) {
        k = min(m, C[a]);
        m -= k;
        ans += a * k;
        a--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 17908
#include<bits/stdc++.h>
using namespace std;
const int MAXN=101;
long long f[MAXN],X;
int main()
{
	cin>>X;f[0]=2;
	for(int i=1;i<=X;i++)f[i]=f[i-1]*2+2;
	cout<<f[X]<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();char[] a=sc.next().toCharArray();int x=0,max=0;
		for(int i=0;i<n;i++)
		{
			x+=(a[i]=='I'?1:-1);
			max=Math.max(max,x);
		}
		out.println(max);out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 8020
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int num=0;
	string s;
	cin>>s;
	int ok=0;
	int lens=s.size();
while(lens>2&&ok!=1)
{
	int cs=0;
	for(int i=1;i<lens-1;i++)	
	{
		if(s[i-1]!=s[i+1])
		{
		s.erase(i,1);
		num++;
		lens=s.size();
		break;
		}
		else
		{
			cs++;
		}
		if(cs==lens-2)
		{
		ok=1;
		break;
		}
	}
}
		if(num%2==0)
		cout<<"Second";
		else
		cout<<"First";
		return 0;
}

Measured memory_bytes: 512
input_date_list = ['SUN','MON','TUE','WED','THU','FRI','SAT' ]
S = input()
today_date_list = ['日','月','火','水','木','金','土']
s1 = input_date_list.index(S)
today_date = (today_date_list[s1])
s2 = 7 - s1
print(s2)

Measured memory_bytes: 9040
n = int(input())
a = [int(i) for i in input().split()]
start = a[0]
for i in range(1, n):
    start = start ^ a[i]
ans = []
for i in range(n):
    ans_i = start ^ a[i]
    ans.append(str(ans_i))
print(' '.join(ans))

Measured memory_bytes: 35812
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#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 << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;
int main(){
    
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

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

#define MAX 2000

int LCSLength(char *, char *);

char X[MAX],Y[MAX];
int c[MAX][MAX];

int main(){

  int i, num, ans;

  scanf("%d", &num);

  for(i = 0; i < num; i++){

    scanf("%s %s", X, Y);

    ans = LCSLength(X,Y);

    printf("%d\n", ans);

  }
  
  return 0;

}

int LCSLength(char *X, char *Y){

  int i, j, m, n;

  m = strlen(X);

  n = strlen(Y);

  for(i = 0; i<=m; i++)
    for(j = 0; j<=n; j++)
      c[i][j]=0;

  for(i = 1; i <= m; i++){

    for(j = 1; j <= n; j++){

      if(X[i-1] == Y[j-1])
	c[i][j] = c[i - 1][j - 1] + 1;

      else if(c[i - 1][j] >= c[i][j - 1])
	c[i][j] = c[i - 1][j];

      else
	c[i][j] = c[i][j - 1];

    }

  }
  
  return c[m][n];

}

Measured memory_bytes: 8796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int H,W; cin>>H>>W;
  vector<bool>A(H+W,true);
  vector<vector<char>>B(H,vector<char>(W));
  rep(i,H){
    string S; cin>>S;
    rep(j,W){B[i][j]=S.at(j);if(S.at(j)=='#'){A[i]=false; A[H+j]=false;}}
  }
  rep(i,H){
    bool D=false;
    rep(j,W){if(!A[i]&&!A[H+j]){cout<<B[i][j]; D=true;}}
    if(D)cout<<endl;
  }
}

Measured memory_bytes: 3652
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#include <bits/stdc++.h>
using namespace std;
const int INF=10000*100000;
int main(){
    int n,k,i,j; cin>>n>>k;
    vector<int> h(n), dp(n,INF);
    for(i=0;i<n;i++) cin>>h[i];
    dp[0]=0;
    for(i=0;i<n-1;i++){
        for(j=1;j<=k&&i+j<n;j++){
            chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4044
import math
N, P = map(int, input().split())
p = P**(1/N)
ans = 1
flag=False
if N==1:
  print(P)
  exit(0)


divisors=[]

for i in range(2,round(P**(1/N))+1):
  if P%i==0:
    divisors.append(i)
for i in reversed(divisors):
    if P % (i ** N) == 0:
        ans = i
        break
print(ans)



Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from functools import reduce

def main():
    A, B = LI()
    if A == 1:
        A = 14
    if B == 1:
        B = 14
    if A > B:
        ans = 'Alice'
    elif A == B:
        ans = 'Draw'
    else:
        ans = 'Bob'
    return ans

print(main())

Measured memory_bytes: 3572
mod = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
# bitにしてor
# 一桁だけの時、111000なら3 * 3
maxl = 0
textlist = []
for i in range(N):
    tmp = str(bin(A[i]))
    tmp = tmp[2:]
    length = len(tmp)
    if maxl < length:
        maxl = length
    textlist.append(tmp)
zeros = {}
ones = {}
for i in range(maxl):
    zeros[i] = 0
    ones[i] = 0

for i in range(N):
    tmp = textlist[i]
    length = len(tmp)
    if maxl < length:
        maxl = length
    for j in range(length):
        if tmp[-j-1]== '1':
            ones[j] += 1
for i in range(maxl):
    zeros[i] = N-ones[i]

result = 0
n2 = 1
for i in range(maxl):
    result = (result + n2 * (zeros[i] * ones[i])) % mod
    n2  = (n2 * 2) % mod
print(result)

Measured memory_bytes: 156644
import sys
N = int(input())
test = lambda x: [ x[0],int(x[1]) ]
array = [ [test(input().split()),int(x+1)] for x in range(N) ]

if not ( 1 <= N <= 100 ): sys.exit()
for I in array:
    if not ( 1 <= len(I[0][0]) <= 10 ): sys.exit()
    if not I[0][0].islower(): sys.exit()
    if not ( 0 <= I[0][1] <= 100 ): sys.exit()
    if not isinstance(I[0][1],int): sys.exit()

array.sort(key=lambda x: x[0][1], reverse=True)
array.sort(key=lambda x: x[0][0])

for I in array:
    print(I[1])

Measured memory_bytes: 9024
#include<bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
const int maxn=2e5+5;
int i,j,n,p[maxn],mx,Cx,Cy,Hx,Hy,Q;
int f[maxn][2],f0,f1,tr[2][maxn<<2];
bool bz[maxn],ans[maxn];
void cmax(int &x,int y){x=max(x,y);}
void find(int o,int k,int l,int r,int x){
	if (mx>=tr[o][k]) return;
	if (l==r) {mx=tr[o][k];return;}
	int m=(l+r)>>1,lk=k<<1,rk=lk+1;
	if (x<=m) cmax(mx,tr[o][rk]),find(o,lk,l,m,x);else find(o,rk,m+1,r,x);
}
void ins(int k,int l,int r,int x){
	if (l==r) {tr[0][k]=f0,tr[1][k]=f1;return;}
	int m=(l+r)>>1,lk=k<<1,rk=lk+1;
	if (x<=m) ins(lk,l,m,x);else ins(rk,m+1,r,x);
	tr[0][k]=max(tr[0][lk],tr[0][rk]);
	tr[1][k]=max(tr[1][lk],tr[1][rk]);
}
bool check(){
	int T=Cx-Cy+Q;
	if (T>=0){
		mx=0,find(T&1,1,1,n,Hy);
		if (mx>=T) return 1;
	}
	T=Cy-Cx+Q;
	if (T>=0){
		mx=0,find(T&1,1,1,n,Hx);
		return mx>=T;
	}return 0;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&p[i]);
		cmax(mx,p[i]),Q+=(bz[i]=p[i]==mx);
	}
	fd(i,n,1){
		mx=0,find(0,1,1,n,p[i]);
		if (bz[i]) f[i][0]=mx+2;else f[i][1]=mx+1;
		mx=0,find(1,1,1,n,p[i]);
		if (bz[i]) f[i][1]=mx?mx+2:0;else f[i][0]=mx?mx+1:0;
		f0=f[i][0],f1=f[i][1];
		ins(1,1,n,p[i]);
	}
	Hx=Hy=-1,f0=f1=0;
	fo(i,1,n){
		int cx=Cx,cy=Cy,hx=Hx,hy=Hy,x=p[i];
		Q-=bz[i];
		ins(1,1,n,x);
		if (x>Hx) Hx=x,Cx++;
		if (check()) continue;
		Hx=hx,Cx=cx,ans[i]=1;
		if (x>Hy) Hy=x,Cy++;
		if (!check()) break;
	}
	if (i<=n) puts("-1");else
	fo(i,1,n) putchar(48+ans[i]);
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    vector<int> a(n,0),b(n,0);
    vector<P> p;
    vector<P> z;
    vector<P> m;
    for (int i = 0; i < n; i++) {
        int c = 0;
        for (int j = 0; j < s[i].length(); j++) {
            if(s[i][j] == '(') c++;
            else c--;
            chmin(b[i], c);
        }
        a[i] = c;
        if(c == 0) z.pb(mp(a[i], b[i]));
        else if(c > 0) p.pb(mp(b[i], a[i]));
        else m.pb(mp(b[i] - a[i], a[i]));
    }

    LL now = 0;
    sort(RALL(p));
    for (int i = 0; i < p.size(); i++) {
        if(now + p[i].fs < 0){
            puts("No");
            return 0;
        }
        else{
            now += p[i].sc;
        }
    }
    for (int i = 0; i < z.size(); i++) {
        if(now + z[i].sc < 0){
            puts("No");
            return 0;
        }
    }
    sort(ALL(m));
    for (int i = 0; i < m.size(); i++) {
        if(now + (m[i].fs + m[i].sc) < 0){
            puts("No");
            return 0;
        }
        else{
            now += m[i].sc;
        }
    }
    if(now == 0){
        puts("Yes");
    }
    else{
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 58160
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int n = s.size(), ans = n / 2;
  rep(i, n) {
    if (s[i] == 'p') ans--;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 512
n,m,x=map(int,input().split())
c=[0]*n
a=[[] for _ in range(n)]
for i in range(n):
    tem=list(map(int,input().split()))
    c[i]=tem[0]
    a[i]=tem[1:]
ans=12*10**5+1
for i in range(2**n):
    aaa=[0]*m
    money=0
    for j in range(n):
        if (i>>j)&1:
            money+=c[j]
            for k in range(m):
                aaa[k]+=a[j][k]
    if min(aaa)>=x:
        ans=min(ans,money)
if ans<12*10**5+1:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    char a, b;
    cin >> a >> b;
    if ( a == 'H' && b == 'H' || a == 'D' && b == 'D' ) cout << 'H' << endl;
    else                                                cout << 'D' << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
	int n, m;
	cin >> n >> m;

	cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  long long a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    while(a[i]%2==0){
      a[i]/=2;
      cnt++;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 384