akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int N;
  cin >> N;
  vector<string> S(N);
  for (auto &x: S) cin >> x;

  int best = 0;
  for (int i = 0; i < N; i++) {
    queue<Pii> que;
    que.emplace(i, 1);
    vector<int> depth(N, 0);
    vector<bool> visited(N, false);
    while (!que.empty()) {
      auto now = que.front();
      que.pop();
      if (visited[now.first]) continue;
      visited[now.first] = true;
      depth[now.first] = now.second;
      for (int j = 0; j < N; j++) {
        if (S[now.first][j] == '0') continue;
        else if (visited[j]) {
          if (depth[now.first]-1 != depth[j]) {
            cout << -1 << endl; // impossible
            return 0;
          }
        }
        else {
          que.emplace(j, now.second+1);
        }
      }
    }
    for (int j = 0; j < N; j++) {
      if (depth[j] > best) {
        best = depth[j];
      }
    }
  }

  cout << best << endl;

  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#define mk make_pair
#define pb push_back
#define scanf scanf_s
#define printf printf_s
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> pos;
const ll N = 200010, MOD = 1000000007;
int x, y, a, b, c;
priority_queue<int> p, q, r;
int main() {
	cin >> x >> y >> a >> b >> c;
	for (int i = 0; i < a; i++) { int v; cin >> v; p.push(-v); }
	for (int i = 0; i < b; i++) { int v; cin >> v; q.push(-v); }
	for (int i = 0; i < c; i++) { int v; cin >> v; r.push(v); }
	while (p.size() != x)p.pop();
	while (q.size() != y)q.pop();
	ll vv = 0;
	while ((!p.empty() || !q.empty()) && !r.empty()) {
		if (q.empty()||-p.top() < -q.top()) {
			ll v1 = -p.top();
			if (r.top() < v1)break;
			p.pop();
			vv += r.top();
			r.pop();
		}
		else {
			ll v1 = -q.top();
			if (r.top() < v1)break;
			q.pop();
			vv += r.top();
			r.pop();
		}
	}
	while (!p.empty()) { vv -= p.top(); p.pop(); }
	while (!q.empty()) { vv -= q.top(); q.pop(); }
	cout << vv << endl;
	return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> grid(h);
    for(int i = 0; i < h; i++){
        cin >> grid[i];
    }
    bool ans = true;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(i == j && j == 0 && grid[i][j] == '#' && (grid[i][j + 1] != '#' && grid[i + 1][j] != '#')) 
                    ans = false;
            if(i == 0 && j != 0 && j != w - 1 && grid[i][j] == '#' && grid[i][j - 1] != '#' && grid[i][j + 1] != '#' && grid[i + 1][j] != '#')
                    ans = false;
            if(i == 0 && j == w - 1 && grid[i][j] == '#' &&grid[i][j - 1] != '#' && grid[i + 1][j] != '#')
                    ans = false;
            if(i != 0 && i != h - 1 && j == 0 && grid[i][j] == '#' && grid[i][j + 1] != '#' && grid[i - 1][j] != '#' && grid[i + 1][j] != '#')
                    ans = false;
            if(i != 0 && i != h - 1 && j != 0 && j != w - 1 && grid[i][j] == '#' && grid[i][j + 1] != '#' && grid[i][j - 1] != '#' && grid[i - 1][j] != '#' && grid[i + 1][j] != '#')
                    ans = false;
            if(i != 0 && i != h - 1 && j == w - 1 && grid[i][j] == '#' && grid[i][j - 1] != '#' && grid[i + 1][j] != '#' && grid[i - 1][j] != '#')
                    ans = false;
            if(i == h - 1 && j == 0 && grid[i][j] == '#' && grid[i][j + 1] != '#' && grid[i - 1][j] != '#')
                    ans = false;
            if(i == h - 1 && j != 0 && j != w - 1 && grid[i][j] == '#' && grid[i][j - 1] != '#' && grid[i][j + 1] != '#' && grid[i - 1][j] != '#')
                    ans = false;
            if(i == h - 1 && j == w - 1 && grid[i][j] == '#' && grid[i][j - 1] != '#' && grid[i - 1][j] != '#')
                    ans = false;
        }

    }
    cout << (ans ? "Yes":"No") << "\n";
}

