akhauriyash/Code-Regression huggingface dataset:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp
#????????????
#????????????python???????????????????????????????????????push???pop?????????
#??????????????????????????°????????§??????????§£???????????\??£???

def rpn(formula):
    stack = Stack()
    
    for d in formula:
        if d == "+":
            stack.push(stack.pop() + stack.pop())
        elif d == "-":
            stack.push(-stack.pop() + stack.pop())
        elif d == "*":
            stack.push(stack.pop() * stack.pop())
        else:
            stack.push(int(d))
            
    return stack.pop()

class Stack:
    def __init__(self):
        self.data = []

    def push(self, d):
        #print(self.data)
        self.data.append(d)
        
    def pop(self):
        #print(self.data)
        r = self.data[-1]
        self.data = self.data[:-1]
        return r
    
def main():
    formula = input().split()
    print(rpn(formula))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 7768
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

string in; int n;

int eval(int s,int t){
  int i,d=0;
  for(i=t-1;i>=s;i--){
    if(in[i]==')')d++;
    else if(in[i]=='(')d--;
    if(d==0&&(in[i]=='+'||in[i]=='-'))break;
  }
  if(i>=s){
    int a=eval(s,i),b=eval(i+1,t);
    return in[i]=='+'?a+b:a-b;
  }
  d=0;
  for(i=t-1;i>=s;i--){
    if(in[i]==')')d++;
    else if(in[i]=='(')d--;
    if(d==0&&(in[i]=='*'||in[i]=='/'))break;
  }
  if(i>=s){
    int a=eval(s,i),b=eval(i+1,t);
    return in[i]=='*'?a*b:a/b;
  }
  if(in[s]=='('&&in[t-1]==')')return eval(s+1,t-1);
  return atoi(in.substr(s,t-s).c_str());
}
int main()
{
  int cs; cin>>cs; cin.ignore();
  rep(i,cs){
    getline(cin,in);
    n=in.size();
    cout<<eval(0,n-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())
s = list(map(int, list(input())))


# しゃくとり法
ans = 0
L, R = 0, 0
s.append(-1)  # 右端の処理

# 指定区間で直立した人の連続数の数
counter = 0
    
while R < n:
    # 右端を進める場合
    if (counter < k) or (counter == k and s[R] == 1):
        if s[R] == 0 and s[R+1] == 1:
            counter += 1
        ans = max(ans, R - L + 1)
        R += 1
    # 右端をこれ以上進められない場合
    # 左端を進める場合
    elif L < R:
        if s[L] == 0 and s[L+1] == 1:
            counter -= 1
        L += 1        
    # 左端も進められない（右端に追いついてしまった）場合
    # 区間全体を右に進める
    elif L == R:  
        L += 1
        R += 1
        
print(ans)

Measured memory_bytes: 4792
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
xsum = sum((i * x[i] - (n - 1 - i) * x[i]) for i in range(n))
ysum = sum((i * y[i] - (m - 1 - i) * y[i]) for i in range(m))
ans = (xsum * ysum) % mod
print(ans)


Measured memory_bytes: 18624
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	int a, b, k;
	cin >> a >> b >> k;
	set<int> st;
	for (int i = a; i <= min(b, a+k-1); ++i) st.insert(i);
	for (int i = b; i >= max(b-k+1, a); --i) st.insert(i);
	for (int v : st) cout << v << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void)
{
	int h,w;
	while(scanf("%d %d",&h,&w)!=EOF)
	{
		int i;
		int j;
		int count=1;
		char s[101][101]={0};
		char q[101];
		for(i=1;i<=h;i++)
		{
			char q[101]={0};
			scanf("%s",&q);
			for(j=1;j<=w;j++)
			{
				s[count][j]=q[j-1];
			}
			count++;
		}
		for(i=1;i<=w+2;i++)
		printf("#");
		printf("\n");
		for(i=1;i<count;i++)
		{
			printf("#");
			for(j=1;j<=w;j++)
			printf("%c",s[i][j]);
			printf("#\n");
		}
		for(i=1;i<=w+2;i++)
		printf("#");
		printf("\n");
		
	}
	
 } 

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

using namespace std;

#define N 100010
vector<int> g[N];
int res,n,dist[2][N],id;

inline void dfs(int v,int p=-1){
    if(p!=-1) dist[id][v]=dist[id][p]+1;
    for(int i=0;i<g[v].size();i++) if(g[v][i]!=p) dfs(g[v][i],v);
    return;
}

int main(){
	ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    id=0;dfs(0);
    id=1;dfs(n-1);
    for(int i=0;i<n;i++) if(dist[0][i]<=dist[1][i]) res++;
    if(res>=n/2+1) cout<<"Fennec";
    else cout<<"Snuke";
    return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, k;
	cin >> n >> k;
	string s[n];
	for(int i = 0; i < n; i++)
		cin >> s[i];
	sort(s,s+n,[&](string &a, string &b){
		return a + b < b + a;
	});
	
	for(int i = 0; i < n; i++)
		cout << s[i];
	

	return 0;
}



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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main (){
    int N,ans=1000000,A,B,t;
    cin >> N;
    for(int a=1;a<N;a++){
        A = findSumOfDigits(a);
        t = N-a;
        B = findSumOfDigits(t);

        if(A+B < ans){
            ans = A+B;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,m = Is()
print((m*1900 + (n-m)*100)*2**m)

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 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(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x;
    cin >> x;
    if (x<30)
    {
        cout << "No" << endl;
    }
    else 
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3648
S = input()
L = len(S)

if L == 2:
    print('1 2' if S[0] == S[1] else '-1 -1')
else:
    result = False
    for i in range(L - 2):
        s = S[i:i + 3]
        if s[0] == s[1] or s[1] == s[2] or s[2] == s[0]:
            print(str(i + 1) + ' ' + str(i + 3))
            result = True
            break

    result or print('-1 -1')

Measured memory_bytes: 3188
#include <iostream>

int main(){
    int64_t X;
    int ans;

    std::cin >> X;

    int64_t deposit = 100;
    // 1年~答えまで見ていく 
    for(int year = 1;; year++){
        deposit *= 1.01;
//        std::cout << deposit << std::endl;
        if(deposit >= X){
            ans = year;
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

bool bellman_ford(const int v, const int s,
                  const vector<pair<pair<int, int>, int64_t>>& g,
                  vector<int64_t>& cost,
                  vector<bool>& negative)
{
    const int64_t inf = 1LL << 60;
    cost[s] = 0;
    for (auto i = 0; i < v * 2; i++) {
        for (auto & elm : g) {
            if(cost[elm.first.first] == inf) continue;
            if(cost[elm.first.second] > cost[elm.first.first] + elm.second) {
                if(i == v - 1) negative[elm.first.second] = true;
                cost[elm.first.second] = cost[elm.first.first] + elm.second;
            }
            // 閉路から進んだ先は閉路を含む扱いにする
            if(i >= v) if(negative[elm.first.first] == true) negative[elm.first.second] = true;
        }
    }
    return false;
}

int main(){
    int n, m; cin >> n >> m;
    vector<pair<pair<int, int>, int64_t>> g;
    const int64_t inf = 1LL << 60;
    vector<int64_t> cost(n, inf); vector<bool> negative(n, false);
    for (auto i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c; a--; b--;
        g.emplace_back(make_pair(a, b), -c);
    }
    bellman_ford(n, 0, g, cost, negative);
    if(negative[n - 1]) {
        cout << "inf" << endl;
        return 0;
    }
    cout << -cost[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>

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

int n,d,x;
int p[10][10];
int dp[11][100001];

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

void init(void) {
  rep(i,n) rep(j,100001) dp[i][j] = 0;
}

void solve() {
  rep (i,d - 1) {
    vector<int> v;

    rep(j,n) {
      v.push_back(p[i+1][j]-p[i][j]);
    }

    init();

    rep (j, v.size()) {
      rep (k, x+1) {
        dp[j+1][k] = dp[j][k];
        if (k - p[i][j] >= 0) chmax(dp[j+1][k], dp[j+1][k - p[i][j]] + v[j]);
      }
    }

    x += dp[v.size()][x];
  }
  cout << x << endl;
}
signed main (void) {
  cin >> n >> d >> x;
  rep (i,d) rep(j,n) cin >> p[i][j];
  solve();
}


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

int main() {
    int N;
    int a[1000];
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    double result1=1, result2=0;
    for(int i = 0; i < N; i++) {
        result2 += double(1.0 / a[i]);
    }
    double result = result1 / result2;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX

int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    multiset<ll>s;
    for(ll i=0;i<n;++i){
        ll now=a[i];
        auto itr=s.lower_bound(now);
        if(itr!=s.begin())s.erase(--itr);
        s.insert(now);
    }
    cout<<s.size()<<endl;
}

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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, m, x, y, z;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; ++i) {
        cin >> x >> y >> z;
        x--, y--;
        uf.unite(x, y);
    }
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        if(uf.root(i) == i) ans++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 896
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


class WeightedUnionFind:
    def __init__(self, node: int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]
        self.diff_weight = [0 for i in range(self.n)]

    # ノードxのルートを求める
    def find(self, x: int) -> int:
        if x == self.par[x]:
            return x
        else:
            r = self.find(self.par[x])
            self.diff_weight[x] += self.diff_weight[self.par[x]]
            self.par[x] = r
            return self.par[x]

    # ノードxのルートからの距離を求める
    def weight(self, x: int) -> int:
        self.find(x)
        return self.diff_weight[x]

    # weight(y) - weight(x) = w となるようにする
    def unite(self, x: int, y: int, w: int) -> bool:
        if self.isSame(x, y):
            # print("x and y has already united")
            return False

        w += self.weight(x)
        w -= self.weight(y)

        rx = self.find(x)
        ry = self.find(y)

        if self.rank[rx] < self.rank[ry]:
            rx, ry = ry, rx
            w = -w

        self.par[ry] = self.par[rx]
        self.diff_weight[ry] = w

        if self.rank[rx] == self.rank[ry]:
            self.rank[rx] += 1

        return True

    def isSame(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    def diff(self, x: int, y: int) -> int:
        if self.isSame(x, y):
            return self.weight(y) - self.weight(x)
        else:
            raise ValueError("xとyは同じ木に属していません")


def judge(wuf, state):
    for l, r, d in state:
        if wuf.diff(l, r) != d:
            return False

    return True


n, m = li()
wuf = WeightedUnionFind(n)

lrd = []

for _ in range(m):
    l, r, d = li()
    l -= 1
    r -= 1

    lrd.append((l,r,d))

    wuf.unite(l, r, d)

print("Yes" if judge(wuf, lrd) else "No")

Measured memory_bytes: 125600
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner input;
    static void Main()
    {

        input = new Scanner();
        int first = input.Int();
        var arr = new List<double>();
        arr.Add(first);
        bool flag = true;
        while(flag)
        {
            if (arr.Count==0)
            {
                arr.Add(first);
            }
            else
            {
                arr.Add(f(arr[arr.Count-1]));
            }
            for(int a = 0; a < arr.Count-1; a++)
            {
                if (arr[a] == arr[arr.Count - 1]) { WriteLine(arr.Count); flag = false; break; }
            }
        }

    }
    static double f(double a)
    {
        if (a%2 == 0)
        {
            return (double)(a/2);
        }
        else
        {
            return (double)(3*a+1);
        }

    }
}

class Scanner
{

    public Scanner()
    {
    }

    public void skip()
    {
        ReadLine();
        return;
    }
    public string String()
    {
        return ReadLine();
    }
    public string[] arrayString()
    {
        return ReadLine().Split();
    }
    public int Int()
    {
        return int.Parse(ReadLine());
    }
    public int[] arrayInt()
    {
        return ReadLine().Split().Select(i => int.Parse(i)).ToArray();
    }
    public long Long()
    {
        return long.Parse(ReadLine());
    }
    public long[] arrayLong()
    {
        return ReadLine().Split().Select(i => long.Parse(i)).ToArray();
    }
    public double Double()
    {
        return double.Parse(ReadLine());
    }
    public double[] arrayDouble()
    {
        return ReadLine().Split().Select(i => double.Parse(i)).ToArray();
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

class Node{
	int id;
	int parent, left, right;
	public Node(int id){
		this.id = id;
		this.parent = -1;
		this.left = -1;
		this.right = -1;
	}
}
class Nodes{
	Node[] nodes;
	public int getDepth(int id){
		int d = 0;
		int u = nodes[id].parent;
		while(u != -1){
			u = nodes[u].parent;
			d++;
		}
		return d;
	}
	public void printChildren(int id){
		int c = nodes[id].left;
		while(c!=-1){
			System.out.print(c);
			c = nodes[c].right;
			if(c!=-1) System.out.print(", ");
		}
	}
	public void printNode(int id){
		System.out.print("node " + id + ": ");
		System.out.print("parent = " + nodes[id].parent + ", ");
		System.out.print("depth = " + getDepth(id) + ", ");
		if(nodes[id].parent == -1)
			System.out.print("root, ");
		else if(nodes[id].left == -1)
			System.out.print("leaf, ");
		else
			System.out.print("internal node, ");
		System.out.print("[");
		printChildren(id);
		System.out.println("]");
	}
}
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		
		Nodes mynodes = new Nodes();
		Node[] nodes = new Node[n];
		mynodes.nodes = nodes;
		for(int i = 0;i<n;i++){
			nodes[i] = new Node(i);
		}
		int l = 0;
		for(int i=0;i<n;i++){
			int id = in.nextInt();
			int k = in.nextInt();
			for(int j=0;j<k;j++){
				int c = in.nextInt();
				if(j==0){
					nodes[id].left = c;
					l = c;
				}
				//????????????????????????
				else nodes[l].right = c;
				l = c;
				nodes[c].parent = id;
			}
		}
		for(int j=0;j<n;j++){
			mynodes.printNode(j);
		}
	}
}

Measured memory_bytes: 134504
//#include "grader.h"
#include <bits/stdc++.h>  

using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
#define div divv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const ll mod = ll(1e9) + 9LL, pr = 239, mod2 = ll(1e9) + 7;

ll n, a, b, c, d;

int main() {
	iostream::sync_with_stdio(0), cin.tie(0);
	cin >> n >> a >> b >> c >> d;
	//n--;
	b -= a;
	for (int i = 0; i <= n - i - 1; i++) {
		ll l = -ll(n - i - 1) * c +ll(i) * d, r = -ll(n - i - 1) * d + ll(i) * c;
		if (l > r) swap(l, r);
		if (b >= l && b <= r) {
			cout << "YES\n";
			re 0;
		}
		swap(l, r);
		if (b >= -l && b <= -r) {
			cout << "YES\n";
			re 0;
		}

	}
	cout << "NO\n";
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    AB = [NLI() for _ in range(N)]
    
    for n in range(N-2):
        if AB[n][0] == AB[n][1]:
            if AB[n+1][0] == AB[n+1][1]:
                if AB[n+2][0] == AB[n+2][1]:
                    print("Yes")
                    sys.exit()
    print("No")





if __name__ == '__main__':
    main()

Measured memory_bytes: 9484
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
    int n; cin >> n;
    vector<double> x(n), y(n); rep(i, n) cin >> x[i] >> y[i];

    double res = 0;
    vector<vector<int>> lst;
    vector<int> array; rep(i, n) array.push_back(i);
    do{
        lst.push_back(array);
    }while(next_permutation(all(array))); 
    for(vector<int> vc: lst){
        double d = 0;
        rep(i, vc.size()-1){
            int cx=x[vc[i]], cy=y[vc[i]], nx=x[vc[i+1]], ny=y[vc[i+1]];
            d = sqrt(pow(cx-nx,2) + pow(cy-ny,2));
            res += d;
        }
    }
    cout << fixed << setprecision(10);
    cout << res / lst.size() << ln;

}


Measured memory_bytes: 3256
// https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<pii> v(N);
    REP(i, N) cin >> v[i].first >> v[i].second;
    sort(ALL(v));

    map<pii, int> dist;
    for (int k = 0; k < N; k++) {
        for (int l = k + 1; l < N; l++) {
            dist[{v[k].first - v[l].first, v[k].second - v[l].second}]++;
        }
    }
    int ans = N;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int p = v[i].first - v[j].first;
            int q = v[i].second - v[j].second;
            int cnt = dist[{p, q}];
            ans = min(ans, N - cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long h = sc.NextLong();
        long w = sc.NextLong();
        long n = sc.NextLong();
        long[] a = sc.LongArray();

        long[,] map = new long[h, w];

        long currentH = 0;
        long currentW = 0;
        for (int i = 0; i < n; i++)
        {
            long count = a[i];
            while (count > 0)
            {
                map[currentH, currentW] = i + 1;
                if (currentH % 2 == 0)
                {
                    currentW++;
                    if (currentW >= w)
                    {
                        currentH++;
                        currentW = w - 1;
                    }
                }
                else
                {
                    currentW--;
                    if (currentW < 0)
                    {
                        currentH++;
                        currentW = 0;
                    }
                }
                count--;
            }
        }


        for (int i = 0; i < h; i++)
        {
            List<long> nums = new List<long>();
            for (int j = 0; j < w; j++)
            {
                nums.Add(map[i, j]);
            }
            Console.WriteLine(string.Join(" ", nums));
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 29596
fn main() {
    let c1 = read::<String>().chars().nth(0).unwrap();
    let c2 = read::<String>().chars().nth(1).unwrap();
    let c3 = read::<String>().chars().nth(2).unwrap();
    println!("{}{}{}", c1, c2, c3);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
const long long MOD = 1000000007;
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n; cin>>n;
  auto A=make_v(n,n,(ll)0);
  rep(i,n)rep(j,n) cin>>A[i][j];
  ll N=1<<n;
  vector<ll> dp(N,0);
  dp[N-1]=1;
  rep(i,n){
    vector<ll> ndp(N,0);
    rep(mask,N){
      if(__builtin_popcount(mask)!=(n-i)) continue;
      rep(j,n){
        if(A[i][j]&&((mask>>j)&1)){
          ndp[mask^(1<<j)]+=dp[mask];
          ndp[mask^(1<<j)]%=MOD;
        }
      }
    }
    dp=ndp;
  }
  cout<<dp[0]<<"\n";
}

Measured memory_bytes: 33024
#include<stdio.h>

int main(void){
  int i,j,takasa[10],temp;

  for(i=0;i<10;i++){
    scanf("%d",&takasa[i]);
  }

  for(i=9;i>0;i--){
    for(j=0;j<i;j++){
      if(takasa[j]<takasa[j+1]){
	temp=takasa[j+1];
	takasa[j+1]=takasa[j];
	takasa[j]=temp;
      }
    }
  }

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

  return 0;
}

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

static const int INF = 1e9+7;

int D,G;
vector<pair<int,int>> data;

int main(){
    cin>>D>>G;
    data.resize(D);
    
    for(int i=0; i<D; i++){
        cin>>data[i].first>>data[i].second;
    }

    int ans = INF;

    for(int bit=0; bit<(1<<D); bit++){
        int cnt,cur;
        cnt = 0;
        cur = 0;
        vector<pair<int,int>> cp(D);
        cp = data;
        
        for(int i=0; i<D; i++){
            if(bit & (1<<i)){
                cur += cp[i].second;
                cur += cp[i].first*100*(i+1);
                cnt += cp[i].first;
                cp[i].first = 0;
            }
        }

        if(cur < G){
            for(int i=D-1; i>=0; i--){
                while(1){
                    if(cur >= G) break;
                    if(cp[i].first == 0) break;
                    cp[i].first--;
                    cnt++;
                    cur += 100*(i+1);
                }
            }
        }

        ans = min(cnt,ans);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  string S;
  cin >> S;
  
  int n = S.size();
  
  bool flag = true;
  
  rep(i,n) {
    if (S.at(i) != S.at(n-1-i)) flag = false;
  }
  
  rep(i,(n-1)/2) {
    if (S.at(i) != S.at((n-1)/2 -1-i)) flag = false;
  }
  
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int64_t powmod(int64_t x, int64_t n, int64_t mod) {
	int64_t ret = 1;
	while (n > 0) {
		if (n & 1) (ret *= x) %= mod;
		(x *= x) %= mod;
		n >>= 1;
	}
	return ret;
}



int main() {

	int n; cin >> n;

	vector<LL> a(n);
	vector<LL> d(n);

	LL mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];

		mx = max(mx, a[i]);
		d[a[i]]++;
	}

	if (a[0] != 0 || d[0]>1) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < mx + 1; i++) {
		if (d[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	LL ans = 1;

	for (int i = 1; i < mx+1; i++) {
		ans = ans * powmod(d[i-1], d[i], 998244353);
      ans%=998244353;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#ifdef DEBUG
#define debug(x) cerr << #x << " " << x << '\n'
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
int a, b, x;
const double pi = acos(-1.0);
int main()
{
 	scanf("%d%d%d",&a,&b,&x);
 	double y = 2.0*x/a/a-b;
 	if(y>=0.0)
	{
		double alpha = atan(1.0*(b-y)/a);
	 	printf("%.10f\n",alpha*180.0/pi);
	}
	else
	{
		double z = 2.0*x/a/b;
		double alpha = atan(b/z); 
		printf("%.10f\n",alpha*180.0/pi);
	} 
	return 0;
}


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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> x, y;
    y.push_back(0);
    for (int i=0;i<n;++i) {
        ll a;
        cin >> a;
        if (a < 0) x.push_back(-a);
        else y.push_back(a);
    }

    x.push_back(0);//番兵
    sort(x.begin(), x.end());
    int ms = min(k, (ll)y.size()-1);
    ll ans = 1e16;
    for (int i = ms; i >= 0; i--) {
        if (k - i >= x.size()) break;
        ans = min(ans, 2 * y[i] + x[k - i]);
        ans = min(ans, 2 * x[k - i] + y[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int A, B, C, D;
  scanf("%d%d%d%d", &A, &B, &C, &D);

  if (A + B > C + D) {
    printf("Left");
  } else if (A + B == C + D) {
    printf("Balanced");
  } else {
    printf("Right");
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<map>
#include<queue>
#define inf1 1000000009
#define inf -1
using namespace std;
bool s[55556];
int s1[55556];int a;
void mm(){
    memset(s,true,sizeof(s));
    s[0]=s[1]=false;
 for(int i=2;i<=55555;i++)
 {
     if(s[i]){s1[a++]=i;}
    for(int j=2*i;j<=55555;j+=i)
    s[j]=false;
}}

int main(){
  mm();
  int t;
    cin>>t;
   for(int i=0;;i++){
    if(s1[i]%5==4) {t--;printf(t==0?"%d\n":"%d ",s1[i]);}
    if(t==0)break;

   }
}

Measured memory_bytes: 384
# https://atcoder.jp/contests/abc157/tasks/abc157_c

N, M = map(int, input().split())
c = [-1 for _ in range(N)]

for _ in range(M):
    S, C = map(int, input().split())
    if c[S - 1] != -1 and c[S - 1] != C:
        print(-1)
        exit(0)
    c[S - 1] = C

if N == 1 and c[0] == 0:
    print(0)
    exit(0)

if N == 1 and c[0] == -1:
    print(0)
    exit(0)

if c[0] == 0:
    print(-1)
    exit(0)

s = ""
for i, a in enumerate(c):
    if i == 0:
        s += str(max(a, 1))
    else:
        s += str(max(a, 0))

print(s)


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

int main() {
  int n;
  cin >> n;
  vector<string>ward(n);
  for(int i = 0;i < n;i++){
    cin >> ward.at(i);
    for(int j = 0;j < i;j++){
      if(ward.at(i) == ward.at(j)||ward.at(i).at(0) != ward.at(i-1).at(ward.at(i-1).size()-1)){
        cout << "No" << endl;
        goto end;
      }
    }
    if(i == n-1){
        cout << "Yes" << endl;
    }
  }
  end:;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

int main() {
  int l, r, ans = INT_MAX;
  scanf("%d %d", &l, &r);
  int mod;
  if (r-l >= 2019) ans = 0;
  else{
    l = l%2019; r = r%2019;
    if (r<l) {
      ans = 0;
    }else {
      for (size_t i = l; i < r; i++) {
        for (size_t j = l+1; j <= r; j++) {
          mod = (i*j)%2019;
          ans = (ans > mod) ? mod : ans;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){
	int n, i;
	int a[100];
	
	cin >> n;
	
	for(i = 0; i < n; i++){
		cin >> a[i];
	}

	for(i = n-1; i>=0; i--){
		if(i != n-1){
			cout << " ";
		}
		cout << a[i];
	}
	
	cout << endl;
	
 	return 0;
}

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

int main(){
	string s;
	cin >> s;
	
	if(s == "zyxwvutsrqponmlkjihgfedcba"){
		cout << -1 << endl;
		return 0;
	}
	
	
	if(s.size() < 26){
		vector<P> alph(26);
		rep(i, 26) alph[i] = make_pair(0, i);
		
		rep(i, s.size()){
			alph[s[i] - 'a'].first++;
			alph[s[i] - 'a'].second = s[i] - 'a';
		}
		sort(alph.begin(), alph.end());
		s += (char)alph[0].second + 'a';
		cout << s << endl;
	}
	else{
		string tmp = s;
		next_permutation(s.begin(), s.end());
		rep(i, 26){
			if(s[i] == tmp[i]){
				cout << s[i];
			}
			else{
				cout << s[i] << endl;
				return 0;
			}
		}
	}
	
	return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def bfs(root):
        dist = [f_inf] * n
        dist[root] = 0
        que = deque()
        que.append(root)
        while que:
            prev = que.popleft()
            for next in tree[prev]:
                if dist[next] == f_inf:
                    dist[next] = dist[prev] + 1
                    que.append(next)
        return dist

    n, x, y = map(int, input().split())
    tree = [[] for _ in range(n)]
    for i in range(n - 1):
        tree[i].append(i + 1)
        tree[i + 1].append(i)
    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

    cnt = [0] * n
    for i in range(n):
        dist = bfs(i)
        for d in dist:
            cnt[d] += 1

    for i in range(1, n):
        print(cnt[i] // 2)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 105308
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()

int main() {
	int N; cin >> N;
	vector<int> a = {1,6,6*6,6*6*6,6*6*6*6,6*6*6*6*6,6*6*6*6*6*6,9,9*9,9*9*9,9*9*9*9,9*9*9*9*9};
	vector<int> dp(N + 1,1000000);
	dp[0] = 0;
	REP(i,N) REP(j,a.size()) if(i + a[j] <= N) dp[i + a[j]] = min(dp[i] + 1, dp[i + a[j]]);
	cout << dp[N] << endl;

	return 0;
}


Measured memory_bytes: 640
/* D */

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    long long int n;
    cin >> n;
    std::vector<long long int> a(n);
    std::vector<long long int> x(n, 0);

    long long int sum = 0;
    long long int oddsum = 0;

    for (long long int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    	sum += a[i];

    	if(i % 2 == 0) oddsum += a[i];

    }

    sum = sum/2;

    x[0] = oddsum - sum; 

    cout << 2 * x[0] << " ";

    for (long long int i = 0; i < n - 1 ; ++i)
    {
    	x[i+1] = a[i] - x[i];
    	cout << 2 * x[i+1] << " ";
    }

    cout << endl;

}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> v = {
        1,1,1,2,1,
        2,1,5,2,2,
        1,5,1,2,1,
        14,1,5,1,5,
        2,2,1,15,2,
         2, 5, 4, 1, 4,
          1, 51
    };
    int a;cin>>a;
    cout << v[a-1] << endl;
    return 0;
}


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

set<int> alphabets[27];

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i, n) {
    alphabets[s[i] - 'a'].insert(i);
    // rep(j, 27) alphabets[i + 1][j] += alphabets[i][j];
  }
  int q;
  cin >> q;
  rep(i, q) {
    int t;
    cin >> t;
    if (t == 1) {
      int iq;
      char c;
      cin >> iq >> c;
      iq--;
      alphabets[s[iq] - 'a'].erase(iq);
      s[iq] = c;
      alphabets[s[iq] - 'a'].insert(iq);
    } else {
      int l, r;
      cin >> l >> r;
      l--, r--;
      int ans = 0;
      rep(j, 26) {
        auto it = alphabets[j].lower_bound(l);
        if (it != alphabets[j].end() && *it <= r) ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 24196
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val s = readLine() ?: return
    var count = 0
    0.until(1000).forEach loop@{
        val target = "%03d".format(it)
        var i = 0
        s.forEach {
            if (target[i] == it) {
                i++
                if (i == 3) {
                    count++
                    return@loop
                }
            }
        }
    }
    println(count.toString())
}

Measured memory_bytes: 34744
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

  ll x;
  std::cin>>x;

  ll mod=x%100;
  ll cnt=x/100;

  std::vector<ll> dp(100,MOD);
  dp[0]=0;

  rep(i,1,100){
    rep(j,1,6){
      if(i-j>=0){
        chmin(dp[i],dp[i-j]+1);
      }
    }
  }

  if(dp[mod]>cnt)std::cout<<0<<"\n";
  else std::cout<<1<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

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

int main() {
	int n; scanf("%d", &n); std::vector<std::string> s(n);
	for(int i = 0; i < n; i++) cin >> s[i];

	int ma = 0;
	std::map<std::string, int> mp;
	for(int i = 0; i < n; i++) ma = std::max(ma, ++mp[s[i]]);

	for(auto v: mp) if(v.second == ma) printf("%s\n", v.first.c_str());
	return 0;
}



Measured memory_bytes: 26752
import sys
N, M = map(int,input().split())
S = input()
S = S[::-1]
i = 0
ans = []
while i < N:
    flag = 0
    for j in range(M,0,-1):
        if i + j <= N and S[i + j] == '0':
            i += j
            flag = 1
            ans.append(j)
            break
    if flag:
        continue
    print(-1)
    sys.exit()
ans.reverse()
print(*ans)

Measured memory_bytes: 6420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

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

    if (k % 2 != 0){
        cout << ll(pow(n / k, 3)) << endl;
    }
    else {
        cout << ll(pow(n / k, 3)) + ll(pow((n * 2) / k - (n / k), 3)) << endl;
    }

    return 0;
}

Measured memory_bytes: 384
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split("\n")
        .skip(1)
        .map(|x| {
            let mut v = x.split_whitespace()
                .map(|y| y.parse::<i32>().unwrap())
                .collect::<Vec<_>>();
            v.sort();
            v
        })
        .collect::<Vec<_>>();

    let mut sum = 0;
    //真ん中のパーツを決める
    for c in &list[1] {
        //上段の数
        let t = lower_bound(&list[0], 0, list[0].len(), c);
        let b = list[2].len() - upper_bound(&list[2], 0, list[2].len(), c);
        sum += t * b;
    }

    sum.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "2
1 5
2 4
3 6" => "3",
    test2: "3
1 1 1
2 2 2
3 3 3
" => "27",
    test3: "6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288" => "87",
}

//vecは昇順ソート済み
//以上
fn lower_bound<T: Ord>(vec: &Vec<T>, mut first: usize, mut last: usize, val: &T) -> usize {
    let mut mid;
    while last - first > 1 {
        mid = (first + last) / 2;
        if &vec[mid] < val {
            first = mid;
        } else {
            last = mid;
        }
    }
    if &vec[first] < val {
        last
    } else {
        first
    }
}

//より大きい
fn upper_bound<T: Ord>(vec: &Vec<T>, mut first: usize, mut last: usize, val: &T) -> usize {
    let mut mid;
    while last - first > 1 {
        mid = (first + last) / 2;
        if &vec[mid] <= val {
            first = mid;
        } else {
            last = mid;
        }
    }
    if &vec[first] <= val {
        last
    } else {
        first
    }
}


Measured memory_bytes: 14328
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std ;

const int N = 200010 ;

int n, k ;
int base[N] ;

int main(){
    cin >> n >> k ;
    cout << 1 + (int)ceil(1.0 * (n - k) / (1.0 * (k - 1))) << endl ;
}


Measured memory_bytes: 256
n = int(input())
al = list(map(int,input().split()))

for a in al:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            continue
        else:
            print("DENIED")
            exit()
    else:
        continue
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<string,int> > a(n);
  for(int i=0;i<n;i++){
    cin >> a[i].first >> a[i].second;
    a[i].second=100-a[i].second;
    a[i].second=a[i].second*1000+i;
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout << a[i].second%1000 +1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256