akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

const int MN = 105;

int N, M, A[MN][MN], B[MN][MN];

int cho[MN], mch[MN], vis[MN], v;
bool DFS(int i) {
	for (int j = 1; j <= M; ++j) if (A[i][j]) {
		int x = (A[i][j] - 1) / M + 1;
		if (vis[x] != v) {
			vis[x] = v;
			if (!mch[x] || DFS(mch[x])) return cho[i] = j, mch[x] = i, 1;
		}
	} return 0;
}

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
			scanf("%d", &A[i][j]);
	for (int j = 1; j <= M; ++j) {
		for (int i = 1; i <= N; ++i) v = (i - 1) * M + j, DFS(i);
		for (int i = 1; i <= N; ++i) B[i][j] = A[i][cho[i]], A[i][cho[i]] = 0, mch[i] = 0;
	}
	for (int i = 1; i <= N; ++i, puts(""))
		for (int j = 1; j <= M; ++j)
			printf("%d ", B[i][j]);
	for (int j = 1; j <= M; ++j) {
		static int per[MN];
		for (int i = 1; i <= N; ++i) per[(B[i][j] - 1) / M + 1] = B[i][j];
		for (int i = 1; i <= N; ++i) B[i][j] = per[i];
	}
	for (int i = 1; i <= N; ++i, puts(""))
		for (int j = 1; j <= M; ++j)
			printf("%d ", B[i][j]);
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> xy(n);
	for (pair<int, int>& i : xy) cin >> i.first >> i.second;
	sort(xy.begin(), xy.end());
	for (pair<int, int>& i : xy) cout << i.first << ' ' << i.second << endl;
}


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

int main() {
    int a,b,c;
    int i = 0;
    cin>>a>>b>>c;
    while(a < b+1){
        if(c % a == 0){
            i++;
        }
        a++;
    }
    cout<<i<<endl;
	return 0;
}



Measured memory_bytes: 3092
import itertools
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(M)]
r = list(range(1,N+1))
ok = 1
cnt = 0
for v in itertools.permutations(r):
    if(v[0] == 1):
        ok = 1
        for i in range(N-1):
            if(list(v[i:i+2]) not in ab and list(reversed(v[i:i+2])) not in ab):
                ok = 0
                break
        if(ok == 1):
            cnt += 1
print(cnt)

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

using namespace std;

struct katana{
	int a,b;
}k[100010];

int n,h;
int ans;

