akhauriyash/Code-Regression huggingface dataset:
import sys
from bisect import bisect_left

n, q = map(int, input().split())
lines = sys.stdin.readlines()
kkk = []
for line in lines[:n]:
    s, t, x = map(int, line.split())
    kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[n:]))

ans = [-1] * q
skip = [-1] * q
for x, s, t in kkk:
    ss = bisect_left(ddd, s - x)
    tt = bisect_left(ddd, t - x)
    while ss < tt:
        sk = skip[ss]
        if sk == -1:
            ans[ss] = x
            skip[ss] = tt
            ss += 1
        else:
            skip[ss] = max(sk, tt)
            ss = sk
print('\n'.join(map(str, ans)))


Measured memory_bytes: 99400
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int M;
    cin >> M;
    cout << 48 - M << endl;


    return 0;
}


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

long long MOD = 1000000007;

int main()
{
  std::string S;
  std::cin >> S;
  int N = S.size();

  int K = 13;
  std::vector<std::vector<long long>> dp(N + 1, std::vector<long long>(K, 0));

  dp[0][0] = 1;
  int m = 1;
  for (int i = 0; i < N; ++i) {
    char c = S[N - i - 1];

    if (c != '?') {
      int x = c - '0';
      for (int k = 0; k < K; ++k) {
        dp[i + 1][(k + x * m) % K] += dp[i][k];
        dp[i + 1][(k + x * m) % K] %= MOD;
      }
    } else {
      for (int x = 0; x < 10; ++x) {
        for (int k = 0; k < K; ++k) {
          dp[i + 1][(k + x * m) % K] += dp[i][k];
          dp[i + 1][(k + x * m) % K] %= MOD;
        }
      }
    }

    m *= 10;
    m %= K;
  }
  std::cout << dp[N][5] << std::endl;

  return 0;
}


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

typedef long long ll;
ll k;
string s;

ll pow (ll p, ll k)
{
	ll ret = 1;
	while (k)
	{
		if (k & 1)
			ret *= p;
		p *= p;
		k >>= 1;
	}
	return ret;
}

int main ()
{
	cin >> s;
	cin >> k;
	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == '1')
			--k;
		if (k <= 0)
		{
			cout << 1;
			break;
		}
		if (s[i] != '1')
		{
			cout << s[i];
			break;
		}
	}
}

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

int c[200001];

