akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    double inf = 1e9;
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    vector<char> d(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> d[i];
    double xfmax = -inf, xfmin = inf;
    double yfmax = -inf, yfmin = inf;
    double xrmax = -inf, xrmin = inf;
    double xlmax = -inf, xlmin = inf;
    double yumax = -inf, yumin = inf;
    double ydmax = -inf, ydmin = inf;
    for (int i = 0; i < N; i++) {
        if (d[i] == 'R' || d[i] == 'L') {
            yfmax = max(yfmax, y[i]);
            yfmin = min(yfmin, y[i]);
        }
        if (d[i] == 'U' || d[i] == 'D') {
            xfmax = max(xfmax, x[i]);
            xfmin = min(xfmin, x[i]);
        }
        if (d[i] == 'R') {
            xrmax = max(xrmax, x[i]);
            xrmin = min(xrmin, x[i]);
        }
        if (d[i] == 'L') {
            xlmax = max(xlmax, x[i]);
            xlmin = min(xlmin, x[i]);
        }
        if (d[i] == 'U') {
            yumax = max(yumax, y[i]);
            yumin = min(yumin, y[i]);
        }
        if (d[i] == 'D') {
            ydmax = max(ydmax, y[i]);
            ydmin = min(ydmin, y[i]);
        }
    }
    vector<double> cand;
    cand.push_back(0);
    
    cand.push_back(ydmin - yfmax);
    cand.push_back(ydmin - yfmin);
    cand.push_back(ydmax - yfmax);
    cand.push_back(ydmax - yfmin);
    cand.push_back(yfmax - yumax);
    cand.push_back(yfmin - yumax);
    cand.push_back(yfmax - yumin);
    cand.push_back(yfmin - yumin);
    
    cand.push_back(xlmin - xfmax);
    cand.push_back(xlmin - xfmin);
    cand.push_back(xlmax - xfmax);
    cand.push_back(xlmax - xfmin);
    cand.push_back(xfmax - xrmax);
    cand.push_back(xfmin - xrmax);
    cand.push_back(xfmax - xrmin);
    cand.push_back(xfmin - xrmin);
    
    cand.push_back((xlmax - xrmax)/2);
    cand.push_back((xlmin - xrmax)/2);
    cand.push_back((xlmax - xrmin)/2);
    cand.push_back((xlmin - xrmin)/2);
    cand.push_back((ydmax - yumax)/2);
    cand.push_back((ydmin - yumax)/2);
    cand.push_back((ydmax - yumin)/2);
    cand.push_back((ydmin - yumin)/2);
    
    double ans = 1e18;
    for (double t : cand) {
        if (t < 0) continue;
        double ymax = max(yfmax, max(yumax + t, ydmax - t));
        double ymin = min(yfmin, min(yumin + t, ydmin - t));
        double xmax = max(xfmax, max(xrmax + t, xlmax - t));
        double xmin = min(xfmin, min(xrmin + t, xlmin - t));
        ans = min(ans, (ymax-ymin)*(xmax-xmin));
    }
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 1920
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    ll N, M; cin >> N >> M;
    
    ll ans = 0;

    if (N==1 && M==1) {
        ans = 1;
    } else if (N==1) { // M>1
        ans = M - 2;
    } else if (M==1) { // N>1
        ans = N - 2;
    } else {
        ans = (N - 2)*(M - 2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define REP(i, n) for(i = 0; i < n; i++)
#define FOR(i, a, b) for(i = a; i < b; i++)
#define N 100000
#define sqN 397  //floor(sqrt(N)) + 1

void is_prime(char num[N + 1]);

int main(){
    char num[N + 1]; //iが素数かどうか
    int like[N + 1];//num[i]にはi以下の条件を満たす素数の個数.
    int i;

    REP(i, N + 1){
        if((i % 2 == 0 && i > 2) || (i % 3 == 0 && i > 3)){
            num[i] = 0;
        }else{
            num[i] = 1;
        }
    }
    num[0] = 0;
    num[1] = 0;

    is_prime(num);
    int n = 0;

    FOR(i, 0, N + 1){
        if(i % 2 && num[i] == 1 && num[(i + 1) / 2] == 1){
            n++;
        }
        like[i] = n;
    }
    int Q, l, r;
    int a, b;

    scanf("%d", &Q);

    REP(a, Q){
        scanf("%d %d", &l, &r);
        printf("%d\n", like[r] - like[l - 1]);
    }

    return 0;
}

void is_prime(char num[N + 1]){
    int x, k;

    FOR(x, 4, sqN + 1){
        if(num[x] == 1){
            FOR(k, 2, N / x + 1){
                if(k * x < N + 1) num[k * x] = 0;
            }
        }
    }
}

/*
ある範囲のの間の個数 -> 1番目からn番目までの個数を記録しておいて引く！
*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    string s; cin>>s;
    int mx=0, k=0;
    for(auto& a:s)
    	if(a=='R') k++;
    	else {
    		mx=max(mx,k); k=0;
    	}
    mx=max(mx,k);
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n;
llint x[200005], y[200005];
llint xinv[200005];
llint h[200005];
UnionFind uf(200005);
map<llint, llint> mp;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	for(int i = 1; i <= n; i++) xinv[x[i]] = i;
	for(int i = 1; i <= n; i++) h[i] = y[xinv[i]];
	
	set<llint> S;
	for(int i = 1; i <= n; i++){
		if(S.size() == 0 || *S.begin() > h[i]){
			S.insert(h[i]);
			continue;
		}
		auto it = S.lower_bound(h[i]); it--;
		for(;;){
			uf.unite(h[i], *it);
			if(it == S.begin()) break;
			auto tmp = it;
			it--;
			S.erase(tmp);
		}
	}
	for(int i = 1; i <= n; i++) mp[uf.root(i)]++;
	
	for(int i = 1; i <= n; i++) cout << mp[uf.root(y[i])] << endl;
	
	return 0;
}

Measured memory_bytes: 13976
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(args){
    var input = args.split("\n");
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);
    var C = parseInt(input[2], 10);
    var X = parseInt(input[3], 10);
    var count = 0;

    for(var i=0; i<=A; i++){
        for(var j=0; j<=B; j++){
            for(var k=0; k<=C; k++){
                (500*i + 100*j + 50*k) == X ? count++ : '';
            }
        }
    }

    console.log( count );
}

Measured memory_bytes: 7372
D = int(input())
c = [int(_) for _ in input().split()]
s = [[int(_) for _ in input().split()] for _ in range(D)]


for d in range(D):
    v = -20000
    j = 0
    for x in range(26):
        if v < s[d][x]:
            j = x
            v = s[d][x]
    print(j+1)


Measured memory_bytes: 9428
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 998244353
#define double long double
#define INF LLONG_MAX/1000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[100010], cnt, ans;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		cnt ^= a[i];
	}
	for (int i = 40; i >= 0; i--) {
		if ((cnt >> i) & 1) {
			rep(j, n) {
				if (((a[j] - 1) ^ a[j]) == (1 << (i + 1)) - 1) {
					ans++;
					cnt ^= (a[j] - 1) ^ a[j];
					break;
				}
			}
		}
	}
	if (!cnt)cout << ans << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int read = rint();
        WriteLine(read*read*3);
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){
        long temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long GCD(long a,long b){
        if(a < b){
            long temp = a;
            a = b;
            b = temp;
        }
        if(a % b == 0){ return b; }
        else{
            long temp = b;
            b = a%b;
            a = temp;
            return GCD(a,b);
        }
    }
    static long LCM(long a,long b){
        return a * b / GCD(a,b);
    }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 11092
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 24;

int a, b, c;

int main() {
    scanf("%d %d", &a, &b);
    
    for ( int i = 0; i < 2; i++ ) {
        if ( a < b ) {
            c += b;
            b--;
        } else {
            c += a;
            a--;
        }
    }

    printf("%d\n", c);
    return 0;
}



Measured memory_bytes: 256
class RollerCoaster:
  def __init__(self):
    self.n, self.k = list(map(int,input().split(' ')))
    self.h = list(map(int,input().split(' ')))
    self.count = 0
  def solve(self):
    for i in self.h:
      if i >= self.k:
        self.count += 1
    print(self.count) 
    
                    
solver =  RollerCoaster()
solver.solve()



Measured memory_bytes: 12284
r,c = map(int,input().split())
a =[]

for i in range(r) :
  a.append(list(map(int,input().split())))
  a[i].append(sum(a[i]))

b = list(map(sum,zip(*a)))

for i in range(r) :
  print(*a[i])
print(*b)


Measured memory_bytes: 6228
from collections import defaultdict as dd
from heapq import heappop, heappush

N, K = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(N)]
l.sort(key=lambda x:-x[1])
used = set()
q2, q3 = [], []

score, kind = 0, 0

for t, d in l[:K]:
    score += d
    if t in used:
        heappush(q3, d)
    else:
        used.add(t)
        kind += 1

ans = score + kind*kind

q1 = dd(list)
for t, d in l[K:]:
    if not t in used:
        heappush(q1[t], -d)
for t in q1.keys():
    d = heappop(q1[t])
    heappush(q2, d)

while q2 and q3:
    d1 = heappop(q2)
    d1 = -d1

    d2 = heappop(q3)
    score -= d2
    score += d1
    kind += 1
    ans = max(ans, score + kind*kind)

print(ans)

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

int main(){
	std::ios::sync_with_stdio(false);
	lld t=1;
	//cin>>t;
	
	while(t--){
		lld a,b,c,x;
		cin>>a>>b>>c>>x;
		lld ans=0;
		x=x/50;
		for(lld i=0;i<=a;i++){
			for(lld j=0;j<=b;j++){
				for(lld k=0;k<=c;k++){
					lld v=10*i+2*j+k;
					
					if(v==x){
						ans++;
					}
				}
				
			}
			
		}
		cout<<ans<<"\n";
		
	}
	
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int D = 13;
const int MOD = 1e9+7;

signed main(){

  string s; cin >> s;

  static int dp[100001][13];
  dp[0][0] = 1;

  for(int pos = 0; pos < s.size(); pos++){
    for(int sum = 0; sum < D; sum++){
      if(!dp[pos][sum]) continue;
      if(s[pos] != '?'){
        (dp[pos + 1][(sum*10 + (int)(s[pos] - '0')) % D] += dp[pos][sum]) %= MOD;
      }
      else {
        for(int d = 0; d < 10; d++){
          (dp[pos + 1][(sum*10 + d) % D] += dp[pos][sum]) %= MOD;
        }
      }
    }

    // for(int j = 0; j < 13; j++){
    //   cout << dp[pos+1][j] << " ";
    // }
    // cout << endl;
  }
  cout << (dp[s.size()][5]) % MOD << endl;

  return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;


// Z-Algorithm; 最長共通接頭辞
// ：文字列sとs[i, s|s|]の最長共通接頭辞の長さを返す。[O(|s|)]
vector<long long> z_algorithm(const string &s){
    vector<long long> prefix(s.size());
    for(long long i=1, j=0; i<(long long)s.size(); i++){
        if(i+prefix[i-j] < j+prefix[j]) prefix[i] = prefix[i-j];
        else{
            long long k = max(0LL, j+prefix[j]-i);
            while(i+k < (long long)s.size() && s[k] == s[i+k]) k++;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (long long)s.size();
    return prefix;
}

int main(){
    Init();
    ll n, ans = 0; string s; cin >> n >> s;

    // 開始文字をi文字目とした部分文字列で最長共通接頭辞を求める
    for(ll i=0; i<n-1; i++){
        string tmp = s.substr(i);
        // z-algorithm
        auto lcp = z_algorithm(tmp);
        // 重なりが生じないように最長共通部分列を求める
        for(ll j=0; j<lcp.size(); j++) chmax(ans, min(lcp[j], j));
    }
    cout << ans << endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a >= 13){
    cout << b << endl;
  }else if(a >= 6 && a <=12){
    cout << b/2 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.abs;
public class Main{
public static void main(String... args){
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int a=sc.nextInt();
int b=sc.nextInt();
if(abs(a-x)<abs(b-x)){
System.out.println("A");
}else{
System.out.println("B");
}
}
}

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

#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << #x " = " << (x) << '\n'
#define DBG         cerr << "Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

struct edgeData{
    int u, v, c;
};
bool operator < (edgeData a, edgeData b)
{
    return a.c < b.c;
}
vector<edgeData>V;
int A[310][310];
int main()
{
//    freopen("in.txt","r",stdin);
    int n;
    sf(n);
    LL sum = 0;
    for(int i = 1; i<=n; i++)
    {
        for(int j = 1; j<=n; j++)
        {
            sf(A[i][j]);
            if(i < j)
                sum += A[i][j], V.pb({i,j,A[i][j]});;
        }
    }
    sort(all(V));
    bool ok = true;
    for(auto e: V)
    {
        int u = e.u, v = e.v, c = e.c;
        bool need = true;
        for(int k = 1; k<=n; k++)
        {
            if(k == u || k == v)
                continue;
            if(A[u][k] + A[k][v] == c)
                need = false;
            else if(A[u][k] + A[k][v] < c)
            {
                ok = false;
                break;
            }
        }
        if(!ok)
            break;
        if(need == false)
            sum -= c;
    }
    if(!ok)
        puts("-1");
    else
        printf("%lld\n",sum);
    return 0;
}




Measured memory_bytes: 1276
#include <iostream>

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = (a + d - 1) / d;
	int y = (c + b - 1) / b;
	cout << (x >= y ? "Yes" : "No") << '\n';
	
	return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		int k,x;
		cin>>k>>x;
		if(k*500>=x)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}



Measured memory_bytes: 3568
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

bool in(ll a, ll b, ll x, ll y){
	return (0<a&&a<x)&&(0<b&&b<y);
}

ll f(ll a, ll b, ll x, ll y){
	ll r = 0;
	if(b==0) r = a;
	else if(a==x) r = x+b;
	else if(b==y) r = x+y+x-a;
	else if(a==0) r = x+y+x+y-b;
	return r;
}

int main(){
	ll xx, yy, n;
	cin>>xx>>yy>>n;
	vector<P> v;
	rep(i, n){
		ll a, b, c, d;
		cin>>a>>b>>c>>d;
		if(in(a, b, xx, yy) || in(c, d, xx, yy)) continue;
		v.push_back(P(f(a, b, xx, yy), i));
		v.push_back(P(f(c, d, xx, yy), i));
	}
	sort(all(v));
	stack<ll> st;
	rep(i, v.size()){
		//cerr<<v[i].fst<<": "<<v[i].snd<<endl;
		if(st.empty() || st.top()!=v[i].snd) st.push(v[i].snd);
		else st.pop();
	}
	cout<<(st.empty()?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 6256
N=int(input())
S=input()
ans=0
for i in range(1000):
    one=str(i//100)
    two=str((i%100)//10)
    three=str(i%10)
    f1,f2,f3=False,False,False
    ptr=0
    for j in range(ptr,N-2):
        if S[j]==one:
            f1=True
            ptr=j+1
            break
    if f1:
        for j in range(ptr,N-1):
            if S[j]==two:
                f2=True
                ptr=j+1
                break
        if f2:
            for j in range(ptr,N):
                if S[j]==three:
                    f3=True
                    ans+=1
                    break
print(ans)

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

int main(){
  string S, T;
  int counter = 0, min;
  cin >> S >> T;
  min = T.size();
  for(int i = 0; i < S.size() - T.size() + 1; i++){
    for(int j = 0; j < T.size(); j++){
      if(T.at(j) != S.at(j + i)) counter++;
    }
    if(counter < min) min = counter;
    counter = 0;
  }
  cout << min << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int K, X; cin >> K >> X;
  int m;
  m = max(-20000, X - K + 1);
  rep (i, 2*K-1) {
    cout << i + m << " ";
  }
  cout << endl;

  return 0;
}


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

#define INF 1e9
using namespace std;

int main() {

    int N, Q; cin >> N >> Q;
    string S; cin >> S;

    vector<int> sum(N);

    sum[0] = 0;
    for (int i = 0; i < N; ++i) {
        if (i == N - 1) {
            break;
        }

        if (S[i] == 'A' && S[i+1] == 'C') {
            sum[i+1] = sum[i] + 1;
        } else {
            sum[i+1] = sum[i];
        }
    }

    for (int j = 0; j < Q; ++j) {
        int l, r; cin >> l >> r;

        cout << sum[r-1] - sum[l-1] << endl;
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    if (s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3652
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-26 21:03:15
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];

    sort(all(h));
    reverse(all(h));
    
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        if (i >= k) {
            ans += h[i];
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys

h, w = map(int, sys.stdin.readline().split())
grid = [sys.stdin.readline().rstrip() for _ in range(h)]

def main():
    cost = [[0] * w for _ in range(h)]
    cost[0][0] = 1 if grid[0][0] == '#' else 0
    for j in range(1, w):
        cost[0][j] = cost[0][j-1]
        if grid[0][j] == '#':
            if grid[0][j-1] == '.':
                cost[0][j] += 1
    
    for i in range(1, h):
        cost[i][0] = cost[i-1][0]
        if grid[i][0] == '#':
            if grid[i-1][0] == '.':
                cost[i][0] += 1
    
    for i in range(1, h):
        for j in range(1, w):
            c1 = cost[i][j-1]
            if grid[i][j] == '#':
                if grid[i][j-1] == '.':
                    c1 += 1
            c2 = cost[i-1][j]
            if grid[i][j] == '#':
                if grid[i-1][j] == '.':
                    c2 += 1
            
            cost[i][j] = min(c1, c2)
    return cost[h-1][w-1]

if __name__ == "__main__":
    ans = main()
    print(ans)

Measured memory_bytes: 3188
"""
    N個のボタン 初期条件としてボタン1が1個光ってる
    ボタンiが光ってる時に押すとiが消えてaiが光る
    i=ai なこともある
    光ってないボタンは押せない
    ボタン2が光ってる状態でおわる
    回数を求める、不可なら-1

    2が返る前に重複したら不可ということ
"""
n = int(input())
# ボタンの番号を 0 ~ n-1 番に読み替え
a = [int(input())-1 for _ in range(n)]
button, count = 0, 0
dup_check = {0}

while button != 1:
    len_check = len(dup_check)
    count += 1
    button = a[button]
    dup_check.add(button)
    if len_check == len(dup_check):
        count = -1
        break

print(count)


Measured memory_bytes: 13220
#include <bits/stdc++.h>
#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  string pre, suf;
  pre = S.substr(0, N / 2);
  suf = S.substr(N / 2, N / 2);
  if (S.substr(0, N / 2) == S.substr(N / 2, N / 2) && N % 2 != 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                        ' '
#define EPS                        1e-9
#define P_INF                      2e9+17
#define N_INF                     -2e9-17
#define MOD                        1000000007
#define PI                         2*acos(0.0)
#define All(x)                     x.begin(),x.end()
#define Mem(Name, type)            memset(Name, type, sizeof(Name))

template<typename T>
T GCD(T a, T b) { return a ? GCD(b % a, a) : b; }

template<typename T>
T LCM(T a, T b) { return (a * b) / GCD(a, b); }

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

template<typename T, typename S>
std::ostream &operator<<(std::ostream &os, const std::map<T, S> &v) {
    for (auto ob : v) os << ob.first << " : " << ob.second << std::endl;
    return os;
}

using ld = double;
using ll = long long int;
using ul = unsigned long long int;
using namespace std;

class ECoprime {
    vector<bool> chk;
    bool flag;

    void Factor(int x) {
        if (chk[x]) {
            flag = true;
            return;
        }
        chk[x] = true;
        for (int i = 2; i * i < x + 1; ++i) {
            if (x % i == 0) {
                if (chk[i]) {
                    flag = true;
                    return;
                }
                if (chk[x / i]) {
                    flag = true;
                    return;
                }
                chk[i] = true;
                chk[x / i] = true;
            }
        }
    }

public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vector<int> a(n);
        chk.resize(1000003);
        for (int i = 0; i < n; ++i) {
            in >> a[i];
        }
        flag = false;
        for (int i = 0; i < n; ++i) {
            if (a[i] != 1) {
                Factor(a[i]);
                if (flag) break;
            }
        }
        if (!flag) {
            out << "pairwise coprime" << endl;
            return;
        }
        int g = a[0];
        for (int i = 1; i < n; ++i) {
            g = GCD(g, a[i]);
        }
        if (g == 1) {
            out << "setwise coprime" << endl;
        } else {
            out << "not coprime" << endl;
        }
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ECoprime solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 7160
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
a = sorted(a)
from collections import deque
q = deque([])
q.extend(a)
p = deque([])
i = 0
while len(q) > 1:
    if i%2 == 0:
        p.appendleft(q.popleft())
        p.append(q.pop())
    else:
        p.append(q.popleft())
        p.appendleft(q.pop())
    i += 1
p1 = list(p) + list(q)
p2 = list(q) + list(p)
ans1 = 0
ans2 = 0
for i in range(n-1):
    ans1 += abs(p1[i+1]-p1[i])
    ans2 += abs(p2[i+1]-p2[i])
print(max(ans1,ans2))

Measured memory_bytes: 16212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

const int MAX_V=100000;

struct edge {int to; ll cost;};
typedef pair<int, int> P; // firstは最短距離, secondは頂点の番号

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+V, LLONG_MAX);
  d[s]=0;
  que.push(P(0, s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second; // 頂点の番号
    if (d[v] < p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  cin>>V;
  for(int i=0;i<V-1;i++){
    int a,b;
    ll c;
    cin>>a>>b>>c;
    a--; b--;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }
  int q, k;
  cin>>q>>k;
  dijkstra(k-1);
  //for(int i=0;i<V;i++) cout<<d[i]<<endl;
  for(int i=0;i<q;i++){
    int x,y;
    cin>>x>>y;
    x--; y--;
    cout<<(d[x]+d[y])<<endl;
  }
  return 0;
}


Measured memory_bytes: 10796
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = max(a+b, max(a-b, a*b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000000
 
int N, M, R;
long long d[201][201];
int A, B;
long long C;
int r[8];
long long ans = INF;
bool used[8];
 
void dfs(int c, int last, long long dist){
    if(c == R){
        //cout << "last" << dist<< endl;
        if(ans > dist)ans = dist;
        return;
    }
    rep(i, R){
        //if(c+1 == i)continue;
        if (!used[i]){
            used[i] = true;
            if(last==-1)dfs(c+1 ,i, 0);
            else {
                //cout << "path" << r[last] << "->" << r[i] << "is"  << dist<< "+" << d[r[last]][r[i]] << endl;
                dfs(c+1, i, dist+d[r[last]-1][r[i]-1]);
            }
            used[i] = false;
        }
    }
 
 
}
int main(){
    cin >> N >> M >> R;
    rep(i, R)cin >> r[i];
    rep(i, 201)rep(j, 201)d[i][j] = INF;
    rep(i, M){
        cin >> A >> B >> C;
        if(d[A-1][B-1] > C)d[A-1][B-1] = d[B-1][A-1] = C;
    }
 
    rep(k, N)rep(i, N)rep(j, N){
        if(d[i][j] > d[i][k] + d[k][j]){
            d[i][j] = d[i][k] + d[k][j];
        }
    }
    //cout << d[0][2] << endl;
    ans = INF;
    dfs(0, -1, 0);
    cout << ans;
 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e5 + 9;

int calc(int x, int y){
    if( x%y == 0 ){
        return x/y;
    }
    return x/y + 1;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    vector<int> v1(n);
    for(auto &c: v1) cin >> c;
    int ans = *max_element( v1.begin(), v1.end() );
    int L = 1; int R = ans-1;
    while( L <= R ){
        int mid = L + (R-L)/2;
        ll op = 0;
        for(auto &c: v1) {
            op += calc(c, mid) - 1;
            //cout << c << " " << mid << " ceil() = " << ceil(c/mid) << "\n";
        }
        //cout << mid << " " << op << " " << k << "\n";
        if( op <= k ){
            ans = mid;
            R = mid-1;
        }
        else{
            L = mid+1;
        }
    }
    cout << ans;

}




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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long n,k;
	cin>>n>>k;
	long long r = n%k;
	if (r){
		cout<<min(abs(r-k),r)<<endl;
	}else{
		cout<<0<<endl;
	}
}


Measured memory_bytes: 3612
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        boolean bool = true;
        for(int i=0;i<k;i++){
            if(a+i<=b){
                System.out.println(a+i);
            }
            else{
                bool = false;
            }
        }
        for(int i=0;i<k;i++){
            if(b-k+1+i>=a&&bool&&a+k-1<b-k+1+i){
                System.out.println(b-k+1+i);
            }
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
typedef long long ll;
using namespace std;

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int count=0;
    int B[M];
    for(int i=0;i<M;i++) cin >> B[i];
    for(int i=0;i<N;i++){
        int s=C;
        for(int j=0;j<M;j++){
            int A;
            cin >> A;
            s += A*B[j];
        }
        if (s > 0) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
n=[int(i) for i in list(input())]
op=[1,-1]
ans=[]
for op1 in op:
	for op2 in op:
		for op3 in op:
			if n[0]+op1*n[1]+op2*n[2]+op3*n[3]==7:
				ans=[op1,op2,op3]
out=''
for i in range(3):
	out+=str(n[i])
	out+='+' if ans[i]==1 else '-'
print(out+str(n[3])+'=7')
		
		

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;

int n,m,k;
ll a[15][1100];
int sz[15];

int getans(int x) {
    memset(sz,0,sizeof(sz));
    int res = 0;
    for(int i=1;i<=m;i++) {
        int cnt = 0;
        int cur = x;
        int flag = 0;
        for(int j=1;j<=n;j++) {
            sz[cnt] += a[j][i];
            if(sz[cnt] > k) flag = 1;
            if(cur&1) cnt++;
            cur >>= 1;
        }
        if(flag && i == 1) return 1e9;
        else if(flag) {
            res++;
            sz[0] = 0;
            cnt = 0;
            cur = x;
            for(int j=1;j<=n;j++) {
                sz[cnt] += a[j][i];
                if(sz[cnt] > k) return 1e9;
                if(cur&1) cnt++,sz[cnt]=0;
                cur >>= 1;
            }
        }
        if(i==1) res+= cnt;
    }
    //if(res == 0) cout<<x<<endl;
    return res;
}


int main() {
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            scanf("%1d",&a[i][j]);
        }
    }
    int ans = 1e9;
    for(int i=0;i<(1<<(n-1));i++) {
        ans = min(ans,getans(i));
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
import itertools
from scipy.sparse.csgraph import dijkstra
import sys 
input = sys.stdin.readline
def solve():
  n,m,R = (int(i) for i in input().split())
  r = list(int(i) for i in input().split())
  d = [[0]*n for _ in range(n)]
  for i in range(m):
    a,b,c = (int(i) for i in input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    
  d = dijkstra(d)

  perm = list(itertools.permutations(range(R)))
  cost = float("Inf")
  for i in range(len(perm)):
    root = perm[i]
    tempcost = 0
    for j in range(R-1):
      na = r[root[j]]-1
      nb = r[root[j+1]]-1
      tempcost += d[na][nb]
    cost = min(tempcost,cost)
  print(int(cost))
solve()

Measured memory_bytes: 22444
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=100000000000;
string u="abcdefghijklmnopqrstuvwxyz";

set<int> st;

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int d;
        cin >> d;
        st.insert(d);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include <vector>
#define ME(x , y) memset(x , y , sizeof(x))
#define SF(n) scanf("%d" , &n)
#define rep(i , n) for(int i = 0 ; i < n ; i ++)
#define INF  0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
using namespace std;
typedef long long ll ;


int main()
{
    char a ;
    cin >> a ;
    cout << (char)(a+1) << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;

int main()
{
  int a, b, n;
  cin >> a >> b;
  n = b - a;
  cout << n * (n+1) / 2 - b << endl;
  return 0;
}

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

#define PI 3.14159265359

int main() {
	double a, b, C;
	double S, L, h;
	scanf("%lf %lf %lf", &a, &b, &C);
	
	S = 0.5*a*b*sin(C*PI / 180);
	L = a + b + sqrt(a*a+b*b-2*a*b*cos(C*PI/180));
	h = b * sin(C*PI / 180);

	printf("%lf\n%lf\n%lf\n",S,L,h);
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
bool used[55][55][55][55];
int n,m;
string s[55],t[55];
int d[]={0,1,0,-1,0};
main()
{
	while(cin>>m>>n,m)
	{
		for(int i=0;i<n;i++)
		{
			cin>>s[i]>>t[i];
			reverse(t[i].begin(),t[i].end());
			for(int j=0;j<m;j++)
			{
				for(int k=0;k<n;k++)for(int l=0;l<m;l++)used[i][j][k][l]=0;
			}
		}
		queue<pair<pair<int,int>,pair<int,int> > >P;
		pair<int,int>Ss,St;
		for(int i=0;i<n;i++)for(int j=0;j<m;j++)
		{
			if(s[i][j]=='L')Ss={i,j};
			if(t[i][j]=='R')St={i,j};
		}
		used[Ss.first][Ss.second][St.first][St.second]=1;
		P.push(make_pair(Ss,St));
		for(int i=0;i<n;i++)for(int j=0;j<m;j++)
		{
			if(s[i][j]=='%')Ss={i,j};
			if(t[i][j]=='%')St={i,j};
		}
		bool flag=1;
		while(flag&&!P.empty())
		{
			pair<int,int>a=P.front().first,b=P.front().second;
			P.pop();
			for(int r=0;r<4;r++)
			{
				pair<int,int>A=a,B=b;
				if(d[r])
				{
					int tx=A.first+d[r];
					if(tx>=0&&tx<n&&s[tx][A.second]!='#')A.first=tx;
					tx=B.first+d[r];
					if(tx>=0&&tx<n&&t[tx][B.second]!='#')B.first=tx;
				}
				else
				{
					int ty=A.second+d[r+1];
					if(ty>=0&&ty<m&&s[A.first][ty]!='#')A.second=ty;
					ty=B.second+d[r+1];
					if(ty>=0&&ty<m&&t[B.first][ty]!='#')B.second=ty;
				}
				if(used[A.first][A.second][B.first][B.second])continue;
				used[A.first][A.second][B.first][B.second]=1;
				if(A==Ss||B==St)
				{
					if(A==Ss&&B==St)
					{
						cout<<"Yes"<<endl;
						flag=0;
						break;
					}
				}
				else P.push(make_pair(A,B));
			}
		}
		if(flag)cout<<(used[Ss.first][Ss.second][St.first][St.second]?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

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

    if(s=="SUN") cout << 7;
    else if(s=="MON") cout << 6;
    else if(s=="TUE") cout << 5;
    else if(s=="WED") cout << 4;
    else if(s=="THU") cout << 3;
    else if(s=="FRI") cout << 2;
    else if(s=="SAT") cout << 1;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  int c=0;
  string S;
  bool flag=true;
  cin>>S;
  if(S[0]!='A'){
    cout<<"WA";
  }
  else{
  for(int i=2;i<S.size()-1;i++){
    if(S[i]=='C'){
      c++;
    }
  }
   for(int i=1;i<S.size();i++){
   if(S[i]>=65&&S[i]<=90&&S[i]!='C'){
     flag=false;
   }
   }
  if(c==1&&flag==true){
    cout<<"AC";
  }
  else{
    cout<<"WA";
  }
  }
  
return 0;
}

Measured memory_bytes: 256
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()

ans=0
for i in b:
    up=bisect.bisect_left(a, i)
    dn=n-bisect.bisect_right(c, i)
    ans+=up*dn

print(ans)


Measured memory_bytes: 23136
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int N,A;
    while (cin >> N >> A) {
        if (A >= N%500)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int x,a,b;
    cin >> x >> a >> b;
    string ans=(abs(x-a)>=abs(x-b))?"B":"A";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
haiku = list(map(int, input().split()))

cnt_5 = 0
cnt_7 = 0
for s in haiku:
    if s == 5:
        cnt_5 += 1
    elif s == 7:
        cnt_7 += 1
if cnt_5 == 2 and cnt_7 == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940