akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, k; cin >> n >> k;
	VI e(k);
	rep(i, k)cin >> e[i];

	for (int bit = 0; bit < (1 << n); bit++) {
		VI s;
		rep(i, n) {
			if (bit&(1 << i))s.pb(i);
		}

		VI re;
		set_intersection(all(e), all(s), inserter(re, re.end()));

		if (re == e) {
			cout << bit << ":";
			for (auto x : s) {
				cout << " " << x;
			}
			puts("");
		}
	}
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
using namespace std;
ll a,b,c;
int main(){

	ios::sync_with_stdio(0);
	
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust"<<endl;
	} else {
		cout<<"win"<<endl;
	}

	return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);
    int a[200001];
    long long res = 0;
    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        res = res ^ a[i];
    }
    
    for(int i=0; i<n; i++) {
        printf("%lld ", res ^ a[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 4616
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

struct Point {
  double x;
  double y;
};

double min(double a, double b) {
  if(a < b) 
    return a;
  else
    return b;  
}

double norm(Point p0, Point p1) {
  return sqrt(pow(p1.x - p0.x, 2) + pow(p1.y - p0.y, 2));
}

double dot(Point p0, Point p1, Point p2) {
  return (p1.x - p0.x) * (p2.x - p0.x) + (p1.y - p0.y) * (p2.y - p0.y);
}

double cross(Point p0, Point p1, Point p2) {
  return ( p1.x - p0.x ) * ( p2.y - p0.y ) - ( p2.x - p0.x) * (p1.y - p0.y);
}

int positional_relationship(Point p0, Point p1, Point p2) {
  if(cross(p0, p1, p2) > 0) //反時計回り
    return 1;
  else if(cross(p0, p1, p2) < 0) //時計回り
    return -1;
  else if(dot(p0, p1, p2) < 0) //一直線上で反転向き
    return 2;
  else if(norm(p0, p1) < norm(p0, p2)) // 一直線上で同じ向き
    return -2;
  else //線分上に存在
    return 0;  
}

bool isIntersected(Point p0, Point p1, Point p2, Point p3) {
  if(positional_relationship(p0, p1, p2) * positional_relationship(p0, p1, p3) <= 0 && positional_relationship(p2, p3 ,p0) * positional_relationship(p2, p3, p1) <= 0)
    return true;
  return false;
};

double distance(Point p0, Point p1, Point p2) {
  if(dot(p0, p1, p2) < 0)
    return norm(p0, p2);
  else if(dot(p1, p0, p2) < 0)
    return norm(p1, p2);
  else
    return fabs( cross(p0, p1, p2) ) / ( norm(p0, p1) );  
}

int main(void) {
  int q;
  cin >> q;
  Point p0, p1, p2, p3;

  for(int i = 0; i < q; i++) {
    cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
    double min_dist = 0.0;
    if(isIntersected(p0, p1, p2, p3)) {
      printf("%.10lf\n", min_dist);
      continue;
    }
    //printf("%lf %lf\n", distance(p0, p1, p2), distance(p0, p1, p3));
    min_dist = min(min( distance(p0, p1, p2), distance(p0, p1, p3) ), min( distance(p2, p3, p0), distance(p2, p3, p1) ) );
    printf("%.10lf\n", min_dist);
  }

}


Measured memory_bytes: 3192
#!/usr/bin/env python3
import sys
import itertools
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))

    l = [i + 1 for i in range(N)]
    p = itertools.permutations(l, N)
    q = itertools.permutations(l, N)
    c = 1
    d = 1
    a = 0
    b = 0
    for i in p:
        x = 0
        for j in range(N):
            if i[j] == P[j]:
                x += 1
            else:
                break
        if x == N:
            a = c
            break
        c += 1
    for i in q:
        x = 0
        for j in range(N):
            if i[j] == Q[j]:
                x += 1
            else:
                break
        if x == N:
            b = d
            break
        d += 1
    ans = abs(a - b)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73900
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n; cin >> n;
    int ct = 0;
    map<int,int> mp;
    rep(i,n) {
        int x; cin >> x;
        if (x >= 3200) {
            ct++;
            continue;
        }
        for (int l = 0; l <= 7; l++) {
            if (l*400 <= x && x < (l+1)*400) mp[l]++;
        }
    }
    int mn, mx;
    mx = mp.size()+ct;
    if (mp.size() >= 1) mn = mp.size();
    else mn = 1;
    cout << mn << " " << mx << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   char[] a = sc.next().toCharArray();
   char[] b = sc.next().toCharArray();
 
   StringBuilder ans = new StringBuilder();
   
   for(int i=0;i<b.length;i++) 
   {
     ans.append(a[i]);
     ans.append(b[i]);
   }
   if(a.length!=b.length) ans.append(a[a.length-1]);
   System.out.println(ans.toString());
 }
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  FOR(i, K, N){
    ll pre = A[i-K];
    ll next = A[i];
    cout << (pre < next ? "Yes" : "No") << endl;
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<ll, vector<int>> mp;
  rep(i, n) mp[a[i]].push_back(i);

  mint in_num = 0, out_num = 0;
  rep(i, n) {
    for(auto x:mp) {
      if(x.first >= a[i]) break;
      in_num += (int)distance(upper_bound(ALL(mp[x.first]), i), mp[x.first].end());
      out_num += (int)x.second.size();
    }
  }
  mint ans = -k*(k+1)/2;
  ans *= out_num;
  ans += (in_num + out_num*k)*k;
  cout << ans.x << endl;
}

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