Measured memory_bytes: 256
import math

A, B, H, M = map(float, input().split())
# A, B, H, M = 3.0,4.0,9.0,0.0
# X_H, Y_H = 0, 0
# X_M, Y_M = 0, 0
# print(float(H/12))
# print(((float(H / 12) * math.pi * 2) * -1))
# print(((float(H / 12) * math.pi * 2) * -1) + math.pi / 2)
X_H = math.cos((((H / 12) + M/60/12)* math.pi * 2) * -1 + math.pi / 2) * A
Y_H = math.sin((((H / 12) + M/60/12)* math.pi * 2) * -1 + math.pi / 2) * A
X_M = math.cos(((M / 60) * math.pi * 2) * -1 + math.pi / 2) * B
Y_M = math.sin(((M / 60) * math.pi * 2) * -1 + math.pi / 2) * B
# print(X_H)
# print(Y_H)
# print(X_M)
# print(Y_M)

print(math.sqrt(((X_H - X_M) ** 2 + (Y_H - Y_M) **2)))
# print(math.cos(0))
# print(math.cos(math.pi/6*5)*3)


Measured memory_bytes: 9556
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;
long long int recursive(
    int start, int end, vector<int>& a, bool turn,
    unordered_map<int, unordered_map<int, long long int>>& table,
    vector<vector<bool>>& visited) {
  if (visited[start][end]) {
    return table[start][end];
  }
  visited[start][end] = true;
  if (table.count(start) <= 0) {
    unordered_map<int, long long int> m;
    m[end] = 0;
    table[start] = m;
  }

  if (start == end) {
    if (turn == 0) {
      table[start][end] = a[start];
      return a[start];
    } else {
      table[start][end] = -a[start];
      return -a[start];
    }
  }
  long long int r1 = recursive(start + 1, end, a, !turn, table, visited);
  long long int r2 = recursive(start, end - 1, a, !turn, table, visited);
  long long int maxR = max(r1 + a[start], r2 + a[end]);
  long long int minR = min(r1 - a[start], r2 - a[end]);
  if (turn == 0) {
    table[start][end] = maxR;
    return maxR;
  } else {
    table[start][end] = minR;
    return minR;
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N, 0);
  for (int i = 0; i < N; ++i) cin >> a[i];
  unordered_map<int, unordered_map<int, long long int>> table;
  vector<vector<bool>> visited(N, vector<bool>(N, 0));
  long long int r = recursive(0, N - 1, a, 0, table, visited);
  cout << r;
}

Measured memory_bytes: 195968
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		long n = sc.nextLong();
		long[] vs = new long[(int) n];
		for (int i = 0; i < n; i++) {
			vs[i] = sc.nextLong();
		}
		Arrays.sort(vs);

		double r = vs[0];
		for (int i = 1; i < n; i++) {
			r = (r+vs[i])/2d;
		}

		pw.println(r);
		pw.flush();
	}

	double create(double x, double y) {
		return (x + y) / 2d;
	}

	static final FastScanner sc = new FastScanner();
	static final PrintWriter pw = new PrintWriter(System.out);

	static class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 22484
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
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;
    }
}   




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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    i64 x, y;
    cin >> x >> y;
    i64 loop = __gcd(x, y);
    x /= loop;
    y /= loop;
    i64 ans = loop + 1;
    ans += (x + y - 2) * loop;
    cout << ans << endl;
}



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

int main() {
  int M = 0;
  int N;
  cin >> N;
  
  for (int i=0;i < N;i++){
    int l,r;
    cin >> l >> r;
    M = M - l + r + 1;
  }
  
  cout << M << endl;

  
}

Measured memory_bytes: 256
import re

def deref(d, expr):
  expr = expr.replace(']', '')
  symb = expr.split('[')
  symb[-1] = symb[-1]
  while len(symb) > 1:
    name, index = symb[-2:]
    if index not in d[name]:
      return None

    symb.pop()
    symb.pop()
    symb.append(d[name][index])

  return symb[0]


