akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int n, p[55], i, j, c=0, d=0;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d", &p[i]);
    }
    for(i=0; i<n; i++)
    {
        if(p[i]!=i+1)
        {
            c++;
        }
    }
    if(c>2)
    {
        printf("NO");
    }
    else if(c==0)
    {
        printf("YES");
    }
    else
    {
        for(i=0; i<n-1; i++)
        {
            for(j=1; j<n; j++)
            {
                if(p[i]!=i && p[j]!=j && p[i]==j)
                {
                    d++;
                    break;
                }
            }
        }
        if(d==0)
        {
            printf("NO");
        }
        else
        {
            printf("YES");
        }
    }
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int N;
vector<int>G[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int x,y;cin>>x>>y;
		x--,y--;
		G[x].push_back(i);
		G[y].push_back(i);
	}
	UF uf(N);
	int cnt=N;
	for(int i=0;i<N;i++)
	{
		if(G[i].size()!=2)
		{
			cout<<-1<<endl;
			return 0;
		}
		cnt-=!uf.unite(G[i][0],G[i][1]);
	}
	cout<<cnt<<endl;
}



Measured memory_bytes: 9736
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
    const T INF = numeric_limits<T>::max();
    using P     = pair<T, int>;
    int n       = G.size();
    vector<T> d(n, INF);
    vector<int> b(n, -1);
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.emplace(d[s], s);
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto &e : G[v]) {
            int u = e.first;
            T c   = e.second;
            if (d[u] > d[v] + c) {
                d[u] = d[v] + c;
                b[u] = v;
                q.emplace(d[u], u);
            }
        }
    }
    return d;
}

int main() {
    double xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int n;
    cin >> n;
    vector<double> x(n + 2), y(n + 2), r(n + 2);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> r[i];
    }
    x[n] = xs, x[n + 1] = xt;
    y[n] = ys, y[n + 1] = yt;
    r[n] = 0, r[n + 1] = 0;

    vector<vector<pair<int, double>>> edges(n + 2);
    for (int i = 0; i < n + 2; ++i) {
        for (int j = 0; j < n + 2; ++j) {
            edges[i].emplace_back(
                j, max(0.0, sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - r[i] - r[j]));
        }
    }
    auto dist = dijkstra(n, edges);
    cout << fixed << setprecision(10) << dist[n + 1] << "\n";
    return 0;
}

Measured memory_bytes: 22008
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
su = sum(A)
check = True
for i in range(M):
  if A[i] < su * 1/(4*M):
    check = False
if check:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9076
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from time import time
from random import randrange
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    start = time()

    for i in range(n):
        if A[i] != B[i]:
            continue
        while time() - start < 1.8:
            j = randrange(n)
            if A[i] != B[j] and A[j] != B[i]:
                B[i], B[j] = B[j], B[i]
                break
        else:
            print("No")
            return

    print("Yes")
    print(*B)
resolve()

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

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

struct line {
	ll m, c;
	line(ll _m, ll _c) {
		m = _m;
		c = _c;
	}
	ll value_at(ll x) const {
		return m * x + c;
	}
	pair<ll, ll> intersect(const line& l) const {
		return {l.c - c, m - l.m};
	}
};

struct CHT {
	deque<line> lines;

	CHT() = default;

	bool chk(const line& l1, const line& l2, const line& l3, char d) {
		pair<ll, ll> p1 = l2.intersect(l3);
		pair<ll, ll> p2 = l1.intersect(l2);
		if (d == 'l') {
			return (p1.first * p2.second) <= (p2.first * p1.second);
		} else {
			return (p1.first * p2.second) >= (p2.first * p1.second);
		}
	}

	void add_line(ll _m, ll _c, char d) {
		line new_line = line(_m, _c);
		while (lines.size() >= 2 && chk(lines[(int) lines.size() - 2], lines[(int) lines.size() - 1], new_line, d)) {
			lines.pop_back();
		}
		lines.emplace_back(new_line);
	}

	ll query(ll x) {
		while (lines.size() > 1 && lines[0].value_at(x) > lines[1].value_at(x))
			lines.pop_front();
		return lines[0].value_at(x);
	}
};

inline ll square(ll x) {
	return x * x;
}

class TaskZ {
public:
	int N;
	ll C, dp;