int main(){
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 1) c[b]++;
    if (b == n) c[a]++;
  }
  for (int i = 0; i <= n; i++) {
    if (c[i] >= 2) {
      printf("POSSIBLE\n");
      return 0;
    }
  }
    printf("IMPOSSIBLE\n");
  return 0;
}


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

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

    int ac = 0, wa = 0, tle = 0, re = 0; 
    vector<string> r(n);
    for (int i = 0; i < n; i++) {
        cin >> r.at(i);
        if(r.at(i) == "AC") ac++;
        else if (r.at(i) == "WA") wa++;
        else if (r.at(i) == "TLE") tle++;
        else if (r.at(i) == "RE") re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

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

int main()
{
    int N,L;
    vector<string> S(110);

    cin>>N>>L;
    for (int i=0;i<N;i++)
    {
        cin>>S[i];
    }

    sort(S.begin(),S.end());

    for (auto x : S)
        cout << x;


    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define INF 1e12
const int MOD = 1000000007;
typedef pair<ll,ll> P;

ll comb2(ll n){
    ll ans = 0;
    ans = n * (n - 1) / 2;
    return ans;
}

int main(void){
    ll N,sum = 0;
    cin >> N ;
    vector<ll> A(N+10);
    vector<ll> bucket(N+10,0);
    REP(i,N){
        cin >> A[i];
        A[i]--;
        bucket[A[i]]++; 
    }
    // すべての組み合わせ
    REP(i,N){
        sum += comb2(bucket[i]);
    }
    REP(i,N){
        ll ans = sum;
        ans -= comb2(bucket[A[i]]);     // sum - A[i]_C_2       全体からA[i]の組み合わせを引く
        ans += comb2(bucket[A[i]] - 1); // sum + (A[i]-1)_C_2　 A[i]の組み合わせを再計算し，結果に加える
        cout << ans << endl; 
    }
    return 0;
}

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

if __name__ == '__main__':
    main()

Measured memory_bytes: 66412
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n, k; cin>>n>>k;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    vector<ll> asum(n+1, 0);
    for(int i=0; i<n; i++) asum[i+1] = asum[i] + a[i];

    vector<ll> v;
    for(int i=1; i<=n; i++){
        for(int j=i; j<=n; j++){
            v.emplace_back(asum[j] - asum[i-1]);
        }
    }

    ll ans = 0;
    for(int bit=50; bit>=0; bit--){
        ans += (1LL << bit);
        int cnt = 0;
        for(int i=0; i<v.size(); i++){
            if((v[i] & ans) == ans) cnt++;
        }

        if(cnt < k) ans -= (1LL << bit);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0
 
z = zip(B,A)
s = sorted(z)
for i in range(N):
  if time + s[i][1] <= s[i][0]:
    time = time +  s[i][1]
    endflg[i] = 1
  else :
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 35640
from operator import itemgetter
from itertools import groupby
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
if D[0]!=0:
    print(0)
    exit()
ID = sorted(enumerate(D[1:]), key=itemgetter(1))
ans = 1
pn = 1

for i, (v, g) in enumerate(groupby(ID, key=itemgetter(1)), 1):
    if i != v:
        ans = 0
    n = len(list(g))
    ans = (ans * pow(pn, n, mod)) % mod
    pn = n

print(ans)


Measured memory_bytes: 19364
def main():
    LIST=[]
    for i in range(int(input())):
        LIST.append(i+1)

    for j in range(int(input())):
        a,b=map(int,input().split(","))
        LIST[a-1],LIST[b-1]=LIST[b-1],LIST[a-1]

    for i in LIST:
        print(str(i))
            
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7720
#include <stdio.h>

int main(void)
{
	double x[3], y[3], px, py;
	double s, s1, s2, s3;
	
	
	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", x, y, x+1, y+1, x+2, y+2, &px, &py) != EOF)
	{
		s =  ((x[1] - x[0]) * (y[2] - y[0]) - (y[1] - y[0]) * (x[2] - x[0])) / 2;
		s1 = ((x[1] - x[0]) * (py - y[0]) - (y[1] - y[0]) * (px - x[0])) / 2;
		s2 = ((px - x[0]) * (y[2] - y[0]) - (x[2] - x[0]) * (py - y[0])) / 2;
		s3 = ((x[1] - px) * (y[2] - py) - (x[2] - px) * (y[1] - py)) / 2;
		
		if (s < 0){
			s *= -1;
		}
		if (s1 < 0){
			s1 *= -1;
		}
		if (s2 < 0){
			s2 *= -1;
		}
		if (s3 < 0){
			s3 *= -1;
		}
		
		if (s == s1 + s2 + s3){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(7);
	
	
	string s, t;
	
	int a, b, c, d;
	
	int n, m;
	
	cin>>n>>a>>b;
	
	cout<<min(a,b)<<" "<<max(0ll,a+b-n)<<endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>

constexpr double PI = 3.141592653589793;

int main()
{
    double r;
    std::cin >> r;
    
    std::cout << std::fixed;
    std::cout << std::setprecision(5) << (r * r * PI) << " " << (r * 2.0 * PI) << std::endl;
    
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    int ans=0;
    cin>>s>>t;
    rep(i,s.size()) if(s[i]!=t[i]) ans++;
    cout<<ans;
}

Measured memory_bytes: 3796
#include<iostream>
#include<string>
#include<vector>
#include <cmath>


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

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    if(A>=13){cout << B;}
    else if(A<=5){cout<<0;}
    else{cout << B/2;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 29
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

ll N, M;

class UnionFind {
    public:
    vector<int> par;
    UnionFind(int n) : par(n) {
        for(int i = 0; i < n; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin >> N >> M;
    vector<ll> p(N), x(M), y(M);
    REP(i, N) {
        cin >> p[i];
        p[i]--;
    }
    REP(i, M) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    UnionFind uf = UnionFind(N);    
    REP(i, M) {
        uf.unite(x[i], y[i]);
    }
    map<int, int> d;
    // priv(p);
    // priv(uf.par);
    REP(i, N) {
        int root = uf.root(i);
        if(d.find(uf.root(i)) == d.end()) d[root] = 0;
        if(uf.same(i, p[i])) d[root]++;
    }
    int ans = 0;
    for(auto p : d) ans += p.second;
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7680
#include <iostream>
#include <algorithm>
#include <vector>
#include "cmath"
#include <cstdlib>

using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int> > a(N, vector<int>(3, 0));
    vector<vector<int> > dp(N, vector<int>(3, 0));
    vector<vector<int> > tmp{{1, 2}, {0, 2}, {0, 1}};

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    dp[0] = a[0];
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = a[i][j] + max(dp[i-1][tmp[j][0]], dp[i-1][tmp[j][1]]);
        }
    }

    cout << max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2]) << endl;

    return 0;
}

Measured memory_bytes: 11264
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    string s;cin>>s;
    cout<<(char)(s[0]+1)<<endl;
    
    return 0;
}


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

int main() {
	int n,rieki;
	cin >> n;
  vector<int> vec(n);
  vector<int> cash(n);
  rieki=0;
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  for(int k=0;k<n;k++){
    cin>>cash.at(k);
  }
  for(int l=0;l<n;l++){
    if(vec.at(l)-cash.at(l)>0){
      rieki+=(vec.at(l)-cash.at(l));
    }
  }
  cout<<rieki<<endl;
}


Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._
  val n = readInt
  for (_ ← 0 until n){
    val Array(a, b) = readLine.trim.split(' ')
    println(
      solve(a, b, readLine.trim.split(' ').toList)
    )
  }

  def solve(a: String, b: String, deck: List[String]): String = {
    def take(deck: List[String], score: Int, hasAce: Int = 0): Int = {
      if (score <= 16) take(deck.tail, score + deck.head.asCard, hasAce + (if (deck.head == "A") 1 else 0))
      else if (score == 17 && hasAce > 0) take(deck.tail, score + deck.head.asCard, hasAce + (if (deck.head == "A") 1 else 0))
      else if (score > 21 && hasAce > 0) take(deck, score - 10, hasAce - 1)
      else score
    }
    if (a.asCard + b.asCard == 21) "blackjack"
    else take(deck, a.asCard + b.asCard, List(a, b).count(_ == "A")) match {
      case s if s <= 21 ⇒ s.toString
      case _ ⇒ "bust"
    }
  }

  implicit class WrappedChar(val value: String) extends AnyVal {
    def asCard: Int = if (value.head.isDigit) value.head.asDigit else if (value.head == 'A') 11 else 10
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
    @inline
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}


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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

# define int long long

int x;
int wuc[N];

signed main()
{
    read(x);
    Rep(i,1,3000)wuc[i]=i*i*i*i*i;
    Rep(i,0,3000)
        Rep(j,0,3000)
            if(wuc[i]+wuc[j]==x)return printf("%lld %lld\n",i,-j),0;
    Rep(i,0,3000)
        Rep(j,0,3000)
            if(wuc[i]-wuc[j]==x)return printf("%lld %lld\n",i,j),0;
    return 0;
}

Measured memory_bytes: 3788
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 100000;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int c[6][6];

int32_t main() {
	FAST;

	int h, w, k;
	cin >> h >> w >> k;

	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			c[i][j] = (s[j] == '.' ? 0 : 1);
		}
	}

	int ans = 0;

	for (int m1 = 0; m1 < (1 << h); m1++) {
		for (int m2 = 0; m2 < (1 << w); m2++) {
			int cnt = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (!(((m1 >> i) & 1) || ((m2 >> j) & 1)) && c[i][j]) cnt++;
				}
			}
			if (cnt == k) ans++;
		}
	}	

	cout << ans;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int n,m;
double ans;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
	{
		int x=i,gs=0;
		double xu=1.0;
		while(x<m)
		{
			x=x*2;
			gs++;
		}
		for(int j=1;j<=gs;j++)xu=xu*0.5;
		ans+=(double)1/n*xu;
	}
	printf("%.12lf",ans);
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            var ab = Console.ReadLine().Split(' ');
            ans += int.Parse(ab[1]) - int.Parse(ab[0]) + 1;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
import sys

def read_str(): return sys.stdin.readline().strip()
def read_int(): return int(sys.stdin.readline().strip())
def read_ints(): return map(int, sys.stdin.readline().strip().split())
def read_str_split(): return list(sys.stdin.readline().strip())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))