def check(s):
  d = {}
  dd = {}
  for i, stmt in enumerate(s, 1):
    if '=' not in stmt:
      name = stmt[0]
      index = stmt[2:-1]
      d[name] = {}
      dd[name] = int(index)
      continue

    lhs, rhs = stmt.split('=')
    
    name = lhs[0]
    index = lhs[2:-1]
    index = deref(d, index)
    value = deref(d, rhs)
    if index is None or value is None or int(index) >= dd[name]:
      print(i)
      return

    d[name][index] = value

  print(0)


def main():
  list_ = []
  with open(0) as fin:
    for line in fin:
      line = line.strip()
      if line == '.':
        if not list_: 
          return 0

        check(list_)
        list_ = []
        continue

      list_.append(line)

if __name__ == '__main__':
  main()



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

typedef long long ll;

int n;
int N;

string red(string s){
	string ret="";
	for(int i=0;i<s.size();i++){
		ret+=s[i];
		if(ret.size()>=2&&ret[ret.size()-1]=='S'&&ret[ret.size()-2]=='S'){
			ret.pop_back();
			ret.pop_back();
		}
	}
	return ret;
}

int ret[1<<24];
void solve(string s,int d,int mask){
	//cerr<<s<<" "<<d<<" "<<mask<<endl;
	int p[3]={0,1,2};
	string t[3];
	for(int i=0;i<s.size();i++){
		if(s[i]=='S'){
			for(int j=0;j<3;j++){
				if(p[j]!=0)p[j]=3-p[j];
				t[j]+='S';
			}
		}
		else {
			for(int j=0;j<3;j++){
				p[j]++;
				if(p[j]==3){
					p[j]=0;
					t[j]+='R';
				}
			}
		}
		/*for(int j=0;j<3;j++){
			cerr<<p[j]<<" ";
		}cerr<<endl;*/
	}
	int m[3];
	m[0]=mask-(1<<(2*d+1))-(1<<(2*d));
	m[1]=mask-(1<<(2*d+1));
	m[2]=mask-(1<<(2*d));
	for(int i=0;i<3;i++){
		ret[m[i]]=p[i];
		//cerr<<m[i]<<" "<<p[i]<<endl;
		if(d+1<n)solve(red(t[i]),d+1,m[i]);
	}
}

int main(){
	string t;
	cin>>n>>t;
	N=1;
	for(int i=0;i<n;i++)N*=3;
	
	int cnt=0;
	for(int i=0;i<t.size();i++){
		if(t[i]=='S')cnt++;
	}
	if(cnt&1)t+='S';
	t=red(t);
	memset(ret,-1,sizeof ret);
	solve(t,0,(1<<(2*n))-1);
	
	bool addS=cnt&1;
	
	vector<int> p;
	for(int i=0;i<(1<<(2*n));i++){
		bool ok=true;
		for(int j=0;j<n;j++){
			if(((i>>(2*j))&3)==3)ok=false;
		}
		if(!ok)continue;
		int cnt=0;
		int tt=N/3;
		int mask=i;
		for(int j=n-1;j>=0;j--){
			int x=0;
			if(ret[mask]==-1)x=(i>>(2*j))&3;
			else x=ret[mask];
			if(addS&&x!=0)x=3-x;
			cnt+=tt*x;
			/*if(ret[mask]==-1)cnt+=tt*((i>>(2*j))&3);
			else {
				cnt+=tt*ret[mask];
			}*/
			mask|=3<<(2*j);
			tt/=3;
		}
		p.push_back(cnt);
	}
	for(int i=0;i<p.size();i++){
		cout<<p[i]<<" ";
	}
	cout<<endl;
}



