akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        StringBuilder builder = new StringBuilder();
        StringBuilder left = new StringBuilder();
        StringBuilder right = new StringBuilder();
        
        int buf;
        while ((buf = System.in.read()) != '\n');
        
        while ((buf = System.in.read()) != '\n') {
            builder.appendCodePoint(buf);
        }
        
        String str = builder.toString();
        
        int idx;
        while ((idx = builder.indexOf("()")) != -1) {
            builder.delete(idx, idx + 2);
        }

        for (char c : builder.toString().toCharArray()) {
            if (c == ')') left.append('(');
            else right.append(')');
        }

        System.out.print(left.toString() + str + right.toString());
    }
}


Measured memory_bytes: 36636
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstring>
#include <limits>

const int nax = 3e3+5;
int dp[nax][nax];
int tp[nax][nax];

const int  UL=1;
const int  L=2;
const int  U=3;

int main() {

	std::string s, t;
	std::cin >> s >> t;

	for (int i=0; i<=s.size(); i++) {
		for (int j=0; j<=t.size(); j++) {
			if (i==0 || j==0) {
				dp[i][j] = 0;
				continue;
			}
			if (s[i-1] == t[j-1]) {
				dp[i][j] = dp[i-1][j-1]+1;
				tp[i][j] = UL;
			}
			else if (dp[i-1][j] > dp[i][j-1]) {
				dp[i][j] = dp[i-1][j];
				tp[i][j] = U;
			} else {
				dp[i][j] = dp[i][j-1];
				tp[i][j] = L;
			}
		}
	}

//	for (int i=0; i<=s.size(); i++) {
	//	for (int j=0; j<=t.size(); j++) {
		//	std::cout << dp[i][j] << " ";
	//	}
//		std::cout << "\n";
//	}

	std::string ans;

	int x = s.size(), y = t.size();

	while (x!=0 && y!=0) {
		if (tp[x][y] == UL) {
			ans.push_back(s[x-1]);
			x--; y--;
		} else if (tp[x][y] == U) {
			x--;
		} else {
			y--;
		}
	}

	std::reverse(ans.rbegin(), ans.rend());

	std::cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 70784
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    n,m,d = MI()
    if d:
        print(2*(n-d)*(m-1) / (n*n))
    else:
        print((n-d)*(m-1) / (n*n))
if __name__ == '__main__':
    main()

Measured memory_bytes: 5392
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n,t;
  cin >> n>> t;
  ll sum = 0;
  vector <ll> time;
  ll ti;
  REP(i,n){
    cin >> ti;
    time.pb(ti);
    
  }
  time.pb(ti+t);
  for(int i = 1;i < time.size();i++){

    if(time[i]-time[i-1] < t){
      sum += time[i]-time[i-1];
    }
    else
      sum+=t;

  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2420
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($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")};}

fn solve() {
    input! {
        s: chars
    }

    let ss = s
        .iter()
        .map(|n| n.to_string().parse::<i32>().unwrap())
        .collect::<Vec<i32>>();

    //println!("{:?}", ss);

    let mut remain = vec![0; s.len()];
    let last = s.len() - 1;
    let mut base = 1;
    for i in 0..last + 1 {
        let index = last - i;
        remain[index] = (ss[index] * base) % 2019;
        base = (base * 10) % 2019;
    }

    //println!("{:?}", remain);

    let mut cum_sum = vec![0; s.len() + 1];
    for i in 1..s.len() + 1 {
        cum_sum[i] = (remain[i - 1] + cum_sum[i - 1]) % 2019;
    }

    //println!("{:?}", cum_sum);

    let mut count = vec![0; 2019];
    for i in 0..s.len() + 1 {
        count[cum_sum[i] as usize] += 1;
    }

    let mut ans = 0;
    for i in 0..2019 {
        if count[i] > 1 {
            ans += (count[i] - 1) * count[i] / 2;
        }
    }

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

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 4024
A,B,C,D = map(int,input().split())

def kosuu(a, b, hoge):
    mae = a // hoge
    if a%hoge == 0:
        mae -= 1
    ato = b // hoge
    wareru = ato - mae
    return wareru

def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return int(x/gcd(x, y)*y)

c_kosuu = kosuu(A,B,C)
d_kosuu = kosuu(A,B,D)
cd_kosuu = kosuu(A,B,lcm(C,D))

# cd_kosuu

print(B-A+1-(c_kosuu+d_kosuu-cd_kosuu))

Measured memory_bytes: 38384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



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

  bool ans = true;
  rep(i, n) {
    int a;
    cin >> a;

    if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
      ans = false;
    }
  }

  if (ans) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    final static long MOD = 1000000007;
    FastScanner sc = new FastScanner();

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

    void solve(){

		int n = sc.nextInt();

        System.out.println(n * n);

    }

    long gcd(long a, long b){ // return aとbの最大公約数
        if(b == 0){
          return a;
        }
        return gcd(b, a % b);
    }

    long pow_mod(long a, long r){ // return a^r (mod MOD)
        long sum = 1;
        while(r > 0){
            if((r & 1) == 1){
                sum *= a;
                sum %= MOD;
            }
            a *= a;
            a %= MOD;
            r >>= 1;
        }
        return sum;
    }

    class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr < buflen){
                return true;
            }else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen <= 0){
                    return false;
                }
            }
            return true;
        }
        private int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;}
        private boolean isPrintableChar(int c){ return 33 <= c && c <= 126;}
        public boolean hasNext(){ while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next(){
            if(!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)){
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong(){
            if(!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if(b == '-'){
                minus = true;
                b = readByte();
            }
            if(b < '0' || '9' < b){
                throw new NumberFormatException();
            }
            while(true){
                if('0' <= b && b <= '9'){
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt(){
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble(){ return Double.parseDouble(next());}
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1e6;
int n;
vector<pair<char, int>> L(MAX / 2 + 2), R(MAX / 2 + 2);
inline void merge(vector<pair<char, int>> &a, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	rep(i, 0, n1) L[i] = a[left + i];
	rep(i, 0, n2) R[i] = a[mid + i];
	L[n1] = R[n2] = mp('Z', 1e9);
	int i = 0, j = 0;
	rep(k, left, right) {
		if(L[i].second <= R[j].second) {
			a[k] = L[i];
			++i;
		} else {
			a[k] = R[j];
			++j;
		}
	}
}
inline void mergeSort(vector<pair<char, int>> &a, int left, int right) {
	if(left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}
inline int partition(vector<pair<char, int>> &a, int p, int r) {
	int x = a[r].second;
	int i = p - 1;
	rep(j, p, r) {
		if(a[j].second <= x) {
			swap(a[++i], a[j]);
		}
	}
	swap(a[++i], a[r]);
	return i;
}
inline void quickSort(vector<pair<char, int>> &a, int p, int r) {
	if(p < r) {
		int q = partition(a, p, r);
		quickSort(a, p, q - 1);
		quickSort(a, q + 1, r);
	}
}
int main() {
	cin >> n;
	vector<pair<char, int>> v, mv; v.reserve(100001);
	char s;
	int x;
	rep(i, 0, n) {
		cin >> s >> x;
		v.eb(mp(s, x));
	}
	mv.assign(all(v));
	quickSort(v, 0, n - 1);
	mergeSort(mv, 0, n);
	P(v == mv ? "Stable" : "Not stable");
	for(auto i : v) {
		cout << i.first << ' ' << i.second << endl;
	}
	return 0;
}

Measured memory_bytes: 12240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
#include <atcoder/all>
using namespace atcoder;

int main() {
    int N, M;
    cin >> N >> M;
    dsu uf(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.merge(a, b);
    }
    vector<vector<int>> g = uf.groups();
    int ans = sz(g) - 1;
    cout << ans << '\n';
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 8924
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
	string a;
	while(cin>>a){
	int joi=0,ioi=0;
	for(int i=0;i<a.size()-2;i++){
		if(a[i]=='J'&&a[i+1]=='O'&&a[i+2]=='I')
			joi++;
		if(a[i]=='I'&&a[i+1]=='O'&&a[i+2]=='I')
			ioi++;
	}
	cout<<joi<<endl;
	cout<<ioi<<endl;
	}
	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

// https://qiita.com/drken/items/cce6fc5c579051e64fab
// UnionFind<int> uf(n);
template <class Abel>
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n);
        rank.resize(n);
        size.resize(n);
        diff_weight.resize(n);
        for (int i = 0; i < n; ++i)
            par[i] = i, rank[i] = 0, size[i] = 1, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]]; // path compression
            return par[x] = r;
        }
    }
    // returns size of connected-tree number
    int get_size(int x) {
        return size[root(x)];
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool is_same(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        size[x] = size[y] = size[x] + size[y];
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind<int> uf(n);
    int ans = n;
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        if (!uf.is_same(x, y)) {
            uf.merge(x, y, 0);
            ans--;
        }
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define max(lhs,rhs) ((lhs)>(rhs)?(lhs):(rhs))

int main(void){
    long long a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    printf("%lld",max(a*c,max(a*d,max(b*c,b*d))));
}

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

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> dp(100001);
    vector<vector<int>> p(d, vector<int>(n));
    for(int i=0; i<d; ++i) {
        for(int j=0; j<n; ++j) {
            cin >> p[i][j];
        }
    }
    int W = x;
    for(int i=0; i<d-1; ++i) {
        fill(dp.begin(), dp.end(), W);
        for(int j=0; j<n; ++j) {
            for(int k=p[i][j]; k<=W; ++k) {
                dp[k] = max(dp[k], dp[k-p[i][j]] - p[i][j] + p[i+1][j]);
            }
        }
        W = dp[W];
    }
    cout << W << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
using ii=long long;

const ii mod = 1e9 + 7;

ii dp[100100][13];

const int ind[6] = {10, 9, 12, 3, 4, 1};

int main()
{
    string s;
    cin >> s;
    reverse(all(s));
    int n = s.size();
    if (s[0] == '?') {
        for (int j = 0; j <= 9; ++j) {
            dp[0][j] = 1;
        }
    }
    else {
        dp[0][s[0] - '0'] = 1;
    }
    for (int i = 1; i < n; ++i) {
        int z = ind[(i - 1) % 6];
        if (s[i] == '?') {
            for (int j = 0; j <= 9; ++j) {
                for (int h = 0; h < 13; ++h) {
                    (dp[i][(z * j + h) % 13] += dp[i - 1][h]) %= mod;
                }
            }
        }
        else {
            int c = s[i] - '0';
            (c *= z) %= 13;
            for (int j = 0; j < 13; ++j) {
                dp[i][(c + j) % 13] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n - 1][5] << "\n";
}


Measured memory_bytes: 10624
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

N=int(input())
A=list(map(int,input().split()))
d1,d2=[],[]
g1,g2=A[0],A[-1]
d1.append(g1)
d2.append(g2)
for n in range(1,N-1):
    g1=gcd(g1,A[n])
    g2=gcd(g2,A[-1-n])
    d1.append(g1)
    d2.append(g2)
dmax=max(d1[N-2],d2[N-2])
for n in range(N-2):
    d=gcd(d1[n],d2[N-3-n])
    if d>dmax:
        dmax=d
print(dmax)



Measured memory_bytes: 14436
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    ll res = 1;
    rep(i, a.size())res+=i;

    ll dic[26] = {};
    rep(i, a.size())dic[a[i]-'a']++;

    rep(i, 26)res-=max((ll)0, dic[i]*(dic[i]-1)/2);
    cout  << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {

  vector<int> A(3);
  REP(i,3) cin>>A[i];
  SORT(A);
  REVERSE(A);
  cout<<A[0]*10+A[1]+A[2]<<endl;
}


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

using namespace std;

int h, w;
int cm[10][10];

int main() {
	scanf("%d %d", &h, &w);
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			scanf("%d", &cm[i][j]);
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				cm[i][j] = min(cm[i][j], cm[i][k] + cm[k][j]);
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int v;
			scanf("%d", &v);
			if (v != -1) {
				sum += cm[v][1];
			}
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{

    int S, h, m, s;

    scanf("%d", &S);

    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;

    printf("%d:%d:%d\n",h , m, s);

    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n, k;
	cin >> n >> k;
	vector<int> p(n, 0);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	sort(p.begin(), p.end());
	int sum = 0;
	for (int i = 0; i < k; i++)
		sum += p[i];
	cout << sum << endl;
}


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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 305;

char s[N][N];
int n, ans;

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  for (int k = 0; k < n; ++k) {
    bool f = true;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (s[(i + k) % n][j] != s[(j + k) % n][i]) {
          f = false;
          break;
        }
      }
    }
    if (f) {
      ans += n;
    }
  }
  printf("%d\n", ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 384
// Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int t_min1 = 60*60*4;
		int t_min2 = 60*60*4;
		int c_min1 = 0;
		int c_min2 = 0;

		int t_max1 = -1;
		int t_max2 = -1;
		int c_max1 = 0;
		int c_max2 = 0;

		for(int i=0; i<n; i++){
			int c1, m1, s1, m2, s2, m3, s3, m4, s4;
			cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;

			int t = (m1+m2+m3+m4)*60+s1+s2+s3+s4;

			if(t<t_min1){
				t_min2 = t_min1;
				t_min1 = t;
				c_min2 = c_min1;
				c_min1 = c1;
			}
			else if(t<t_min2){
				t_min2 = t;
				c_min2 = c1;
			}

			if(t>t_max1){
				t_max2 = t_max1;
				t_max1 = t;
				c_max2 = c_max1;
				c_max1 = c1;
			}
			else if(t>t_max2){
				t_max2 = t;
				c_max2 = c1;
			}
		}

		cout << c_min1 << endl;
		cout << c_min2 << endl;
		cout << c_max2 << endl;
	}

	return 0;
}

Measured memory_bytes: 868
import numpy as np
from sys import stdin
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
res = np.cumsum(data)
res=np.insert(res,0,0)
cnt=1
ans=0
tmp=float("inf")
ite=np.append(sorted(res),float("inf"))
for j in ite:
    if j == tmp:
        cnt+=1
    else:
        ans=ans+((cnt*(cnt-1))/2)
        cnt=1
    tmp=j
print(int(ans))

Measured memory_bytes: 34560
#include <iostream>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

int pow(int a, int b) {
  int res = a;
  REP(i, b-1) {
    res = res*a;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  int res = 0;

  for (int n=3; n<10; ++n) {
    int count = 0;
    while (count < pow(3, n)) {
      int tmp = count;
      int val = 0;
      bool b3 = false, b5 = false, b7 = false;
      REP(i, n) {
        val *= 10;
        int p = tmp % 3;
        if (p == 0) {
          val += 3;
          b3  = true;
        } else if (p == 1) {
          val += 5;
          b5 = true;
        } else {
          val += 7;
          b7 = true;
        }
        tmp /= 3;
      }

      if (val <= N && b3 && b5 && b7) {
        res++;
      }


      count++;
    }
  }

  cout << res << endl;

  return 0;
}

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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int N, T, A;
	cin >> N >> T >> A;

	int ans = 0;
	double minval = (double)100000;
	for (int i = 0; i < N; ++i) {
		int H;
		cin >> H;

		double tmp = (double)T - H * 0.006;
		double dist = abs(A - tmp);
		if (dist < minval) {
			ans = i;
			minval = dist;
		}
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 3544
N, C = list(map(int, input().split()))
tmax = 0
s = [0 for _ in range(N)]
t = [0 for _ in range(N)]
c = [0 for _ in range(N)]
for i in range(N):
    s[i], t[i], c[i] = list(map(int, input().split()))

tmax = max(t)
c_timeline = [[0]*C for _ in range(2 * tmax + 1)]
for i in range(N):
    S = s[i]
    T = t[i]
    channel = c[i] - 1
    for j in range(2 * S - 1, 2 * T + 1):
        c_timeline[j][channel] = 1

rokuga = 0
for timeline in c_timeline:
    time = sum(timeline)
    if rokuga < time:
        rokuga = time

print(rokuga)


Measured memory_bytes: 76036
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
vector<int>ve[N];
int c[N];
int num[N];
int cnt,ans;
void dfs(int u,int f){
    for(int i=0;i<ve[u].size();i++){
        int v=ve[u][i];
        if(v!=f){
            num[v]=c[cnt--];
            dfs(v,u);
        }
    }
}
int main(){
    int n;
    scanf("%d",&n);
    int u,v;
    for(int i=1;i<n;i++){
        scanf("%d %d",&u,&v);
        ve[u].push_back(v);
        ve[v].push_back(u);
    }
    for(int i=0;i<n;i++) scanf("%d",&c[i]);
    sort(c,c+n);
    num[1]=c[n-1];
    cnt=n-2;
    ans=0;
    dfs(1,0);
    for(int i=0;i<n-1;i++) ans+=c[i];
    printf("%d\n",ans);
    printf("%d",num[1]);
    for(int i=2;i<=n;i++) printf(" %d",num[i]);
}


Measured memory_bytes: 1408
#include <iostream>

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

using namespace std;

int main () {

    int input = 0;
    cin >> input;

    while(input > 0) {
        if (input % 10 == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        input = input / 10;
    }
	cout << "No" << endl;
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s;
  cin >> s;

  int ans = 0;
  int now = 0;
  rep(i, s.size()) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      now++;
    } else {
      now = 0;
    }
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}


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

#define N 100005

int a[N], b[N], id[N], n;
int c[N], d[N], deg[N];

vector <int> v[N];

bool cmp(int x, int y) {return c[x] < c[y];}

queue <int> Q;

int main() {
	scanf("%d", &n);
    for (int i = 1; i < n; i ++) {
		scanf("%d %d", &a[i], &b[i]);
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    for (int i = 1; i <= n; i ++) deg[i] = v[i].size();
    for (int i = 1; i <= n; i ++) scanf("%d", &c[i]), id[i] = i;
    sort(id+1, id+n+1, cmp);
    for (int i = 1; i <= n; i ++) if (deg[i] == 1) Q.push(i);
    int cs = 0;
    while (!Q.empty()) {
        int x = Q.front(); Q.pop();
		cs ++;
        d[x] = c[id[cs]];
        for (auto y : v[x]) {
			deg[y] --;
			if (deg[y] == 1) Q.push(y);
        }
    }
    int ans = 0;
    for (int i = 1; i < n; i ++) {
		ans += min(d[a[i]], d[b[i]]);
    }
    printf("%d\n", ans);
    for (int i = 1; i <= n; i ++) printf("%d%c", d[i], " \n"[i==n]);
	return 0;
}


Measured memory_bytes: 4864
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$sumr=array_sum($a);
$suml=0;
$i=0;
while($i<$n){
  $suml+=$a[$i];
  $sumr-=$a[$i];
  $d[$i]=abs($sumr-$suml);
  ++$i;
}
echo min($d);

Measured memory_bytes: 31284
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  string s;
  cin >> s;
  char a,b;
  a = s.at(0);
  if (a == s.at(1)){
    if (s.at(2) != a && s.at(2) == s.at(3)){
      cout << "Yes" << endl;
      return 0;
    }
  }else{
    b = s.at(1);
    if ( s.at(2) == a){
      if (s.at(3) == b){
        cout << "Yes" << endl;
        return 0;
      }
    }else if ( s.at(2) == b){
      if (s.at(3) == a){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
import collections


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    counters = collections.Counter(A)
    ans = 0
    for _, c in counters.items():
        ans += c*(c-1)//2

    for K in range(N):
        if A[K] in counters:
            c = counters[A[K]]
            if counters[A[K]] > 2:
                print(ans - (c*(c-1)//2) + ((c-1)*(c-2)//2))
            else:
                print(ans - (c*(c-1)//2))
        else:
            print(ans)


# Solve
if __name__ == "__main__":
    solve()


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

int ab(int a){
	if(a>=0) return a;
	return -a;
}

int main(){
	int n,nt=0,x=0,y=0,t,a,b; cin>>n;
	for(int i=0;i<n;i++){
		cin>>t>>a>>b;
		if(ab(a-x)+ab(b-y)>t-nt) { cout<<"No"<<endl; return 0; }
		if((ab(a-x)+ab(b-y))%2!=(t-nt)%2) { cout<<"No"<<endl; return 0; }
		x=a,y=b,nt=t;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nx: Vec<usize> = read_vec();
    let n = nx[0];
    let x = nx[1];
    if x == 1 || x == 2 * n - 1 {
        println!("No");
        return;
    }
    let mut ans: Vec<usize> = vec![0; 2 * n - 1];
    if n == 2 {
        ans[0] = 1;
        ans[1] = 2;
        ans[2] = 3;
    } else {
        if x == 2 * n - 2 {
            ans[n - 2] = 1;
            ans[n - 1] = 2 * n - 1;
            ans[n] = x;
            ans[n + 1] = 2;
            let mut tmp = 1;
            for i in 0..2 * n - 1 {
                if n - 2 <= i && i <= n + 1 {
                    continue;
                }
                while vec![1, 2, x, 2 * n - 1].contains(&tmp) {
                    tmp += 1;
                }
                ans[i] = tmp;
                tmp += 1;
            }
        } else {
            ans[n - 2] = 2 * n - 1;
            ans[n - 1] = 1;
            ans[n] = x;
            ans[n + 1] = 2 * n - 2;
            let mut tmp = 1;
            for i in 0..2 * n - 1 {
                if n - 2 <= i && i <= n + 1 {
                    continue;
                }
                while vec![1, x, 2 * n - 2, 2 * n - 1].contains(&tmp) {
                    tmp += 1;
                }
                ans[i] = tmp;
                tmp += 1;
            }
        }
    }

    println!("Yes");
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 7676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N == 1) {
			System.out.println(1);
		} else if(N >= 2 && N <= 3) {
			System.out.println(2);
		} else if(N >= 4 && N <= 7) {
			System.out.println(4);
		} else if(N >= 8 && N <= 15) {
			System.out.println(8);
		} else if(N >= 16 && N <= 31) {
			System.out.println(16);
		} else if(N >= 32 && N <= 63) {
			System.out.println(32);
		} else {
			System.out.println(64);
		}
	}
}


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

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

    int n, t;
    cin >> n;
    vector<long long> X(n), Y(n), H(n);
    for(int i = 0; i < n; i++){
        cin >> X[i] >> Y[i] >> H[i];
        if(H[i] > 0) t = i;
    }

    for(long long cx = 0; cx <= 100; cx++){
        for(long long cy = 0; cy <= 100; cy++){
            long long hoge;
            bool f = true;
            hoge = H[t] + abs(X[t] - cx) + abs(Y[t] - cy);
            for(int i = 0; i < n; i++){
                if(H[i] == max(hoge - abs(X[i] - cx) - abs(Y[i] - cy), 0LL));
                else {f = false; break;}
            }
            if(f){
                cout << cx << ' ' << cy << ' ' << hoge << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

int main(){

        int a,b,c;

        cin >> a;
        cin >> b;
        cin >> c;

        if((a < b) && (b < c)){

                cout << "Yes" << endl;

        }

        else{
                cout << "No" << endl;

        }

        return 0;

}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,x=0,y,i,j,k;
	scanf("%lld",&n);
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			y = __gcd(i, j);
			for (k = 1; k <= n; k++)
			{
				x += __gcd(y, k);
			}
		}
	}
	printf("%lld\n", x);
}

Measured memory_bytes: 3824
#include <iostream>
using namespace std;
typedef long long ll;
ll mod=998244353;

ll fac[3000010];
 
ll modinv(ll a){
    ll b=mod,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
        }
        u%=mod;
        if(u<0) u+=mod;
    return u;
}
 
void modfac(){
    fac[0]=1;
    for(ll i=1;i<3000010;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
}
 
ll modperm(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return (fac[n]*modinv(fac[n-k]))%mod;
}
 
ll modcomb(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}

ll modhom(ll n,ll k){
  if(n==0&&k==0) return 1;
  else if(n<0||k<0) return 0;
  else return modcomb(n+k-1,k);
}
 
ll modpow(ll a,ll b){
  ll ans=1;
  a%=mod;
  while(b){
    if(b&1) ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}

int main(){
  modfac();
  ll n,m;
  cin >> n >> m;
  ll ans=modhom(n,3*m);
  for(ll i=0;i<m;i++){
    ans=(ans-n*modhom(n-1,i)%mod+mod)%mod;
  }
  for(ll i=m+1;i<=n;i++){
    if((3*m-i)%2==0){
      ans=(ans-modcomb(n,i)*modhom(n,(3*m-i)/2)%mod+mod)%mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 23808
N=int(input())
l=[]
for i in range(N):
  l.append(str(input()))


a=l.count("AC")
w=l.count("WA")
t=l.count("TLE")
r=l.count("RE")

print("AC x {}\nWA x {}\nTLE x {}\nRE x {}".format(a,w,t,r))

Measured memory_bytes: 16140
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll dp[3300][3300];

int main(){cout<<fixed<<setprecision(10);
		   string s,t;
           cin>>s>>t;
           int n=s.size(),m=t.size();
           rep(i,1,n+1){
            rep(j,1,m+1){
             chmax(dp[i][j],dp[i-1][j]);
             chmax(dp[i][j],dp[i][j-1]);
             if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1; 
            }
           }
           //cout<<dp[n][m]<<endl;
           string ans="";
           while(n>=1&&m>=1){
               if(dp[n][m]==dp[n][m-1])m--;
             else if(dp[n][m]==dp[n-1][m])n--;
             else {
              n--;m--;
               ans=s[n]+ans;
             }
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 80992
# include <iostream>
using namespace std;
int N, K, h[100010];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> h[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++) if (h[i] >= K) ans++;
  cout << ans << endl;
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> p(N),mini(N);
  for(int i=0;i<N;i++) cin >> p[i];
  
  int i,count=0;
  int mi = p[0];
  for(i=0;i<N;i++){
    if(mi < p[i]) {
      count++;
      continue;
    }
    else{
      mi = p[i];
    }
  }
  
  cout << N - count << endl;
}

Measured memory_bytes: 1792
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))

#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl A, B;

void solve(void) {
  set<sl> S;
  S.insert(1);
  S.insert(2);
  S.insert(3);
  S.erase(A);
  S.erase(B);
  cout << *S.begin() << endl;
}

int main(void) {
  cin >> A;
  cin >> B;
  solve();
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    println!("{}", if a * b % 2 == 0 { "Even" } else { "Odd" });
}

Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
    }
    int M;
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++) {
        cin >> t.at(i);
    }
    
    map<string, int> wordcnt;
    for (int i = 0; i < N; i++) {
        wordcnt[s.at(i)]++;
    }
    for (int i = 0; i < M; i++) {
        wordcnt[t.at(i)]--;
    }
    int ans = 0;
    for (auto iter = wordcnt.begin(); iter != wordcnt.end(); iter++) {
        ans = max(ans, iter->second);
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>s;
    int i=0;
    int j=s.size()-1;
    int ans=0;
    while(j-i>=0){
        if(s[i]!=s[j])
        ans++;
        i++;
        j--;
    }
    cout<<ans<<"\n";
}



Measured memory_bytes: 256
n = int(input())
s_list = [input() for _ in range(n)]

ac = 0
wa = 0
tle = 0
re = 0

for s in s_list:
    if s == 'AC':
        ac+=1
        
    elif s == 'WA':
        wa+=1
        
    elif s == 'TLE':
        tle+=1
    
    else:
        re+=1
        
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Measured memory_bytes: 16324
#include <iostream>
using namespace std;
int main()
{
    int n,a,b;
    int sum=0;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        int x=i%10;
        int y=((i-x)%100)/10;
        int z=((i-y*10-x)%1000)/100;
        int w=((i-z*100-y*10-x)%10000)/1000;
        int u=((i-w*1000-z*100-y*10-x)%100000)/10000;
        int t=x+y+z+w+u;
        if(a<=t&&t<=b)sum+=i;
    }
    cout<<sum<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
int main(void)
{
	int A, B;
	scanf("%d%d", &A, &B);
	if (A - 2 * B < 0) {
		printf("0");
		return 0;
	}
	printf("%d", A - 2 * B);
	return 0;

}


Measured memory_bytes: 256
from sys import stdin


n = int(stdin.readline().rstrip())
a = [stdin.readline().rstrip().split() for _ in range(n)]

#b=[0]*n



for i in range(n):
    a[i].append(i+1)
    a[i][1]=int(a[i][1])

#b=sorted(a,reverse=True ,key=lambda x: x[1])

#print(b)

#b.sort()
a.sort()

for i in range(n):
    for j in range(n-1):
        if(a[j][0]==a[j+1][0] and a[j][1]<a[j+1][1]):
            k=a[j]
            a[j]=a[j+1]
            a[j+1]=k


'''for i in range(n):
    print(b[i][2])'''

for i in range(n):
    print(a[i][2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define maxn 100003
using namespace std;
struct edge{int to,next;}e[maxn<<1];
int head[maxn],cnte,fa[maxn];
void add(int u,int v){e[++cnte].to=v,e[cnte].next=head[u],head[u]=cnte;}
int n,sz[maxn],s[maxn];
long long d[maxn],sum;
map<long long,int> b;
bool cmp(int x,int y){return d[x]<d[y];}
void dfs(int u,int depth){
	sum+=depth;
	for(int i=head[u];i;i=e[i].next){
		int v=e[i].to;
		if(v==fa[u])continue;
		dfs(v,depth+1);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",d+i),s[i]=i,b[d[i]]=i,sz[i]=1;
	sort(s+1,s+n+1,cmp);
	for(int i=n;i>=2;i--){
		int v=s[i];
		long long d_u=d[v]-(n-sz[v])+sz[v];
		if(d_u>=d[v]||!b.count(d_u)){puts("-1");return 0;}
		int u=b[d_u];
		add(u,v),add(v,u),fa[v]=u;
		sz[u]+=sz[v];
	}
	if(cnte!=(n-1)*2){puts("-1");return 0;}
	dfs(s[1],0);
	if(sum!=d[s[1]]){puts("-1");return 0;}
	for(int u=1;u<=n;u++){
		for(int i=head[u];i;i=e[i].next){
			int v=e[i].to;
			if(v==fa[u])continue;
			printf("%d %d\n",u,v);
		}
	}
	return 0;
}

Measured memory_bytes: 13056