akhauriyash/Code-Regression huggingface dataset:
/**
 *     author: qodjf
 *     created: 04.22.2020 23:13:03
 */
#include <bits/stdc++.h>
using namespace std;

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<ll, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

struct edge {
  int to, cost;
};

vector<ll> dijkstra(int n, const vector<vector<edge>> &g, int s) {
  vector<ll> d(n, LLINF);
  priority_queue<P, vector<P>, greater<P>> que;
  d[s] = 0;
  que.emplace(0, s);
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    int u = p.second;
    if (d[u] < p.first) continue;
    for (auto &e : g[u]) {
      int v = e.to;
      if (d[v] > d[u] + e.cost) {
        d[v] = d[u] + e.cost;
        que.emplace(d[v], v);
      }
    }
  }
  return d;
}

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

  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--;
  t--;
  vector<vector<edge>> g1(n), g2(n);
  for (int i = 0; i < m; i++) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    g1[u].push_back(edge{v, a});
    g1[v].push_back(edge{u, a});
    g2[u].push_back(edge{v, b});
    g2[v].push_back(edge{u, b});
  }

  vector<ll> disS = dijkstra(n, g1, s);
  vector<ll> disT = dijkstra(n, g2, t);

  vector<ll> ans(n + 1, 0);
  const ll X = 1e15;
  for (int i = n - 1; i >= 0; i--) {
    ans[i] = max(ans[i + 1], X - disS[i] - disT[i]);
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 16120
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
using ll = long long int;
const int MAX_NUM = 2 * 1e5 + 10;
vector<int> a(MAX_NUM, 0);
vector<int> b(MAX_NUM, 0);

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

    priority_queue<pair<int, int>> pq;
    int n; cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i]; 
    }
    for(int i=0; i<n; i++){
        cin >> b[i]; 
        if(b[i] != a[i]){
            pq.push(pair<int, int>{b[i], i});
        }
    }

    ll ans = 0;
    while(!pq.empty()){
        pair<int, int> maxp = pq.top(); pq.pop();
        ll m = maxp.first; int id = maxp.second;
        ll l = b[(id + n - 1) % n];
        ll r = b[(id + 1) % n];
        ll div = m / (l + r);
        if((m - a[id]) % (l + r) == 0){
            div = (m - a[id]) / (l + r);
            ans += div;
            b[id] = a[id];
            continue;
        }
        if(l + r >= m){
            cout << -1 << endl;
            return 0;
        }
        m %= (l + r);
        ans += div;
        b[id] = m;
        // for(int i=0; i<n; i++){
        //     cout << b[i] << " ";
        // }
        // cout << endl;
        if(m < a[id]){cout << -1 << endl; return 0;}
        pq.push(pair<int, int>{m, id});
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3956
n=int(input())
ar=list(map(int,input().split()))
c=1000
for i in range(n-1):
    if ar[i+1]>ar[i]:
        cur=c//ar[i]
        c%=ar[i]
        c+=ar[i+1]*cur
##        print(i,cur,c)
print(c)


Measured memory_bytes: 61768
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M;
    vi p(M);
    vector<string> s(M);
    REP(i, M) {
        cin >> p[i] >> s[i];
        p[i]--;
    }
    vi ac(N), wa(N);
    REP(i, M) {
        if (s[i] == "AC") {
            if (ac[p[i]] == 0) {
                ac[p[i]] = 1;
            }
        } else {
            if (ac[p[i]] == 0) {
                wa[p[i]]++;
            }
        }
    }
    REP(i, N) {
        if (ac[i] == 1) {
            ans += wa[i];
        }
    }
    cout << accumulate(ALL(ac), 0) << " " << ans << endl;
}

Measured memory_bytes: 7040
import itertools
n=int(input())
l=list(itertools.permutations(range(1,n+1),n))

a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
a_index=0
b_index=0

for i in range(len(l)):
    if l[i]==a:
        a_index=i+1
    elif l[i]==b:
        b_index=i+1
    else:
        continue
if a_index==0 or b_index==0:
    print(0)
else:    
    result=abs(a_index-b_index)
    print(result)

Measured memory_bytes: 8052
def f(num, base):
    # calc max Pth Power
    ret = 1
    while ret <= num:
        ret *= base
    return ret // base