Measured memory_bytes: 74092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int result[] = new int[200000];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			result[A[i]+1]++;
		}
		for(int i=0;i<N;i++) {
			result[A[i]]++;
		}
		for(int i=0;i<N;i++) {
			result[A[i]+2]++;
		}
		int max =0;
		for(int i=0;i<200000;i++) {
			if (result[i]>max) {
				max = result[i];
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 60200
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Double> lst = new ArrayList<>();
		while (sc.hasNext()) {
			lst.add(Double.parseDouble(sc.next()));
		}
		double T = lst.get(0);
		double X = lst.get(1);

		System.out.println(T/X);
	}

}


Measured memory_bytes: 23124
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    ll t=0;
    ll x=0,y=0;
    bool ok=true;
    rep(i,n){
        ll cur,nx,ny;
        cin >> cur >> nx >> ny;
        ll d=abs(x-nx)+abs(y-ny);
        ll dt=cur-t;
        if(d<=dt && (dt-d)%2==0){
            t=cur;
            x=nx;
            y=ny;
        }
        else{
            ok=false;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 3560
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),k=stdIn.nextInt(),a,i;
		for(i=0;i<n;i++) a=stdIn.nextInt();
		System.out.print((n-2)/(k-1)+1);
	}
}

Measured memory_bytes: 48348
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << ((b - a == c - b) ? "YES" : "NO") << "\n";
    return 0;
}

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

using namespace std;

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