def Main():
    n, k = read_ints()
    s = read_str()
    cnt = s.count('RL') + s.count('LR') + 1
    cnt = min(n-1, n-cnt+2*k)
    print(cnt)

if __name__ == '__main__':
    Main()


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

int main(){
    int H,R;

    cin >> H >> R;

    if(H+R>0){
        cout << '1' << endl;
    }

    else if(H+R<0){
        cout << "-1" << endl; 
    }

    else{
        cout << "0" << endl;
    }
    

    return 0;
}


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

int main(int argc, char const *argv[])
{
    int n,x;
    int L[120] = {0};
    cin >> n >> x;
    for(int i=1; i<=n; i++){
        cin >> L[i];
    }
    int ansTime = 1;
    int d = 0;
    int flag = 0;
    for(int i=0; i<= n; i++){
        d = d + L[ansTime];
        if(d > x){
            flag = 1;
            break;
        }
        ansTime++;
    }
    if(flag == 0){
        ansTime --;
    }
    cout << ansTime << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int A, B, Q;
    ll x;
    cin >> A >> B >> Q;
    vector<ll> SH(A + 2);
    vector<ll> TE(B + 2);
    ll d1, d2, ret;
    SH[0] = -inf;
    rep(i, 1, A + 1) cin >> SH[i];
    SH[A + 1] = inf;
    TE[0] = -inf;
    rep(i, 1, B + 1) cin >> TE[i];
    TE[B + 1] = inf;

    rep(i, Q) {
        cin >> x;
        auto sl = lower_bound(SH.begin(), SH.end(), x);
        auto tl = lower_bound(TE.begin(), TE.end(), x);
        ret = inf;
        rep(j, 2) {
            rep(k, 2) {
                ll d1 = abs(*(sl - j) - x) + abs(*(sl - j) - *(tl - k));
                ll d2 = abs(*(tl - k) - x) + abs(*(sl - j) - *(tl - k));
                ret = min(ret, min(d1, d2));
            }
        }
        printf("%lld\n", ret);
    }
}

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