def main():
    N = int(input())
    st = {N}
    ans = 0
    while (all(st)):
        st = {x - f(x, 6) for x in st} | {x - f(x, 9) for x in st}
        ans += 1
    print(ans)
    return


main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

bool f(int a, int b, int c, int d) {
    return abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d);
}

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (f(a, b, c, d)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) {
    cin >> D[i];
  }
  sort(D.begin(), D.end());
  cout << D[N / 2] - D[N / 2 - 1] << '\n';
  return 0;
}


Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = input().rstrip()
    b = input().rstrip()
    c = input().rstrip()
    res = 0
    for i in range(n):
        d = [a[i], b[i], c[i]]
        res += len(set(d))-1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
import std.typecons;

void main(){
    stdin.byLine.map!(a => a.chomp.split(",")).filter!(a => (a[1].to!real / (a[2].to!real^^2)) >= 25).map!(a => (a[0].writeln, 0)).array;
}

Measured memory_bytes: 1024
N,M=map(int,input().split())
A=[[]for i in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  A[a-1].append(b-1)
S,T=map(int,input().split())  
from collections import deque
import sys
sys.setrecursionlimit(10**7) #再帰制限のとっぱらい
D=[[-1]*3 for i in range(N)]
def bfs(x,n):
  q=deque()
  q.append((x,n)) 
  while len(q):
    x,n=q.popleft()
    for i in A[x]:
      d=(n+1)%3
      if D[i][d]==-1:
        D[i][d]=D[x][n]+1
        q.append((i,d))
D[S-1][0]=0
bfs(S-1,0)
if D[T-1][0]==-1:
  print(-1)
else:
  print(D[T-1][0]//3)

Measured memory_bytes: 42508
n = int(input())
a = [int(input()) for i in range(n)]
max1 = max(a)
ind = a.index(max1)
if ind == 0:
    a_ = a[1:len(a)]
elif ind == len(a)-1:
    a_ = a[0:len(a)-1]
else:
    a_ = a[0:ind] + a[ind+1:len(a)]
max2 = max(a_)
for i in range(n):
    if a[i] == max1:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 14636
#include <iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	while (s != "-") {
		int n, sh;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> sh;
			s += s.substr(0, sh);
			s = s.substr(sh, s.size() - sh);
		}
		cout << s << '\n';
		cin >> s;
	}
}


Measured memory_bytes: 3172
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

class Main {

	final long MOD = 1_000_000_000 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int n = S.length();
		int ans = n / 2;
		int left = n - ans - 1;
		int right = ans;
		char c = S.charAt(left);

		while (left >= 0 && S.charAt(left) == S.charAt(right) && S.charAt(left) == c) {
			--left;
			++right;
			++ans;
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}
}


Measured memory_bytes: 26804
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
A,B,DEGREE = map(int,input().split())
 
rad = math.radians(DEGREE)
 
S = A*B*math.sin(rad)/2.0
C = math.sqrt(A*A+B*B-2*A*B*math.cos(rad))
h = 2*S/A
 
print("%.10f %.10f %.10f"%(S,A+B+C,h))