struct UnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;

    UnionFind(int sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

bool judge(int n, vector<P>& ans) {
    vector<int> sum(n + 1, 0);
    UnionFind uf(n + 1);
    for (P& p : ans) {
        sum[p.first] += p.second;
        sum[p.second] += p.first;
        uf.unite(p.first, p.second);
    }
    if (uf.size(1) != n) return false;
    int s = sum[1];
    for (int i = 2; i <= n; i++) {
        if (s != sum[i]) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int m = n / 2 * 2;

    vector<P> ans;
    for (int i = m; i >= 1; i--) {
        int j = m + 1 - i;
        for (int k = 1; k <= m; k++) {
            if (k == j || k == i) continue;
            if (i < k) continue;
            ans.emplace_back(k, i);
        }
    }

    if (n % 2 == 1) {
        for (int i = 1; i <= m; i++) {
            ans.emplace_back(i, n);
        }
    }

    //assert(judge(n, ans));

    cout << ans.size() << endl;
    for (P& p : ans) {
        cout << p.first << " " << p.second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<int> a;
  int n;
  while(cin >> n){
    if(n==0){
      cout<< a.back()<<endl;
      a.pop_back();//delete
    }else
      a.push_back(n);
  }
  return 0;
}

Measured memory_bytes: 1212
#encoding: utf-8
import sys

input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

N = int(input())
S = input()

# 入力の網羅は 30,000C3 の組み合わせとなり全探索は不可能
# 出力は000〜999までの10**3であり、3*10**4とのかけあわせで
# O(10**7)であれば、制限時間内に計算が可能（出力全探索による貪欲法）

# PIN[0]に該当する文字が入力Sから見つかった場合、
# そのSを利用するのが最も効果的であるので貪欲法が利用できる
# (最初に見つかったものを使うとのちのちの制約に引っかかる、というような場合はDPなどを考慮)

# s in S に対し、PIN[0]に該当するsがあれば PIN[1]に該当するsを探索、、という繰り返しで3桁分見つかればans+=1

ans = 0
for i in range(1000):
	pin = str(i).zfill(3)
	cnt = 0 # 該当するsのカウント
	idx = 0 # 探索するPINのインデックス
	for s in S:
		if s==pin[idx]:
			cnt += 1 # カウントアップ
			idx += 1 # インデックスをPINの次の文字へ送る
			if idx == 3:
				break
	if cnt == 3:
		#print(pin)
		ans += 1
				
print(ans)

Measured memory_bytes: 41180
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans=0;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> P(M), S(M);
	for(int i=0; i<M; i++){
		string s;
		cin >> P[i] >> s;
		P[i]--;
		if(s=="AC"){
			S[i]=1;
		} else {
			S[i]=0;
		}
	}

	vector<int> wa(N);
	vector<bool> ac(N);
	for(int i=0; i<M; i++){
		if(S[i]==1){
			ac[P[i]]=true;
		} else {
			if(!ac[P[i]]) wa[P[i]]++;
		}
	}

	int n_ac = 0, n_pe = 0;
	for(int i=0; i<N; i++){
		if(ac[i]){
			n_ac++;
			n_pe += wa[i];
		}
	}
	cout << n_ac << " " << n_pe << endl;

	return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream & operator>>(istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

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

	vector<int> ans;

	int now = N;
	while (now > 0) {
		int found = false;
		for (int deme = min(now,M); deme >= 1; deme--) {
			if (S[now - deme] == '0') { ans.push_back(deme); now -= deme; found = true; break; }
		}
		if (!found) { cout << -1 << endl; return 0; }
	}

	for (auto i = ans.rbegin(); i != ans.rend(); i++) {
		cout << *i << " ";
	}cout << endl;


}

Measured memory_bytes: 1528
#include <iostream>
#include <string>

bool isLargest(const std::string& str, int pos) {
    for (int i = 0; i < str.length(); ++i) {
        if (i != pos && str[i] >= str[pos]) {
            return false;
        }
    }
    return true;
}

const char letters[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int n;
    std::cin >> n;
    std::string cur, max;
    for (int i = 0; i < n; ++i) {
        cur += 'a';
        max += letters[i];
    }
    --n;
    std::cout << cur << '\n';

    while (cur < max) {
        if (!isLargest(cur, n)) {
            ++cur[n];
        } else {
            int pos = n;
            do {
              cur[pos--] = 'a';
            } while (isLargest(cur, pos));
            ++cur[pos];
        }
        std::cout << cur << '\n';
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 100000000000;

signed main() {
  int N;
  cin >> N;
  
  int ans = 0;
  map<int, int> cnt;
  for( int i = 1; i <= N; i++ ){
    int A;
    cin >> A;
    ans += cnt[i-A];
    cnt[i+A]++;
  }
  cout << ans << endl;
  
}


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

int main(){
    int a;scanf("%d", &a);
    int L = a / 100;
    int R = a % 100;
    if (1 <= L && L <= 12){
        if (1 <= R && R <= 12) printf("AMBIGUOUS\n");
        else printf("MMYY\n");
    } else {
        if (1 <= R && R <= 12) printf("YYMM\n");
        else printf("NA\n");
    }
}

Measured memory_bytes: 256
N = int(input())
S = input()
X = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
res = ""
for s in S:
    moto_index = X.index(s)
    index = moto_index+N
    if(index >= 26):
        index -= 26
    res += X[index]
print(res)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> K,W;
void init(){
  K.resize(0);
  W.resize(0);
}

void input(){
  for(int i=0;i<10;i++){
    int tmp;
    cin>>tmp;
    W.push_back(tmp);
  }
  for(int i=0;i<10;i++){
    int tmp;
    cin>>tmp;
    K.push_back(tmp);
  }
}

struct A{
  int W,K;
};


A ans(){
  A res;
  sort(W.rbegin(),W.rend());
  res.W=W[0]+W[1]+W[2];
  sort(K.rbegin(),K.rend());
  res.K=K[0]+K[1]+K[2];
  return res;
}

int main(){
  init();
  input();
  A a=ans();
  cout<<a.W<<" "<<a.K<<endl;
}

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

using namespace std;
const int mod = 1e9 + 7;

int dp[102][100002], sum[102][100002], n, k, a[102];


int main()
{
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  dp[0][0] = sum[0][0] = 1;
  for (int i = 1; i <= k; i++)
    sum[0][i] = dp[0][i] + sum[0][i - 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = (sum[i - 1][j] - ((j - a[i] - 1 >= 0) ? sum[i - 1][j - a[i] - 1] : 0) + mod) % mod;
    }
    sum[i][0] = dp[i][0];
    for (int j = 1; j <= k; j++)
      sum[i][j] = (dp[i][j] + sum[i][j - 1]) % mod;
  }
  cout << dp[n][k];
  return 0;
}


Measured memory_bytes: 79488
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    map<int, int> mp;
    for(auto &x : a){
        cin >> x;
        mp[x]++;
    }
    sort(ALL(a));
    uni(a);
    sort(ALL(a), [&](int x, int y){
        return mp[x] > mp[y];
    });
    int ans = 0;
    for(int i = k; i < SZ(a); i++){
        ans += mp[a[i]];
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#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 repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
// const ll INF = 1LL << 30;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

// O(N*M)

int main() {
    ll n, m; cin >> n >> m;
    Vl c(m);
    rep(i, 0, m) cin >> c[i];
    Vl dp(n+1, INF);
    dp[0] = 0;
    rep(i, 0, n){
        rep(j, 0, m){
            if(i+c[j] > n) continue;
            chmin(dp[i+c[j]], dp[i]+1);
        }
    }
    co(dp[n]);

    return 0;
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll ans=INF;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll j=n/i;
            ans=min(ans,j+i-2);
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double l = (m * 360) / 60;
    double s = (h * 60 + m) * 360 / (12 * 60);
    double theta = s - l;
    theta = cos((3.14159265358979323846 / 180) * theta);
    double p = 3.14159265358979323846;
    if (theta >= 3.14159265358979323846)
    {
        theta = 2 * p - theta;
    }
    double ans = sqrt(a * a + b * b - 2 * a * b * theta);
    if (a + b > ans && b + ans > a && a + ans > b)
    {
        printf("%.12f\n", ans);
    }
    else
    {
        double thetas = sqrt(1 - theta * theta);
        if (theta > p / 2.0)
        {
            ans = ((-b) * theta - a) * ((-b) * theta - a) + (-b) * thetas * (-b) * thetas;
            ans = sqrt(ans);
            printf("%.12f\n", ans);
        }
        else
        {
            ans = (b * theta - a) * (b * theta - a) + b * thetas * b * thetas;
            ans = sqrt(ans);
            printf("%.12f\n", ans);
        }
    }
    return 0;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define MOD 1000000007
 
ll gcd(ll a, ll b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void){
    int N; cin >> N;
    int P[N];
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    int MIN[N];
    MIN[0] = P[0];
    int ans = 1;
    for (int i = 1; i < N; i++)
    {
        MIN[i] = min(MIN[i-1],P[i]);
        if(P[i] == MIN[i]) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1792
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <ctime>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int a;
	vector<int> snake;
	for (int i = 0; i < n; i++) {
		cin >> a;
		snake.emplace_back(a);
	}
	sort(snake.begin(), snake.end(), greater<int>());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += snake[i];
	}
	cout << ans << endl;
}

	



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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();

    int r = n - k;
    r++;

    long long che = 10e8 + 7;
    for(int i = 1; i <= k; i++){
        long long ans = 0;
        ans = COM(r, i);
        ans %= che;
        ans *= COM(k - 1, i - 1);
        ans %= che;
        cout << ans << endl;
    }


}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll A,P;
  IN(A,P);

  OUT((3*A+P)/2);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int n = Integer.parseInt(a + "" + b);
		double d = Math.sqrt(n);
		int i = (int)d;
		String message = "No";
		if(i == d) {
			message = "Yes";
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
    const char *Alice = "Alice";
    const char *Brown = "Brown";

    int X, Y;
    if (scanf("%d%d", &X, &Y) < 2) return 0;

    printf("%s\n", abs(X - Y) <= 1 ? Brown : Alice);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128_A_Apple_pie
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int apple = int.Parse(input[0]);
			int part = int.Parse(input[1]) + apple * 3;

			Console.WriteLine(part / 2);
		}
	}
}


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

int main(){
string hoge[10000];
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>hoge[i];
}
int bx=0;
int xa=0;
int ba=0;
int ans=0;
for(int i=0;i<n;i++){
	bool a=false;
	bool b=false;
	for(int j=0;j<hoge[i].size();j++){
		if(j==0 and hoge[i][j]=='B'){b=true;}
		if(hoge[i][j]=='A' and j<hoge[i].size()+1){
			if(hoge[i][j+1]=='B'){ans++;}
		}
		if(j==hoge[i].size()-1 and hoge[i][j]=='A'){a=true;}
	}
	if(a==true and b==true){ba++;}
	else if(a==true){xa++;}
	else if(b==true){bx++;}
}
if(bx==0 and xa==0){if(ba>0){ans+=ba-1;}}
else{ans+=ba+min(bx,xa);}
cout<<ans<<endl;
return 0;

}

Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        BigInteger answer = BigInteger.ZERO;
        long temp = (long) Math.sqrt(N);
        temp += 10;
        BigInteger x = new BigInteger(Long.toString(temp));
        BigInteger y = BigInteger.ZERO;
        do {
            x = x.subtract(BigInteger.ONE);
            y = (x.add(BigInteger.ONE)).multiply(x);
        }
        while ((new BigInteger(Long.toString(N)).compareTo(y)) < 1);
        for (int i = 1; i < x.longValue()+1; i++) {
            if (N % i != 0) {
                continue;
            }
            answer = answer.add(new BigInteger(Long.toString(N / i - 1)));
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 24404
/******************************************
* AUTHOR : SARTHAK GUPTA *
* NICK : SOPHOZAAR *
* INSTITUTION : BIT MESRA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

int n, W;
LL w[N], v[N];
LL dp[105][N]; 

LL knapsack() {
	
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= W; j++) {
				dp[i][j] = 0;
		}
	}

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= W; j++) {
			if(w[i] <= j) 
				dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	return dp[n][W];
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);

cin >> n >> W;

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

cout << knapsack() << "\n";

return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int calc_pair(int n){
    int r = 1;
    int k = n;
    while(k>0){
        r<<=1;
        k>>=1;
    }
    return r-n;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int a;
  int ans = 0;
  cin >> n;
  vector<int> A;
  multiset<int> st;
  REP(i,n){
      cin >> a;
      A.push_back(a);
      st.insert(a);

  }
  SORT(A);
  REV(A);
  REP(i,n){
      a = A[i];
      auto itr = st.find(a);
      if (itr == st.end())continue;
      //dump(st.size());
      st.erase(itr);//ペアを組めなかったとしても、今後使うことはないので決して良い
      //dump(st.size());
      int p = calc_pair(a);
      //cout << a << " " << p << endl;
      itr = st.find(p);
      if (itr == st.end())continue;
      st.erase(itr);
      ans++;
      }
  cout << ans << endl;
}


Measured memory_bytes: 10484
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    cout<<1110-n<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int count=0;
unsigned GetDigit(unsigned num){
    return log10(num)+1;
}
int main(){
    int N,i;
    scanf("%d",&N);
    
    for(i = 1 ; i <= N ; i++){
        int ans = GetDigit(i);
        if(ans % 2 == 1){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
use proconio::marker::Usize1;
fn main() {
    proconio::input! {
        d: usize,
        c: [i64;26],
        s: [[i64;26];d],
        mut t: [Usize1;d],
        m: usize,
        dq: [(Usize1,Usize1);m],
    }
    for (d,q) in dq {
        t[d]=q;
        let mut last=[0;26];
        let mut v=0;
        for (i,&t) in t.iter().enumerate() {
            v+=s[i][t];
            last[t]=i+1;
            for (&c,&last) in c.iter().zip(last.iter()) {
                v-=c*(i+1-last)as i64;
            }
        }
        println!("{}",v);
    }
}

Measured memory_bytes: 4456
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int main() {
    int N, X;
    scanf("%d %d", &N, &X);
    int D = 0;
    int cnt = 1;
    for (int i = 0; i < N; ++i) {
        int L;
        scanf("%d", &L);
        D = D + L;
        if (D <= X) {
            ++cnt;
        }
    }
    printf("%d\n", cnt);
    return 0;
}



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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  vector<char> chs;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'B') {
      if (chs.size() > 0) {
        chs.erase(chs.end() - 1);
      }
    } else {
      chs.push_back(s[i]);
    }
  }

  string ans(chs.begin(), chs.end());
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3580
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;

int tx[] = {1,0};
int ty[] = {0,1};

int main(){
	int p[3];
	int ju[2];
	for(int i=0;i<3;i++){
		scanf("%d",p+i);
	}

	for(int i=0;i<2;i++){
		scanf("%d",ju+i);
	}

	int res = INF;
	for(int i=0;i<3;i++){
		for(int j=0;j<2;j++){
			res = min(res,p[i]+ju[j] -50);
		}
	}
	printf("%d\n",res);
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val Hn = readLine()!!.split(" ").map(String::toInt)
    val AB = (1..M).map{
        val (a, b) = readLine()!!.split(" ").map(String::toInt)
        Pair(a, b)
    }
    val junction = (1..N).map {
        0
    }.toMutableList()
    AB.map {
        val (a, b) = it
        junction[a - 1] = if(junction[a - 1] > Hn[b - 1]) {junction[a - 1]} else { Hn[b - 1] } 
        junction[b - 1] = if(junction[b - 1] > Hn[a - 1]) {junction[b - 1]} else { Hn[a - 1] }
    }
    Hn.indices.map {
        val h = Hn[it]
        (junction[it]) < h
    }.filter { it }.size.run(::println)
}

Measured memory_bytes: 70672
#include <cstdio>
#define MAX_N (10010)
using namespace std;
int par[MAX_N];
int rank[MAX_N];

int root( int x ) {
    if ( par[x] == x ) return par[x];
    else return par[x] = root( par[x] );
}

void unite( int x, int y ) {
    int r_x = root(x);
    int r_y = root(y);    

    par[r_y] = par[r_x];
}

bool isSame( int x, int y ) {
    return root(x) == root(y);
}


int main()
{
    int n, q;

    scanf("%d %d", &n, &q);

    for ( int i = 0; i < n; i++ ) {
	par[i] = i;
	rank[i] = i;
    }

    for ( int i = 0; i < q; i++ ) {
	int c, x, y;
	scanf("%d %d %d", &c, &x, &y);
	if ( c == 0 ) {		// unite
	    unite( x, y );
	}
	else { 			// same
	    printf("%d\n", isSame( x, y ) ? 1 : 0);
	}
    }

    return 0;
}

Measured memory_bytes: 1104
#include<cstdio>
int ans[14]={0,0,1,1,7,4,1,336,384,334,220,108,36,6};
int main(){
	long long N;scanf("%lld",&N);
	printf("%d\n",N<14?ans[N]:N==27||N==134217723?976:N==28||N==268435451||N==2044?108:N==29||N==536870907?4:N==60||N==1020||N==1152921504606846970ll?220:N==61?1:N==124||N==508?334:N==252?384:N==4092?36:N==8188?6:-1);
}

Measured memory_bytes: 3212
N = int(input())

testimony = [[] for _ in range(N)]

for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)



int main(void){

	string s; cin >> s;
	int ans = 0;
	REP(i,s.size()){
		if(s[i] == '1') ans++;
	}

	cout << ans << endl;

	return 0;

}


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

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

int main(){
    int n;
    cin >> n;
    int money = 0;

    vector<bool> test(60000);
    vector<int> test2(60000);
    reps(i,1,55000){
        money = i * 1.08;
        test2[money] = i; 
        test[money] = true;
    }

    if(test[n]){
        cout << test2[n] << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}


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

int main() {
  string str;
  cin >> str;
  int n=0;
  int e=0;
  int w=0;
  int s=0;
  
  for(int i=0; i<str.size(); i++){
    if(str.at(i) == 'N'){
      n++;
    }
    if(str.at(i) == 'E'){
      e++;
    }
    if(str.at(i) == 'W'){
      w++;
    }
    if(str.at(i) == 'S'){
      s++;
    }
  }
  
  if(n*s == 0){
    if(n*n + s*s != 0){
      cout << "No" << endl;
    }
    else{
      if(e*w == 0){
        cout << "No" << endl;
      }
      else{
        cout << "Yes" << endl;
      }
    }
  }
  
  else{
    if(e*w != 0){
      cout << "Yes" << endl;
    }
    else{
      if(e*e + w*w == 0){
      cout << "Yes" << endl;
    }
      else{
        cout << "No" << endl;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 256