akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static final int MAX_WEIGHT = 1_000_000_000;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] d = new int[n];
        int[] toMin = new int[n];
        int[] curMin = new int[n];
        int[] edgeMin = new int[n];
        Arrays.fill(curMin, Integer.MAX_VALUE);

        for (int i = 0; i < n; i++) {
            d[i] = scanner.nextInt();
        }

        int u, v;
        for (int i = 0; i < m; i++) {
            u = scanner.nextInt()-1;
            v = scanner.nextInt()-1;
            if(curMin[u]>d[v]){
                toMin[u] = v;
                curMin[u] = d[v];
                edgeMin[u] = i;
            }
            if(curMin[v]>d[u]){
                toMin[v] = u;
                curMin[v] = d[u];
                edgeMin[v] = i;
            }
        }

        for (int i = 0; i < n; i++) {
            if(d[i]<curMin[i]){
                System.out.println(-1);
                return;
            }
        }
        
        Boolean[] nodeColors = new Boolean[n];
        Integer[] edgeWeights = new Integer[m];
        Stack<Integer> stack = new Stack<>();

        for (int i = 0; i < n; i++) {
            if(nodeColors[i]!=null) continue;
            stack.push(i);
            while (!stack.isEmpty()){
                Integer peeked = stack.peek();
                if(nodeColors[toMin[peeked]]!=null){
                    nodeColors[peeked]=!nodeColors[toMin[peeked]];
                    edgeWeights[edgeMin[peeked]] = d[peeked];
                    stack.pop();
                }else{
                    if(d[toMin[peeked]]== d[peeked]){
                        toMin[toMin[peeked]] = peeked;
                        nodeColors[toMin[peeked]] = true;
                        nodeColors[peeked] = false;
                        edgeWeights[edgeMin[peeked]] = d[peeked];
                        stack.pop();
                    }else{
                        stack.push(toMin[peeked]);
                    }
                }
            }
        }

        for (int i = 0; i < m; i++) {
            if (edgeWeights[i] == null) edgeWeights[i] = MAX_WEIGHT;
        }

        StringBuilder sb = new StringBuilder(m);
        for (boolean color: nodeColors) {
            sb.append(color ? "B" : "W");
        }
        System.out.println(sb.toString());
        for (int w : edgeWeights) {
            System.out.println(w);
        }
    }
}

Measured memory_bytes: 159268
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
typedef long long ll;
const ll mod = 1e9 + 7; // change to something else
ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}
struct Mod {
    ll x;
    Mod(ll xx = 0) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x + mod) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e&1 ? *this * r : r;
    }
};
void solve() {  
    int n;
    cin >> n;
    if (n <= 4) {
        cout << 0 << '\n';
        return;
    }
    n -= 5;
    // 1/(1+x)^5(1-x)^16 coefficient of x^n
    // (1+x^2+x^4+...)^5 * (1+x+x^2+...)^11
    // 1/
    Mod ans(0);
    for (int mask = 0; mask < (1 << 11); ++mask) {
        int need = n, sign = 1;
        for (int bit = 0; bit < 11; ++bit) {
            if (((1 << bit) & mask))
                --need, sign *= -1;
        }
        if (need % 2)
            continue;
        need /= 2;
        // C(20 + need, need)
        Mod here(1);
        for (int i = 15 + need; i > need; --i) {
            here = here * Mod(i);
        }
        for (int i = 1; i <= 15; ++i) {
            here = here / Mod(i);
        }
        ans = ans + here;
    }
    cout << ans.x << '\n';
}       

Measured memory_bytes: 3660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int A,B;
   cin >> A >> B;
   for(int i = 1; i<=1000000;i++){
      int a = i*8/100;
      int b = i*10/100;
      if(a==A && b == B){
         cout << i << endl;
         return 0;
      }
   }
   cout << -1 << endl;
   return 0;
}


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