	void solve(std::istream& in, std::ostream& out) {
		in >> N >> C;
		vector<ll> h(N);
		for (int i = 0; i < N; i++) in >> h[i];
		dp = 0;
		char c = 'l';
		CHT a;
		a.add_line(-2 * h[0], square(h[0]) + dp, c);
		for (int i = 1; i < N; i++) {
			ll val = a.query(h[i]);
			dp = val + square(h[i]) + C;
			a.add_line(-2 * h[i], square(h[i]) + dp, c);
		}
		out << dp;
	}
};

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


Measured memory_bytes: 6808
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i]; 
	LL sumALL = abs(0 - A[0]);

	FOR(i,1, N) {
		sumALL += abs(A[i - 1] - A[i]);
	}
	sumALL += abs(A[N - 1] - 0);

	REP(pass, N) {
		LL sum = sumALL;
		if (pass == 0) {
			sum -= abs(A[pass] - 0);
			sum -= abs(A[pass + 1] - A[pass]);
			sum += abs(0 - A[pass + 1]);
		}
		else if (pass == N - 1) {
			sum -= abs(A[pass-1] - A[pass]);
			sum -= abs(A[pass] - 0);
			sum += abs(A[pass - 1] - 0);
		}
		else {
			sum -= abs(A[pass - 1] - A[pass]);
			sum -= abs(A[pass] - A[pass + 1]);
			sum += abs(A[pass - 1] - A[pass + 1]);
		}
		cout << sum << endl;
	}

}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG aising/b.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int n, a, b;
    cin >> n;
    cin >> a >> b;
    vector<int> p(n);

    rep(i, n){
        cin >> p[i];
    }
    int cnt[3];
    cnt[0] = 0;
    cnt[1] = 0;
    cnt[2] = 0;
    rep(i, n){
        if(p[i] <= a) cnt[0]++;
        else if(p[i] <= b) cnt[1]++;
        else cnt[2]++;
    }

    cout << min(min(cnt[0], cnt[1]), cnt[2]) << "\n";
    return 0;
}

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

