akhauriyash/Code-Regression huggingface dataset:
public class Main {


  private static void solve() {
    int n = ni();
    long[] cnt = new long[4];
    long ret = 0;
    for (int i = 0; i < n; i ++) {
      char[] s = ns();
      
      int b = 0;
      if (s[0] == 'B') {
        b |= 2;
      }
      if (s[s.length - 1] == 'A') {
        b |= 1;
      }
      cnt[b] ++;
      
      for (int j = 0; j < s.length - 1; j ++) {
        if (s[j] == 'A' && s[j + 1] == 'B') {
          ret ++;
        }
      }
    }

    ret += Math.max(0, cnt[3] - 1);
    if (cnt[3] > 0 && cnt[1] > 0) {
      ret ++;
      cnt[1] --;
    }
    if (cnt[3] > 0 && cnt[2] > 0) {
      ret ++;
      cnt[2] --;
    }
    ret += Math.min(cnt[1], cnt[2]);
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

struct node{
    int key;
    node* parent;
    node* left;
    node* right;
};

node *nil, *root;

void insert(int key){

    node *y = nil;          // ノードyはzの親
    node *x = root;    // ノードxは木の根をさす
    node *z = (node *)malloc(sizeof(node));
    
    // 挿入ノードの初期値
    z->key = key;
    z->left = nil;
    z->right = nil;

    //　挿入先ノード探索
    while(x != nil){        // xがnilを指している(初期ノード)のとき終了
        y = x;              // zの親がxであるとする。
        
        if(z->key < x->key){// xのキーよりzのキーがxを小さければ左、そうでなければ右へ
            x = x->left;
        }else{
            x = x->right;
        }
    }

    z->parent = y;

    if(y == nil){ // treeが空の時
        root = z; 
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void find(int key){
    node *x = root;
    while(x != nil){
        if(x->key < key){
            x = x->right;
        }else if(x->key > key){
            x = x->left;
        }else{
            cout << "yes" << endl;
            return;
        }
    }
    cout << "no" << endl;
    return;
}

void preorder(node *x){
    if(x == nil){
        return;
    }
    cout << " " << x->key;
    preorder(x->left);
    preorder(x->right);
}

void inorder(node *x){
    if(x == nil){
        return;
    }
    inorder(x->left);
    cout << " " << x->key;
    inorder(x->right);
}

int main(){
    int n; cin >> n;
    
    
    rep(i, n){
        string command; cin >> command;

        if(command == "insert"){
            int x; cin >> x;
            insert(x);

        }else if(command == "find"){
            int x; cin >> x;
            find(x);

        }else if(command == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 21832
SENTINEL = 2000000000

def merge(arr, length, left, mid, right):

    cnt = 0

    L = arr[left : mid]
    R = arr[mid : right]

    L.append(SENTINEL)
    R.append(SENTINEL)

    i, j = 0, 0
    for k in range(left, right):
        if (L[i] <= R[j]):
            arr[k] = L[i]
            i += 1
        else:
            arr[k] = R[j]
            j += 1
            cnt += len(L) - 1 - i # mid + j - k - 1
    return cnt

def merge_sort(arr, length, left, right):
    if (left + 1 < right):
        mid = (left + right)//2
        v1 = merge_sort(arr, length, left, mid)
        v2 = merge_sort(arr, length, mid, right)
        v3 = merge(arr, n, left, mid, right)
        return v3 + v2 + v1
    else:
        return 0    

if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().split()))

    cnt = merge_sort(A, n, 0, n)
    print(cnt)


Measured memory_bytes: 27476
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Iterator;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int in_A;
    int in_B;

    int cnt;
    int ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_A   = Integer.parseInt(in_str_split[0]);
      in_B   = Integer.parseInt(in_str_split[1]);


      ans = 0;
      for(cnt=in_A; cnt<=in_B; cnt++)
      {
        if( (String.valueOf(cnt).substring(0, 1).equals(String.valueOf(cnt).substring(4, 5))) &&
            (String.valueOf(cnt).substring(1, 2).equals(String.valueOf(cnt).substring(3, 4)))    )
        {
          ans++;
        }
      }


      System.out.println("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 38740
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  char x='\0',y='\0';
  cin >> x >> y;
  cout << ( x<y?'<':x>y?'>':'=') << endl;

  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
LRD = [LIST() for _ in range(M)]

graph = [[] for _ in range(N)]
for L, R, D in LRD:
	graph[L-1].append((R-1, D))
	graph[R-1].append((L-1, -D))

check = [1]*N
i = 0
while i < N:
	while check[i] == 0:
		i += 1
		if i == N:
			print("Yes")
			exit()

	check[i] = 0
	dis = defaultdict(int)
	dis[i] = 0
	q = deque([i])
	while q:
		p = q.popleft()
		for v, dist in graph[p]:
			if check[v] == 1:
				check[v] = 0
				dis[v] = dis[p] + dist
				q.append(v)
			if check[v] == 0 and dis[v] != dis[p] + dist:
				print("No")
				exit()

Measured memory_bytes: 113776
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail ,n;

void enqueue(P x){
  Q[tail]=x;
  tail = (tail +1)%LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head +1)%LEN;
  return x;
}

int min(int a,int b){ return a < b ? a:b;}

int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail=n+1;

  while(head != tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps +=c;
    if(u.t>0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<vector<int>> f(N, vector<int>(10));
  vector<vector<int>> p(N, vector<int>(11));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }

  long long ret = -1e18;
  for (int i = 0; i < (1 << 10); i++) {
    if (__builtin_popcount(i) == 0) continue;
    vector<int> c(N);
    for (int j = 0; j < 10; j++) {
      if ((i >> j) & 1) {
        for (int k = 0; k < N; k++) {
          if (f[k][j]) c[k]++;
        }
      }
    }
    long long sum = 0;
    for (int j = 0; j < N; j++) {
      sum += p[j][c[j]];
    }
    ret = max(ret, sum);
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s="";
    while(n){
        n--;
        ll b=n%26;
        s+=('a'+b);
        n/=26;
    }
    reverse(ALL(s));
    cout<<s<<"\n";
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

#define FOR(i,n) for(ll i=0;i<n;i++) 
#define RFOR(i,n) for(ll i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl

//宣言　
	string A = "vowel" ;
	string B = "consonant";
	
//入力
	char c ;


int main() {

	cin >> c;

	if(c == 'a'|| c == 'i' || c == 'u' || c == 'e' || c == 'o') COUT(A);
	
	else COUT(B);

	return 0;
}


Measured memory_bytes: 256
#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--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,z,w;
    cin >> n >> z >> w;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    if(n == 1) cout << abs(w-a[0]) << endl;
    else cout << max(abs(a[a.size()-1]-a[a.size()-2]),abs(a[a.size()-1]-w)) << endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * https://abc060.contest.atcoder.jp/tasks/arc073_b
 */
public class Main {

	static long[] v;
	static long[] w;
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		v = new long[N];
		w = new long[N];
		for(int i=0; i<N; i++){
			w[i] = sc.nextLong();
			v[i] = sc.nextLong();
		}
		sc.close();

		long ans = dfs(0,W);
		
		System.out.println(ans);

	}

	static Map<String,Long> dp = new HashMap<>();
	private static long dfs(int n, long cw){
		
		if(n>=w.length){
			return 0;
		}
		
		Long res = dp.get(getKey(n,cw));
		if(res!=null){
			return res;
		}
		
		if(cw-w[n]>=0){
			res = Math.max(dfs(n+1, cw-w[n])+v[n], dfs(n+1, cw));
		}else{
			res = dfs(n+1, cw);
		}
		
		dp.put(getKey(n,cw), res);
		return res;
	}
	
	static String getKey(int n, long w){
		return n+"."+w;
	}
	
	

}

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

ll mod = 1000000007;
ll ans = 1<<29;

int main() {
    ll n,k;
    cin>> n >> k;
    vector<pair<ll,ll>> P (n);
    rep(i,n){
        cin >> P[i].first>>P[i].second;
    }
    sort(P.begin(),P.end());
    ll sum = 0;
    ll index;
    rep(i,n){
        sum +=P[i].second;
        if(sum>=k) {
            index = i;
            break;
        } 
    }
    cout << P[index].first << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

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

int main(void) {
	ll N;
	cin >> N;
	ll tmp_N = N;
	typedef pair<ll, int> P;
	//prime_factors[i].first: 素因数i, second: 素因数iの個数
    vector<P> prime_factors;
	for(ll i=2; i*i<tmp_N; i++){
		ll num = 0;
		if(tmp_N % i != 0) continue;
		while(tmp_N % i == 0){
			tmp_N /= i;
			num++;
		}
		prime_factors.emplace_back(i, num);
	}
	if(tmp_N != 1) prime_factors.emplace_back(tmp_N, 1);
	//cout << "  comp " << endl;
	// vector<ll> divisors;
	// for(int i=0; i<prime_factors.size(); i++){
	// 	for(int j=1; j<=prime_factors[i].second; j++){
	// 		divisors.push_back(j * prime_factors[i].first);
	// 		//cout << prime_factors[i].first << " ";
	// 	}
	// }
	// //cout << "   divisors.size(): " << divisors.size() << endl;
	// sort(divisors.begin(), divisors.end());
	// cout << " divisors: " ; print_vec(divisors);
	// ll ans = 0;
	// for(ll x : divisors){
	// 	if(N % x != 0) continue;
	// 	ans++;
	// 	N /= x;
	// }
	ll ans = 0;
	for(int i=0; i<prime_factors.size(); i++){
		ll cnt = 0;
		while(true){
			cnt++;
			if(prime_factors[i].second - cnt < 0) break;
			prime_factors[i].second -= cnt;
			ans++;
		}
	}
	cout << ans << endl;



}


Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;

int main() {
	
	int n, sum = 0;
	cin >> n;
	VI s(n);
	FOR(i, n) {
		cin >> s[i];
		sum += s[i];
	}

	if (sum % 10 == 0) {
		SORT(s);
		FOR(i, n) {
			if (s[i] % 10 != 0) {
				cout << sum - s[i] << endl;
				return 0;
			}
		}
		sum = 0;
	}
	cout << sum << endl;

	return 0;
}

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

n, q = map(int, input().split())
ab = [tuple(map(int,input().split())) for i in range(n-1)]
px = [tuple(map(int,input().split())) for i in range(q)]

es = [[] for i in range(n)]
for a,b in ab:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

ans = [0]*n

# DFS for tree (再帰はpypyの方が遅かったりするので注意)
def dfs(v=0, parent=-1):# どこからきたかの情報を入れとく
    for to in es[v]:
        if to == parent: continue # 今回はcontinue

        ans[to] += ans[v]
        dfs(to, v)


for p, x in px:
    ans[p-1] += x

dfs(0)

print(*ans, sep=' ')


Measured memory_bytes: 315904
/**-------------------------
|--------From A.R.A--------|
-------------------------**/

#include <bits/stdc++.h>

#define ll            long long int
#define pb            push_back
#define ull           unsigned long long int
#define endl          "\n"
#define sz(c)         (c).size()
#define sall(c)       sort((c).begin(),(c).end())
#define rsall(c)      sort((c).rbegin(),(c).rend())
#define rev(c)        reverse((c).begin(),(c).end())
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define max3(a,b,c)   max(max(a,b),c)
#define min3(a,b,c)   min(min(a,b),c)
#define input(a,i,n)  for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}

using namespace std;

int R=1;
void solution(){
    int64_t a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}
int main()
{
    //cin>>R;
    FOR(i,R){solution();}
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    int ans = 0;
    rep(i, n)
    {
        rep2(j, i + 1, n)
        {
            double res = 0;
            rep(k, d)
            {
                res += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            res = sqrt(res);
            if (res == (int)res)
            {
                ans++;
            }
        }
    }

    cout << ans << '\n';
    return (0);
}


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

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

	vector<int32_t> a(n), b(n);
	for (int32_t i = 0; i < n; i++) {
		cin >> a[i];
	}
	int32_t _index = n / 2;
	bool is_plus = n % 2 != 0;
	int32_t diff = 1;
	for (int32_t i = 0; i < n; i++) {
		b[_index] = a[i];
		if (is_plus)
			_index += diff;
		else
			_index -= diff;
		diff++;
		is_plus = !is_plus;
	}

	bool is_first = true;
	for (int32_t i = 0; i < n; i++) {
		if (is_first) {
			cout << b[i];
			is_first = false;
		} else {
			cout << " " << b[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,k,q;
    cin >> n >> k >> q;
    vector <long> a(q);
    vector <long> dp(n+1,0);
    for(long i = 0; i < q; i++){
        cin >> a[i];
        dp[a[i]]++;
    }
    for(long i = 1; i <= n; i++){
        if(dp[i]-q+k<=0){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int H,W;
	cin>>H>>W;
	string a[100];
	rep(i,H)cin>>a[i];
	
	rep(i,W+2)cout<<"#";
	cout<<endl;
	rep(i,H){
		cout<<"#";
		rep(j,W)cout<<a[i][j];
		cout<<"#"<<endl;
	}
	rep(i,W+2)cout<<"#";
	cout<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
 
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)
 
using namespace std;
 
typedef long long LL;
const int N = 2000010;
const int mod = 924844033;
const int G = 5;
 
LL qpow(LL a, LL b)
{
    LL ret = 1, base = a;
    while (b) {
        if (b & 1) ret = ret * base % mod;
        base = base * base % mod, b >>= 1;
    }
    return ret;
}
 
void NTT(LL *a, int len, int f)
{
    for (int i = 0, j = 0; i < len; i ++) {
        if (i < j) swap(a[i], a[j]);
        for (int t = len >> 1; (j ^= t) < t; t >>= 1);
    }
    for (int i = 1; i < len; i <<= 1) {
        LL wn = f ? qpow(G, (mod - 1) / (i << 1)) : qpow(G, (mod - 1) - (mod - 1) / (i << 1));
        for (int j = 0; j < len; j += (i << 1)){
            LL w = 1;
            for (int k = 0; k < i; k ++, w = w * wn % mod){
                LL x = a[j + k], y = w * a[j + k + i] % mod;
                a[j + k] = (x + y) % mod;
                a[j + k + i] = (x - y + mod) % mod;
            }
        }
    }
    if (!f) for (int i = 0; i < len; i ++) a[i] = a[i] * qpow(len, mod - 2) % mod;
}
 
LL p[N], invp[N];

struct Edge{ int to, next;} edge[N * 2];
int n, head[N], num;
void add_edge(int a, int b) { edge[++ num] = (Edge){b, head[a]}, head[a] = num;}

LL a[N], b[N];

int dfs(int x, int fa)
{
	int sz = 1;
	RepG(i, x) if (v != fa) {
		int tmp = dfs(v, x);
		sz += tmp, a[n - tmp] ++;
	}
	a[sz] ++;
	return sz;
}

int main()
{
	scanf("%d", &n);
	Rep(i, n - 1) {
		int a, b;
		scanf("%d%d", &a, &b);
		add_edge(a, b); add_edge(b, a);
	}
	dfs(1, 0);
	p[0] = invp[0] = 1;
	Rep(i, n) p[i] = p[i - 1] * i % mod, invp[i] = qpow(p[i], mod - 2);
	
	Rep0(i, n){
		a[i] = a[i] * p[n - i] % mod;
		b[i] = invp[i];
	}
	
	int len = 1;
	while (len <= n << 1) len <<= 1;

	NTT(a, len, 1); NTT(b, len, 1);
	Rep0(i, len) a[i] = a[i] * b[i] % mod;
	NTT(a, len, 0);
	Rep(i, n){
		LL tmp = p[n] * invp[i] % mod * invp[n - i] % mod;
		printf("%lld\n", (n * tmp % mod - a[n - i] * invp[i] % mod + mod) % mod);
	}
	
	return 0;
}

Measured memory_bytes: 36608
using System;
using System.Linq;
using System.Collections.Generic;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            HashSet<int> number = new HashSet<int>(Enumerable.Range(1, 30));
            for(int i=0; i < 28; ++i) {
                number.Remove(int.Parse(Console.ReadLine()));
            }
            foreach(int i in number.OrderBy(p => p)) {
                Console.WriteLine(i);
            }
        }
    }
}

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

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; }
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

double L;

// *********************************************************



int main(){

    cin >> L;
    cout  << fixed << setprecision(10) << L*L*L/27 <<endl;
   


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  ll N;
  1+scanf("%lld", &N);
  vector<ll> vll;
  for (int i = 0; i < 5; i++) {
    ll tmp;
    1+scanf("%lld", &tmp);
    vll.push_back(tmp);
  }
  sort(vll.begin(), vll.end());
  
  printf("%lld", N / vll[0] + 5 - (((N % vll[0]) == 0)?1:0));
  
  return 0;
}


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

typedef std::pair<int,int> coordinate;

int main()
{
	while (true) {
		int H, W;
		std::cin >> H >> W;
		if ( H==0 && W==0 ) break;
		
		std::string* board = new std::string[H];
		for (int i=0; i<H; i++) {
			std::cin >> board[i];
		}
		
		coordinate curr_pos = coordinate(0,0);
		int count = 0;
		while (true) {
			char mark = board[curr_pos.first][curr_pos.second];
			if (mark == '.') {
				std::cout << curr_pos.second << " " << curr_pos.first << std::endl;
				break;
			} else if (mark == '>') {
				curr_pos.second++;
			} else if (mark == '<') {
				curr_pos.second--;
			} else if (mark == '^') {
				curr_pos.first--;
			} else {
				curr_pos.first++;
			}
			count++;
			if (count > H * W) {
				std::cout << "LOOP" << std::endl;
				break;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3096
use std::io::*;
use std::str::FromStr;

fn main() {
    let r: usize = read();
    let d: usize = read();
    let mut x: usize = read();

    for i in 0..10 {
        x = r * x - d;
        println!("{}", x);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

int prime(long long n){
	for(long long i=2;i<=sqrt(n);i++){
    	if(n%i==0){
    	    return 0;
    	}
	}
	return 1;
}
	
int main()
{
	long long n,p;
	cin>>n>>p;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
		long long maxn= 1;
		double f=pow(p,1.0/n);
		for(long long i=f+1;i>=2;i--){
		long long sum=1;
		for(long long j=0;j<n;j++){
			sum*=i;
			if(sum>p)
				break;
			}
		if(p%sum==0){
			maxn=i;
			break;
		}
	}
	cout<<maxn<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        char[] S = scanner.next().toCharArray();

        int count = 0;
        char tempSlime = 0;
        for (int i=0; i< N; i++) {
            if (S[i] != tempSlime) {
                tempSlime = S[i];
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 25940
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

h1,m1,h2,m2,k = I2()
m = (h2-h1)*60+(m2-m1)
#print(m)
print(max(0,m-k))

Measured memory_bytes: 9224
n = int(input())
C = []
S = []
F = []
for i in range(n-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(n-1):
    ans = S[i] + C[i]
    j = i + 1
    while j < n-1:
        if ans < S[j]:
            ans += (S[j] - ans) + C[j]
        else:
            if (ans-S[j])%F[j] == 0:
                ans += C[j]
            else:
                ans += C[j] + F[j] - (ans%F[j])
        j += 1
    print(ans)
print(0)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

const int N=1005;
const int P=998244353;

int n;
int a[N];
int first[2];
long long ans,res[2];
long long seq[3*N],Index;

void init(){
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=n;i>=1;i--) if(a[i]>=0) res[i&1]+=a[i],first[i&1]=i;
	if(first[1]==first[0] && first[1]==0){
		ans=1;
		for(int i=2;i<=n;i++) if(a[i]>a[ans]) ans=i;
		for(int i=n;i>ans;i--) seq[++Index]=i;
		for(int i=1;i<ans;i++) seq[++Index]=1;
		ans=a[ans];
	}
	else if(res[1]>res[0]){
		int tmp=n;
		while(a[tmp]<0 || (tmp&1)==0){
			seq[++Index]=tmp;
			tmp--;
		}
		for(int i=tmp;i>first[1];){
			int j=i-2;
			while(a[j]<0) j-=2;
			while(i!=j+2){
				seq[++Index]=j+2;
				i-=2;
			}
			seq[++Index]=j+1;
			i-=2;
		}
		while(first[1]>1){
			seq[++Index]=1;
			first[1]--;
		}
		ans=max(res[0],res[1]);
	}
	else{
		int tmp=n;
		while(a[tmp]<0|| (tmp&1)==1){
			seq[++Index]=tmp;
			tmp--;
		}
		for(int i=tmp;i>first[0];){
			int j=i-2;
			while(a[j]<0) j-=2;
			while(i!=j+2){
				seq[++Index]=j+2;
				i-=2;
			}
			seq[++Index]=j+1;
			i-=2;
		}
		while(first[0]>1){
			seq[++Index]=1;
			first[0]--;
		}
		ans=max(res[0],res[1]);
	}
	//cout<<res[0]<<" "<<res[1]<<endl;
	printf("%lld\n",ans);
	printf("%lld\n",Index);
	for(int i=1;i<=Index;i++){
		printf("%lld\n",seq[i]);
	}
}

int main(){
	init();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;cin>>N>>M;
    int K[N];int A[N][M];
    int backet[M]={0};
    for(int i=0;i<N;i++){
        cin>>K[i];
        for(int j=0;j<K[i];j++){
            cin>>A[i][j];
            backet[A[i][j]-1]++;
        }
    }int result=0;
    for(int k=0;k<M;k++){
        if(backet[k]==N){
            result++;
        }
    }cout<<result<<endl;
}

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

int main(void){
    string a,b,e;int c,d;cin>>a>>b>>c>>d>>e;
    if(a==e)cout<<c-1<<" "<<d<<endl;
    else if(b==e) cout<<c<<" "<<d-1<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,c,f;
	string s;
	cin>>s;
	n=s.length();
	if(s[n-1]=='s')s+="es";
	else s+='s';
	cout<<s;
	return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>
    #include<stdlib.h>
    #define MIN 1
    #define MAX 100
    int main(){
      int N,A[MAX],i,j,tmp,count=0,minj;
      scanf("%d",&N);
      if(N<MIN||N>MAX) exit(1);
      for(i=0;i<N;i++){
        scanf("%d",&A[i]);
      }
      for(i=0;i<N;i++){
        minj = i;
        for(j=i; j<N; j++)
          if(A[j] < A[minj]){
            minj = j;
          }
        if(minj!=i){
          tmp = A[i];
          A[i] = A[minj];
          A[minj] =tmp;
          count++;
          }
          if(i==N-1){
            printf("%d\n",A[i]);
            break;
          }
          printf("%d ",A[i]);
      }
      printf("%d\n",count);
      return 0;
    }



Measured memory_bytes: 2128
N,A,B = [int(x) for x in input().split()];
#print(A);
#print(B);
#print(N);
#lm = int(A + (B-A-1)/2);
lm = A + (B-A-1)//2;
#print(lm);
#rm = int(N-B+1 + (B-A-1)/2);
rm = N-B+1 + (B-A-1)//2;
#print(rm);
if (B-A)%2 == 0 :
    print((B-A)//2);
else :
    print(min(lm,rm));

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

using namespace std;

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

    int n, a, b;

    cin >> n;
    vector<int> sum(n + 3, 0);
    for (int i  = 0; i < n; ++i) {
        cin >> a >> b;
        if (a <= n + 1)
            ++sum[a - 1];
        if (b <= n + 1)
            --sum[b];
    }

    for (int i = 1; i <= n; ++i)
        sum[i] += sum[i - 1];

    int ans = 0;
    for (int i = 0; i <= n; ++i)
        if (i <= sum[i])
            ans = max(ans, i);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3300
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int[][] v=new int[n+1][n+1];
			for(int i=0; i<n; i++) {
				int u=sc.nextInt();
				int k=sc.nextInt();
				for(int j=1; j<=k; j++) {
					int t=sc.nextInt();
					v[u][t]=1;
				}
			}
			for(int i=1; i<=n; i++) {
				for(int j=1; j<=n; j++) {
					if(j==1) {
						System.out.print(v[i][j]);
					}
					else {
						System.out.print(" "+v[i][j]);
					}
				}
				System.out.println();
			}
			

		}
	}
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

int n, k;

bool valid(vector<int> &r, int d) {
    int tot = accumulate(r.begin(), r.end(), 0ll);

    if (tot == 0)return true;
    int maxK = 0, netR = 0;
    for (auto x: r) {
        maxK += d - x;
        netR += x;
        if (maxK == tot - netR and maxK <= k)
            return true;
    }
    return false;
}

void solve() {
    cin >> n >> k;

    int s = 0;
    vector<int> v(n);
    for (int i = 0; i < n; i++)cin >> v[i], s += v[i];

    vector<int> div;
    for (int i = 1; i * i <= s; i++) {
        if (s % i == 0) {
            div.push_back(i);
            if (s / i != i)div.push_back(s / i);
        }
    }
    sort(div.rbegin(), div.rend());
    for (auto x: div) {
        vector<int> r;
        for (auto ele: v)r.push_back(ele % x);
        sort(r.rbegin(), r.rend());

        if (valid(r, x)) {
            cout << x << endl;
            return;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int n,a[200005],ans;
map<int,int>f;
int main()
{
	scanf("%d",&n);for(int i=1;i<=n;++i) {scanf("%d",&a[i]);f[a[i]]++;}
	sort(a+1,a+1+n);
	for(int i=n;i;--i) {
		if(!f[a[i]]) continue;
		for(int j=1;j<=30;++j) {
			if((1<<j)==a[i]+a[i]&&f[a[i]]>1) {f[a[i]]-=2;ans++;}
			else if((1<<j)>a[i]&&f[(1<<j)-a[i]]&&(1<<j)-a[i]<a[i]) {f[a[i]]--;f[(1<<j)-a[i]]--;ans++;}
			if((1<<j)>a[i]&&(1<<j)-a[i]<=a[i]) break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19712
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
#define P pair<int,int>

bool cmp(P p,P q){
  if( p.first > q.first ) return true;
  if( p.first < q.first ) return false;
  if( p.second < q.second ) return true;
  return false;
}

int main(){
  int m;

  while( cin>>m && m ){
    vector<int> v;
    vector<P> s;
    P p; // 得点、学籍番号
    //    cout << "m="<< m << endl; // **********************

    for( int lp=0;lp<m;lp++ ){
      cin >> p.second; // 学籍番号
      //      cout << " std"<<lp<<"="<<p.second << endl; //********
      v.clear();
      int n=9, a,b;
      while( n>0 ){ // 9投目まで
	cin >> a; v.push_back( a );
	if( a!=10 ){ cin >> a; v.push_back( a ); }
	n--;
      }
      //      cout << endl;

      // 10投目
      cin >> a >> b;
      v.push_back( a );      v.push_back( b );
      if( a+b>=10 ){  cin >> a; v.push_back( a ); }
      p.first = 0; // 得点
      n=0;
      for( int i=0,j;i<9;i++ ){
	j = v[n] + v[n+1];
	p.first += j;
	if( v[n]==10 ){ // strike
	  p.first += v[n+2];
	}else {
	  if( j==10 ) p.first += v[n+2];
	  n++;
	}
	n++;
      }
      while( n<(int)v.size() ) p.first += v[n++];

      //      cout << "  score="<<p.first << endl;
      s.push_back( p );
    }
    
    sort( s.begin(),s.end(), cmp );
      for( unsigned int i=0;i<s.size();i++ )
	cout << s[i].second << " " << s[i].first << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(void)
{
	int a,b;
	char op;

	while(1){	
		cin >> a >> op >> b;
		if(op=='?')break;

		switch(op){
		case '+':
			cout << a+b << endl;
			break;

		case '-':
			cout << a-b << endl;
			break;

		case '*':
			cout << a*b << endl;
			break;

		case '/':
			cout << a/b << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll x; cin >> n >> x;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  sort(all(A));
  int ans = 0;
  rep(i, n) {
    if(i == n-1) {
      if(x == A[i]) {
        ans++;
      }
    } else {
      if(x >= A[i]) {
        ans++;
        x -= A[i];
      }
    }
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int n, q, i, p, u, x, nr;
set<int> s;
struct str{
    int t, tip, x;
};
str v[400005];
int cmp(str a, str b){
    if(a.t == b.t){
        return a.tip > b.tip;
    }
    return a.t < b.t;
}
int main(){
    cin>> n >> q;
    for(i = 1; i <= n; i++){
        cin>> p >> u >> x;
        nr += 2;
        v[nr - 1].x = v[nr].x = x;
        v[nr - 1].t = p - x;
        v[nr].t = u - x;
        v[nr].tip = 1;
    }
    sort(v + 1, v + nr + 1, cmp);
    u = 1;
    for(; q; q--){
        cin>> x;
        while(u <= nr && v[u].t <= x){
            if(v[u].tip == 0){
                s.insert(v[u].x);
            }
            else{
                s.erase(v[u].x);
            }
            u++;
        }
        set<int> :: iterator it = s.begin();
        if( s.empty() ){
            cout<<"-1\n";
        }
        else{
            cout<< *it <<"\n";
        }
    }
}


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

const int N = 2e5+7;
int n,m;
char s[N];

int type[N];

bool vis[N];

int wei[N][2];

set<int> vc[N];

void add(int x, int y)
{
    int sz = vc[x].size();
    vc[x].insert(y);

    if(sz!=vc[x].size())
        wei[x][type[y]]++;// 0 is red
}

queue<int> Q;
bool topsort()
{
    int ans=0;
    rep(i,1,n+1)
    {
        if(wei[i][0]<=0 || wei[i][1]<=0){
            Q.push(i);
            vis[i]=1;
            ans++;
        }
    }

    while(Q.size()){
        int cur = Q.front();
        Q.pop();

        for(auto v:vc[cur]){
            wei[v][type[cur]]--;
            if(vis[v]) continue;
            if(wei[v][0]<=0 || wei[v][1]<=0){
                Q.push(v);
                vis[v]=1;
                ans++;
            }

        }
    }
    return ans!=n;
}

int main()
{
    scanf("%d%d",&n,&m);
    scanf("%s",s);
    rep(i,0,n)
    {
        type[i+1]=(s[i]-'A');
    }
    rep(i,1,m+1)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
    }
    if(topsort())puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 30464
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
double a,b;
int h,m;
int main()
{
	scanf("%lf%lf%d%d",&a,&b,&h,&m);
	double ah=pi*2/12*h+pi*2/12/60*m;
	double am=pi*2/60*m;
	double ar=abs(ah-am);
	double ans=sqrt(a*a+b*b-2*a*b*cos(ar));
	printf("%.12lf\n",ans);
	return 0;
}


Measured memory_bytes: 4220
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  ll h[n];
  for(i = 0; i < n; ++i) scanf("%lld", &h[i]);
  for(i = n - 2; i >= 0; --i) if(h[i] > h[i + 1]) h[i]--;
  for(i = 1; i < n; ++i) if(h[i] < h[i - 1]) {
    printf("No");
    return 0;
  }
  printf("Yes");
  return 0;
}

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

int n,l,t,x[100010],s;

void work()
{
	scanf("%d %d %d",&n,&l,&t);
	for (int i=1,w; i<=n; i++)
		{
			scanf("%d %d",&x[i],&w);
			if (w==1)
				x[i]+=t,s=(s+x[i]/l)%n,x[i]%=l;
			else
				{
					x[i]-=t,s=(s+x[i]/l+n)%n,x[i]%=l;
					if (x[i]<0)  x[i]+=l,s--;
				}
		}
	sort(x+1,x+n+1);
	for (int i=1; i<=n; i++)  printf("%d\n",x[(i+s-1)%n+1]);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 1536
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	N := nextInt()
	D := nextInt()
	d := D*2 + 1
	fmt.Fprint(out, (N+d-1)/d, "\n")
}

func solve(N int, a []int, used []int, s2, x1, x2, depth int) bool {
	// fmt.Fprint(out, used, depth, x1, x2, "\n")
	if depth == N {
		// fmt.Fprint(out, "atta\n")
		return x1^x2^a[0] == 0 && x2^a[0]^s2 == 0
	}
	for i := 0; i < N; i++ {
		if used[i] > 0 {
			continue
		}
		if depth >= 2 && x1^x2^a[i] != 0 {
			continue
		}
		used[i] = 1
		if depth == 1 {
			s2 = a[i]
		}
		if solve(N, a, used, s2, x2, a[i], depth+1) {
			return true
		}
		used[i] = 0
	}
	return false
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


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

using namespace std;
long int c = 1000000007;
vector<long int> power2(1000001);
int main(){

int l,r,d;
cin>>l>>r>>d;
int ans = r/d - l/d;
if(l%d==0)
  ans+=1;
cout<<ans;
}
/*
// Sample code to perform I/O:

cin >> name;                            // Reading input from STDIN
cout << "Hi, " << name << ".\n";        // Writing output to STDOUT

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here


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

int main(void) {
    int a, b; cin >> a >> b;
    double mean = (a + b) / 2.0;
    int m = (a + b) / 2;
    if (mean - (double)m > 0) cout << m + 1 << '\n';
    else cout << m << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n, e=0;
    std::cin >> n;
    rep(i,n){
        int ai; std::cin >> ai;
        if(!(ai%2)) e++;
    }

    std::cout << pow(3,n)-pow(2,e) << "\n";
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int b;
    b = n;
    int a = 0;
    int i = 0;
    while (b){
        a += b%10;
        b /= 10;
    }
    if (n%a == 0){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i=0;i<100;i++)
			for (int j=0;j<100;j++)
				if (i*4+j*7==n) {
					System.out.println("Yes");
					return;
				}
		System.out.println("No");
	}

}


Measured memory_bytes: 23764
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

int main(int argc, char* argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> As(N);
  for (auto&& A : As) {
    std::cin >> A;
  }
  for (;;) {
    int v          = *std::min_element(std::begin(As), std::end(As));
    bool diff_flag = false;
    for (auto&& A : As) {
      A %= v;
      if (A == 0) {
        A = v;
      } else {
        diff_flag = true;
      }
    }
    if (!diff_flag) {
      std::cout << v << std::endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 640
def main():
    S = input()
    N = len(S)

    res = [0] * N

    count = 0
    for i, s in enumerate(S[:-1]):
        if s == 'R':
            count += 1

            if S[i + 1] == 'L':
                if count % 2 == 0:
                    res[i] += count // 2
                    res[i + 1] += count // 2
                else:
                    res[i] += count // 2 + 1
                    res[i + 1] += count // 2

        else:
            count = 0

    count = 0
    for i, s in enumerate(S[::-1], start=1):
        if s == 'L':
            count += 1

            if S[-(i + 1)] == 'R':
                if count % 2 == 0:
                    res[-i] += count // 2
                    res[-(i + 1)] += count // 2
                else:
                    res[-i] += count // 2 + 1
                    res[-(i + 1)] += count // 2

        else:
            count = 0

    print(*res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49340
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
long long a[N], b[N];
int main() {
	int n;
	cin >> n;
	for(int i(1); i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	long long inc(0);
	for(int i(n); i >= 1; i--) {
		a[i] += inc;
		inc += (b[i] - a[i] % b[i]) % b[i];
	}
	cout << inc << endl;
}



Measured memory_bytes: 1920