int main(){
	char c[1000][1001];
	int a;
	
	for (int i=0;i<1000;i++){
		scanf("%s",c[i]);
		//if (c[i][0] == '0' && c[i][1] == NULL) {
		if (strcmp(c[i],"0") == 0) {
			a = i;
			break; 
		}
	}
	for (int i=0;i<=a;i++){
		int sum = 0;
		for (int j=0;j<1000;j++){
			if (c[i][j] == '\0') break;
			sum += c[i][j] - 48;
		}
		if (sum != 0) cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
from collections import deque
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

class Node:
    def __init__(self):
        self.parent_id = -1
        self.depth = 0
        self.children = []

global nodes

def calc_depth(node_id,arg_depth):

    nodes[node_id].depth = arg_depth
    for child in nodes[node_id].children:
        calc_depth(child, arg_depth+1)


V = int(input())

nodes = []
#あらかじめ、V個のノードを用意しておく
for loop in range(V):
    node = Node()
    nodes.append(node)

#親子関係の取得
for loop in range(V):

    table = list(map(int,input().split()))
    node_id = table[0]
    num = table[1]

    for i in range(num):
        child_id = table[2+i]
        nodes[node_id].children.append(child_id)
        nodes[child_id].parent_id = node_id


#根を探して、深さを計算する
for i in range(V):
    if nodes[i].parent_id == -1:
        calc_depth(i,0)
        break


for i in range(V):

    print("node %d: parent = %d, depth = %d, "%(i,nodes[i].parent_id,nodes[i].depth),end = "")

    if nodes[i].parent_id == -1:
        print("root,",end = "")
    else:
        if len(nodes[i].children) == 0: #葉
            print("leaf,",end = "")
        else: #節
            print("internal node,",end = "")

    print(" [",end = "")
    print(', '.join(map(str,nodes[i].children)),end = "")
    print("]")



Measured memory_bytes: 41508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll q;
  cin >> q;
  string str1,str2;
  rep(_,q){
    cin >> str1;
    cin >> str2;
    ull len1 = str1.size();
    ull len2 = str2.size();
    vector<vector<ll>> dp(len1+1,vector<ll> (len2+1,0));
    rep(i,len1){
      rep(j,len2){
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
        if(str1[i] == str2[j]){
          chmax(dp[i+1][j+1],dp[i][j] + 1);
        }
      }
    }
    cout << dp[len1][len2] << endl;
  }
}


Measured memory_bytes: 10792
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const double PI = 3.14159265358979323846;
int main() {
	int A, B, H, M;
	scanf("%d %d %d %d", &A, &B, &H, &M);
	double a1 = PI * H / 6 + PI * M / 360, a2 = PI * M / 30;
	double ang = abs(a1 - a2);
	double ans = A * A + B * B - 2 * A * B * cos(ang);
	printf("%.10lf", sqrt(ans));
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    int sum = 0;
    int maxv = 0;
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        sum += p[i];
        maxv = max(maxv, p[i]);
    }
    cout << sum - maxv / 2 << endl;
}

Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())


a_kakudo = 90-(30*h + (1/2) * m)
b_kakudo = 90- 6 *m

#距離 = math.sqrt((x座標の差)*2 + (y座標の差)*2)
x = math.sqrt((a*math.cos(math.radians(a_kakudo)) - b*math.cos(math.radians(b_kakudo)))**2 + (a*math.sin(math.radians(a_kakudo)) - b*math.sin(math.radians(b_kakudo)))**2)
print(x)

Measured memory_bytes: 9504
def main():
  import sys
  input=sys.stdin.buffer.readline
  h,w=map(int,input().split())
  s=input()
  a=x=s[0]>>3
  b=y=5-a
  d=[(b,a)]
  for i in range(1,w):
    f=s[i]>>3
    b+=a^f
    a=f
    d+=(b,a),
  for _ in range(1,h):
    s=input()
    f=s[0]>>3
    y+=x^f
    b=y
    a=x=f
    p=[(b,a)]
    for i in range(1,w):
      f=s[i]>>3
      b+=a^f
      c,g=d[i]
      c+=f^g
      if b>c:b=c
      a=f
      p+=(b,a),
    d=p
  print(b+1>>1)
main()

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


int n;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    vl a(n);

    ll ans=1;
    //unsigned long long uans = 1;
    ll LIM=1000000000000000000;

    VIN(a);
    // REP(i,n){
    //     cin>>a[i];
    // }

    sort(ALL(a));
    if(a[0] == 0){
        cout<<"0"<<endl;
        return 0;
    }

    ll prv = ans;
    REP(i,n){
        ans *= a[i];

        if( (ans > LIM) || (ans < prv) ){
            ans = -1;
            cout << ans << endl;
            return 0;
        }

        prv = ans;
    }

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

Measured memory_bytes: 3976
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL;
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef pair<lli, lli> ii;
typedef long double ld;
typedef vector<lli> vi;

int main()
{   _
    map<string, int> mp;
    lli n; cin >> n; string s;
    fore(i,0 , n) {
        cin >> s;
        ++mp[s];
    }
    vector<string> v = {"AC", "WA", "TLE", "RE"};
    for(auto it : v) {
        cout << it << " x " << mp[it] << ENDL;
    }
    return 0;
}


Measured memory_bytes: 3668
s = gets.chomp!.to_i
p = Array.new(s,0)

for i in 0..s-1
	p[i]=gets.chomp!.to_i
	if !(p[i]>p[i-1]) then p[i],p[i-1]= p[i-1],p[i] end
end
p[s-1] = p[s-1]/2

answer = 0

for j in 0..s-1
	answer += p[j]
end

puts answer

Measured memory_bytes: 1788
using System;

class Problem {
    public static void Main() {
        var n = int.Parse(Console.ReadLine());
        var list = new int[2];
        for (var i = 0; i < n; i++) {
            var ins = Console.ReadLine().Split();
            var c = string.Compare(ins[0], ins[1]);
            list[0] += c > 0  ? 3 :
                       c == 0 ? 1 : 0;
            list[1] += c < 0  ? 3 :
                       c == 0 ? 1 : 0;
        }
        Console.WriteLine(list[0] + " " + list[1]);
    }
}