using namespace std;

int main() {
  int H, N;
  cin >> H >> N;
  int total = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    total += a;
  }
  if (total >= H) puts("Yes");
  else puts("No");
  return 0;
}



Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
        
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
n,m = inpl()
a = inpl()
uf = UnionFind(n)
for i in range(m):
    x,y = inpl()
    x -= 1; y -= 1
    uf.union(x,y)
res = 0
for i in range(n):
    if uf.same(a[i]-1, i):
        res += 1
print(res)


Measured memory_bytes: 108724
#include <bits/stdc++.h>
using namespace std;
int newArr[11];

bool compare(int ans){
    while (ans > 0)
    {
        if(newArr[ans % 10] == 1)
            return false;
        
        ans /= 10;
    }

    return true;
    
}

int main(){
    int N,K,value;
    cin >> N >> K ;
    
    for(int i = 0; i < K; i++){
        cin >> value;
        newArr[value] = 1;
    }


    for(int i = N; i < 100000; i++){
        
        if(compare(i)){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    for(int i=0; i<5; i++)
    {
        int x;
        cin >> x;
        if(x == 0)
        {
            cout << i+1;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
import fractions

N, M = map(int, input().split())
S = input()
T = input()

g = fractions.gcd(N, M)

lcm = N * M // g

ln = lcm // N
lm = lcm // M

count_n = 0
count_m = 0

while count_n != N and count_m != M:

    temp_n = count_n * ln
    temp_m = count_m * lm

    if temp_n == temp_m:
        if S[count_n] != T[count_m]:
            print(-1)
            break
    
    if count_n == (N - 1):
        count_m += 1
    elif count_m == (M - 1):
        count_n += 1
    elif temp_n <= temp_m:
        count_n += 1
    else:
        count_m += 1
else:
    print(lcm)


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

using namespace std;

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  for(int i = 0; i < N; i++) {
    int A;
    cin >> A;
    for(int j = 1; j <= D; j += A) ++X;
  }
  cout << X << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
def f(x,y):
    ret=(1 if x%3 else 0)*y
    for i in range(1,x):
        f=sorted((i*y,y//2*(x-i),(1+y)//2*(x-i)))
        ret=min(ret,f[2]-f[0])
    return ret
print(min(f(h,w),f(w,h)))

Measured memory_bytes: 67768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
const int MOD = 1e9+7;
const ll INF =1e18;

int main(){
    int n;cin >> n;
    int a;
    int p = 0;
    fr(i,n){
        cin >> a;
        if(a%2==0) p ++;
    }
    cout << pow(3,n)-pow(2,p) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    double n;
    cin >> n;
    double ans = (n/3)*(n/3)*(n/3);
    printf("%10.9lf\n", ans);
}



Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

#define MAX_N 10
#define MAX_D 10
#define MAX_X 20

using namespace std;
int main(){
    int n,d,x_ij;
    cin >> n>>d;
    int x[MAX_N][MAX_D];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x_ij;
            x[i][j]=x_ij;
        }
    }
    int count=0,sum_d,m;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum_d=0;
            for(int k=0;k<d;k++){
                m=x[i][k]-x[j][k];
                sum_d+=m*m;
            }
            for(int k=0;k<=2*MAX_X*d;k++){
                if(sum_d==k*k){
                    count++;
                    break;
                }
            }
            
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
int main() {

	int X, A, B;

	cin >> X >> A >> B;

	if (A >= B)
		cout << "delicious\n";
	else if ((B - A) <= X)
		cout << "safe\n";
	else
		cout << "dangerous\n";

	cin >> X;

	return 0;
}

Measured memory_bytes: 256
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x is not None: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 55692
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto s = sread();
    bool b = s[0] == s[2];
    writeln(b ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<stdio.h>

#define BLACK 2
#define GRAY  1
#define WHITE 0
#define MAX 100

int n=0, time=0;
int color[MAX]={};
int d[MAX]={}, f[MAX]={};
int matrix[MAX][MAX] = {};

void dfs();
void visit(int);

int main(void){
    int i, j;
    scanf("%d\n", &n);

    
    for(i = 0; i < n; i++){
        int u, k, v;
        scanf("%d %d", &u, &k);
        for(j=0;j<k;j++){
            scanf(" %d", &v);
            matrix[u-1][v-1]=1;
        }
    }

    dfs();

    for(i=0;i<n;i++){
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }

    return 0;
}

void dfs(){
    int i;
    for(i=0; i<n; i++){
        if(color[i] == WHITE){
            visit(i);
        }
    }
}

void visit(int u){
    int i, j;
    color[u] = GRAY;
    d[u] = ++time;
    for(i=0;i<n;i++){
        if(matrix[u][i] && color[i] == WHITE){
            visit(i);
        }
    }
    color[u] = BLACK;
    f[u] = ++time;
}


Measured memory_bytes: 2112
N = input()
c = [1]*("z".encode()[0]-"a".encode()[0]+1)
for x in map(lambda x: x-"a".encode()[0], input().encode()):
	c[x] += 1

m = 1
for x in c:
  m = (m * x) % (1e9+7)

print("{:.0f}".format(m-1))


Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
if 0 in a:
  print(0)
  exit(0)

mul = 1
for i in range(n):
  mul *= a[i]
  if (mul > 1000000000000000000):
  	print(-1)
  	exit(0)

print(mul)

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

int main(){
  
 int n,ans=0;
 string s;
  
 cin >> n >> s;
  
  for(int i=0; i < n-2; i++){
    if(s.at(i)=='A')
      if(s.at(i+1)=='B')
        if(s.at(i+2)=='C')
          ans++;
  }
  cout << ans;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <utility>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
	int u, d, n;
	cin >> d >> u >> n;
	map<int, bool> m = {};
	if (u - n < d) {
		n = u-d;
	}
	if (u - d == 0) {
		n += 1;
	}
	for (int i = d; i < d + n; ++i) {
		cout << i << endl;
		m[i] = true;
	}
	for (int i = u - n + 1; i < u + 1; ++i) {
		if (!m[i]) {
			cout << i << endl;
			m[i] = true;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    set<int> st;
    int n;
    cin >> n;
    int a;
    rep(i,n) cin >> a, st.insert(a);
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 7756
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	int L[15],sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>L[i];
	}
	sort(L,L+n);

	for(int i=0;i<n-1;i++){
		sum+=L[i];
	}

	if(sum>L[n-1]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

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

	ll n = 0;
	cin >> n;
	vi num(n);
	
	rep(i, n)	cin >> num[i];
	ll ans = 0;
	for(ll i = 0; i < n; ++i)
	{
		for(ll j = 0; j < n; ++j)
		{
			if(i != j)
			{
				if(abs(num[i] - num[j]) > ans)
					ans = abs(num[i] - num[j]);
			}
		}
	}
	cout << ans << endl;
	#ifdef LOCAL_DEFINE
		cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}



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

using namespace std;

int n, m;
vector<int> g[200000];
char s[200001];
int deg[200000][2];
bool used[200000];

int main() {
  scanf("%d %d", &n, &m);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    s[i] -= 'A';
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
    deg[u][s[v]]++;
    if (u != v) {
      g[v].push_back(u);
      deg[v][s[u]]++;
    }
  }
  queue<int> que;
  for (int i = 0; i < n; i++) {
    if (deg[i][0] == 0 || deg[i][1] == 0) {
      que.push(i);
      used[i] = true;
    }
  }
  while (!que.empty()) {
    n--;
    int u = que.front(); que.pop();
    for (int v : g[u]) if (v != u) {
      if (--deg[v][s[u]] == 0) {
        if (!used[v]) {
          used[v] = true;
          que.push(v);
        }
      }
    }
  }
  puts(n > 0 ? "Yes" : "No");
}


Measured memory_bytes: 12544
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

double calc(int l) {
    double x = l / 3.0;
    return x ^^ 3;
}

void main() {
    int l; scan(l);
    writefln("%.10f", calc(l));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : December 03 2019 23:34:24 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;
ll dp[53][53][2533];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n,A;
    cin >> n >> A;
    vi x(n);
    fori(i,n) cin >> x[i];
    fori(i,n+1){
        fori(j,2533){
            dp[n][i][j] = 0;
        }
    }
    dp[n][0][0] = 1;
    ford(i,n){
        fori(j,n+1){
            fori(k,2533){
                dp[i][j][k] = dp[i+1][j][k];
                if(j and k >= x[i]){
                    dp[i][j][k] += dp[i+1][j-1][k-x[i]];
                }
            }
        }
    }
    ll ans = 0;
    rep(j,1,n){
        ans += dp[0][j][A*j];
    }
    cout << ans << endl;
    time_taken();
    return 0;
}

Measured memory_bytes: 55552
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=2005;



void solve()
{
    set<pair<int,int>> s[4];
    int n;
    cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
    
        if(i!=0)
        {
        for(int j=0;j<4;j++)
        {
            auto it= (--s[j].end());
            int in=(*it).se;
            ans=max(ans,abs(a[i][0]-a[in][0])+abs(a[i][1]-a[in][1]));
        }
        }
        for(int j=0;j<4;j++)
        {
            int y=0;
            for(int k=0;k<2;k++)
            {
                if(j&(1<<k))
                {
                    y=y-a[i][k];
                }
                else
                    y=y+a[i][k];
            }
            s[j].insert(m1(y,i));
        }
    }
    cout<<ans<<endl;
    
    
    
}

int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}







Measured memory_bytes: 56784
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<int,int> mp;
  rep(i,n) mp[a[i]]=i;
  set<int> st={-1,n};
  ll ans=0;
  for(ll i=n;i>=1;i--){
    auto itr=st.upper_bound(mp[i]);
    int r=*itr;
    int r2=r==n?r+1:*(next(itr));
    int l=*(prev(itr));
    int l2=l==-1?l-1:*(prev(itr,2));
    int dr=l==-1?0:r-mp[i];
    int dl=r==n?0:mp[i]-l;
    int dr2=r2-r;
    int dl2=l-l2;
    ans+=i*(dl2*dr+dr2*dl);
    st.insert(mp[i]);
  }
  cout << ans << endl;
}

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

typedef long long ll;
const int maxn = 1e5 + 3;
const ll mo = 1e9 + 7;

ll mpow(ll u, ll k) {
    ll ans = 1;
    for(; k > 0; k >>= 1, u = u * u % mo) {
        if(k & 1)
            ans = ans * u % mo;
    }
    return ans;
}

int n, k;
int a[maxn];
ll fact[maxn], ract[maxn], ans;

ll C(int u, int v) {
    if(u < 0)
        return 0;
    if(v < 0 || v > u)
        return 0;
    return fact[u] * ract[v] % mo * ract[u - v] % mo;
}

int main() {
    fact[0] = 1;
    for(int i = 1; i < maxn; ++i)
        fact[i] = fact[i - 1] * (ll)i % mo;
    ract[maxn - 1] = mpow(fact[maxn - 1], mo - 2);
    for(int i = maxn - 2; i >= 0; --i)
        ract[i] = ract[i + 1] * (ll)(i + 1ll) % mo;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; ++i)
        scanf("%d", a + i);
    std::sort(a, a + n);
    for(int i = n - 1; i >= 0; --i) {
        ans = (ans + a[i] * (ll)C(i, k - 1)) % mo;
        ans = (ans - a[i] * (ll)C(n - i - 1, k - 1)) % mo;
    }
    printf("%lld\n", ans);
    return 0;
}

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

#define ll long long
#define inf 1000000000
using namespace std;


int e;

int yy(int a){
		int i=0;
		while(i*i<=a){
				if(i*i==a)return i;
				i++;
		}
		return inf;
}

int zzz(int a){
		int i=0;
		while(i*i*i<=a){
				if(i*i*i==a)return i;
				i++;
		}
		return inf;
}

int main(){
		while(cin>>e,e){
				int ans=inf;
				for(int i=0;i*i*i<=e;i++){
						for(int j=0;j*j<=e;j++){
								if(i*i*i+j*j<=e){
										ans=min(ans,i+j+(e-i*i*i-j*j));
								}	
						}
				}
				cout<<ans<<endl;
		}
		return 0;
}

Measured memory_bytes: 2976
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NAB = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, A, B) = (NAB[0], NAB[1], NAB[2]);
            var X = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var answer = 0L;
            for (var i = 1; i < N; i++)
            {
                answer += Math.Min((X[i] - X[i - 1]) * A, B);
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 38692
import itertools


N, M = map(int, input().split())
connected_switches = [[int(x) - 1 for x in input().split()[1:]] for x in range(M)]
conditions = list(map(int, input().split()))

ok = 0
for patterns in itertools.product((0, 1), repeat=N):
    patterns = list(patterns)
    is_lighting = True
    for i, lights in enumerate(connected_switches):
        turned_sw = sum([patterns[x] for x in lights])
        if turned_sw % 2 != conditions[i]:
            is_lighting = False
            break
    if is_lighting:
        ok += 1

print(ok)


Measured memory_bytes: 3064
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    cout << (1000 - n % 1000) % 1000 << endl;
}



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


int main() {
	int n, k;
	cin >> n >> k;
	int current = 1;
	for (int i = 0; i < n; i++) {
		current = (current * 2 < current + k ? current * 2 : current + k); 
	}
	cout << current << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define MAX 2000005
using namespace std;
int A[MAX], H=0;
void insertkey(int key)
{
  H++;
  A[H] = key;
  int i = H;
  while(i>1 && A[i/2] < A[i])
  {
    swap(A[i/2], A[i]);
    i = i/2;
  }
}

void maxHeapify(int i)
{
  int l, r, largest;
  l = 2*i; r = 2*i + 1;
  if(l <= H && A[l] > A[i])
  {
    largest = l;
  }
  else largest = i;
  if(r <= H && A[r] > A[largest])
  {
    largest = r;
  }
  if(largest != i)
  {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

void popout()
{
  int maxv;
  maxv = A[1];  A[1] = A[H]; H--;
  maxHeapify(1);
  printf("%d\n", maxv);
}
int main()
{
  string s; int key;
  while(1)
  {
    cin >> s;
    if(s == "insert")
    {
      scanf("%d", &key); insertkey(key);
    }
    else if(s == "extract")  popout();
    else if(s == "end") break;
  }

  return 0;
}



Measured memory_bytes: 7184
n=int(input())
ans=[0]*4
for i in range(n):
	s=input()
	if s=="AC":
		ans[0]+=1
	elif s=="WA":
		ans[1]+=1
	elif s=="TLE":
		ans[2]+=1
	else:
		ans[3]+=1
print("AC x",ans[0])
print("WA x",ans[1])
print("TLE x",ans[2])
print("RE x",ans[3])

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m>>n)
    { i=m*n;
      i-=(m+n);
      i++;
      if(m==0||n==0)i=0;
      cout<<i<<endl;

    }
    return 0;
}


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

using namespace std;
long long cost[100000][101], w[101], v[101];

long long solve(int W, int n) {
	if(n == 0 || W == 0)
		return 0;
	if(cost[W][n] != -1)
		return cost[W][n];

	if(w[n] > W) {
		cost[W][n] = solve(W, n - 1);
		return cost[W][n];
	}
	cost[W][n] = max(solve(W - w[n], n - 1) + v[n], solve(W, n - 1));
	return cost[W][n];
}

int main() {
	int W, n;
	cin >> n >> W;
	for(int i = 1 ; i <= n; i++)
		cin >> w[i] >> v[i];

	for(int i = 0 ; i <= W ; i++) {
		for(int j = 0 ; j <= n ; j++)
			cost[i][j] = -1;
	}

	solve(W, n);
	cout << cost[W][n] << endl;
	return 0;
}

Measured memory_bytes: 79104
#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))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint n, m, Q;
vector<llint> G[100005];
llint dist[100005], color[100005];
vector<P> vec[15][100005];
P dp[15][100005];

int main(void)
{
	cin >> n >> m;
	llint u, v;
	for(int i = 1; i <= m; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	cin >> Q;
	llint d, c;
	for(int i = 1; i <= Q; i++){
		cin >> v >> d >> c;
		vec[d][v].push_back(P(i, c));
	}
	
	for(int i = 10; i >= 0; i--){
		for(int j = 1; j <= n; j++){
			for(int k = 0; k < vec[i][j].size(); k++){
				dp[i][j] = max(dp[i][j], vec[i][j][k]);
			}
			if(i > 0){
				dp[i-1][j] = max(dp[i-1][j], dp[i][j]);
				for(int k = 0; k < G[j].size(); k++){
					llint u = G[j][k];
					dp[i-1][u] = max(dp[i-1][u], dp[i][j]);
				}
			}
		}
	}
	for(int i = 1; i <= n; i++) cout << dp[0][i].second << endl;
	
	return 0;
}


Measured memory_bytes: 66036
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    string s, t; cin >> s >> t;
    int ans = 0;
    if(s[0] == t[0]) ans++;
    if(s[1] == t[1]) ans++;
    if(s[2] == t[2]) ans++;
    COUT(ans);
}



Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        {
            Scanner input = new Scanner(System.in);
            int a = input.nextInt(), b = input.nextInt();
            int k = (a+b)/2;
            if((a%2) == (b%2))
                System.out.println(k);
            else
                System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

vector<long long> solve(const vector<pair<long long, long long>>& vp, long long X, long long Z){
    priority_queue<long long> qu;
    long long cur = 0;
    for(int i=0;i<X;i++){
        cur += vp[i].first;
        qu.emplace(vp[i].second - vp[i].first);
    }
    vector<long long> res;
    res.push_back(cur);
    for(int i=X;i<X+Z;i++){
        cur += vp[i].first;
        qu.emplace(vp[i].second - vp[i].first);
        cur += qu.top(); qu.pop();
        res.push_back(cur);
    }
    return res;
}

int main(){
    int X, Y, Z;
    while(cin >> X >> Y >> Z){
        vector<vector<long long>> C(X+Y+Z, vector<long long>(3));
        for(auto& v : C){
            for(auto& t : v) cin >> t;
        }
        sort(C.begin(), C.end(), [](const vector<long long>& a, const vector<long long>& b){ return a[0]-a[1] > b[0]-b[1]; });
        vector<vector<long long>> res;
        for(int i=0;i<2;i++){
            vector<pair<long long, long long>> vp;
            for(auto& c : C) vp.emplace_back(c[i], c[2]);
            res.emplace_back(solve(vp, i==0?X:Y, Z));
            reverse(C.begin(), C.end());
        }
        long long best = 0;
        for(int i=0;i<=Z;i++) best = max(best, res[0][i] + res[1][Z-i]);
        cout << best << endl;
    }
}

Measured memory_bytes: 10068
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

ll S[100100]; // S[i] := [1,i]に含まれるお菓子の総数をmで割ったあまり
int main(){
    ll n,m; cin >> n >> m;
    ll A[100100];
    S[0] = 0;
    for(int i=1;i<=n;i++){
        cin >> A[i];
        S[i] = (S[i-1] + A[i]) % m; 
    }
    map<ll,ll> mp;
    ll ans = 0;
    mp[S[0]]++;
    for(int i=1;i<=n;i++){
        //ans += mp[S[i]%m];
        mp[S[i]%m]++;
    }
    /*for(int i=1;i<=n;i++){
        if(A[i] % m == 0) ans++;
    }*/
    for(auto itr = mp.begin();itr != mp.end();itr++){
        ans += itr->second * (itr->second - 1) / 2;
    }
    // ans += mp[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll n;
    cin >> n;
    ll a[n];
    double ave=0,mn=10000;
    rep(i,n){
        cin >> a[i];
        ave += a[i];
    }
    ave /= n;
    rep(i,n){
        if(mn > abs(a[i]-ave)) mn=abs(a[i]-ave);
    }
    rep(i,n){
        if(mn == abs(a[i]-ave)){
            cout << i << endl; return 0;
        }
    }
}

Measured memory_bytes: 256
//\\========================================//\\
  //  \\            @SHIMOL NAHA              //  \\
 // SN \\           @worst_coder             // SN \\
//======\\==================================//======\\

#include<bits/stdc++.h>
#define ll long long int
#define pp push_back
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<fixed;
    cout<<setprecision(9);
    ll n,m,i,p,k,l,q,r,j,x,y,t;
    cin>>l;
    k=0;
    for(i=1; i<l; i++)
    {
        p=l/i;
        if(l%i!=0)
        {
            k+=p;
        }
        else k+=p-1;
    }
    cout<<k;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long size = Long.parseLong(values[0]);
        values = scanner.nextLine().split(" ");
        for (int i = 0; i < size; i++) {
            String value = values[i];
            long v = Long.parseLong(value);
            if (v % 2 == 0) {
                if (v % 3 == 0 || v % 5 == 0) {
                    continue;
                } else {
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 537427207;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string st;
    string s; cin>>s;
    rep(i,s.size()){
        if(s[i]=='B'){if(st.size())st.pop_back();}
        else st.push_back(s[i]);
    }
    cout<<st<<endl; return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;
using ll = long long;

int main()
{
    ll Q, A, B;

    cin >> Q;


    for (int i = 0; i < Q;i++)
    {
        ll ans = 0;

        cin >> A >> B;
        ll s = A * B;
        ll rs = (ll)sqrt(s);

        ll t = rs - 1;
        if(rs * (rs + 1) < s)
        {
            t++;
            ans = t * 2 - 1;
            //cout << 'a' << endl;
        }
        else if(A == B && rs * rs == s)
        {
            ans = t * 2;
            //cout << 'b' << endl;
        }
        else if (A != B && rs * rs == s)
        {
            ans = t * 2 - 1;
        }    
        else
        {
            ans = t * 2;
            //cout << 'd' << endl;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256