string s;
char buf[500010];
int fail1[500010], fail2[500010]; 
int n;

void getfail(string &s, int *fail){
	fail[0] = -1;
	int j = -1;
	for (int i = 1; i <= n; i++){
		while (~j && s[j] != s[i - 1]) j = fail[j];
		fail[i] = ++j;
	}
}

int main(){
	scanf("%s", buf), s = buf;
	n = s.length();
	getfail(s, fail1);
	int len = n % (n - fail1[n]) == 0 && (n - fail1[n] <= n / 2) ? n - fail1[n] : -1;
	if (len == -1){
		printf("1\n1\n");
		return 0;
	}
	if (len == 1){
		printf("%d\n1\n", n);
		return 0;
	}
	printf("2\n");
	reverse(s.begin(), s.end());
	getfail(s, fail2);
	int ans = 0;
	for (int i = 1; i < n - 1; i++){
		if ((!fail1[i] || i % (i - fail1[i])) && (!fail2[n - i] || (n - i) % ((n - i) - fail2[n - i]))) ans++;
	}
	printf("%d\n", ans + 1);
	return 0;
}


Measured memory_bytes: 5120
# coding: utf-8


def rotate(strg, n):
    return strg[n:] + strg[:n]


def main():
    s = input()
    t = input()

    for i in range(len(s)):
        if rotate(s, i) == t:
            print("Yes")
            return

    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
 
using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;
 
ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
 
const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
std::vector<edge>v[1000];
 