Measured memory_bytes: 9868
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


//ABC119
int main(void) {
  int n, k, i, cou=0, tmp;
  char s[10];
  scanf("%s", s);
  if(s[5]*10+s[6]-480-48>=5)printf("TBD");
  else printf("Heisei");
  return 0;
}


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

int main() {
    ll a, b;
    cin >> a >> b;
    rep(i,1010){
        if (i * 8 / 100 == a && i / 10 == b)
        {
            cout << i << endl;
            break;
        }
        else if (i == 1009)
        {
            cout << -1 << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll inf = 0x3f3f3f3f;
#define case(i) "Case #" << i << ": "
 
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
    out << '(' << p.first << ", " << p.second << ')';
    return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++) out << v[i] << ' ';
    if (l > 0) out << v[l - 1];
    return out;
}

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

    int x, y;
    cin >> x >> y;
    cout << (x ^ y) << endl;
}

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

using namespace std;

vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  for (int i = 0; i < H; i++) {
    cin >> A[i];
  }
  vector<vector<int>> grid(H, vector<int>(W, 0));
  queue<pair<int, int>> que;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A[i][j] == '#') {
        que.push(make_pair(i, j));
        grid[i][j] = 0;
      }
    }
  }
  while (!que.empty()) {
    pair<int, int> yx = que.front();
    que.pop();
    int x = yx.second, y = yx.first;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
      if (A[ny][nx] == '#' || grid[ny][nx] != 0) continue;
      grid[ny][nx] = grid[y][x] + 1;
      que.push(make_pair(ny, nx));
    }
  }
  int res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      res = max(res, grid[i][j]);
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 13456
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
a = LIST()
a.sort(reverse=True)
alc = 0
bob = 0
for i in range(n):
    if not i % 2:
        alc += a[i]
    else:
        bob += a[i]
print(alc - bob)

Measured memory_bytes: 60140
#include <iostream>

using namespace std;

int main() {

  int n;
  int x,y,h,w;

  int sum;


  while(cin >> n) {

    if(n==0) break;

    sum=0;

    for(int i=0;i<n;i++) {

      cin >> x >> y >> h >> w;

      if(x+y+h>160 || w>25) continue;

      else if(x+y+h>140 || w>20) sum+=1600;

      else if(x+y+h>120 || w>15) sum+=1400;

      else if(x+y+h>100 || w>10) sum+=1200;

      else if(x+y+h>80 || w>5) sum+=1000;

      else if(x+y+h>60 || w>2) sum+=800;

      else sum+=600;

    }

    cout << sum << endl;

  }

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  using Mint = ModInt<998244353>;
  int N, S;
  cin >> N >> S;
  Mint dp[S + 1];
  fill(dp, dp + S + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    Mint tmp[S + 1];
    for (int j = S; j >= 0; j--) {
      tmp[j] = Mint(2) * dp[j];
    }
    for (int j = S; j >= A; j--) {
      tmp[j] += dp[j - A];
    }
    for (int j = S; j >= 0; j--) {
      dp[j] = tmp[j];
    }
  }
  cout << dp[S] << endl;
  return 0;
}


Measured memory_bytes: 3672
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
B = [0 for _ in range(N+1)]
for a in A:
  B[a] = 1
mod = 10**9 + 7
dp = [-1 for _ in range(N+1)]
dp[0] = 1
dp[1] = 1
for i in range(2, N+1):
  if B[i-2] == 0 and B[i-1] == 1:
    dp[i] = dp[i-2]
  elif B[i-2] == 1 and B[i-1] == 0:
    dp[i] = dp[i-1]
  elif B[i-2] == 0 and B[i-1] == 0:
    dp[i] = dp[i-1] + dp[i-2]
  else:
    dp[i] = 0
  dp[i] %= mod
 
print(dp[-1])


Measured memory_bytes: 57176
#include <stdio.h>
#include <ctype.h>
int main(){
	
	char m[1201]={'0'},b[27]={ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
                     'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
                     'u', 'v', 'w', 'x', 'y', 'z' };
	int i,a[27]={0};
	
	i=0;
	while (scanf("%c", &m[i++]) != EOF){
	}
	
	/*for(i=0;m[i-1]!=EOF;i++){
		scanf("%c",&m[i]);
	}
	*/
	
	/*while(1){
		if(m[i]!=EOF){
			scanf("%c",&m[i++]);
		}
		else break;
	}*/
	for(int t=0;t<i;t++){
		if(isupper(m[t])){
			m[t]=tolower(m[t]);
		}
	}
	//printf("%s",m);
	for(int t=0;t<i;t++){
		if(m[t]>='a'&&m[t]<='z'){
			a[m[t]-'a']++;
		}
	}
	for(int t=0;t<26;t++){
		printf("%c : %d\n",b[t],a[t]);
	}
	return 0;
}