int main(){
  int A, B, K;
  int count=0;
  int i;
  cin >> A >> B >> K;
  for(i=100; i>=1; i--){
    if(A%i==0 && B%i==0) count++;
    if(count==K) break;
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
graph = {i: deque() for i in range(1, n+1)}
for _ in range(n):
    u, k, *v = [int(x) for x in input().split()]
    v.sort()
    for i in v:
        graph[u].append(i)
        #graph[i].append(u)

seen = [0]*(n+1)
stack = []
time = 0
seentime = [0]*(n+1)
donetime = [0]*(n+1)

def dfs(j):
    global time
    seen[j] = 1
    time += 1
    seentime[j] = time
    stack.append(j)
    while stack:
        s = stack[-1]
        if not graph[s]:
            stack.pop()
            time += 1
            donetime[s] = time
            continue
        g_NO  = graph[s].popleft()
        if seen[g_NO]:
            continue
        seen[g_NO] = 1
        stack.append(g_NO)
        time += 1
        seentime[g_NO] = time

for j in range(1, n+1):
    if seen[j]:
        continue
    dfs(j)

for k, a, b in zip(range(1, n+1), seentime[1:], donetime[1:]):
    print(k, a, b)


Measured memory_bytes: 6092
class BinaryTree {
  constructor(n) {
    this.nodes = [];
    for (let i = 0; i < n; i++) this.nodes[i] = {id: i + 1, parentId: -1, leftId: -1, rightId: -1}
  }

  get root() { return this.nodes.find(n => n.parentId === -1); }

  find(id) { return this.nodes[id - 1]; }

  getByPostorder() {
    let res = [];
    const postorder = (id) => {
      if (id === -1) return;
      let n = this.find(id);
      postorder(n.leftId);
      postorder(n.rightId);
      res.push(id);
    };
    postorder(this.root.id);
    return res;
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const preOrder = lines.shift().split(' ').map(Number);
  const inOrder = lines.shift().split(' ').map(Number);

  let tree = makeTree(preOrder, inOrder);
  console.log(tree.getByPostorder().join(' '));
})();

function makeTree(preOrder, inOrder) {
  let tree = new BinaryTree(preOrder.length);
  const innerMakeTree = (p, i) => {
    let midId = p[0];
    let midIdx = i.indexOf(midId);
    if (midIdx > 0) {
      tree.find(midId).leftId = p[1];
      tree.find(p[1]).parentId = midId;
      innerMakeTree(p.slice(1, midIdx + 1), i.slice(0, midIdx))
    }
    if (midIdx < i.length - 1) {
      tree.find(midId).rightId = p[midIdx + 1];
      tree.find(p[midIdx + 1]).parentId = midId;
      innerMakeTree(p.slice(midIdx + 1), i.slice(midIdx + 1))
    }
  }
  innerMakeTree(preOrder, inOrder);
  return tree;
}



Measured memory_bytes: 15420
import java.util.Scanner;

/**
 * B - Roller Coaster
 */
public class Main {

    public static void main( String[] args ) {
        Scanner sc = new Scanner( System.in );
        // 一緒に遊園地へ行った人数
        int n = sc.nextInt();
        // 身長制限
        int k = sc.nextInt();
        // ジェットコースターに乗れる人数：結果
        int result = 0;
        // 人数分の身長取得
        int[] a = new int[n];
        for( int i = 0; i < n; i++ ) {
//          System.out.println( "i : " + i );
          a[i] = sc.nextInt();
//          System.out.println( "a[" + i + "]" + a[i] );
          if( a[i] >= k ) {
              result++;
          }
        }
        System.out.println( result );
    }
}

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

int main() {
    int a, count = 0;
    string s = "No";
    cin >> a;
    
    for(int i=1;i<=9;i++){


        for(int j=1;j<=9;j++){
            if(i*j==a) {
                s ="Yes";
            }
        }
    }

    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  string s;
  cin>>s;
  
  if(s=="Sunny")
    cout<<"Cloudy\n";
  else if(s=="Cloudy")
    cout<<"Rainy\n";
  else if(s=="Rainy")
       cout<<"Sunny\n";
}

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

int main(){
    int n;
    string ans="No";
    cin>>n;
    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < 15; ++j) {
            if((4*i+7*j)==n) {
                ans = "Yes";
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

#define N_MAX 100000
#define MOD 1000000007

typedef long long int lli;

lli gcd(lli a, lli b)
{
	return b != 0 ? gcd(b, a%b) : a;
}

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

void solv()
{
	lli A, B; scanf("%lld%lld", &A, &B);
	printf("%lld", lcm(A, B));

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
package main

import (
    "fmt"
)

func main() {
    var n, m int
    fmt.Scan(&n, &m)
	x := combination(n,2) + combination(m,2)
  	fmt.Println(x)
}

func permutation(n int, k int) int {
    v := 1
    if 0 < k && k <= n {
        for i := 0; i < k; i++ {
            v *= (n - i)
        }
    } else if k > n {
        v = 0
    }
    return v
}

func factorial(n int) int {
    return permutation(n, n - 1)
}

func combination(n int, k int) int {
    return permutation(n, k) / factorial(k)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  int a[5];
  int res=0;

  rep(i,3) cin >> a[i];

  sort(a,a+3);

  rep(i,2){
    res += a[i];
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
//ll INF = 1LL<<40;
int INF = 1e9+7;

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

    int D, G;
    cin >> D >> G;
    vector<P> pc(D);
    REP(i, D){
        int p, c;
        cin >> p >> c;
        pc[i].first = p;
        pc[i].second = c;
    }
    //sort(pc.begin(), pc.end());
    int ans = INF;
    for(int i = 0; i < 1 << D; i++){
        int sum = 0;
        int cnt = 0;
        //cout << i << " : ";
        for(int j = 0; j < D; j++){
            if(i & 1 << j){
                sum += pc[j].second;
                //cout << sum << ",";
                sum += pc[j].first*(j+1)*100;
                //cout << sum << ",";
                cnt += pc[j].first;
            }
        }
        if(sum < G){
            for(int j = D - 1; j >= 0; j--){
                if(!(i & 1 << j)){
                    double div = ceil((G-sum)/((j+1)*100.0));
                    if(div < pc[j].first){
                        //cout << "cnt=" << cnt << ", div" << div;
                        cnt += div;
                        sum += div*(j+1)*100;
                    }else{
                        cnt = INF;
                    }
                    break;
                }
            }
        }
        if(sum >= G){
            //cout << cnt << ":" << i << "," << sum << endl;
            ans = min(ans, cnt);
        }
        //cout << endl;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    vector<int> v(4);
    for(int i=0;i<4;i++){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    if(v.at(0)==1&&v.at(1)==4&&v.at(2)==7&&v.at(3)==9){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){

string s;cin>>s;
if(s=="ABC")cout<<"ARC"<<endl;
if(s=="ARC")cout<<"ABC"<<endl;
}

Measured memory_bytes: 3596
import sys
readline = sys.stdin.readline

class WeightedUnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            y = self.find(self.parents[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.parents[x]]
            self.parents[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.parents[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.parents[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

def main():
    N, M = map(int, readline().rstrip().split())    
    uf = WeightedUnionFind(N)

    for _ in range(M):
        l, r, d = map(int, readline().rstrip().split())
        l -= 1
        r -= 1
        if uf.same(l, r):
            if uf.diff(l, r) != d:
                print('No')
                return

        uf.union(l, r, d)
    
    print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 15880
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

int N, MOD = 998244353;
int d1[200020], d2[200020], pow2[200020], s[4][200020];
pair<int,int> p[200020];

inline void add(int i) { for(;i <= N; i+=i&-i) d1[i] += 1; }
inline int  sum(int i) { int ret=0; for(; i > 0; i-=i&-i) ret += d1[i]; return ret; }

int main() {
    scanf("%d", &N);
    for(int i=0; i < N; ++i) scanf("%d%d", &p[i].first, &p[i].second);
    sort(p, p + N);

    map<int,int> m; int j = 0;
    for(int i = 0; i < N; ++i) m[p[i].second] = 0;
    for(auto&& i : m) i.second = ++j;
    for(int i = 0; i < N; ++i) p[i].second = m[p[i].second];

    for(int i = 0; i < N; ++i) {
        s[0][i] = sum(p[i].second);
        s[1][i] = i - s[0][i];
        add(p[i].second);
    }
    swap(d1, d2);
    for(int i = N-1; i >= 0; --i) {
        s[2][i] = sum(p[i].second);
        s[3][i] = (N-1-i) - s[2][i];
        add(p[i].second);
    }

    pow2[0] = 1;
    for(int i = 1; i <= N; ++i) pow2[i] = pow2[i-1] * 2 % MOD;

    long ans = 0, tmp1[4], tmp2[4];
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 4; ++j) {
            tmp1[j] = pow2[s[j][i]];
            tmp2[j] = tmp1[j] - 1;
        }
        ans = (ans + tmp2[0] * tmp1[1] % MOD * tmp1[2] % MOD * tmp2[3] % MOD) % MOD;
        ans = (ans + tmp1[0] * tmp2[1] % MOD * tmp2[2] % MOD * tmp1[3] % MOD) % MOD;
        ans = (ans - tmp2[0] * tmp2[1] % MOD * tmp2[2] % MOD * tmp2[3] % MOD + MOD) % MOD;
        ans = (ans + tmp1[0] * tmp1[1] % MOD * tmp1[2] % MOD * tmp1[3] % MOD) % MOD;
    }

    printf("%ld", ans);
    return 0;
}

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

int main() {
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s) cout << a-1 << ' ' << b <<endl;
    else cout << a << ' ' << b-1 <<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

import javax.sound.midi.MidiUnavailableException;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    long x = sc.nextLong();
    long k = sc.nextLong();
    long d = sc.nextLong();

    long counter = 0;

    long devide = Math.abs(x / d);
    long plus_nearest;
    long minus_nearest;

    if(devide > k){
      if(x >= 0){
        System.out.println(x - k*d);
      }else{
        System.out.println(Math.abs(x + k*d));
      }
    }else{
      if(x >= 0){
        plus_nearest = x - devide * d;
        minus_nearest = plus_nearest - d;

        if(((k - devide) % 2) == 0){
          System.out.println(plus_nearest);
        }else{
          System.out.println(Math.abs(minus_nearest));
        }
      }else{
        minus_nearest = x + devide * d;
        plus_nearest = minus_nearest + d;

        if(((k - devide) % 2) == 0){
          System.out.println(Math.abs(minus_nearest));
        }else{
          System.out.println(plus_nearest);
        }
      }
    }

    return;

  }
}

Measured memory_bytes: 35816
import math
N,K=map(int,input().split())
ans=0

if K%2!=0:
  n=N//K
  ans+=n*(n-1)*(n-2)+n*(n-1)*3+n
else:
  n=N//K
  ans+=n*(n-1)*(n-2)+n*(n-1)*3+n
  k=K//2
  n1=N//k
  n=n1-n
  ans+=n*(n-1)*(n-2)+n*(n-1)*3+n
print(ans)

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

int main() {
  int n, a;
  cin >> n;
  int ans = 0;
  while (n--) {
    cin >> a;
    while (a % 2 == 0) {
      ans++;
      a /= 2; 
    }
  }
  printf("%d\n", ans);
  return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N){
        cin>>A.at(i);
    }
    sort(A.begin(),A.end(),greater<ll>());
    ll B=A.at(0);
    ll sum=0;
    ll count=0;
    rep(i,N){
        if(i>0){
            sum+=A.at(i/2);
        }
    }
    cout<<sum<<endl;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int calc(int n){
    if(n == 1)return 1;
    return 1 + calc(n-1) * 2;
}

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

    int n;cin >> n;
    vector<ll> x(n);
    rep(i,n)cin >> x[i];
    vector<ll> t(x);
    sort(ALL(t));
    int t_size = t.size();
    double median = (t[t_size/2] + t[t_size/2-1]) / 2.0;
    for(int i=0;i<t_size;i++){
        if(x[i] > median)cout << t[t_size/2-1] << endl;
        else if(x[i] <= median)cout << t[t_size/2] << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
n=int(input())
l=[]
s=0
for i in range(n+2):
  l.append(s)
  s+=i+1
if n not in l:
  print('No')
else:
  k=l.index(n)+1
  ans=[[] for i in range(k)]
  c=0
  for i in range(k):
    for j in range(i+1,k):
      ans[i].append(c+1)
      ans[j].append(c+1)
      c+=1
  print('Yes')
  print(k)
  for i in range(k):
    print(k-1,*ans[i])

Measured memory_bytes: 16968
def run():
  N = int(input())
  if N%2 == 1:
    print(0)
    exit()
  k = 1
  while N > 5**k:
    k += 1
  ans = 0
  for i in range(1, k):
    ans += N//((5**i)*2)
  print(ans)
    
  
if __name__ == '__main__':
  run()

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a + b > 9)
        cout << "error";
    else
        cout << a + b;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;
int main() {
	int n, count = 1;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1])continue;
		count++;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int h,w,c;
int field[8][8];
int tmpfield[8][8];
int lt;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

void dfs(int a,int b,int cc){
  if(a<0||h<=a||b<0||w<=b) return;
  if(tmpfield[a][b]!=lt) return;
  tmpfield[a][b]=cc;
  for(int i=0;i<4;++i)
    dfs(a+dx[i],b+dy[i],cc);
  return;
}

void color(int cc){
  lt=tmpfield[0][0];
  if(lt==cc) return;
  dfs(0,0,cc);
  return;
}

int main(void){
  while(cin >> h >> w >> c,h+w+c){
    int answer=0;
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j){
	cin >> field[i][j];
      }
    int ch[6]={};
    for(int chp=0;chp<6*6*6*6;++chp){
      ch[0]=chp%6+1;
      ch[1]=(chp/6)%6+1;
      ch[2]=(chp/6/6)%6+1;
      ch[3]=(chp/6/6/6)%6+1;
      ch[4]=c;
      ch[5]=0;
      for(int i=0;i<h;++i)
	for(int j=0;j<w;++j)
	  tmpfield[i][j]=field[i][j];
      for(int i=0;i<6;++i) color(ch[i]);
      int tmpanswer=0;
      for(int i=0;i<h;++i)
	for(int j=0;j<w;++j)
	  if(tmpfield[i][j]==0) tmpanswer++;
      answer=max(answer,tmpanswer);
    }
    cout << answer << endl;
  }
  return 0;
}

Measured memory_bytes: 3040
#include <iostream>

using namespace std;

int main()
{
    int N, K;
    int s = 0;
    cin >> N >> K;
    int d[K];
    int a[N];
    for(int i = 0; i < N; i++){
        a[i] = 0;
    }
    for(int i = 0; i < K; i++){
        cin >> d[i];
        int A[d[i]];
        for(int j = 0; j < d[i]; j++){
            cin >> A[j];
            a[A[j] - 1] += 1;
        }
    }
    for(int i = 0; i < N; i++){
        if (a[i] == 0){
            s += 1;
        } 
    }
    cout << s;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int n;
    cin >> n;
    priority_queue<ll> l_que;
    priority_queue<ll,vector<ll>, greater<ll> > r_que;
    l_que.emplace(-mod);
    r_que.emplace(mod);
    ll b_sum = 0;
    ll l_sum = 0;
    ll r_sum = 0;
    rep(i,n) {
        int x;
        cin >> x;
        if (x == 1) {
            ll a,b;
            cin >> a >> b;
            b_sum += b;
            if (l_que.size() == r_que.size()) {
                if (l_que.top() >= a) {
                    l_que.emplace(a);
                    l_sum += a;
                }
                else
                {
                    r_que.emplace(a);
                    r_sum += a;
                    ll tmp_num = r_que.top(); r_que.pop();
                    r_sum -= tmp_num;
                    l_que.emplace(tmp_num);
                    l_sum += tmp_num;
                }
            }
            else
            {
                if (l_que.top() >= a) {
                    l_que.emplace(a);
                    l_sum += a;
                    ll tmp_num = l_que.top(); l_que.pop();
                    l_sum -= tmp_num;
                    r_que.emplace(tmp_num);
                    r_sum += tmp_num;
                }
                else
                {
                    r_que.emplace(a);
                    r_sum += a;
                }
            }
            // cout << "1 come" << endl;
            // cout << l_que.top() << " " << r_que.top() << endl;
        }
        else if (x == 2) {
            ll min_num = l_que.top();
            // cout << "debug" << endl;
            // cout << "lquesize" << l_que.size() << endl;
            // cout << "rquesize" << r_que.size() << endl;
            // cout << "minnum" << min_num << endl;
            // cout << "lsum" << l_sum << endl;
            // cout << "rsum" << r_sum << endl;
            // cout << "bsum" << b_sum << endl;
            // cout << "debug finished" << endl;

            ll ans = (l_que.size() - r_que.size()) * min_num - l_sum + r_sum + b_sum;
            cout << min_num << " " << ans << endl;
        }
    }


    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 3828
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  n--;
  n /= 111;
  cout << 111 * (n + 1) << endl;
}

Measured memory_bytes: 256
n=int(input())
a=input().split()
numbers=[b for b in a]
n=len(numbers)
if n%2==0:
    kisuu=numbers[1::2]
    guusuu=numbers[0::2]
    kisuu.reverse()
    kotae=kisuu+guusuu
else:
    kisuu=numbers[1::2]
    guusuu=numbers[0::2]
    guusuu.reverse()
    kotae=guusuu+kisuu
answer=''
for z in kotae:
    answer+=str(z)
    answer+=' '
print(answer)


Measured memory_bytes: 28308
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <time.h>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;
#define mod 1000000007
typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

bool ok(vint a, int n)
{
	clock_t start = clock();
	for (int i = n-1; 1 <= i; i -= 2)
	{
		int k = count(a.begin(), a.end(), i);
		if (k != 2)
		{
			clock_t end = clock();
			const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
			cout << time << endl;
			return false;
		}
	}
	if (n % 2 == 1 and count(a.begin(), a.end(), 0) != 1)
	{
		clock_t end = clock();
		const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
		cout << time << endl;
		return false;
	}
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
	cout << time << endl;
	return true;
}
bool ok2(vint a,int n)
{
	sort(a.begin(), a.end());
	for (int i = (n % 2); i < a.size()-1; i += 2)
	{
		if (a[i] != a[i + 1])
		{
			return false;
		}
	}
	if (n % 2 == 1 and a[0] != 0)
	{
		return false;
	}
	return true;
}
long myPow(long x, long n, long m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
int main()
{
	int N;
	cin >> N;
	vint A(N);
	rep(i, N)
	{
		cin >> A[i];
	}

	
	
//	clock_t start2;
//		clock_t end2;
	if (ok2(A,N))
	{
	//	end = clock();
	//	start2 = clock();
		cout << myPow(2,N / 2,mod);
	//	 end2 = clock();
	}
	else
	{
		cout << 0;
	}
	
	
//	const double time2 = static_cast<double>(end2 - start2) / CLOCKS_PER_SEC * 1000.0;
//	cout << time << endl;

}


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

int main(){
  int N;
  cin>>N;
  std::vector<int> v(100,0);
  for(int i=0;i<N;i++){
    int k=i+1;
    for(int j=2;j*j<=k;j++){
      if(k%j==0){
        v[j]++;
        k/=j;
        j=1;
      }
    }
    if(k!=1)v[k]++;
  }
  //for(int i=0;i<10;i++)cout<<v[i+1]<<endl;
  int a74=0;
  int a24=0;
  int a4=0;
  int a14=0;
  int a2=0;
  for(int i=0;i<100;i++){
    if(v[i+1]>=74)a74++;
    if(v[i+1]>=24)a24++;
    if(v[i+1]>=4)a4++;
    if(v[i+1]>=14)a14++;
    if(v[i+1]>=2)a2++;
  }
  int ans=0;
  ans+=a74;
  ans+=(a2-a24)*a24+a24*(a24-1);
  ans+=(a4-a14)*a14+a14*(a14-1);
  ans+=(a2-a4)*a4*(a4-1)/2+a4*(a4-1)*(a4-2)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import collections
N,K=map(int,input().split())
G=[set() for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  G[a].add(b)
  G[b].add(a)
m=0
id=9
for i in range(N):
  if len(G[i])>m:
    id=i
    m = len(G[i])
q=collections.deque()
q.append(0)
colored=[False]*N
colored[0]=True
from math import factorial
mod = 10**9 + 7
ans = K
while(q):
  x= q.popleft()
  count=0
  for y in G[x]:
    if colored[y]:
      continue
    else:
      q.append(y)
      colored[y]=True
      count+=1
      
  for i in range(count):
    ans *= K-1-(len(G[x])-count)-i
    ans %= mod
  #print(ans,count,factorial(K-1-(len(G[x])-count)),factorial(count))
print(ans)

  
  
      
  

Measured memory_bytes: 38412
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream & operator>>(istream & is, vector<T> &);
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream &, tuple<T...> &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream & is, tuple<T...> & t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream & operator>>(istream & is, tuple<T...> & t){ _it<0>(is, t); return is; }
template<class T, class U> istream & operator<<(istream & is, pair<T,U> & p){ return is >> p.first >> p.second; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> istream & operator>>(istream & is, vector<T> & v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

ll dp[100000][20];
int main(){
    string s;
    while(cin>>s && s!="0"){
        memset(dp,0,sizeof(dp));
        ll ans = 0;
        int n = s.size();
        rep(i,n){
            int x = s[i]-'0';
            rep(j,11){
                dp[i+1][(j*10+x)%11] += dp[i][j];
            }
            if(x) dp[i+1][x]++; // 一桁だけ
            ans += dp[i+1][0];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 16956
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n;
	 cin>>n;
	 //vector<int> v(n);
	 int ans=0;
	 for(int i=0;i<n;i++)
	 {
		 int x;
		 cin>>x;
		 if((i+1)%2==1 && x%2==1)
		 ans++;
	 }
	 cout<<ans;
	 return 0;
	 
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
	int N;
	cin>>N;
	int cnt=0;
	rep(i,N){
		int p;cin>>p;
		if(p!=i+1)cnt++;
	}
	if(cnt<=2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    cout << (1900*m + 100*(n-m))*(int)pow(2,m) << endl;;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    double x, h;
    while (1) {
        cin >> x; cin >> h;
        if (x == 0 && h == 0) {
            break;
        }
        cout.precision(10);
        cout << x * x + sqrt((x/2)*(x/2) + h*h) * x * 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <string.h>

void quick(char s[][101], int left, int right){
  int pl = left, pr = right;
  char x[101];  strcpy(x, s[(left + right) / 2]);
  do{
    while(strcmp(s[pl], x) < 0)  pl++;
    while(strcmp(s[pr], x) > 0)  pr--;
    if(pl <= pr){
      char tmp[101];
      strcpy(tmp, s[pl]);
      strcpy(s[pl], s[pr]);
      strcpy(s[pr], tmp);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(s, pl, right);
  if(pr > left)  quick(s, left, pr);
}

int main(){
  int n, l;  scanf("%d %d", &n, &l);
  char s[101][101];
  for(int i=0; i<n; i++)  scanf("%s", s[i]);
  quick(s, 0, n-1);
  for(int i=0; i<n; i++)  printf("%s", s[i]);  puts("");
  return 0;
  
}


Measured memory_bytes: 128
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ll k;
  cin >> k;
  ll ans = 0;
  rep(i, k) rep(j, k) rep(l, k) ans += __gcd(i+1, __gcd(j+1, l+1));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int x, y;

int main() {
    cin >> x >> y;
    if (2*x > y || y > 4*x || y%2) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	int sum = 0;
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a.at(i);
		sum += a.at(i);
	}
	if (sum > n) {
		cout << "-1" << endl;
		return 0;
	}
	cout << n - sum << endl;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int w,h;
char f[55][55];
int dx[] = {1,0};
int dy[] = {0,1};
int dp[55][55];
int solve(int x,int y){
  if(dp[x][y] >= 0) return dp[x][y];
  int ret = 1 << 26;
  for(int i = 0; i < 2; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(f[nx][ny]){
      ret = min(ret,solve(nx,ny) + f[nx][ny] - '0');
    }
  }
  return dp[x][y] = (ret == 1 << 26)?0:ret;
}
int main(void){
  memset(dp,-1,sizeof(dp));
  scanf("%d%d",&h,&w);
  for(int i = 1; i <= h; i++){
    scanf("%s",f[i]+1);
  }
  printf("%d\n",solve(1,1));
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

vector<ll> dr = {-2, 2, 0, 0};
vector<ll> dc = {0, 0, 2, -2};

int main() {
    std::cout << std::fixed << std::setprecision(15);
    
    while(true){
        ll w, h; cin >> w >> h;
        if(h == 0 && w == 0){
            break;
        }
        vector<vector<string>> maze(2*h-1, vector<string>(2*w-1, "."));

        rep(i, 2*h-1){
            if(i % 2 == 0){
                rep(j, w-1){
                    ll tmp; cin >> tmp;
                    if(tmp == 1) maze[i][2*j+1] = "#";
                }
            }else{
                rep(j, w){
                    ll tmp; cin >> tmp;
                    if(tmp == 1) maze[i][2*j] = "#";
                }
            }
        }

        vector<vector<ll>> dist(2*h-1, vector<ll>(2*w-1, -1));
        queue<pair<ll, ll>> que;
        dist[0][0] = 0;
        que.push({0, 0});

        while(!que.empty()){
            pair<ll, ll> now_pos = que.front();
            ll now_row = now_pos.first;
            ll now_col = now_pos.second;
            que.pop();
            rep(i, 4){
                ll next_row = now_row + dr[i];
                ll next_col = now_col + dc[i];

                //場外ならcontinue
                if(next_row < 0 || next_row >= 2*h - 1) continue;
                if(next_col < 0 || next_col >= 2*w - 1) continue;

                //すでに訪れていたらcontinue
                if(dist[next_row][next_col] != -1) continue;

                //壁があったらcontinue
                if(maze[now_row + dr[i]/2][now_col + dc[i]/2] == "#") continue;

                //dist格納,que追加
                dist[next_row][next_col] = dist[now_row][now_col] + 1;
                que.push({next_row, next_col});
            }
        }

        /*
        rep(i, 2*h-1){
            rep(j, 2*w-1){
                cout << dist[i][j] << " ";
            }
            br;
        }
        */

        cout << dist[2*h-2][2*w-2] + 1 << endl;

    }

}


Measured memory_bytes: 3248
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAX_N = 1005;

int h, w;
bool a[MAX_N][MAX_N];
ll dp[MAX_N][MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> h >> w;
	for (int i = 0; i < h; i++)
	{
		string s; cin >> s;
		for (int j = 0; j < w; j++)
			a[i][j] = s[j] == '.';
	}

	dp[0][0] = 1;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
		{
			if (dp[i][j] == 0)
				continue;
			if (i + 1 < h && a[i + 1][j])
				dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
			if (j + 1 < w && a[i][j + 1])
				dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
		}

	cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 9088