int main() {
	ll a, b, c, n;
	string s, t, r;
	cin >> a >> b >> c;
	if (a + b >= c)cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[1001][1001];
int wi[8]={1,1,0,-1,-1,-1,0,1};
int wj[8]={0,-1,-1,-1,0,1,1,1},n=0,m=0;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='#')
            {
                cout<<'#';
            }
            else
            {
                int num=0;
                for(int m=0;m<8;m++)
                {
                    if(a[i][j]!='.')
                    {
                        continue;
                    }
                    if(a[i+wi[m]][j+wj[m]]=='#')
                    {
                        num++;
                    }
                }
                cout<<num;
            }
        }
        cout<<endl;
    }
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> x(M), y(M);
    REP(i, M)
    {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    vector<ll> countBall(N, 1);
    vector<bool> isRed(N, false);
    isRed[0] = true;

    REP(i, M)
    {
        if (isRed[x[i]])
        {
            isRed[y[i]] = true;
            if (countBall[x[i]] == 1)
            {
                isRed[x[i]] = false;
            }
        }
        countBall[x[i]]--;
        countBall[y[i]]++;
    }
    ll ans = 0;
    REP(i, N)
    {
        if (isRed[i])
        {
            ans++;
        }
    }

    cout << ans << endl;
}


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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	String solve(int n, int[] cnt){
		
		int diam = n - 1;
		while (cnt[diam] == 0) {
			diam--;
		}
		
		if (cnt[diam] == 1) {
			return "Impossible";
		}
		
		if (diam == 1) {
			return (n == 2 ? "Possible" : "Impossible");
		}
		
		int cant = (diam - 1) / 2;
		for (int i = 1; i <= cant; i++) {
			if (cnt[i] != 0) {
				return ("Impossible");
			}
		}
		
		if (diam % 2 == 0) {
			if (cnt[diam / 2] != 1) {
				return ("Impossible");
			}
			for (int i = diam / 2 + 1; i <= diam; i++) {
				if (cnt[i] < 2) {
					return ("Impossible");
				}
			}
		} else {
			if (cnt[diam / 2 + 1] != 2) {
				return "Impossible";
			}
			for (int i = diam / 2 + 2; i <= diam; i++) {
				if (cnt[i] < 2) {
					return ("Impossible");
				}
			}
		}
		
		return "Possible";
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int n = nextInt();
		int[] cnt = new int[n];
		for (int i = 0; i < n; i++) {
			int x = nextInt();
			cnt[x]++;
		}
		out.println(solve(n, cnt));
		
//		int n = 5;
//		
//		for (int c1 = 0; c1 <= n; c1++)
//			for (int c2 = 0; c1 + c2 <= n; c2++)
//				for (int c3 = 0; c1 + c2 + c3 <= n; c3++) {
//					
//					int[] tmp = {0, c1, c2, c3, n - c1 - c2 - c3};
//					if (solve(n, tmp).equals("Possible")) {
//						System.err.println(Arrays.toString(tmp));
//					}
//					
//				}
		
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

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

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

Measured memory_bytes: 8276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
    int count = 0;
    int N, D;
    cin >> N >> D;
    int x[N][D];

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

    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            int dist=0;
            for(int l=0;l<D;l++){
                dist += (x[i][l] - x[j][l])*(x[i][l] - x[j][l]);
            }
            for(int l=1;l<127;l++){
                if(l*l == dist){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

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

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

    int n; cin>>n;
    string s;
    map<string, int> m;
    while(n--){
        cin>>s;
        m[s]++;
    }

    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";
    return 0;
}

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

int main() {
    ll X;
    cin >> X;

    ll A = 0, B = 0;
    for (ll a = 0; a <= 1000; a++) {
        for (ll b = -1000; b <= 1000; b++) {
            ll a5 = a * a * a * a * a;
            ll b5 = b * b * b * b * b;
            if (a5 - b5 == X) {
                A = a;
                B = b;
            }
            if (A != 0 && B != 0) break;
        }
        if (A != 0 && B != 0) break;
    }

    cout << A << " " << B << endl;

    return 0;
}



Measured memory_bytes: 3632
N,X,M=map(int,input().split())

term_set={X}
term_list=[X]
for i in range(1,N):
  term1=term_list[-1]
  term2=term1**2%M
  term_list.append(term2)
  if term2 in term_set:
    break
  else:
    term_set.add(term2)
#print(term_list)
#print(len(term_list))

if len(term_list)==N:
  print(sum(term_list))
else:
  c2=len(term_list)-1
  c1=term_list.index(term_list[-1])
  #print(c1,c2)
  
  answer=sum(term_list[:c1])
  sum_cycle=sum(term_list[c1:c2])
  
  num_cycle=(N-c1)//(c2-c1)
  rem_cycle=(N-c1)%(c2-c1)
  answer+=sum_cycle*num_cycle
  answer+=sum(term_list[c1:c1+rem_cycle])
  print(answer) 

Measured memory_bytes: 77332
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX = 100000;

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	for (int i = 0; i < a; i++) cin >> p[i];
	for (int i = 0; i < b; i++) cin >> q[i];
	for (int i = 0; i < c; i++) cin >> r[i];
	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());
	p.resize(x);
	q.resize(y);
	//p.reserve(3 * MAX);
	p.insert(p.end(), q.begin(), q.end());
	p.insert(p.end(), r.begin(), r.end());
	sort(p.begin(), p.end(), greater<int>());
	long long ans = 0;
	for (int i = 0; i < x+y; i++) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2808
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
using edge_to = std::pair<long long, long long>; // {weight, to}
using edge = std::vector<long long>; // {weight, from, to}

std::vector<edge> edges(0); // 選んだ順に辺を格納　逆順に辿って経路復元
std::vector<long long> dijkstra(
	long long V,
	long long E,
	long long r,
	std::vector<std::vector<edge_to>>& adj_list
) {
	std::vector<long long> ret(V, LLONG_MAX);
	ret[r] = 0;
	using P = std::pair<long long, edge>;
	std::priority_queue<P, std::vector<P>, std::greater<P>> pq;
	for (auto i : adj_list[r]) {
		pq.push({i.first, {i.first, r, i.second}});
	}
	while (pq.size()) {
		while (pq.size() && ret[pq.top().second[2]] < LLONG_MAX) pq.pop();
		if (pq.empty()) break;
		long long w = pq.top().first; edge e = pq.top().second;
		pq.pop();
		ret[e[2]] = w;
		edges.push_back(e);
		for (auto i : adj_list[e[2]]) {
			if (ret[i.second] < LLONG_MAX) continue;
			long long next_w = ret[e[2]] + i.first;
			edge next_e = {i.first, e[2], i.second};
			pq.push({next_w, next_e});
		}
	}
	return ret;
}

int main() {
	long long V, E, r;
	std::cin >> V >> E >> r;
	std::vector<std::vector<edge_to>> adj_list(V);
	for (long long i = 0; i < E; i++) {
		long long s, t, d;
		std::cin >> s >> t >> d;
		adj_list[s].push_back({d, t});
	}
	std::vector<long long> dist = dijkstra(V, E, r, adj_list);
	for (auto i : dist) {
		if (i == LLONG_MAX) std::cout << "INF\n";
		else std::cout << i << '\n';
	}
}


Measured memory_bytes: 32668
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let n=tn()
  tn()
  for(let i=0;i<n;i++){
    let a=ts()
    to(a)
    to(a)
  }
}
main()