Measured memory_bytes: 2684
#include<stdio.h>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int c[12][1100];
char in[50];
int h[20];
int dp[1<<12][12];
int g[20][20];
int hv[20];
int main(){
	int a;
	while(scanf("%d",&a),a){
		int sz=0;
		map<string,int>m;
		for(int i=0;i<a;i++){
			for(int j=0;j<1100;j++)c[i][j]=9999999;
		}
		for(int i=0;i<a;i++){
			int p;scanf("%d",&p);
			for(int j=0;j<p;j++){
				int t;
				scanf("%s%d",in,&t);
				string tmp=in;
				int at=0;
				if(!m.count(tmp)){
					at=sz;
					m[tmp]=sz++;
				}else at=m[tmp];
				c[i][at]=min(c[i][at],t);
			}
		}
		int b;scanf("%d",&b);
		bool dame=false;
		for(int i=0;i<b;i++){
			scanf("%s",in);
			string tmp=in;
			if(!m.count(tmp)){dame=true;continue;}
			h[i]=m[tmp];
		}
		int e;scanf("%d",&e);
		for(int i=0;i<=a;i++)for(int j=0;j<=a;j++)g[i][j]=9999999;
		for(int i=0;i<=a;i++)g[i][i]=0;
		for(int i=0;i<e;i++){
			int p,q,r;scanf("%d%d%d",&p,&q,&r);
		//	printf("%d %d %d\n",p,q,r);
			g[p][q]=g[q][p]=min(g[p][q],r);
		}
		if(dame){
			printf("impossible\n");continue;
		}
		for(int k=0;k<=a;k++)for(int i=0;i<=a;i++)for(int j=0;j<=a;j++)
			g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
		int ret=0;
		for(int i=0;i<b;i++){
			hv[i]=9999999;
			for(int j=0;j<a;j++){
				hv[i]=min(hv[i],c[j][h[i]]);
			}
			ret+=hv[i];
			if(hv[i]>9888888)dame=true;
		}
		if(dame){printf("impossible\n");continue;}
		for(int i=0;i<(1<<a);i++)for(int j=0;j<=a;j++)
			dp[i][j]=9999999;
		for(int i=0;i<a;i++)dp[1<<i][i+1]=g[0][i+1];
		for(int i=0;i<(1<<a);i++){
			for(int j=0;j<=a;j++){
				dp[i][0]=min(dp[i][0],dp[i][j]+g[j][0]);
				for(int k=1;k<=a;k++){
					dp[i|(1<<(k-1))][k]=min(dp[i|(1<<(k-1))][k],dp[i][j]+g[j][k]);
				}
			}
		}
		int dist=9999999;
		for(int i=0;i<(1<<a);i++){
			bool ok=true;
			for(int j=0;j<b;j++){
				bool OK=false;
				for(int k=0;k<a;k++)if(hv[j]==c[k][h[j]]&&(i&(1<<k)))OK=true;
				if(!OK)ok=false;
			}
			if(ok){
				dist=min(dist,dp[i][0]);
			}
		}
		if(b==0)ret=dist=0;
		if(dist>9999988)printf("impossible\n");
		else printf("%d %d\n",ret,dist);
	}
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <math.h>
#include <string.h>



int main(void){
  int n,a,b,kaigai,kouho=0;
  char s[100005];
  
  scanf("%d %d %d", &n,&a,&b);
  	  scanf("%s", s);

  
  
  for(int i=0;i<n;i++){

    if(s[i] =='a'){
      if(kouho<(a+b)){
        printf("Yes\n");
        kouho++;
      }
      else printf("No\n");
    }
    else if(s[i] =='b'){
      if(kouho<(a+b) && kaigai <b){
	      kaigai++;
        printf("Yes\n");
        kouho++;
      }
      else printf("No\n");
    }
    else printf("No\n");
  }
    
    return 0;
}


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

signed main() {
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B(M);
    vector<vector<int>> A(N, vector<int> (M));
    for (int& x : B) cin >> x;
    for (auto& v : A) for (int& x : v) cin >> x;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int t = 0;
        for (int j = 0; j < M; j++) {
            t += A[i][j] * B[j];
        }
        ans += (t + C > 0);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = a - b;
    for(int i=0; i<=10000; i++)
    {
        if(ans >= c)
        {
            ans = ans - c;
        }
        else
            break;
    }
    cout << ans << endl;
}


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


using namespace std;


using vi=vector<int>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using ll=long long;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n), b(n);
		vpii ab(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d%d", &a[i], &b[i]);
			ab[i].first=a[i]+b[i];
			ab[i].second=i;
		}
		sort(ab.rbegin(), ab.rend());

		ll ans_t=0, ans_a=0;
		for(int i=0;i<n;i++)
		{
			if(i&1)
			{
				ans_a+=b[ab[i].second];
			}
			else
			{
				ans_t+=a[ab[i].second];
			}
		}
		printf("%lld\n", ans_t-ans_a);
	}

	return 0;
}


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

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

    int i;
    int ans = INT_MAX;
    for (i = 1; i < n; i++)
    {
        string a,b;
        int buf = 0;
        a = to_string(i);
        b = to_string(n - i);
        //cout << a << " " << b << endl;
        for (int j = 0; j < a.size(); j++)buf += a[j] - '0';
        for (int j = 0; j < b.size(); j++)buf += b[j] - '0';

        ans = min(ans, buf);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<limits>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    long double n,hoge;
	cin>>n>>hoge;
	vector<int> m(n);
	long double t=0;
	for(int i=0;i<n;i++){
		cin>>m[i];
		t+=m[i];
	}
	sort(m.begin(),m.end(),greater<int>());
	//cout<<t*(1/(4*hoge))<<endl;
	//cout<<m[hoge-1]<<endl;
	if(t*(1/(4*hoge))<=m[hoge-1]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

int main()
{
	double cx = 0, cy = 0, r = 0;
	int q = 0;
	double x1 = 0, y1 = 0, x2 = 0, y2 = 0;

	cin >> cx >> cy >> r >> q;

	for (int i = 0; i < q; i++) {
		cin >> x1 >> y1 >> x2 >> y2;

		double a = 0, b = 0, s = 0, t = 0, u = 0,
			v1 = 0, v2 = 0, w1 = 0, w2 = 0;

		if (x1 == x2) {
			v1 = x1;
			v2 = x2;
			w1 = cy - sqrt(r * r - (x1 - cx) * (x1 - cx));
			w2 = cy + sqrt(r * r - (x1 - cx) * (x1 - cx));
		}
		else {
			a = (y2 - y1) / (x2 - x1);
			b = (x2 * y1 - x1 * y2) / (x2 - x1);

			s = a * a + 1;
			t = a * b - a * cy - cx;
			u = cx * cx + (b - cy) * (b - cy) - r * r;

			v1 = (-t - sqrt(t * t - s * u)) / s;
			v2 = (-t + sqrt(t * t - s * u)) / s;
			w1 = a * v1 + b;
			w2 = a * v2 + b;
		}

		cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(8)
			 << v1 << " " << w1 << " " << v2 << " " << w2 << endl;
	}

	return 0;
}


Measured memory_bytes: 3280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.InputMismatchException;


public class Main {
	
	private static int[][] cache;
	private static int[] r;
	private static int[] c;
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = sc.nextInt();
		cache = new int[n][n];
		r = new int[n];
		c = new int[n];

		for (int i = 0; i < n; i++) {
			r[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		for (int j = 0; j < n; j++) {
			for (int i = 1; i <= n && i + j <= n; i++) {
				cache[i-1][i+j-1] = mcm(i, i + j);
//				System.out.println(i + " " + (i + j));
			}
		}

		System.out.println(cache[1 - 1][n - 1]);
		
		sc.close();
	}
	
	private static int mcm(int i, int j) {
		if (i == j) {
			return 0;
		} else {
			int min = Integer.MAX_VALUE;
			for (int k = 0; k < j - i; k++) {
				assert c[i+k-1] == r[i+k+1-1] : i + k + ":" + c[i+k-1] + "," + r[i+k+1-1];
				int result = cache[i-1][i+k-1] + r[i-1] * r[i+k+1-1] * c[j-1] + cache[i+k+1-1][j-1];
				if (result < min) {
					min = result;
				}
			}
			
			return min;
		}
	}

	private static class Scanner {
		InputStreamReader isr;
		BufferedReader br;
		StreamTokenizer st;
		
		Scanner (InputStream in) {
			isr = new InputStreamReader(in);
			br = new BufferedReader(isr);
			st = new StreamTokenizer(br);
		}
		
		String next() throws RuntimeException  {
			try {
				if (st.nextToken() != StreamTokenizer.TT_WORD) {
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}
			
			return st.sval;
		}
		
		int nextInt() throws RuntimeException {
			try {
				if (st.nextToken() != StreamTokenizer.TT_NUMBER) {
					throw new InputMismatchException();
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}
			
			return (int)st.nval;
		}

		void close() {
		}
	}
}

Measured memory_bytes: 18996
N=int(input())
triangle=[(i*(i-1))//2 for i in range(0,2*N+1)]
if not N in triangle:
    print('No')
else:
    print('Yes')
    k=triangle.index(N)
    print(k)
    count=0
    S=[[] for i in range(0,k)]
    for i in range(0,k):
        if i==0:
            S[i]=[j for j in range(1,k)]
            count=k-1
        else:
            for j in range(0,i):
                S[i].append(S[j][i-1])
            for j in range(0,k-1-i):
                S[i].append(count+1)
                count+=1
        print(k-1,*S[i])


Measured memory_bytes: 52592
(m,n=$_.split;p=*1..m.to_i;1.upto(n.to_i){|i|c=p.shift;/^#{(f="#{[:Fizz][i%3]}#{[:Buzz][i%5]}")[0]?f:i}$/!~gets&&p[0]||p<<c};puts p.sort*" ")while gets>?1

Measured memory_bytes: 6520
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;

int main(void){
	cin >> str;
	int res=0;
	for(int i=0;i<min(4,(int)str.size());i++){
		if(i==0 && str[i]=='Y')res++;
		if(i==1 && str[i]=='A')res++;
		if(i==2 && str[i]=='K')res++;
		if(i==3 && str[i]=='I')res++;
	}
	printf("%s\n",res==4?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split(' '))
groupA = set([1,3,5,7,8,10,12])
groupB = set([4,6,9,11])
groupC = set([2])
if set([x, y]) <= groupA or set([x, y]) <= groupB:
    print('Yes')
else: print('No')

Measured memory_bytes: 3060
open Printf
open Scanf

module Wf = struct
  type cost = C of int | Inf

  type t = int * cost array array

  let make n : t = let ar = Array.make_matrix n n Inf in
                   let rec loop i =
                     if i = n then ()
                     else begin
                         ar.(i).(i) <- C 0;
                         loop (i + 1)
                       end in
                   loop 0;
                   (n, ar)

  let set ((n, ar) : t) u v c = ar.(u).(v) <- C c

  let add x y =
    match x, y with
      C x, C y -> C (x + y)
    | _, _ -> Inf

  let compare x y =
    match x, y with
      C x, C y -> x - y
    | Inf, Inf -> 0
    | Inf, _ -> 1
    | _, Inf -> (-1)
                  
  let min x y =
    match compare x y with
      0 -> x
    | r when r > 0 -> y
    | _ -> x

  let max x y =
    match compare x y with
      0 -> x
    | r when r > 0 -> x
    | _ -> y
                
  let calc ((n, ar) : t) =
    let rec loop k i j =
      if k = n then ()
      else if i = n then loop (k + 1) 0 0
      else if j = n then loop k (i + 1) 0
      else let nc = add ar.(i).(k) ar.(k).(j) in
           ar.(i).(j) <- min nc ar.(i).(j);
           loop k i (j + 1) in
    loop 0 0 0

  let cost = function
      C x -> x
    | _ -> (-1)
end

module A = struct
  include Array

  let fold_lefti f iv ar = snd (fold_left (fun (i, r) v -> (i+1, f i r v)) (0, iv) ar)
end

let () =
  let solve n =
    let tbl = Wf.make 10 in
    let rec read x =
      if x = 0 then ()
      else
        let a, b, c = scanf "%d %d %d " (fun x y z -> (x, y, z)) in
        Wf.set tbl a b c;
        Wf.set tbl b a c;
        read (x - 1)
    in
    read n;
    Wf.calc tbl;
    A.fold_lefti (fun i (mi, mc) a ->
                  let sm = A.fold_left (fun ac c ->
                                        match c with
                                          Wf.Inf -> ac
                                        | _ -> Wf.add c ac
                                       ) (Wf.C 0) a in
                  match sm with
                    Wf.C 0 -> (mi, mc)
                  | _ when Wf.compare sm mc < 0 -> (i, sm)
                  | _ -> (mi, mc)
                 ) (-1, Wf.Inf) (snd tbl) |> (fun (x, y) -> printf "%d %d\n" x (Wf.cost y))
  in
  let rec loop () =
    let n = scanf "%d " (fun x -> x) in
    if n = 0 then ()
    else begin
        solve n;
        loop ()
      end
  in loop ()

Measured memory_bytes: 2372
import java.io.*;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			int sum = 0;
			String index = "0123456789";
			while ((buf = br.readLine())!=null) {
				for (int i=0;i<buf.length();i++) {
					String str = "";
					while (index.indexOf(buf.charAt(i))!=-1) {
						str = str+buf.charAt(i);
						if (i+1<buf.length()) i++;
						else break;
					}
					if (!str.equals("")) sum += Integer.parseInt(str);
				}
			}
			System.out.println(sum);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ios std::ios::sync_with_stdio(false);
map <string ,int>s;
map <string,int>::iterator it;
int main(){
    ios;
      
     int n;
     while(cin>>n)
     {
          s.clear();
          int maxs=0;
          for(int i=1;i<=n;i++)
            { 
                string str;cin>>str;
                s[str]++;
                maxs=max(maxs,s[str]  );
            }
            it = s.begin();
            string ss[n+1];
            int cnt=0;
            while(it!=s.end())
            {     
               if( it->second ==maxs )
                ss[++cnt]=it->first;
                it++;
            }
            sort(ss+1,ss+cnt+1);
          //  cout<<"****************"<<endl;
            for(int i=1;i<=n;i++)
                cout<<ss[i]<<endl;
            
     }
    return 0;
}


Measured memory_bytes: 25472
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n;cin>>n;
    vector<long long> a(n);
    int mi = 1<<30,ma = 0;
    for(int i=0;i<n;++i){
        int tmp;cin>>tmp;
        mi = min(mi,tmp);
        ma = max(ma,tmp);
        a[i] = tmp;
    }
    if(ma-mi > 1){
        cout<<"No"<<endl;
        return 0;
    }
    if(mi == ma){
        if(mi == n-1){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(2*mi <= n){
            cout<<"Yes"<<endl;
            return 0;
        }
        cout<<"No"<<endl;
        return 0;
    }
    long long k=0;
    for(int i=0;i<n;++i)k+=(a[i]==mi);
    n -= k;
    if(ma>=k+1 && 2*ma <= 2*k + n){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    int n1, n2, n3, n4;
    n1 = N/1000;
    n2 = (N/100)%10;
    n3 = (N/10)%10;
    n4 = N%10;

    if((n1==n2 and n2==n3) or (n2==n3 and n3==n4))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
#include <sstream>
#include <unordered_map>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;

char a[26];
string t;
int main(){
	ll n;
	cin>>n;
	string s[n];
	
	for(ll i=0; i<n; i++){
		cin>>s[i];
	}
	
	for (char c = 'a'; c <= 'z'; c++)
 	   a[c - 'a'] = c;
	
	for(int i=0; i<26; i++){
		bool ok=true;
		for(ll j=0; j<n; j++){
			
			if(s[j].find(a[i])== string::npos){
				ok=false;
				break;
			}
		}
		ll mn=1e18;
		if(ok==true) {
		
			for(ll j=0; j<n; j++){
				ll ans=0;
				for(ll k=0; k<s[j].size(); k++){
					if(s[j][k]==a[i]) ans++;
				}
				mn=min(mn,ans);
			}
			for(ll h=1; h<=mn; h++){
				t +=a[i];
			}
		}
	}
	cout<<t<<endl;
	
}


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

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


int main(){
	string s;
	cin>>s;
	if(s[0] >= 'A' && s[0] <= 'Z'){
		cout<<"A"<<endl;
	}else{
		cout<<"a"<<endl;
	}
    return 0;
}






Measured memory_bytes: 3624
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n=5;
    ll ans=1;
    for(int i=1;i<=5;i++)
    {
        ll c;
        cin>>c;
        if(c==0)
            ans=i;
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15500
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  string s;
  cin >> s;
  set<char> st;
  for(char a:s){
    st.insert(a);
  }
  bool is=false;
  for(char c='a';c<='z';c++){
    if(st.find(c)==st.end()){
      cout << c;
      is=true;
      break;
    }
  }
  if(!is) cout <<"None";
  cout << endl;
}


Measured memory_bytes: 512
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,m,h,l):
    res = []
    g = {i:[] for i in range(1,n+1)}
    for a,b in l:
        g[a].append(b)
        g[b].append(a)
    for i in range(1,n+1):
        if len(g[i]) == 0:
            res.append(i)
            continue
        maxheight = 0
        for p in g[i]:
            maxheight = max(maxheight, h[p-1])
        if h[i-1] > maxheight:
            res.append(i)
    return len(res)

n,m = mi()
h = mi()
l = mix(m)
print(main(n,m,h,l))

Measured memory_bytes: 51800
S=list(input())
S1 = S[:]
S2 = S[:]
N=len(S)
output=0
n1=0
n2=0
if N>1:
    for i in range(1,N):
        if int(S1[i])==int(S1[i-1]):
            S1[i]=str(1-int(S1[i]))
            n1 += 1
    n2 += 1
    S2[0]=str(1-int(S2[0]))
    for i in range(1,N):
        if int(S2[i])==int(S2[i-1]):
            S2[i]=str(1-int(S2[i]))
            n2 += 1

    output = min(n1,n2)

print(output)

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

int main(){
    ll n,a;
    cin>>n;
    map<ll,ll> mp;
    rep(i,n){
        cin>>a;
        mp[a]++;
    }
    ll cnt=0;
    for(auto x:mp) cnt+=x.second-1;
    if(cnt%2) cout<<n-cnt-1<<endl;
    else cout<<n-cnt<<endl;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  string s;
  while (cin >> s && s != "#") {
    int64 y, m, d;
    cin >> y >> m >> d;
    if (y > 31 || (y == 31 && m > 4)) {
      cout << "? " << y-30 << " " << m << " " << d << endl;
    } else {
      cout << s << " " << y << " " << m << " " << d << endl;
    }
  }
}


Measured memory_bytes: 3152
import java.awt.geom.Point2D;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		Point2D.Double a = getPoint(scanner);
		Point2D.Double b = getPoint(scanner);
		double sum = 0;
		while (scanner.hasNext()) {
			Point2D.Double c = getPoint(scanner);
			double A = a.distance(b);
			double B = b.distance(c);
			double C = c.distance(a);
			double z = (A + B + C) / 2;
			sum += Math.sqrt(z * (z - A) * (z - B) * (z - C));
			b = c;
		}
		System.out.println(sum);
	}

	private static double getArea(double a, double b, double c, double d) {
		return Math.abs(a * d - b * c) / 2;
	}

	public static Point2D.Double getPoint(Scanner scanner) {
		StringTokenizer tokenizer = new StringTokenizer(scanner.nextLine(), ",");
		return new Point2D.Double(Double.parseDouble(tokenizer.nextToken()),
				Double.parseDouble(tokenizer.nextToken()));
	}
}

Measured memory_bytes: 17152
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

mod = 10**9+7

def main():
    N = I()
    X = LI()
    D = [X[-1]-x for x in X[:-1]]

    f = 1
    for i in range(1,N):
        f *= i
        f %= mod

    ans = 0
    for i in range(N-1):
        tmp = (D[i] * f)%mod
        tmp *= pow(i+1,mod-2,mod)
        tmp %= mod
        ans += tmp
        ans %= mod
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 61336
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

N = INT()
A_ = LIST()
A = sorted([[A_[i], i+1] for i in range(N)])

B = [A[i][1] for i in range(N)]

print(*B)


Measured memory_bytes: 71660
#include<bits/stdc++.h>
#define MAX 100000

int n;
int a[MAX];

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

    int a;
    scanf("%d", &a);
    int t;
    for (int i=0; i<n-1; i++) {
        scanf("%d", &t);
        a ^= t;
    }

    if (a==0) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
#define inf (ll)1e18+1
using namespace std::chrono;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%mod;
    if(b%2==1){
        temp=(temp*a)%mod;
    }
    return temp;
}

ll inv_mod(ll a){
    return power(a,mod-2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll> ar(n);
    for(ll x=0;x<n;x++){
        cin>>ar[x];
    }
    sort(ar.begin(),ar.end());
    vector<ll> fact(n+1);
    fact[0]=1;
    for(ll x=1;x<=n;x++){
        fact[x]=(fact[x-1]*x)%mod;
    }
    vector<ll> inv(n+1);
    for(ll x=0;x<=n;x++){
        inv[x]=inv_mod(fact[x]);
    }
    ll ans=0;
    for(ll x=0;x<n;x++){
        ll rem=n-1-x;
        if(rem>=k-1){
            ll temp=(((ar[x]*fact[rem])%mod)+mod)%mod;
            temp=(temp * inv[k-1] + mod)%mod;
            temp=(temp * inv[rem-(k-1)] + mod)%mod;
            temp=-temp;
            temp+=mod;
            ans+=temp;
            ans%=mod;
        }else{
            break;
        }
    }
    for(ll x=n-1;x>=0;x--){
        ll rem=x;
        if(rem>=k-1){
            ll temp=(((ar[x]*fact[rem])%mod)+mod)%mod;
            temp=(temp * inv[k-1] + mod)%mod;
            temp=(temp * inv[rem-(k-1)] + mod)%mod;
            ans+=temp;
            ans%=mod;
        }else{
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
from Queue import Queue
mvL=((-1, 0), (-1, 1), (-1, 2), (-1, -1), (-1, -2), (-2, 0), (-2, 1), (-2, -1), (-3, 0))
mvR=((1, 0), (1, 1), (1, 2), (1, -1), (1, -2), (2, 0), (2, 1), (2, -1), (3, 0))
mv=(mvL,mvR)
while True:
    w,h=map(int,raw_input().split())
    if w==h==0:break
    INF=1000
    LEFT,RIGHT=0,1
    S=[raw_input().split() for i in range(h)]
    D=[[[INF,INF] for j in range(w)] for i in range(h)]
    Q=Queue()
    posT=[]
    for i in range(h):
        for j in range(w):
            if S[i][j]=="S":
                Q.put((j,i,LEFT))
                Q.put((j,i,RIGHT))
                D[i][j][LEFT]=D[i][j][RIGHT]=0
            elif S[i][j]=="T":
                posT.append((j,i))
    while not Q.empty():
        x,y,foot=Q.get()
        if foot==RIGHT:
            for dx,dy in mv[LEFT]:
                mx=x+dx
                my=y+dy
                if 0<=mx<w and 0<=my<h and S[my][mx]!="X" and S[my][mx]!="S":
                    if S[my][mx]=="T":
                        cost=D[y][x][RIGHT]
                    else:
                        cost=int(S[my][mx])+D[y][x][RIGHT]
                    if D[my][mx][LEFT]>cost:
                        D[my][mx][LEFT]=cost
                        Q.put((mx,my,LEFT))
        elif foot==LEFT:
            for dx,dy in mv[RIGHT]:
                mx=x+dx
                my=y+dy
                if 0<=mx<w and 0<=my<h and S[my][mx]!="X" and S[my][mx]!="S":
                    if S[my][mx]=="T":
                        cost=D[y][x][LEFT]
                    else:
                        cost=int(S[my][mx])+D[y][x][LEFT]
                    if D[my][mx][RIGHT]>cost:
                        D[my][mx][RIGHT]=cost
                        Q.put((mx,my,RIGHT))
    minCost=INF
    for x,y in posT:
        minCost=min(minCost,D[y][x][LEFT])
        minCost=min(minCost,D[y][x][RIGHT])
    print minCost if minCost!=INF else -1

Measured memory_bytes: 5344