bool cmp(katana x,katana y){
	return x.b>y.b;
}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>h;
	int i,j;
	int maxv=0;
	for (i=1;i<=n;i++)cin>>k[i].a>>k[i].b,maxv=max(maxv,k[i].a);
	
	sort(k+1,k+n+1,cmp);
	
	i=1;
	while (i<=n && k[i].b>maxv){
		h-=k[i].b;
		ans++;
		if (h<=0){
			cout<<ans<<endl;
			return 0;
		}
		i++;
	}
	ans+=h/maxv;
	if (h%maxv!=0)ans++;
	cout<<ans<<endl;
	return 0;
}


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

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N;
    vector<int> t(N);
    for(int i = 0; i < N; i++){
        cin >> t.at(i);
    }
    cin >> M;
    vector<int> p(M);
    vector<int> x(M);
    for(int i = 0; i < M; i++){
        cin >> p.at(i);
        cin >> x.at(i);
    }
    for(int i = 0; i < M; i++){
        int sum = 0;
        for(int j = 0; j < N; j++){
            if(j == p.at(i)-1){
                sum += x.at(i);
            }else{
                sum += t.at(j);
            }
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string a,b;
  cin >>a >> b;
  int c=0;
  if (a[0] == b[0]) {
    c++;
  }
  if (a[1] == b[1]) {
    c++;
  }
  if (a[2] == b[2]) {
    c++;
  }
  cout << c;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n;
  cin >> n;
  set<int> s;
  bool t=true;
  rep(i,n){
    int f;
    cin >> f;
    if (s.find(f)!=s.end()) t=false;
    s.insert(f);
  }
  if (t) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
R0とL0がそれぞれ存在して、＋－が打ち消しあえばよさそう
+++----
0のやつが互いに端にならぶ
どちらも0でない、はありうるか
はじからスタートして、最小値がマイナスになったらOUT
0のやつの総和を、調整できないやつが超えてもOUT
((() (()((( (((     )))((()))(((    )))() (())) )))
0の余力　　　　　　　　ちょうど分ける？　　　　　　余力

))(  )))))(   )((((((
*/
int main(){
  ll N; cin>>N;
  vector<ll> R(N,0), L(N,0);
  set<ll> S;
  for(ll i=0; i<N; i++){
    string S; cin>>S;
    ll sz=S.size(), tmp=0, left=0,right=0;
    for(ll j=0; j<sz; j++){//)のあぶれ数
      if(S[j]=='(') tmp++;
      else{
        tmp--;
        left=min(left,tmp);
      }
    }
    L[i]=left;
    tmp=0;
    for(ll j=sz-1; j>=0; j--){//(のあぶれ数
      if(S[j]==')') tmp++;
      else{
        tmp--;
        right=min(right,tmp);
      }
    }
    R[i]=right;
  }
  //L0の総和と、そうじゃないやつの総和
  ll L0=0, L1=0, Lmin=-1e8, Rmin=-1e8, R0=0, R1=0;
  for(ll i=0; i<N; i++){
    if(L[i]==0) L0+=R[i];//余力
    else{
      if(R[i]!=0) Lmin=max(Lmin,L[i]);//外側にのこるであろう？
      L1+=L[i]-R[i];
    }
  }
  if(Lmin==-1e8) Lmin=0;
  Lmin=min(Lmin,L1);//耐えるべき攻撃

  for(ll i=0; i<N; i++){
    if(R[i]==0) R0+=L[i];//余力
    else{
      if(L[i]!=0) Rmin=max(Rmin,R[i]);//外側にのこるであろう？
      R1+=R[i]-L[i];
    }
  }
  if(Rmin==-1e8) Rmin=0;
  Rmin=min(Rmin,R1);//耐えるべき攻撃
//  cout<<"L0:"<<L0<<" Lmin:"<<Lmin<<" R0:"<<R0<<" Rmin:"<<Rmin<<endl;
  if(L0==Lmin && R0==Rmin) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 18760
import numpy as np
N, K   = map(int, input().split())
A=np.array(list(map(int, input().split())))
right=[]
left=[]
for i in range(N):
    right.append(np.count_nonzero(A[i:] < A[i]))
    left.append(np.count_nonzero(A[:i] < A[i]))
ans=sum(right)*(K*(1+K)//2)+sum(left)*((K-1)*K//2)
print(ans%(10**9+7))

Measured memory_bytes: 12484
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n, y = map(int, input().split())
    for i in range(n+1):
        for j in range(n+1):
            if n - i - j < 0:
                continue
            if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
                print(i, j, n-i-j)
                exit()

    print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, k; cin >> n >> k;
    int ans = 0;
    int h;
    rep(i,n) {
        cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n,m = gets.chomp.split(" ").map(&:to_i)
sc_arr = m.times.map{gets.chomp.split(" ").map(&:to_i)}

arr = []
n.times do
  arr << -1
end

if m == 0 then
  if n == 1 then
    puts 0
  elsif n == 2 then
    puts 10
  else
    puts 100
  end
  exit
end

hash = {}
sc_arr.each do |s, c|
  if !hash[s].nil? && hash[s] != c then
    puts "-1"
    exit
  end
  hash[s] = c
end

arr.each_with_index do |a, i|
  if hash[i+1] then
    arr[i] = hash[i+1]
  end
end

if arr[0] == 0 then
  if n == 1 then
    puts 0
  else
    puts "-1"
  end
  exit
end

arr.each_with_index do |a, i|
  if a == -1 then
    if i == 0 then
      arr[i] = 1
    else
      arr[i] = 0
    end
  end
end
result = arr.join("").to_i
if result.to_s.length == n then
  puts result
else
  puts "-1"
end


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

int main() {
    string s;
    cin >> s;
    unordered_map<char, int> mp;
    unordered_map<char, int> mpidx;
    int slen = s.size();
    int ans = 101;
    for (int i = 0; i < slen; i++) {
        mp[s.at(i)] = 0;
        mpidx[s.at(i)] = slen - 1 - i;
    }
    for (int i = 0; i < slen; i++) {
        int cnt = 0;
        for (int j = i-1; j >= 0; j--) {
            if (s.at(i) != s.at(j)) cnt++;
            else break;
        }
        if (mp[s.at(i)] < cnt) mp[s.at(i)] = cnt;
    }
    for (auto it = mp.begin(); it != mp.end(); it++) {
        if (mpidx[it->first] <= it->second) ans = min(ans, it->second);
        else ans = min(ans, mpidx[it->first]);
    }
    cout << ans << endl;
}

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

int main(void)
{
    int a,b,x,y;
    cin >> x >> y;
    for(b=x;b>=0;b--)
    {
        a=x-b;
        if(2*a+4*b==y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])


if a%3==0 or b%3==0 or (a+b)%3==0:
    
    print("Possible")
    
else:

    print("Impossible")

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
typedef pair<int,int> PA;
int main(){
  int h,w;
  PA p[6];
  for(int i=0;i<6;i++){
    scanf("%d %d",&h,&w);
    p[i] = PA(min(h,w),max(h,w));
  }
  sort(p,p+6);
  if(p[0]==p[1]&&p[2]==p[3]&&p[4]==p[5]&&p[0].first==p[2].first&&p[2].second==p[4].second&&p[0].second==p[4].first) puts("yes");
  else puts("no");
  return(0);
}



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

using namespace std;

int main() {
    long long N;
    cin >> N;

    long long minA = INT64_MAX;
    for (int i = 0; i < 5; ++i) {
        long long a;
        cin >> a;
        minA = min(minA, a);
    }
    
    cout << (N + minA - 1) / minA + 4 << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  if (n % 10 == 9 || n / 10 == 9) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws IOException {
        Deck deck = new Deck();

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            br.readLine();//1行目は捨てる;
            br.lines().map(Card::new).forEach(deck::add);//行ごとにカード生成してデッキに追加
        }

        System.out.print(deck);
    }
}

class Deck {
    private final Map<String, Suit> suits;

    public void add(Card card) {
        suits.get(card.getSuitSymbol()).add(card.getRank());
    }

    private boolean isMissing(String suitSymbol, int rank) {
        return suits.get(suitSymbol).isMissing(rank);
    }

    private String getMissingCardListAsString() {
        List<String> missingCardList = new ArrayList<>();
        String[] suitSymbol = {"S", "H", "C", "D"};

        for(int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                if (isMissing(suitSymbol[i], j)) {
                    missingCardList.add(suitSymbol[i] + " " + j);
                }
            }
        }
        if(missingCardList.size() > 0) {
            return missingCardList.stream().collect(Collectors.joining(String.format("%n"),"", String.format("%n")));
        } else {
            return "";
        }
    }

    @Override
    public String toString() {
        return getMissingCardListAsString();
    }

    public Deck(){
        super();
        suits = new HashMap<>();
        suits.put("S", new Suit());
        suits.put("C", new Suit());
        suits.put("H", new Suit());
        suits.put("D", new Suit());
    }
}

class Suit {
    private final boolean[] cards;

    public void add(int rank) {
        cards[rank - 1] = true;
    }

    public boolean isMissing(int rank) {
        return !cards[rank - 1];
    }

    public Suit() {
        super();
        cards = new boolean[13];
    }
}

class Card {
    private final String suitSymbol;
    private final int rank;

    public String getSuitSymbol() {
        return suitSymbol;
    }

    public int getRank() {
        return rank;
    }

    private Card(String suitSymbol, int rank) {
        super();
        this.suitSymbol = suitSymbol;
        this.rank = rank;
    }

    public Card(String lineString) {
        this(lineString.split(" ")[0], lineString.split(" ")[1]);
    }

    private Card(String suitSymbol, String rank) {
        this(suitSymbol, Integer.parseInt(rank));
    }
}


Measured memory_bytes: 31532
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int H, W, N;
	static char[][] f;
	static int r, c;
	static int[][] pos;
	static int[] DR = { 1, 0, -1, 0 };
	static int[] DC = { 0, 1, 0, -1 };

	static int dist(int rs, int cs, int rg, int cg) {
		boolean[][] visited = new boolean[H][W];
		ArrayList<Integer> cur = new ArrayList<Integer>();
		visited[rs][cs] = true;
		cur.add((rs << 10) + cs);
		int turn = 1;
		while (true) {
			ArrayList<Integer> next = new ArrayList<Integer>();
			for (int p : cur) {
				int r = p / 1024;
				int c = p % 1024;
				for (int i = 0; i < 4; ++i) {
					int nr = r + DR[i];
					int nc = c + DC[i];
					if (nr < 0 || H <= nr || nc < 0 || W <= nc) continue;
					if (visited[nr][nc] || f[nr][nc] == 'X') continue;
					if (rg == nr && cg == nc) return turn;
					visited[nr][nc] = true;
					next.add((nr << 10) + nc);
				}
			}
			++turn;
			cur = next;
		}
	}

	public static void main(String[] args) {
		H = sc.nextInt();
		W = sc.nextInt();
		N = sc.nextInt();
		f = new char[H][W];
		pos = new int[N + 1][2];
		for (int i = 0; i < H; ++i) {
			f[i] = sc.next().toCharArray();
			for (int j = 0; j < W; ++j) {
				char ch = f[i][j];
				if (ch == 'S') {
					pos[0][0] = i;
					pos[0][1] = j;
				} else if ('0' <= ch && ch <= '9') {
					pos[ch - '0'][0] = i;
					pos[ch - '0'][1] = j;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			ans += dist(pos[i][0], pos[i][1], pos[i + 1][0], pos[i + 1][1]);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 18000
#include <iostream>
#include <cstring>
using namespace std;
int ans[51];
void rec(int sum, int d){
  if(d == 4){
    ans[sum]++;
    return;
  }
  for(int i = 0 ; i <10; i++){
    rec(sum+i,d+1);
  }
}
void init(){
  memset(ans,0,sizeof(ans));
  rec(0,0);
}
int main(){
  int n;
  init();
  while(cin >> n){
    cout << ans[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n, m = [int(i) for i in input().split()]
E = [[] for i in range(n+1)]
used = [False] * (n + 1)
IN = [0] * (n + 1)

for i in range(m):
    a, b = [int(i) for i in input().split()]
    E[a].append(b)
    E[b].append(a)
    IN[a] += 1
    IN[b] += 1

cnt_4 = 0
cnt_6 = 0
v_4 = []
for j, i in enumerate(IN[1:]):
    if i % 2 == 1 or i == 0:
        print('No')
        exit()
    if i >= 4:
        cnt_4 += 1
        v_4.append(j + 1)
    if i >= 6:
        cnt_6 += 1

def dfs(p, v):
    if v == v_4[0]:
        return v_4[0]
    if v == v_4[1]:
        return v_4[1]

    for e in E[v]:
        if e == p:
            continue
        return dfs(v, e)

if cnt_4 > 2 or cnt_6 >= 1:
    print('Yes')
elif cnt_4 == 2:
    if all(dfs(v_4[0], e) == v_4[1] for e in E[v_4[0]]):
        print('No')
    else:
        print('Yes')

else:
    print('No')


Measured memory_bytes: 44704
N, K = map(int, input().split())
S = input()

LR = S.count("LR")
RL = S.count("RL")
RRLL = N-1-LR-RL

if min(LR,RL) != 0: 
    if K <= min(LR,RL):
        print(RRLL+K*2)       
    if K > min(LR,RL):
        if min(LR,RL) != max(LR,RL):
            print(RRLL+min(LR,RL)*2+1)
        if min(LR,RL) == max(LR,RL):
            print(RRLL+min(LR,RL)*2)
if min (LR,RL) == 0:
    if max(LR,RL) !=0:
        print(RRLL+1)
    if max(LR,RL) ==0:
        print(RRLL)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using i64 = long long;

template <typename T>
inline bool par(T a) { return a & 1; }

template <typename T>
inline T sgn(T a) { return a > 0 ? 1 : -1; }

int main() {
    int k, x, y;
    std::cin >> k >> x >> y;
    int a = x + y, b = x - y, sa = sgn(a), sb = sgn(b);
    a *= sa; b *= sb;
    auto pa = par(a), pb = par(b), pk = par(k);

    if (!pk && pa) {
        std::cout << -1 << std::endl;
        return 0;
    }

    std::deque<int> qa, qb;
    for (int i = 0; i < a / k; i++) qa.push_back(k);
    for (int i = 0; i < b / k; i++) qb.push_back(k);
    if (a % k > 0) {
        int r = a % k;
        if (pk == par(r)) qa.push_back(r);
        else {
            qa.push_back(k);
            qa.push_back(r - k);
        }
    }
    if (b % k > 0) {
        int r = b % k;
        if (pk == par(r)) qb.push_back(r);
        else {
            qb.push_back(k);
            qb.push_back(r - k);
        }
    }

    // for (auto e : qa) std::cerr << e << " ";
    // std::cout << std::endl;
    // for (auto e : qb) std::cerr << e << " ";
    // std::cout << std::endl;
    if (qa.size() == qb.size()) {
        if (qa.size() == 1 && qa.front() != k && qb.front() != k) {
            if (pk) {
                qa.push_front(k);
                qa.push_front(-k);
                qb.push_front(k);
                qb.push_front(-k);
            } else {
                qa.push_front(k);
                qb.push_front(k);
                qa.back() -= k;
                qb.back() -= k;
            }
        }
    } else {
        int d = (int)qa.size() - (int)qb.size();
        auto &q = d > 0 ? qb : qa, &o = d > 0 ? qa : qb;
        if (par(d)) {
            // k, a, and b are all even
            if (q.empty()) {
                // 0
                if (o.front() == k) q.push_back(0);
                else {
                    // d == 1
                    q.push_back(k);
                    q.push_back(-k);
                    o.push_back(0);
                }
            } else if (q.back() == k) {
                q.push_back(0);
            } else {
                auto t = q.back();
                q.pop_back();
                q.push_back(k);
                q.push_back(t - k);
            }
        }

        d = abs(d) >> 1;
        while (d--) {
            q.push_front(k);
            q.push_front(-k);
        }
    }

    std::reverse(qb.begin(), qb.end());
    int s = qa.size(), cx = 0, cy = 0;
    std::cout << s << std::endl;
    for (int i = 0; i < s; i++) {
        int dx = (sa * qa[i] + sb * qb[i]) / 2,
            dy = (sa * qa[i] - sb * qb[i]) / 2;
        cx += dx;
        cy += dy;
        std::cout << cx << " " << cy << std::endl;
    }

    return 0;
}


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

class Team
{
public:
	int id, penalty, acs;
	vector<int> buffer;

	Team(int id, int problem_number) : id(id), penalty(0), acs(0), buffer(problem_number) { }

	void submit(int m, int p, int j)
	{
		if(!j) {
			acs++;
			penalty += buffer[p] + m;
		} else {
			buffer[p] += 20;
		}
	}
};

bool operator == (const Team& a, const Team& b)
{
	return a.acs == b.acs && a.penalty == b.penalty;
}

bool operator < (const Team& a, const Team& b)
{
	if(a.acs != b.acs) return a.acs > b.acs;
	if(a.penalty != b.penalty) return a.penalty < b.penalty;
	return a.id > b.id;
}

int main()
{
	for(int M, T, P, R; cin >> M >> T >> P >> R && (M||T||P||R); ) {
		vector<Team> teams;

		for(int i = 0; i < T; i++) {
			teams.push_back(Team(i+1, P));
		}

		for(int i = 0; i < R; i++) {
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			teams[t-1].submit(m, p-1, j);
		}

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

		for(int i = 0; i < T; i++) {
			cout << teams[i].id << (i+1 == T ? '\n' : (teams[i] == teams[i+1] ? '=' : ','));
		}
	}
}

Measured memory_bytes: 1204
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var d, n int
	fmt.Fscan(r, &d)
	fmt.Fscan(r, &n)

	ans := 1
	for i := 1; i <= d; i++ {
		ans *= 100
	}
	if n == 100 {
		ans *= 101
	} else {
		ans *= n
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int s = sc.nextInt();
   int w = sc.nextInt();

   if(s>w) {
	   System.out.println("safe");
   }
   else {
	   System.out.println("unsafe");
   }
 }
}

Measured memory_bytes: 35796
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;


ll check(ll a[],ll n,ll k,ll mid)
{
    ll i,j;
    ll res=0;
    for(i=0;i<n;i++)
    {
        res+=(((a[i]+mid-1)/mid)-1); 
    }
    if(res<=k)
    {
        return 1;
    }
    return 0;
}

void solve()
{
    ll n,k;
    ll i,j;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll maxi = *max_element(a,a+n);
    
    ll l=1,r=maxi;
    ll ans=maxi;
    while(l<=r)
    {
        ll mid = l+(r-l)/2;
        
        if(check(a,n,k,mid))
        {
            ans=min(ans,mid);
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    cout<<ans<<"\n";

    

}

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

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5164
#include<iostream>
using namespace std;
int main(){
long long int x,ans;
cin>>x;
if(x>11){
ans=(x/11)*2;
if(x%11<=6 && x%11!=0)ans++;else if(x%11!=0)ans+=2;
}else{
if(x>6)ans=2;else ans=1;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
//                     بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
//                   لآ اِلَهَ اِلّا اللّهُ مُحَمَّدٌ رَسُوُل اللّهِ
#include <bits/stdc++.h>

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a-c)*(b-d) << endl;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n,m; cin >> n >> m;
  vector<vi> to(n);
  rep(i,m){
    int a,b; cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  rep(i,to[0].size()){
    rep(j,to[to[0][i]].size()){
      if(to[to[0][i]][j] == n-1){
        cout << "POSSIBLE\n";
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 14892
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#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 pb(z) push_back(z)
#define ff first
#define ss second
#define pi(a,b) make_pair(a,b)
#define pii pair<ll,ll>
#define T int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define input(v,n) vector<int>v;for(int i=0;i<n;i++){int x;cin>>x;v.push_back(x);}
#define debugg(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;


const int inf    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 1e9+7;
const int mx     = 2e5+5;
//vector<int>v;
//for(int i=0; i<n; i++)
//{
//    int x;
//    cin>>x;
//    v.push_back(x);
//}
inline ll ok(ll n)
{
    return (n*(n+1))/2;
}

int main()
{
   int n;
   cin>>n;
   input(v,n);
   int gcd=v[0];
   rep(i,0,n)
   {
       gcd=__gcd(gcd,v[i]);
   }
   cout<<gcd<<endl;
}




Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  while (true) {
    vector<vector<int>> vec(101, vector<int>(0));
    int a, b;
    while (cin >> a >> b, b) {
      vec[a].push_back(b);
      vec[b].push_back(a);
    }

    if (cin.fail())
      break;

    bool flag = vec[1].size() % 2 != 0 && vec[2].size() % 2 != 0;
    for (int i = 3; i < 101; ++i)
      if (vec[i].size() % 2 != 0)
        flag = false;
    cout << (flag ? "OK" : "NG") << endl;
  }
}


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

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N;
string s[10010];

void solve() {

	int a = 0;
	int b = 0;
	int ab = 0;
	int abNum = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		for (int j = 0; j < s[i].length(); j++) {
			if (s[i].substr(j, 2) == "AB") {
				abNum++;
			}
		}
		if (s[i].back() == 'A') {
			if (s[i][0] == 'B') ab++;
			else a++;
		}
		else if (s[i][0] == 'B') b++;
	}

	int tmp;
	tmp = min(a, ab);
	abNum += tmp;
	ab -= tmp;
	tmp = min(b, ab);
	abNum += tmp;
	ab -= tmp;

	if (ab > 0) {
		abNum += ab - 1;
		ab = 1;
		if (a > 0 || b > 0) {
			abNum++;
			ab = 0;
		}
	}

	tmp = min(a, b);
	abNum += tmp;
	a -= tmp; b -= tmp;

	cout << abNum << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 768
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int INF_INT = 1e9;

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    ll sche[N][3];
    for(int i = 0 ; i < N; i++){
        cin >> sche[i][0] >> sche[i][1] >> sche[i][2];
    }
    ll dp[N+1][3];
    for(int i = 0; i <= N; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = 0;
        }
    }
    vector<int> check = {0,1,2};
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < 3; j++){
            for(auto k : check){
                if(k == j) continue;
                dp[i][j] = max(dp[i][j],dp[i-1][k]+sche[i-1][k]);
            }
        }
    }
    cout << max(dp[N][0],max(dp[N][1],dp[N][2]));
    return 0;
}


Measured memory_bytes: 8220
let scan_line () = Scanf.scanf "%d %d %d\n" (fun a b c -> (a, b, c))

let w, h, n = scan_line ()

let rec f i l r d u =
  if i = 0 then max (r - l) 0 * max (u - d) 0
  else
    let x, y, a = scan_line () in
    match a with
    | 1 -> f (i - 1) (max l x) r d u
    | 2 -> f (i - 1) l (min r x) d u
    | 3 -> f (i - 1) l r (max d y) u
    | _ -> f (i - 1) l r d (min u y)


let () = Printf.printf "%d\n" (f n 0 w 0 h)

Measured memory_bytes: 512
n = int(input())
card = list(map(int, input().split()))

alice, bob = [],  []

card = sorted(card)
for i, _ in enumerate(range(n)):
    if i % 2 == 0:
        alice.append(card.pop())
    else:
        bob.append(card.pop())
        
print(sum(alice) - sum(bob))

Measured memory_bytes: 3060
import itertools

def main():
  n, k = map(int, input().split())
  d_li = []
  a_li = []
  for i in range(k):
    d_li.append(int(input()))
    a_li.append(list(map(int, input().split())))

  res = itertools.chain(*a_li)
  res = list(res)
  print(n-len(list(set(res))))

if __name__ == '__main__':
  main()


Measured memory_bytes: 9192
import sys
from copy import copy
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
INF = float('inf')

n = int(input())
a = list(map(int, input().split()))

graph = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

ans = [0] * n
dp = [INF] * n
dp[0] = a[0]
# dp[i] = (長さi+1の増加部分列の最終項のmin)


def dfs(v, v_p):
    ans[v] = bisect_left(dp, INF)

    for v_next in graph[v]:
        if v_next == v_p:
            continue

        idx = bisect_left(dp, a[v_next])
        past = dp[idx]
        dp[idx] = a[v_next]
        dfs(v_next, v)
        dp[idx] = past


dfs(0, -1)
print(*ans, sep='\n')


Measured memory_bytes: 224968
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans=0;
    ans=b-b/c-b/d+b/(c*d/__gcd(c,d));
    ans-=(a-1-(a-1)/c-(a-1)/d+(a-1)/(c*d/__gcd(c,d)));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a[31];
int b,c,i,d,e,f;
scanf("%d\n",&b);
for(i=0;i<b;i++){
a[i]=i+1;
}
scanf("%d\n",&c);
for(i=0;i<c;i++){
scanf("%d,%d\n",&d,&e);
f=a[d-1];
a[d-1]=a[e-1];
a[e-1]=f;
}
for(i=0;i<b;i++){
printf("%d\n",a[i]);
}
return 0;
}




Measured memory_bytes: 1996
#include <bits/stdc++.h>
using namespace std;
int n,m,c,a[200][200],b[200],k;
long long sum;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>m>>c;
for(int i=0;i<m;i++){
    cin>>b[i];
}
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        cin>>a[i][j];
    }
}
for(int i=0;i<n;i++){
        sum=0;
    for(int j=0;j<m;j++){
    sum+=(a[i][j]*b[j]);
    }
sum+=c;
if(sum>0)k++;
}
cout<<k;
return 0;}



Measured memory_bytes: 3672
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
    int n;
    scanf("%d",&n);
    int x[n][2];
    for(int i=0;i<n;i++)scanf("%d%d",&x[i][0],&x[i][1]);
    double sum = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            sum += hypot(x[i][0]-x[j][0],x[i][1]-x[j][1]);
        }
    }
    printf("%.9f",sum/n);
    return 0;
}

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

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

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

int a, b;

int main() {
	cin >> a >> b;
	cout << a + b / 2 << endl;
	return 0;
}


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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define MOD 1000000007
#define TIME system("date +%M:%S.%N")
using Graph = vector<vector<int>>;
using ll = long long;
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

int main() {
  int n;cin>>n;
  string ans = "";
  while (n != 0) {
    if (n % 2 != 0) {
      n--;
      ans = "1" + ans;
    }
    else ans = "0" + ans;
    n /= -2;
  }
  if (ans == "") ans = "0";
  cout << ans << endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

struct UnionFind {
	int s, num; // [0, s) の s 個の要素がある。num は非空集合の個数。
	vector<vector<int>> v;
	vector<int> find;
	
	UnionFind() { s = 0; }
	UnionFind(int s) { init(s); }
	void init(int arg_s) {
		num = s = arg_s;
		v.clear();
		find.clear();
		inc(i, s) { v.PB({i}); find.PB(i); }
	}
	bool unite(int x, int y) {
		assert(inID(x, 0, s) && inID(y, 0, s));
		if(find[x] == find[y]) { return false; }
		num--;
		if(v[find[x]].size() > v[find[y]].size()) { swap(x, y); }
		int fx = find[x];
		for(auto && e: v[fx]) { v[find[y]].PB(e); find[e] = find[y]; }
		v[fx].clear();
		return true;
	}
};

// ----

int n, m, x[200000], y[200000];
int c[100000];
vector<int> g[100000];

bool dfs(int v, int w) {
	if(c[v]) { return (c[v] == w); }
	c[v] = w;
	bool f = true;
	for(auto && e: g[v]) { f &= dfs(e, -w); }
	return f;
}

LL a, b;
void search(int v) {
	if(c[v]) { return; }
	if(g[v].size() == 0) { a++; return; }
	if(dfs(v, +1)) { b++; };
}

LL id(LL a, LL b) { return n * a + b; }

int main() {
	cin >> n >> m;
	inc(i, m) { cin >> x[i] >> y[i]; x[i]--; y[i]--; }
	
	UnionFind uf(n);
	inc(i, m) {
		g[x[i]].PB(y[i]);
		g[y[i]].PB(x[i]);
		uf.unite(x[i], y[i]);
	}
	
	LL k = uf.num;
	inc(i, n) { search(i); }
	/*
	cout << "a, b, k: " << a << " " << b << " " << k << endl;
	cout << "孤立点: " << a << endl;
	cout << "　二部: " << b << endl;
	cout << "￢二部: " << k - a - b << endl;
	*/
	
	cout << 2 * a * n - a * a + (k - a) * (k - a) + b * b << endl;
	
	/*
	UnionFind u(n * n);
	inc(i, m) {
	inc(j, m) {
		u.unite(id(x[i], x[j]), id(y[i], y[j]));
		u.unite(id(x[i], y[j]), id(y[i], x[j]));
	}
	}
	cout << u.num << endl;
	*/
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum;
  if (N < 10) sum = N;
  else if (N < 100) sum = 9;
  else if (N < 1000) sum = 9 + (N-99);
  else if (N < 10000) sum = 909;
  else if (N < 100000) sum = 909 + (N-9999);
  else sum = 90909;
  
  cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <time.h>
using namespace std;
    int su(int n){
        for(int i=2;i<=sqrt(n);i++)
            if(n%i==0) return 0;
        return 1;
    }
int main()
{
    srand((int)time(0));
    int num[55555];
    for(int i=1;i<=55555;i++) num[i]=i;
    num[1]=0;
    for(int i=2;i<=55555;i++)
    if(num[i]!=0){
        for(int k=2;k*i<=55555;k++) num[k*i]=0;
    }
    int n,t=0;
    int s[1000];
    for(int i=0;i<=55555;i++)
        if(num[i]!=0) s[t++]=num[i]-3;
    int q=0;
    int w[55];
    for(int i=0;i<t;i++){
        if(s[i]%3==0||s[i]%5==0||s[i]%15==0) w[q++]=s[i]+3;
    }
    cin>>n;
    for(int i=0;i<n;i++)
        cout<<w[i]<<' ';
    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	v vec(5);
	for (int i = 0; i < 5; ++i)
	{
		cin>>vec[i];
		if(!vec[i])cout<<i+1<<"\n";
	}
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>
int main() {
	int in[100]={0};
	int out[100]={0};
	int count = 0;
	int i = 0,z = 0,c;
	while(scanf("%d",&in[i])!=EOF){
		if(in[i]!=0){
			i++;
			//printf("in[%d]=%d\n",i,in[i]);
		}else{
			//printf("%d",in[i-1]);
			out[z] = in[i-1];
			//printf("out[%d]=%d\n",z,out[z]);
			z++;
			i--;
		}
	}
	for(i=0;i<z;i++){
		printf("%d\n",out[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

//高速な素因数分解(abc 177-e)
//前処理O(N*logN), クエリO(Q*log(x_i))
template<typename T>
vector<T> smallest_prime_factors(T n) {
  vector<T> spf(n + 1);
  for (int i = 0; i <= n; i++) spf[i] = i;
  for (T i = 2; i * i <= n; i++) {
  // 素数だったら
    if (spf[i] == i) {
      for (T j = i * i; j <= n; j += i) {
      // iを持つ整数かつまだ素数が決まっていないなら
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
  return spf;
}

template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
  vector<T> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
      x /= spf[x];
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main(){
  int n;
  cin >> n;
  auto spf = smallest_prime_factors(1010);
  int ans = 1;
  for(auto u : factolization(n,spf)){
    // cout << u << endl;
  }
  // cout << "aaaaaaaaaaaaaaaaa" << endl;
  FOR(i,1,n+1){
    map<int,int> mii;
    // cout << "start : " << i << endl;
    for(auto u : factolization(i,spf)){
      mii[u]++;
    }
    for(auto u : mii){
      // if(u.second != 1)
        // ans = i;
        // cout << u.first << " " << u.second << endl;
    }
    // cout << "------------" << endl;
    // cout << mii.size() << " size" << endl;
    bool ok = 1;
    int pre = mii.begin()->second % 2;
    for(auto u : mii){
      if(u.second == 1 || pre != u.second%2){
        ok = 0;
      }
      // cout << u.first << " " << u.second << endl;
    }
    if(ok)
      ans = i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
n,c,k = map(int,input().split())
t = sorted([int(input()) for i in range(n)])
ans = 0
j = 1
rimit = 0
for i in t:
    if j<c and rimit>=i:
        j+=1
    else:
        ans+=1
        rimit=i+k
        j=1
print(ans)

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, k;
    cin >> n >> k;
    ll num = n/2 + (n%2 == 1 ? 1 : 0);
    (num >= k) ? YES() : NO();
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

signed main() {
  int A, B, X;
  cin >> A >> B >> X;
  
  X = min(X, B-1);
  int num = (A*X)/B - A*(X/B);
  cout << num << endl;
  
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <list>
#include <utility>

int main()
{
	int n;
	std::string s;
	std::cin >> n >> s;
	
	int r = std::count(s.begin(), s.end(), 'R');
	int g = std::count(s.begin(), s.end(), 'G');
	int b = n - r - g;
	auto cnt = static_cast<long long>(r) * g * b;
	for (int i = 0; i < n - 2; i++) {
		int j = i + 1;
		int k = i + 2;
		while (k < n) {
			if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
				cnt--;
			}
			j++;
			k += 2;
		}
	}
	
	std::cout << cnt << std::endl;
	
	return 0;
}


Measured memory_bytes: 3204
sx, sy, tx, ty = gets.split.map(&:to_i)
x = tx - sx
y = ty - sy
ans = ""
ans += ?R * x
ans += ?U * y
ans += ?L * x
ans += ?D * y
ans += ?D + ?R * (x + 1) + ?U * (y + 1) + ?L
ans += ?U + ?L * (x + 1) + ?D * (y + 1) + ?R
puts ans

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

using namespace std;

int n, ans;
vector<int> b;

int main() {
	cin >> n;
	b.resize(n);
	for(int& v: b)
		cin >> v;
	
	sort(b.begin(), b.end());
	
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int equal_or_greater = distance(b.begin(), lower_bound(b.begin(), b.end(), b[i] + b[j]));
			ans += equal_or_greater - 1 - j;
		}
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = args[0][0]
	let cnt = 0
	if (N[0] === '2') cnt++
	if (N[1] === '2') cnt++
	if (N[2] === '2') cnt++
	if (N[3] === '2') cnt++
	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main()
{
	string S;

	cin >> S;

	for (int loop = 0; loop < S.size(); ++loop) {
		for (int loop2 = loop + 1; loop2 < S.size(); ++loop2) {
			if (S.at(loop) == S.at(loop2)) {
				cout << "no";
				return 0;
			}
		}
	}

	cout << "yes";

	return 0;
}


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

int main() {
    int a, b, c, ans;
    cin >> a >> b >> c;
    ans = max(a, max(b, c)) - min(a, min(b, c));
    cout << ans << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    string S, T; cin >> S >> T;

    rep (i, 0, S.size()) {
        if (S.at(i) != T.at(i)) {
            cout << "No" << endl;
            return 0;
        }
    }

    if (T.size() - S.size() != 1) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3596