Measured memory_bytes: 6432
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  string a,b,c; cin >> a >> b >> c;



  int ans = 0;
  rep(i, n){
    map<char,int> list;
    list[a[i]]++;
    list[b[i]]++;
    list[c[i]]++;
    int maxc = 0;
    for(auto li : list){
      chmax(maxc, li.second);
    }
    ans += 3-maxc;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
N=int(input())
T=[0]+[int(i) for i in input().split()]
M=int(input())
drinks=[[int(i) for i in input().split()] for _ in range(M)]
for drink in drinks:
    copyedT=[i for i in T]
    copyedT[drink[0]]=drink[1]
    print(sum(copyedT))

Measured memory_bytes: 38512
from queue import Queue
 
n, q = [ int( val ) for val in input( ).split( " " ) ]
processes = Queue( )
for i in range( n ):
    name, time = input( ).split( " " )
    processes.put( ( name, int( time ) ) )
  
qsum = 0
output = []
while not processes.empty( ):
    process = processes.get( )
    if process[1] <= q:
        qsum += process[1]
        output.append( "{:s} {:d}".format( process[0], qsum ) )
    else:
        processes.put( ( process[0], process[1]- q ) )
        qsum += q
 
print( "\n".join( output ) )

Measured memory_bytes: 21536
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;

    cout << N/(A+B)*A+min(A,N%(A+B)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

vector<string> str = {"dream", "dreamer", "erase", "eraser"};
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = (int)s.size();
    vector<bool> dp(n + 1); dp[0] = true;
    rep (i, n) {
        for (string t : str) {
            int m = t.size();
            if (dp[i] && i + m <= n && s.substr(i, m) == t) dp[i + m] = true;
        }
    }
    rep (i, n) eprintf("%d", 1*dp[i + 1]); eprintf("\n");
    cout << (dp[n] ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

int main(){
    int N,M;
    std::cin >> N >> M;
    float A[N];
    float sum=0;
    int temp=0;
    std::string s="No";
    for(int i=0;i<N;++i){
        std::cin >> A[i];
        sum+=A[i];
    }
    
    for(int i=0;i<N;++i){
        if(A[i]<sum/(4*M)){
        } else {
            temp++;
        }
        if(temp==M){
            s="Yes";
            break;
        }
    }
    
    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define N 100010
ll n,a[N],b[N],s[N];
int main(){
	cin>>n;
	for(int i=0;i<=n;i++)cin>>a[i];
	if(n==0){
		if(a[0]==1)cout<<1<<endl;
		else cout<<-1<<endl;
		return 0;
	}
	if(a[0]>0){
		cout<<-1<<endl;
		return 0;
	}
	s[n+1]=0;
	for(int i=n;i>=0;i--){
		s[i]=s[i+1]+a[i];
	}
	b[0]=1;
	for(int i=1;i<=n;i++){
		b[i]=2*b[i-1]-a[i];
		chmin(b[i],s[i+1]);
		if(b[i]<0||a[i]+b[i]<b[i-1]){
			cout<<-1<<endl;
			return 0;
		}
	}
	ll ans=0;
	for(int i=0;i<=n;i++){
		ans+=a[i]+b[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5920
from collections import deque
N, M = map(int, input().split())
G = [[] for i in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)
#bfsで探索
T = [-1]*N
que = deque()
que.append(0)
while que:
    v = que.popleft()
    for e in G[v]:
        if T[e] == -1:
            T[e] = v+1
            que.append(e)
print("Yes")
print(*T[1:], sep="\n")

Measured memory_bytes: 38516
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(void)
{
	char str[1001];

	while(1){
		scanf("%s", str);
		if(str[0] == '0') break;

		int sum = 0;
		for(int i = 0; i < strlen(str); i++){
			sum += (str[i] - '0');
		}

		cout << sum << endl;
	}

    return 0;
}



Measured memory_bytes: 3168
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n + 1) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
tree = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    tree.union(a, b)

ans = 0
for root in tree.roots():
    ans = max(ans, tree.size(root))
print(ans)

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 3e5 + 5;

int A[11], N, M, Q;
int a[55], b[55], c[55], d[55];
ll ans;

ll cal() {
	ll ret = 0;
	for(int i=1; i<=Q; i++) {
		if(A[b[i]] - A[a[i]] == c[i]) ret += d[i];
	}
	return ret;
}

void f(int n) {
	if(n == N) {
		ans = max(ans, cal());
		return;
	}
	for(int i=A[n]; i<=M; i++) {
		A[n+1] = i;
		f(n+1);
	}
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	A[0] = 1;
	cin >> N >> M >> Q;
	for(int i=1; i<=Q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	f(0);
	cout << ans;
}


Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    y = [0 for i in range(N)]
    y[0] = sum([A[i] if i%2 == 0 else (-1) * A[i] for i in range(N)])
    for i in range(0, N-1):
        y[i+1] = 2 * A[i] - y[i]
    result = [str(i) for i in y]
    print(' '.join(result))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 30384
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll n, m;

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2) {
		cout << b - a << endl;
	}
	else {
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(void){
    int N;
    scanf("%d", &N);
    int max = 0;
    int sum = 0;

    int *p;
    p = (int*)malloc(N * sizeof(int));
    int i;
    for(i=0; i<N; i++) {
        scanf("%d", &p[i]);
        sum += p[i];

        if(p[i] > max){
            max = p[i];
        }
    }
    printf("%d\n", sum - (int)((double)max /  2.0));

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const ll INF = 1001001001;
const ll MOD = 1e9 + 7;

int main(){
  int n;
  int a[200001];
  cin >> n;
  rep(i, n) cin >> a[i+1];
  vector<int> ans;
  for(int i = (n+2)/2; i <= n ;i++){
    if(a[i]) ans.push_back(i);
  }
  for(int i = n/2; i >= 1; i--){
    bool flag = true;
    for(int j = 2; i*j <= n; j++){
      if(a[i*j]) flag = !flag;
    }
    if((flag && a[i])||(!flag&& !a[i])){
      ans.push_back(i);
      a[i]=1;
    }else{
      a[i] = 0;
    }
  }
  cout << ans.size() <<endl;
  for(int x: ans) printf("%d ", x);
}



Measured memory_bytes: 2424
#include <bits/stdc++.h> 
/*#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif
*/

using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
   
        int n;
        cin>>n;
        cout<<((n+999)/1000)*1000-n<<endl;
    
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N - 1);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  for(int i = 0; i < N; i++) cin >> B.at(i);
  for(int i = 0; i < N - 1; i++) cin >> C.at(i);
  
  int answer = 0;
  
  for(int i = 0; i < N; ++i) {
    answer += B.at(A.at(i) - 1);
    if(i > 0 && A.at(i) - 1 == A.at(i - 1)) {
      answer += C.at(A.at(i) - 2);
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
import Foundation
 
let input_line = readLine()!
 
let split = input_line.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
let X = Int(split[0])!
let A = Int(split[1])!
 
if X < A {
    print(0)
} else  {
    print(10)
}

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

#define max(a, b) ((a > b) ? a : b)
#define min(a, b) ((a < b) ? a : b)

#define forn(n) for(int i = 0; i < n; i++)
#define fork(k, n) for(int i = k; i < n; i++)

#define pb(n) push_back(n);

typedef long long ll;
typedef double dbl;

const int MX = 1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

int main(){
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll res = 1;
    res = a * c;
    res = max(res, a * d);
    res = max(res, b * c);
    res = max(res, b * d);
    cout<<res<<endl;
}

Measured memory_bytes: 3592
using System;

namespace AOJ0054
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                string[] num = input.Split(' ');

                float a = float.Parse(num[0]);
                int b = int.Parse(num[1]);
                int N = int.Parse(num[2]);
                //Calculation
                decimal d = (decimal) a / b;
                d -= (int) a / b;
                int sum = 0;

                if (!d.Equals(decimal.Zero))
                {
                    //Get Length
                    string dstr = d.ToString();
                    dstr = dstr.Substring(2);

                    for (int i = 0; i < N; i++)
                    {
                        if (i >= dstr.Length) break;

                        sum += int.Parse(dstr.Substring(i, 1));
                    }
                } 

                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 9328
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N, W;
  cin >> N >> W;
  int64_t w[110], v[110];
  for(int i=1; i<=N; i++) cin >> w[i] >> v[i];
  
  int64_t dp[100100][110];
  for(int i=0; i<=N; i++) dp[0][i] = 0;
  for(int i=0; i<=W; i++) dp[i][0] = 0;
  
  for(int i=1; i<=W; i++){
    for(int j=1; j<=N; j++){
      if(i-w[j] >= 0) dp[i][j] = max(dp[i][j-1], v[j] + dp[ i-w[j] ][j-1]);
      else dp[i][j] = dp[i][j-1];
    }
  }
  
  cout << dp[W][N] << endl;
  
}

Measured memory_bytes: 86144
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, N) for(int i = 0; i < N; i++)

int INF = 1000000000;
int N, A, B, C;
int l[1010];

int dfs(int cur, int a, int b, int c) {
    if (cur == N)
        return min(a, min(b, c)) > 0 ? abs(a - A) + abs(b - B) + abs(c - C) - 30 : INF;
    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
    int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    return min(ret0, min(ret1, min(ret2, ret3)));
}

int main() {
    scanf("%d %d %d %d", &N, &A, &B, &C);
    rep(i, N) scanf("%d", &l[i]);
    printf("%d\n", dfs(0, 0, 0, 0));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
void sach(int x,int sum){
  if(x==4){
    if(sum==n) cnt++;
    return;
  }
  for(int i=0;i<10;++i) sach(x+1,sum+i);
}
int main(){
  while(cin>>n){
    cnt=0;
    sach(0,0);
    cout<<cnt<<endl;
  }
  return 0;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int k = in();
  int psts[n];
  REP(i,n) {
    cin >> psts[i];
  }
  int ans = 1000000000;
  REP(i,n-k+1) {
    int left = psts[i];
    int right = psts[i+k-1];
    int tmp_ans = abs(left) + abs(right - left);
    tmp_ans = min(tmp_ans, abs(right) + abs(right - left));
    ans = min(ans, tmp_ans);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <iomanip>
#define rep(i,n) for (int i=0; i<(n); i++)

using namespace std;

int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;

    double result;
    double angle_h = (360 * h / 12) + (m * 0.5);
    double angle_m = 360 * m / 60;
    double angle = abs(angle_h - angle_m);
    double rad = angle * M_PI / 180.0;
    double len;

    len = sqrt(a*a + b*b - 2*a*b*cos(rad));
    cout << setprecision(10) <<len << endl;


    return 0;
}

Measured memory_bytes: 4188
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string s;
  cin >> s;
  int n = s.length();
  bool flag = false;
  string temp;
  for(int i=0;i<n+1;i++){
    for(int j=i;j<n+1;j++){
      temp = "";
      for(int p=0;p<i;p++) temp += s[p];
      for(int p=j;p<n;p++) temp += s[p];
      if(temp == "keyence") flag = true;
    }
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[105];

int bubble_sort(int a[], int n)
{
	bool flag = true;
	int cnt = 0;
	for(int i = n-1; i >= 0; i--)
	{
		flag = true;
		for(int j = 0; j < i; j++)
		{
			if(a[j+1] < a[j])
			{
				swap(a[j+1], a[j]);
				cnt++;
				flag = false;			
			}
		}
		if(flag)
		{
			for(int i = 0; i < n; i++)
			{
				if(i)
					cout << " ";
				cout << a[i];
			}
			cout << endl;
			return cnt;
		}
	}
}


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


Measured memory_bytes: 3100
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, m, p, q, c;
vector<P> nodes, input[100010];
map<P, vector<pair<P,int>>> vec;
map<P, int> dist;
void dijkstra() {
	prique<pair<int, P>, vector< pair<int, P>>, greater<pair<int, P>>> que;
	que.push(make_pair(0, make_pair(1, -1)));
	dist[make_pair(1, -1)] = 0;
	while (!que.empty()) {
		auto p = que.top();
		que.pop();
		if (dist[p.second] < p.first)continue;
		for (auto e : vec[p.second]) {
			if (dist.find(e.first) == dist.end() || dist[e.first] > p.first + e.second) {
				dist[e.first] = p.first + e.second;
				que.push(make_pair(p.first + e.second, e.first));
			}
		}
	}
}
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> p >> q >> c;
		nodes.push_back(make_pair(p, c));
		nodes.push_back(make_pair(q, c));
		input[p].push_back(make_pair(q, c));
		input[q].push_back(make_pair(p, c));
		vec[make_pair(p, c)].push_back(make_pair(make_pair(q, c), 0));
		vec[make_pair(q, c)].push_back(make_pair(make_pair(p, c), 0));
	}
	for (P i : nodes) {
		vec[i].push_back(make_pair(make_pair(i.first, -1), 0));
	}
	REP(i, n) {
		for (P j : input[i]) {
			vec[make_pair(i, -1)].push_back(make_pair(j, 1));
		}
	}
	dijkstra();
	if (dist.find(make_pair(n, -1)) == dist.end())cout << -1 << endl;
	else cout << dist[make_pair(n, -1)] << endl;
}

Measured memory_bytes: 140392
n = gets.to_i
ts = n.times.map{gets.chomp.split.map(&:to_i)}
t_c = x_c = y_c = 0
flag = true
ts.each do |t,x,y|
  t_diff = t_c - t
  dist = (x - x_c)**2 + (y - y_c)**2
  if dist > t_diff**2 || ((x + y)-(x_c + y_c)-t_diff).odd?
    flag = false
  end
  t_c = t
  x_c = x
  y_c = y
end
puts flag ? "Yes" : "No"


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

typedef long long ll;

const int maxn = 2e5 + 1e2;
int val[maxn];
int next[maxn][26];
int dp[maxn];
int dpnext[maxn];
char dpnextc[maxn];

int main(){
	std::ios::sync_with_stdio(false);

	ll n;

	std::string s;
	std::cin >> s;

	n = s.size();

	for(int i = 0; i < 26; i++){
		next[n][i] = n;
	}

	for(int i = n - 1; i >= 0; i--){
		for(int j = 0; j < 26; j++){
			next[i][j] = next[i + 1][j];
		}
		next[i][s[i] - 'a'] = i;
	}

	dp[n] = 1;

	for(int i = n - 1; i >= 0; i--){
		dp[i] = maxn;

		for(int j = 0; j < 26; j++){
			int get = next[i][j];

			int attempt = 1 + dp[get + 1];

			if(dp[i] > attempt){
				dp[i] = attempt;
				dpnext[i] = get + 1;
				dpnextc[i] = 'a' + j;
			}
		}
	}

	std::string res = "";
	int pos = 0;
	while(pos < n - 1){
		res += dpnextc[pos];
		pos = dpnext[pos];
	}

	std::cout << res << '\n';
}


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

using namespace std;

int main() {
	int city[5] = {0}, a, b, f=0;
	for (int i = 0; i < 3; i++) {
		cin >> a >> b;
		city[a]++; city[b]++;
	}

	for (int i = 1; i < 5; i++) {
		if (city[i] > 2) {
			f = 1;
		}
	}

	if (f) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s; 
    REP(i, n)
    {
        if(i == k-1) cout << char(s[i] - 'A' + 'a');
        else cout << s[i];
    }
    cout << endl;
}

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

int main() {
  string s;
  cin >> s;
  if ((s[0]==s[1] && s[1]==s[2]) || (s[2]==s[3] && s[1]==s[2])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LSON            id << 1 , l , mid
#define RSON            id << 1 | 1 , mid + 1 , r
#define ROOT            1 , 1 , n
#define CLR(x , y)      memset(x , y , sizeof(x))
#define LOWBIT(x)       x & (-x)
#define FORN(i , a , n)  for(int i = (a) ; i <= (n) ; ++i)
#define FORP(i , n , a)  for(int i = (n) ; i >= (a) ; --i)
#define CASE(x)		printf("Case %d: ", x)
#define SFD(x)      scanf("%lf" , &x)
#define SFC(x)      scanf(" %c" , &x)
#define SFS(x)      scanf(" %s" , x)
#define SFI(x)      scanf("%d" , &x)
#define SFL(x)      scanf("%lld" , &x)
#define PFD(x)         printf("%lf\n" , x)
#define PFI(x)         printf("%d\n" , x)
#define PFC(x)         printf("%c\n" , x)
#define PFS(x)         printf("%s\n" , x)
#define LOCAL
static const double PI = acos(-1.0);
static const double EPS = 1e-8;
static const int INF = 0X3fffffff;
typedef long long LL;
typedef double DB;
template<class T> inline
T read(T &x)
{
    x = 0;
    int f = 1 ; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}
typedef long long LL;
int main()
{
#ifdef LOCAL
    //freopen("D:\\系统优化\\Desktop\\littlepea\\in.data" , "r" , stdin);
#endif
    LL x , y , ans;
    SFL(x);SFL(y);
    if(abs(x - y) > 1)
        puts("Alice");
    else
        puts("Brown");
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long a[105];
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n) {
    int he;
    cin >> he;
    h[i] = he;
  }

  vector<set<int>> ms(n);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    ms[a-1].insert(h[b-1]);
    ms[b-1].insert(h[a-1]);
  }

int ans = 0;
  rep(i, n) {
    if (ms[i].size() == 0) {
      ans++;
      continue;
    }
    bool find = false;
    for(int he : ms[i]) {
      int tmp = h[i];
      if(h[i] <= he) {
        find = true;
        break;
      }
    }
    if(!find) ans++;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17776
//author: zekigurbuz (Zeki Gurbuz) 2020
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;

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

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define all(x) begin(x),end(x)

const int N = 1e5 + 10;
const int M = 1e9 + 7;

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

template<class T>void ckmin(T&a,T b){a=min(a,b);}
template<class T>void ckmax(T&a,T b){a=max(a,b);}

void precomp() {

}


void solve() {
	int n, k; cin >> n >> k;
	vector<vector<int>> v(n, vector<int>());
	for (int i = 0; i < k; i++) {
		int d; cin >> d;
		for (int j = 0; j < d; j++) {
			int x; cin >> x;
			v[x-1].push_back(i);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) ans += v[i].empty();
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	precomp();
	int t = 1; // cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 3688
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int> a, pair<int,int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a * b, c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i < n; ++i)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

void solve() {
  // main coding
  ll n,m; cin>>n>>m;
  vector<vector<ll>> E(n);
  ll x,y;
  rep(i,m) {
    cin>>x>>y;
    x--; y--;
    E[x].push_back(y);
  }
  vector<ll> dp(n,-1);
  function<void(ll)> dfs=[&](ll v){
    if(dp[v]!=-1) return;
    dp[v]=0;
    for(ll u:E[v]) {
      if(dp[u]==-1) dfs(u);
      dp[v]=max(dp[v],dp[u]+1);
    }
  };
  rep(i,n) dfs(i);
  cout<<*max_element(dp.begin(),dp.end())<<"\n";
}

int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 9216
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    for (int i = K + 1; i <= N; i++) {
        ans += (ll)(i - K) * (N / i);
        if ((N % i) >= K) ans += (N % i) - max(0, K - 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
module Main where

import Data.List
import Control.Monad
import Debug.Trace

solve :: [(Integer,Integer)] -> Integer  -> Integer
solve abs m = fst $ foldl inner (0, m) sortedAbs where 
    sortedAbs = sortOn fst abs
    inner (money, remain_drinks) (a,b) = 
        if remain_drinks == 0 then
            (money, remain_drinks)
        else if remain_drinks <= b then
            (money + a*remain_drinks, 0)
        else
            (money + a*b, remain_drinks - b)

getAB :: IO (Integer, Integer)
getAB = do
    [n,m] <- fmap read . words <$> getLine
    pure (n,m)

main = do
    [n,m] <- fmap read . words <$> getLine
    abs <- replicateM n getAB
    print $ solve abs (fromIntegral m )






Measured memory_bytes: 91004
/**
 * author: dannysmyda
 */ 
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string contest;
    cin >> contest;
    if(contest == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;    
}


Measured memory_bytes: 3612
// ※※※ 解答不能 ※※※
// DEGwer氏.
// https://atcoder.jp/contests/ddcc2020-qual/submissions/8582087
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int n;

bool ask(vector<int> v){
    printf("?");
    rep(i, v.size()) printf(" %d", v[i] % (n + n) + 1);
    printf("\n");
    fflush(stdout);
    char s[10];
    scanf("%s", s);
    return s[0] == 'R';
}

vector<int> make(int t, int len){
    vector<int> v;
    rep(i, len) v.push_back(i + t);
    return v;
}

bool ans[1000];

int main(){
    scanf("%d", &n);
    bool s = ask(make(0, n));
    int beg = 0, end = n - 1;
    if (s)beg = n, end = n + n - 1;
    for(;;){
        if(beg == end) break;
        int med = (beg + end + 1) / 2;
        if(ask(make(med, n))) end = med - 1;
        else                  beg = med;
    }
    ans[beg % (n + n)] = false, ans[(beg + n) % (n + n)] = true;
    rep(i, n - 1){
        vector<int> z = make(beg + 1, n - 1);
        z.push_back(beg + n + i + 1);
        ans[(beg + n + i + 1) % (n + n)] = ask(z); 
        z = make(beg + n + 1, n - 1);
        z.push_back(beg + i + 1);
        ans[(beg + i + 1) % (n + n)] = ask(z);
    }
    printf("! ");
    rep(i, n + n) printf(ans[i] ? "R" : "B");
    printf("\n");
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 724
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<ctime>
#define RG register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;

#define ll long long 
int main(){
	ll a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF){
		printf("%lld ",__gcd(a,b));
		printf("%lld\n",1ll*a*b/__gcd(a,b));
	}
	return 0;
}



Measured memory_bytes: 3100
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String[] s = in.nextLine().split(" ");
            out.println("A" + s[1].substring(0, 1) + "C");
        }

    }
}



Measured memory_bytes: 23636