Measured memory_bytes: 9264
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
score_of_alice = score_of_bob = 0
for i, a_i in enumerate(a):
    if i % 2 == 0:
        score_of_alice += a_i
    else:
        score_of_bob += a_i

print(score_of_alice - score_of_bob)


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

int ketasa(int x,long int y){
    int x_count=0;
    int y_count=0;
    while(x>0){
        x/=10;
        x_count++;
    }
    while(y>0){
        y/=10;
        y_count++;
    }

    return y_count;
}

int main(){
    long int N;
    cin>>N;
    long int saisyo=100;
    for(long int i=1;i*i<=N;i++){
        if(N%i==0){
             long int keta=ketasa(i,N/i);
        saisyo=min(saisyo,keta);
        }
    }
    
  
    cout<<saisyo<<endl;



}
    


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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=0; i<n; i++){
		int l,r;
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    ll single = 0;
    ll doublei = 0;
    for(ll i=A; i<=B; i++){
        string s = to_string(i);
        reverse(s.begin(), s.end());
        if(s[0] == '0') continue;

        ll j = stoi(s);

        if(i == j){
            single++;
            continue;
        }
        // if(j >= A && j <= B){
        //     cout << j << endl;
        //     doublei++;
        //     continue;
        // }
    }
    cout << single << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
n, m, *ab = map(int, open(0).read().split())
from_1, to_n = set(), set()
for a, b in zip(*[iter(ab)] *2):
    if a == 1: from_1.add(b)
    if b == n: to_n.add(a)
print('POSSIBLE' if from_1 & to_n else "IMPOSSIBLE")


Measured memory_bytes: 46660
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

using namespace std;

bool is_prime(int n) {
  for (int i = 2; i < (int) sqrt(n); ++i) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  int x;
  cin >> x;
  for (int i = x; ; ++i) {
    if (is_prime(i)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,ans=inf,cur; cin>>n;
    vector<int> x(n,0);
    rep(i,n) cin>>x[i];
    for(int i=1;i<=100;i++){
        cur=0;
        rep(j,n) cur+=(x[j]-i)*(x[j]-i);
        ans=min(ans,cur);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const int N = 101010;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    ll cnt = 0;
    set<tuple<int,int,int>> s;
    while(a%2 != 1 && b%2 != 1 && c%2 != 1) {
        tuple<int,int,int> t = make_tuple(a,b,c);
        if(s.find(t) != s.end()) {
            cout << -1; return 0;
        }
        s.insert(make_tuple(a,b,c));
        int q, r, s;
        q = b/2 + c/2;
        r = a/2 + c/2;
        s = a/2 + b/2;
        a = q; b = r; c = s;
        cnt++;
    }
    cout << cnt;
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x,y;
    cin >>n >> k >> x>> y;
    if(n>k)
    {
        cout << (k*x)+((n-k)*y) << endl;
    }
    else
    {
        cout << n*x << endl;
    }
    
}

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

int main(){
    char s;
    cin >> s;
    // scanf("%c", &s);
    s=s+1;
    printf("%c",s);
    // cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    vector<ll> b(n, 0);
    for(ll& val: a)
        cin >> val;
    for(ll& val: b)
        cin >> val;
    ll sA = accumulate(a.begin(), a.end(), 0LL);
    ll sB = accumulate(b.begin(), b.end(), 0LL);
    if (sA > sB)
        cout << "No" << endl;
    else {
        ll quota = sB - sA;
        ll cast_b = 0;
        vector<ll> buffer_a;
        for(int i = 0; i < n; i++) {
            if (a[i] < b[i])
                buffer_a.push_back(b[i]-a[i]);
            if (a[i] > b[i])
                cast_b += (a[i]-b[i]);
        }
        if (cast_b > quota) {
            cout << "No" << endl;
        } else {
            ll remain = quota - cast_b;
            ll after = 0;
            for(ll val: buffer_a) {
                if (cast_b > 0 && val > 1) {
                    ll sub = min(cast_b, val/2);
                    cast_b -= sub;
                    val -= sub*2;
                }/*
                while(cast_b > 0 && val > 2) {
                    cast_b--;
                    val-=2;
                }*/
                after += val;
            }
            if (cast_b > 0) {
                cout << "No" << endl;
            } else {
                if (after == remain) {
                    cout << "Yes" << endl;
                } else {
                    cout << "No" << endl;
                }
            }
        }
    }
    return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h> 
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	ll a[200]={0};
	ll mod=1e9+7;
	for(ll i=0;i<s.size();i++)
	{
		a[s[i]-'a']++;
	 } 
	 ll ans=1;
	 for(ll i=0;i<26;i++)
	 {
	 	ans*=a[i]+1;
	 	ans%=mod;
	 }
	 cout<<ans-1;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,a,b;

int main(){
	cin>>n>>a>>b;
	cout<<n/(a+b)*a+min(n%(a+b),a)<<endl;
}

Measured memory_bytes: 256
//vacations at coder
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define N 100001
int arr[N][3];
vector<vector<long long> > dp(N,vector<long long>(3,-1));
long long fun(int i, int j){
    if(i<0) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    
    if(j==0){
        dp[i][j]= max( arr[i][0]+ fun(i-1,1), arr[i][0]+ fun(i-1,2));
        
    }
     if(j==1){
        dp[i][j]= max( arr[i][1]+ fun(i-1,0), arr[i][1]+ fun(i-1,2));
        
    }
     if(j==2){
        dp[i][j]= max( arr[i][2]+ fun(i-1,1), arr[i][2]+ fun(i-1,0));
        
    }
    return dp[i][j];
}





int main(){
    int n;
    cin>>n;
   
    for(int i=0;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        arr[i][0]=a;
        arr[i][1]=b;
        arr[i][2]=c;
    }
    int mins=0;
    
    long long ans1= fun(n-1,0);
    long long ans2= fun(n-1,1);
    long long ans3= fun(n-1,2);
    
    long long min1= ans1>ans2?ans1:ans2;
    long long min2= min1>ans3?min1:ans3;
    cout<<min2<<endl;
    //cout<<dp[n-1][0]<<endl<<dp[n-1][1]<<endl<<dp[n-1][2]<<endl;
    
    
}

Measured memory_bytes: 13184
n = int(input())
x = str(input())

one = x.count("1")
X = int(x, 2)

if one==1:
    for i in range(n):
        if x[i]=="1":
            print(0)
        elif i==n-1:
            print(2)
        else:
            print(1)
    
    
elif one>1:
    
    Xp = X % (one+1)
    Xm = X % (one-1)

    def f(x):
        if x==0:
            return 0
        return 1+f(x%bin(x).count("1"))

    for i in range(n):
        
        if x[i]=="0":
            c = pow(2, n-i-1, one+1)
            print(f((Xp+c)%(one+1))+1)
        else:
            c = pow(2, n-i-1, one-1)
            print(f((Xm-c)%(one-1))+1)
else:
    for i in range(n):
        print(1)

Measured memory_bytes: 79640
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    vector<string> vec(4);
    vec[0] = "dream";
    vec[1] = "dreamer";
    vec[2] = "erase";
    vec[3] = "eraser";
    bool flag = false;
    while(s.length() > 0) {
        rep(i, 4) {
            if (s.length() < vec[i].length()) continue;
            if (s.substr(s.length() - vec[i].length(), vec[i].length()) == vec[i]) {
                s.erase(s.length() - vec[i].length(), vec[i].length());
                flag = true;
                break;
            }
        }
        if (!flag) {
            cout << "NO" << endl;
            return 0;
        } else {
            flag = false;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())
l = []
for i in range(n):
    x,y,z = map(int,input().split())
    l.append([x,y,z])

dp = []
for _ in range(n):
    dp.append([0,0,0])

dp[0] = l[0][0],l[0][1],l[0][2]
for i in range(n-1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][j] = max(dp[i+1][j],dp[i][k]+ l[i+1][j])


print(max(dp[n-1]))

Measured memory_bytes: 75480
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b;
    a = sc.nextInt();
    b = sc.nextInt();

    System.out.printf("%d %d %f%n", a / b, a % b, a / (double)b);
/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

int n,m,a[10],dp[10005];
int c[10]={0,2,5,5,4,5,6,3,7,6};

int main() {
	cin >> n >> m;
	for(int i = 0; i < m; i++) cin >> a[i];
	dp[0]=1;
	for(int i = 0; i < m; i++){
		for(int j = c[a[i]]; j <= n;j++)
			dp[j] = max(dp[j],dp[j-c[a[i]]]+1);
	}
	sort(a,a+m);
	m--;
	while(n>0){
		if(n-c[a[m]] >= 0 && dp[n]==dp[n-c[a[m]]]+1){
			n -= c[a[m]];
			cout<<a[m];
		}else m--;
	}
	return 0;
}


Measured memory_bytes: 256