akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    int arr[n+1],ar[n+1];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n-1;j++)
        {
            if(arr[j]>arr[j+1])
            {
            int aa =arr[j+1];
            arr[j+1]=arr[j];
            arr[j]=aa;
            }
        }
    }
    int sum=0;
    for(int i=0;i<k;i++)
    {
        sum+=arr[i];
    }
    printf("%d\n",sum);
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  ll n, y;
  cin >> n >> y;
  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= n; j++) {
      ll rest = y - i * 10000 - j * 5000;
      bool can = (rest % 1000 == 0);
      int cnt = 0;
      if (can) {
        cnt = rest / 1000;
      }
      if (can && cnt >= 0 && cnt <= n && i * 10000 + j * 5000 + cnt * 1000 == y && i + j + cnt == n) {
        cout << i << ' ' << j << ' ' << cnt << '\n';
        return 0;
      }
    }
  }
  cout << "-1 -1 -1\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	private static Scanner sc=new Scanner(System.in);
	private static int r=sc.nextInt();
	private static int c=sc.nextInt();
	private static int[][] data=new int[r+1][c+1];
	public static void main(String args[]){
		input();
		setSum();
		output();
	}
	private static void input(){
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				data[i][j]=sc.nextInt();
			}
		}
	}
	private static void setSum(){
		for(int i=0;i<r;i++){
			int sum=0;
			for(int j=0;j<c;j++){
				sum+=data[i][j];
			}
			data[i][c]=sum;
		}
		for(int j=0;j<c+1;j++){
			int sum=0;
			for(int i=0;i<r;i++){
				sum+=data[i][j];
			}
			data[r][j]=sum;
		}
	}
	private static void output(){
		for(int i=0;i<=r;i++){
			for(int j=0;j<c;j++){
				System.out.print(data[i][j]+" ");
			}
			System.out.println(data[i][c]);
		}
	}
}

Measured memory_bytes: 41176
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

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

using namespace std;

int n, q;
int A[30];
int m[220];

bool rec(int t, int sum, int i) {
    if (sum == m[t])  return true;
    else if (sum > m[t] || i > n) return false;
    bool f = false;
    f |= rec(t, sum+A[i], i+1);
    f |= rec(t, sum, i+1);
    return f;
}

int main() {
    cin >> n;
    rep(i, n) cin >> A[i];
    cin >> q;
    rep(i, q) cin >> m[i];

    rep(i, q) {
        if (rec(i, 0, 0))  cout << "yes" << endl;
        else cout << "no" << endl;
    }
}



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

int main(){
    string s;
    cin >> s;
    
    int cnt=0;
    if(s[0]=='o') cnt++;
    if(s[1]=='o') cnt++;
    if(s[2]=='o') cnt++;
    
    cout << 700+cnt*100 << endl;
}


Measured memory_bytes: 256
def max_num(n,N,list):
    for i in range(N):
        if list[i] == n:
            num = n
            break
        return n

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
copy_V = []
for i in range(N):
    if V[i] - C[i] < 0:
        V[i] = 0
        copy_V.append(V[i])
        C[i] = 0
    else:
        copy_V.append(V[i])
X = 0
Y = 0
Max = 0
for i in range(N):
    X += max(V)
    tmp = max(V)
    Y += C[copy_V.index(tmp)]
    tmp_1 = copy_V.index(tmp)
    del V[V.index(max(V))]
    if Max < X - Y:
        Max = X - Y
print(Max)

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

int main(void){
    string s;
    string t;

    cin >> s >> t;
    int count = 0;
    rep(i, 3){
        if(s.at(i) == t.at(i)) count++;
    }
    
    cout << count << endl;
}


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

int main() {
    int e;
    while (cin >> e, e) {
        int ans = e;
        for (int z = 0; z * z * z <= e; z++) {
            int y = sqrt(e - z * z * z);
            int x = e - z * z * z - y * y;
            ans = min(ans, x + y + z);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3032
N=int(input())
for h in range(1,3500):
  for n in range(1,3500):
    if 4*h*n-N*n-N*h>0 and (N*h*n)%(4*h*n-N*n-N*h)==0:
      print(h,n,(N*h*n)//(4*h*n-N*n-N*h))
      exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  string s, ans;
  cin >> s;
  ans = "Yes";
  for(int i=0; i<s.length(); i+=2){
    if (s[i] == 'L') ans = "No";
  }
  for(int i=1; i<s.length(); i+=2){
    if (s[i] == 'R') ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 10;
int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size(),m = t.size();
    int ans = m;
    for(int i = 0;i < n - m + 1;i++){
        int c = 0;
        for(int j = 0;j < m;j++){
            if(s[i + j] != t[j])c++;
        }
        ans = min(ans, c);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 998244353
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;


int main(){

    int n;
    cin >> n;

    vector<pair<double,double>> v;

    rep(i,n){
        double x,y;
        cin >> x >> y;
        v.pback(mpair(x,y));
    }

    double sum = 0.0;

    rep(i,n){
        rep(j,n){
            if(i == j) continue;
            double x1 = v[i].first;
            double x2 = v[j].first;
            double y1 = v[i].second;
            double y2 = v[j].second;

            sum += sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
    }

    cout << setprecision(12) << sum / n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;

typedef long long LL;
const int N = 1e5 + 10;
struct E {int v, w, nt;} e[N<<1];
int n, m, ok, poi, edg, tot = 1, h[N], pai[N], cnt[3], vis[N<<1]; LL ans;

inline void add(int u, int v, int w1, int w2) {
	e[++tot] = (E){v, w1, h[u]}, h[u] = tot;
	e[++tot] = (E){u, w2, h[v]}, h[v] = tot;
}

template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline void dfs(int x, int c) {
	if (~pai[x]) {
		if (pai[x] != c) ok = 0;
		return;
	}
	++cnt[pai[x] = c], ++poi;
	for (int i = h[x]; i; i = e[i].nt)
		if (!vis[i] && !vis[i ^ 1]) {
			vis[i] = vis[i ^ 1] = 1, ++edg;
			dfs(e[i].v, (c + e[i].w) % 3);
		}
}

int main() {
	int u, v; in(n), in(m), fill(pai, pai + N, -1);
	for (int i = 1; i <= m; ++i) in(u), in(v), add(u, v, 1, 2);
	for (int i = 1; i <= n; ++i) {
		if (~pai[i]) continue;
		poi = edg = 0, ok = 1;
		fill(cnt, cnt+3, 0), dfs(i, 0);
		if (!ok) ans += 1LL * poi * poi;
		else if (!cnt[0] || !cnt[1] || !cnt[2]) ans += (LL)edg;
		else ans += 1LL * cnt[0] * cnt[1] + 1LL * cnt[1] * cnt[2] + 1LL * cnt[2] * cnt[0];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
    ll n,m;
    cin >> n >> m;
    if(n==1||m==1){
        ll a = max(n,m);
        if(a==1)cout << 1 << endl;
        else if(a==2)cout << 0 << endl;
        else cout << a-2 << endl;
    }else{
        ll ans = (n-2)*(m-2);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

template <typename T>
T gcd(T a, T b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}

template <typename T>
__int128 lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int main(void) {
  lint n, m;
  cin >> n >> m;
  vector<lint> a(n);
  rep (i, n) cin >> a[i];
  __int128 tmp = 1;
  rep (i, n) {
    tmp = lcm((lint)tmp, a[i]);
    if (tmp > 2 * m) {
      cout << 0 << endl;
      return 0;
    }
  }
  lint x = tmp;
  rep (i, n) {
    if (!((x / a[i]) & 1)) {
      cout << 0 << endl;
      return 0;
    }
  }
  lint sum = (m - x / 2) / x + 1;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  ll x, a;
  cin >> x >> a;
  
  if(x<a) pt(0);
  else pt(10);
  
  
  
}







Measured memory_bytes: 256
import array;R=range;L=input;T=[0]*28;N=int(L());S=[[ord(C)-95 for C in L()]for _ in[0]*N];U=N*26**2*array.array('i',[0]);V=N*[0];Q=int(L())
for X in S:
	P=0
	for C in X:
		if T[P+C]==0:T[P+C]=len(T);T+=[0]*28
		T[P]+=1;P=T[P+C]
	T[P]+=1;T[P+1]=1
while N:
	N-=1;P=0
	for C in S[N]:
		for A in R(26):
			X=T[P+A+2]
			if(A!=C-2)*X:U[676*N+26*A+C-2]+=T[X]
		V[N]+=T[P+1]
		P=T[P+C]
while Q:
	K,P=L().split();K=int(K)-1;P=[ord(C)-97 for C in P];X=1+V[K]
	for A in R(26):
		for B in R(A+1,26):
			X+=U[676*K+26*P[A]+P[B]]
	print(X);Q-=1

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


int main() {
    ll A, B;
    char op;
    cin >> A >> op >> B;
    if (op == '+') cout << A+B << endl;
    else cout << A-B << endl;
}



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

using namespace std;

vector<int> split(string* str, char sep) {
    vector<int> v;
    stringstream ss(*str);
    string buffer;
    while (getline(ss, buffer, sep))
        v.push_back(atoi(buffer.c_str()));
    return v;
}

int main() {
    string s;
    int a, sz;
    vector<int> dp[100];
    for (sz = 0; getline(cin, s); sz++)
        dp[sz] = split(&s, ',');

    for (int i = 1; i < sz; i++)
        for (int j = 0; j < dp[i].size(); j++) {
            int l, r;
            if (i <= sz / 2) l = j - 1, r = j;
            else l = j, r = j + 1;

            if (l < 0) dp[i][j] += dp[i - 1][r];
            else if (r >= i) dp[i][j] += dp[i - 1][l];
            else dp[i][j] += max(dp[i - 1][l], dp[i - 1][r]);
        }

    cout << dp[sz - 1][0] << endl;

    return 0;
}


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

int main() {

	int N;cin>>N;
	string S;cin>>S;
	if(N%2)cout<<"No"<<endl;
	else
	{
		bool flag = true;
		for(int i=0;i<N/2;i++)if(S[i] != S[N/2+i])flag = false;
		cout<<(flag?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left
from heapq import heappush, heappop

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
td = [LIST() for _ in range(N)]
td.sort(key=lambda x:-x[1])

q = []
v = set()
s = 0
for t, d in td[:K]:
	s += d
	if t in v:
		heappush(q, d)
	else:  # その種類で最大(最初)のものは以後取り出さないのでヒープに追加しない
		v.add(t)
s += len(v) ** 2  # +種類ボーナス
ans = s

for t, d in td[K:]:  # 残りについて取り替えるか取り替えないか決める
	if t not in v and len(q) != 0:
		z = heappop(q)
		s += d + 2*len(v)+1-z  # 種類ボーナスと満足ボーナスの差分
		v.add(t)
		ans = max(ans, s)
print(ans)


Measured memory_bytes: 33016
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll X;

struct func {
	ll L, R;
	ll l, r;
	// segment: [0, L] [L, R], [R, X]
	// value:   [l]    [l + (x - L)] [r]
};

struct event {
	bool c;
	ll t;
	ll a;
};

bool operator < (event a, event b) {
	return a.t < b.t;
}

func make(func f, ll q, bool inc) {
	func g;
	if (inc) {
		// Increase
		if (f.l + q >= X) {
			g.L = X;
			g.R = X;
			g.l = X;
			g.r = X;
		}
		else if (f.r + q <= X) {
			g.L = f.L;
			g.R = f.R;
			g.l = f.l + q;
			g.r = f.r + q;
		}
		else {
			ll ct = f.r - (X - q);
			g.L = f.L;
			g.R = f.R - ct;
			g.l = f.l + q;
			g.r = X;
		}
	}
	else {
		// Decrease
		if (f.l - q >= 0) {
			g.L = f.L;
			g.R = f.R;
			g.l = f.l - q;
			g.r = f.r - q;
		}
		else if (f.r - q <= 0) {
			g.L = X;
			g.R = X;
			g.l = 0;
			g.r = 0;
		}
		else {
			ll ct = q - f.l;
			g.L = f.L + ct;
			g.R = f.R;
			g.l = 0;
			g.r = f.r - q;
		}
	}
	return g;
}

int main() {
    ios::sync_with_stdio(false);
    ll K;
    cin >> X >> K;
    vector<event> G;
    for (int i = 0;i < K;i++) {
    	event n;
    	cin >> n.t;
    	n.c = 1;
    	G.push_back(n);
    }
    int Q;
    cin >> Q;
    for (int i = 0;i < Q;i++) {
    	event n;
    	cin >> n.t >> n.a;
    	n.c = 0;
    	G.push_back(n);
    }
    sort(G.begin(), G.end());
    func f;
    f.L = 0;
    f.R = X;
    f.l = 0;
    f.r = X;
    ll crt = 0;
    bool sg = 0;
    vector<ll> sol;
    for (int i = 0;i < G.size();i++) {
    	event q = G[i];
    	if (q.c == 1) {
    		// Swap.
    		func g = make(f, q.t - crt, sg);
    		crt = q.t;
    		f = g;
    		sg = !sg;
    	}
    	else {
    		// Calculate.
    		func g = make(f, q.t - crt, sg);
    		crt = q.t;
    		f = g;
    	    ll a = q.a;
    	    if (a <= f.L) {
    	    	sol.push_back(f.l);
    	    }
    	    else if (a <= f.R) {
    	    	sol.push_back(f.l + a - f.L);
    	    }
    	    else {
    	    	sol.push_back(f.r);
    	    }
    	}
    }
    for (int i = 0;i < sol.size();i++) cout << sol[i] << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	int prev = 0;
	for(int i = 0; i < n; i++){
		int x; cin>>x;
		if(prev + 1 == x)prev++;
	}
	if(!prev)cout<<-1<<endl;
	else cout<<n - prev<<endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(map(int,input().split()))
B = []

if N%2:
	B = [0]
	for i in range(N//2):
		B += [(i + 1)*2]*2
else:
	for i in range(N//2):
		B += [i*2 + 1]*2	
#print(A, B)
#print(B)
if A==B:
	print(2**(N//2)%((10**9) + 7))
else:
	print(0)




Measured memory_bytes: 14008
gohya =int(input())
hya = int(input())
goju = int(input())
total = int(input())
count = 0
for gh in range(gohya+1):
	for hy in range(hya+1):
		for gj in range(goju+1):
			if 500*gh + 100*hy + 50*gj == total:
				count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M + 1);

    rep(i, N) {
        int K;
        cin >> K;
        dump(K);
        rep(j, K) {
            int O;
            cin >> O;
            dump(O);
            L.at(O)++;
        }
    }

    int cnt = 0;
    rep(i, M + 1) {
        if(L.at(i) == N) cnt++;
    }

    cout << cnt << endl;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s.length() == 2)
	{
		if (s[0] == s[1])
		{
			cout << 1 << ' ' << 2 << endl;
			return 0;
		}
	}
	for (size_t i = 0; i < s.length() - 2; i++)
	{
		if (s[i] == s[i + 1])
		{
			cout << i + 1 << ' ' << i + 2 << endl;
			return 0;
		}
		if (s[i] == s[i + 2])
		{
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << ' ' << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct Order {
    int idx;
    int acc;

    Order(int input_idx, int input_acc)
    {
        idx = input_idx;
        acc = input_acc;
    }

    bool operator<(const Order &another) const
    {
        return acc < another.acc;
    };
};

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    vector<Order> B;
    for(int i=0; i<N; i++) {
        B.push_back(Order(i, A[i]));
    }
    sort(B.begin(), B.end());

    for(auto itr: B) {
        cout << (itr.idx+1) << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2164
# encoding: utf-8
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

route = [[] for i in range(N)]
for ai, bi in ab:
    route[ai - 1].append(bi - 1)
    route[bi - 1].append(ai - 1)

# print("#", route)
    
def walk(pos, footprint):
    # goal
    if footprint == 2 ** N - 1: return 1
    # search route
    # print("##", pos, bin(footprint))
    ans = 0
    for to in route[pos]:
        if footprint & 2 ** to > 0: continue
        else: ans += walk(to, footprint + 2 ** to)
    return ans

print(walk(0, 1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s; cin >> s;
  int ans = 0;
  if(s[1] == 'R'){
    ans ++;
    if(s[0] == 'R')
      ans++;
    if(s[2] == 'R')
      ans++;
  }
  else if(s[0] == 'R' || s[2] == 'R')
    ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='+') sum++;
		else sum--;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> x(n),y(m);
    rep(i,n) cin>>x[i];
    rep(i,m) cin>>y[i];
    
    ll X=0;
    rep(k,n){
        X+=(ll)(k*x[k]-(n-k-1)*x[k]);
        X=(X+MOD)%MOD;
    }
    ll Y=0;
    rep(k,m){
        Y+=(ll)(k*y[k]-(m-k-1)*y[k]);
        Y=(Y+MOD)%MOD;
    }
    cout<<X*Y%MOD<<endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<ll>
#define vpi vector< pi >
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL)
const int N=200010;

int main()
{
  char c;
  cin>>c;
  c+=1;
  cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

long long mod = 1e9 + 7;
vector<long long> Fac(100100);

long long mod_pow(long long x, long long y) {
    if (y == 1) return x;
    long long A = mod_pow(x, y / 2);
    if (y % 2 == 0) return A * A % mod;
    else return A * A % mod * x % mod;
}

long long mod_com(int x, int y) {
    if (x < y) return 0;
    long long ans = Fac[x];
    ans *= mod_pow(Fac[y], mod - 2);
    ans %= mod;
    ans *= mod_pow(Fac[x - y], mod - 2);
    ans %= mod;
    return ans;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    rep(i, N) cin >> A[i];
    
    Fac[0] = 1;
    REP(i, 100100) Fac[i] = Fac[i - 1] * i % mod;
    
    sort(A.begin(), A.end());
    long long minSum = 0;
    rep(i, N) {
        long long x = mod_com(N - i - 1, K - 1);
        x *= A[i];
        x %= mod;
        if (x < 0) x += mod;
        minSum += x;
        minSum %= mod;
    }
    
    reverse(A.begin(), A.end());
    int maxSum = 0;
    rep(i, N) {
        long long x = mod_com(N - i - 1, K - 1);
        x *= A[i];
        x %= mod;
        if (x < 0) x += mod;
        maxSum += x;
        maxSum %= mod;
    }
    
    if (maxSum < minSum) maxSum += mod;
    cout << maxSum - minSum << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            if (n == 0 && x == 0){
                break;
            }
            int count = 0;
            for(int i = 1;i <= n-2; i++){
                for(int j = i+1; j <= n-1; j++){
                    int k = x - i - j;
                    if(k >= 1 && k <= n && k != i && k != j && j < k){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 26376
n=int(input())
Ans=[0]*n
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            num=x**2+y**2+z**2+x*y+y*z+z*x
            if num<=n:
                Ans[num-1]+=1
print(*Ans,sep='\n')

Measured memory_bytes: 73940
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF 1000000000
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOREACH(i, v) for(auto i = v.begin(); i != v.end(); i++)
#define P pair<int, int>

using namespace std;
using ll = long long;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int dx2[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy2[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct edge {int from, to, cost; };

int bfs(int sx, int sy, int gx, int gy, int N, int M){
    int distance[N][M];
    queue<P> que;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            distance[i][j] = -1;
        }
    }
    que.push(P(sx, sy));
    distance[sx][sy] = 0;

    while(que.size()){
        P p = que.front(); que.pop();
        if(p.first == gx && p.second == gy) break;  //ゴールなら探索終了
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];    //nx, nyは移動後の点
            if(0 <= nx && nx < N && 0 <= ny && ny < M && /*s[nx][ny] != '#' &&*/ distance[nx][ny] == -1){
                que.push(P(nx, ny));
                distance[nx][ny] = distance[p.first][p.second] + 1;
            }
        }
    }
    return distance[gx][gy];
}

void solve(){
    int V, E, r;
    cin >> V >> E >> r;
    edge es[E];
    REP(i, E) cin >> es[i].from >> es[i].to >> es[i].cost;

    int d[V];
    REP(i, V) d[i] = INF;
    d[r] = 0;
    while(true){
        bool update = false;
        for(int i = 0; i < E; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) break;
    }

    for(int i = 0; i < V; i++){
        if(d[i] != INF) cout << d[i] << endl;
        else cout << "INF" << endl;
    }
}

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



Measured memory_bytes: 9192
from collections import deque
H, W = map(int, input().split())
route = []
n_black = 0
for _ in range(H):
  tmp_ls = input()
  n_black += tmp_ls.count("#")
  route.append(tmp_ls)
visited = [[False]*W for _ in range(H)]
dist = [[-1]*W for _ in range(H)]
dist[0][0] = 0
tmp = [0,0]
goal = [H-1, W-1]
kouho = deque()
def rinsetsu(ls):
  x, y = ls[0], ls[1]
  ans = []
  if x-1 >= 0:
    ans.append([x-1, y])
  if x+1 <= H-1:
    ans.append([x+1, y])
  if y-1 >= 0:
    ans.append([x, y-1])
  if y+1 <= W-1:
    ans.append([x, y+1])
  return ans
for ls in rinsetsu([0,0]):
  if route[ls[0]][ls[1]] == ".":
    kouho.append([ls[0], ls[1], 0, 0])
def bfs():
  while True:
    while True:
      if len(kouho) == 0:
        return
      tmp = kouho.popleft()
      if not visited[tmp[0]][tmp[1]]:
        break
    x, y = tmp[0], tmp[1]
    visited[x][y] = True
    dist[x][y] = dist[tmp[2]][tmp[3]] + 1
    if [x, y] == goal:
      return
    for ls in rinsetsu([x,y]):
      if not visited[ls[0]][ls[1]] and route[ls[0]][ls[1]] == ".":
        kouho.append(ls + [x, y])
bfs()
if dist[H-1][W-1] == -1:
  print(-1)
else:
  white = dist[H-1][W-1] + 1
  print(H*W - white - n_black)



Measured memory_bytes: 9328
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{

	int n,k;
	cin>>n>>k;
	int h[n];
	int i;
	for(int i = 0;i<n;i++)
		cin>>h[i];
	int dp[n];
	dp[n-1] = 0;
	for(i=n-2;i>=0;i--)
	{	
		dp[i] = dp[i+1]+abs(h[i]-h[i+1]);
		for(int j = 2;j<=k;j++)
		{
			if(i+j>=n)
				break;
			dp[i] = min(dp[i],dp[i+j]+abs(h[i]-h[i+j]));
		}
	}
	cout<<dp[0]<<"\n";
	return 0;

}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  int ans = 0;
  cin >> s;
  if(s / 100 == 1){
    ans ++;
    s = s - 100;
  }
  if(s / 10 == 1){
    ans ++;
    s = s - 10;
  }
  if(s / 1 == 1){
    ans ++;
  }
  cout << ans << endl;
}

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

int main(){
    long long int N, A, B;
    cin >> N >> A >> B;
    if(N <= A || B == 0) cout << N << endl;
    else if(A == 0) cout << 0 << endl;
    else if(N <= A + B) cout << A << endl;
    else if(A < N % (A + B)){
        long long int ans1 = (N / (A + B)) * A + A;
        cout << ans1 << endl;
    }
    else{
        long long int ans2 = (N / (A + B)) * A + (N % (A + B));
        cout << ans2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out

bool ok=true;
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    string s,t;
    cin>>s>>t;

    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    for(int i=s.length()-t.length();i>=0;i--){
        ok=true;
        for(int j=0;j<t.length();j++){
            if(s[i+j]==t[j]||s[i+j]=='?')continue;
            else ok=false;
        }
        if(ok){
            for(int j=0;j<t.length();j++){
                s[i+j]=t[j];
            }
            break;
        }
    }
    if(!ok){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    rep(i,s.size()){
        if(s[i]=='?')s[i]='a';
    }
    cout<<s<<endl;
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using static System.Math;

class P
{
  static int[] Input(){
    return Console.ReadLine().Split().Select(int.Parse).ToArray();
  }
  static int[][] Input2(int n){
    int[][] X = new int[n][];
    for(int i = 0; i < n; i++){
      X[i] = Input();
    }
    return X;
  }
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    int bt = 0; int aa = 0; int bb = 0;
    string R = "Yes";
    for(int i=0;i<N;i++){
      int[] txy = Input();
      int d = Abs(txy[1]-aa) + Abs(txy[2]-bb);
      if (d<=txy[0]-bt && (txy[0]-bt) % 2 == d % 2){
        bt = txy[0]; aa = txy[1]; bb = txy[2];
        continue;
      }
      R = "No";
    }
    var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
    Console.SetOut(sw);
    Console.WriteLine(R);
    Console.Out.Flush();
  }
}


Measured memory_bytes: 15440
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int idx = 0, ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i]== 'T') continue;
        ans = max(ans, i-idx);
        idx = i+1;
    }
    ans = max(ans, (int)s.size()-idx);

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

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

int main(){
	int n;
	cin>>n;
	string but[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	
	for(int x=0;x<n;x++){
		string a;
		cin>>a;
	
	string ans="";
	int b=0,c=0;
		for(int i=0;i<a.size();i++){
			if(a[i]=='0'){
				if(b!=0){
				int num=(c+but[b].size()-1)%but[b].size();
				ans.push_back(but[b][num]);
				b=0,c=0;
				}
				}
			else{
				b=a[i]-'0';
				c++;
				}	
				
			}
			cout<<ans<<endl;
		}
		return 0;
	}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int res[n] = { 0 };
	for (int i = 1; i < n; i++) res[ri() - 1]++;
	for (auto i : res) printf("%d\n", i);
	puts("");
	return 0;
}


Measured memory_bytes: 4616
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
	int n;
	while(scanf("%d",&n),n){
		for(int i = 0; i < n; i++){
			int form1[4],form2[4];/*0:x,1:y,2:z,w:3*/
			
			for(int i = 0; i < 4; i++)scanf("%d",&form1[i]);
			for(int i = 0; i < 4; i++)scanf("%d",&form2[i]);
			
			int ans[4] = {0};
			int mid[5][5]={{0}};
			
			for(int i = 0; i < 4; i++){
				for(int j = 0; j < 4; j++){
					mid[i][j] = form1[i]*form2[j];
				}
			}
			ans[0] = mid[0][0]-mid[1][1]-mid[2][2]-mid[3][3];
			ans[1] = mid[0][1]+mid[1][0]+mid[2][3]-mid[3][2];
			ans[2] = mid[0][2]+mid[2][0]-mid[1][3]+mid[3][1];
			ans[3] = mid[0][3]+mid[1][2]-mid[2][1]+mid[3][0];
			
			for(int i = 0;i < 3; i++)printf("%d ",ans[i]);
			printf("%d\n",ans[3]);
		}
	}
	return 0;
}

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

int what_color(int N, int a, int b) {
    int mid = (N+1)/2;
    if (a > mid) a = N - a + 1;
    if (b > mid) b = N - b + 1;
    if (a > b) swap(a, b);
//    cout << a << ' ' << b << endl;
    int ret_v;
    if (a % 3 == 0) ret_v = 3;
    else ret_v = a % 3;
    return ret_v;
}

int main() {
    int N, K; cin >> N >> K;
    while (K--) {
        int a, b; cin >> a >> b;
        cout << what_color(N, a, b) << endl;
    }
    return 0;
}

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

int n, k, r, s, p;
string t, u;

int main() {
    cin >> n >> k >> r >> s >> p >> t;
    int scr = 0;
    rep(i, n) {
        if (i < k) {
            if (t[i] == 'r') {
                scr += p;
                u.push_back('p');
            } else if (t[i] == 's') {
                scr += r;
                u.push_back('r');
            } else if (t[i] == 'p') {
                scr += s;
                u.push_back('s');
            }
        } else {
            if (t[i] == 'r') {
                if (u[i-k] != 'p') {
                    scr += p;
                    u.push_back('p');
                } else {
                    if (i+k < n) {
                        u.push_back(t[i+k]);
                    }
                }
            } else if (t[i] == 's') {
                if (u[i-k] != 'r') {
                    scr += r;
                    u.push_back('r');
                } else {
                    if (i+k < n) {
                        u.push_back(t[i+k]);
                    }
                }
            } else if (t[i] == 'p') {
                if (u[i-k] != 's') {
                    scr += s;
                    u.push_back('s');
                } else {
                    if (i+k < n) {
                        u.push_back(t[i+k]);
                    }
                }
            }
        }
    }
    cout << scr << endl;
}

Measured memory_bytes: 3732
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long[] a = new long[n + 1];
		int cnt = 0;
		for (int i = 1; i < n + 1; i++) {
			int tmp = sc.nextInt();
			if (tmp > n) {
				cnt++;
				continue;
			}
			a[tmp]++;
		}
		for (int i = 1; i < n + 1; i++) {
			if (a[i] > i)
				cnt += a[i] - i;
			else if (a[i] < i)
				cnt += a[i];
		}
		System.out.println(cnt);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

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

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

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

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

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

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23892
package main

import "fmt"

func main() {
	var sx, sy, tx, ty int
	fmt.Scan(&sx, &sy, &tx, &ty)
	tx -= sx
	ty -= sy
	sx = 0
	sy = 0
	for ; sx != tx; sx++ {
		fmt.Print("R")
	}
	for ; sy != ty; sy++ {
		fmt.Print("U")
	}
	for ; sx != 0; sx-- {
		fmt.Print("L")
	}
	for ; sy != 0; sy-- {
		fmt.Print("D")
	}
	fmt.Print("D")
	sy--
	for ; sx != tx+1; sx++ {
		fmt.Print("R")
	}
	for ; sy != ty; sy++ {
		fmt.Print("U")
	}
	fmt.Print("LU")
	sx--
	sy++
	for ; sx != -1; sx-- {
		fmt.Print("L")
	}
	for ; sy != 0; sy-- {
		fmt.Print("D")
	}
	fmt.Print("R")
	fmt.Println()
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n,k;
    cin>>n>>k;
    cout<<max(max(n+k,n*k),n-k)<<endl;
    

//////////////////////////////////////////////////////
return 0;}

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

using namespace std;

int main()
{
    string s;
    long long k;
    cin >> s >> k;
    long long solA = 0;
    long long solB = 0;
    string s2 = s;

    for(int i = 1; i < s.length(); i++){
        if(s[i] == s[i-1]){
            s[i] = '_';
            solA++;
        }
    }

    if(s[0] == s[s.length()-1]){
        solB++;
        s2[0] = '_';
    }

    for(int i = 1; i < s.length(); i++){
         if(s2[i] == s2[i-1]){
            s2[i] = '_';
            solB++;
        }
    }

    long long sol = 0;

    if(s == s2){
        sol = solA*k;
    }
    else if(s2[s2.length()-1] == s[0]){
        sol = solA + solB*(k-1);
    }
    else{
        sol = solA*((k+1)/2) + solB*(k/2);
    }

    cout << sol << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int top,fa[N],dep[N],s[N],np[N],p1[N],p2[N];
vector<int>g[N];
void dfs(int x,int p)
{
	fa[x]=p;dep[x]=dep[p]+1;
	for(int i=0;i<g[x].size();i++)if(g[x][i]!=p)dfs(g[x][i],x);
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1,u,v;i<n;i++){scanf("%d%d",&u,&v);g[u].push_back(v);g[v].push_back(u);}
	dfs(1,0);int x=1;
	for(int i=2;i<=n;i++)if(dep[i]>dep[x])x=i;
	dfs(x,0);int y=1;
	for(int i=2;i<=n;i++)if(dep[i]>dep[y])y=i;
	for(int i=y;i;i=fa[i])s[i]=1;
	for(int i=1;i<=n;i++)if(!s[i]&&(++s[fa[i]])==1){puts("-1");exit(0);}
	vector<int>a;
	for(int i=y;i;i=fa[i])a.push_back(s[i]);
	top=0;
	for(int i=0;i<a.size();i++)
	{
		np[top+1]=top+a[i];
		for(int j=1;j<a[i];j++)np[top+j+1]=top+j;
		top+=a[i];
	}
	for(int i=1;i<=n;i++)p1[np[i]]=i;
	top=0;
	for(int i=a.size()-1;i>=0;i--)
	{
		np[top+1]=top+a[i];
		for(int j=1;j<a[i];j++)np[top+j+1]=top+j;
		top+=a[i];
	}
	for(int i=1;i<=n;i++)p2[np[i]]=i;
	int i=1;
	while(p1[i]==p2[i]&&i<=n)i++;
	if(p1[i]<p2[i])for(int i=1;i<=n;i++)printf("%d ",p1[i]);
	else for(int i=1;i<=n;i++)printf("%d ",p2[i]);
	return 0;
}

Measured memory_bytes: 13816
def i():
	return str(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = list(i())
s.sort()

for i in range(len(s)-1):
	if s[i] == s[i+1]:
		print('no')
		exit()
print('yes')


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    bool isGood = true;
    REP(i, S.size())
    {
        if ((i+ 1) % 2 == 0)
        {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D')
            {
                continue;
            }
            else
            {
                isGood = false;
                break;
            }
        }
        else
        {
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D')
            {
                continue;
            }
            else
            {
                isGood = false;
                break;
            }
        }
        
    }
    string ans = isGood ? "Yes" : "No";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+10;
int n;
char s[N], p[N];
int f[N];

int main() {
	cin>>s+1;n=strlen(s+1);
	REP(i,1,n) ++f[s[i]];
	REP(i,1,n) {
		vector<int> v;
		if (i>1) v.pb(p[i-1]);
		if (i>2) v.pb(p[i-2]);
		int c = 0, cnt = 0;
		REP(j,'a','z') {
			int ok = 1;
			for (auto t:v) if (t==j) ok=0;
			if (!ok) continue;
			if (f[j]>cnt) cnt=f[j],c=j;
		}
		if (!c) return puts("NO"),0;
		p[i] = c;
		--f[c];
	}
	puts("YES");
}









Measured memory_bytes: 2432
h,w = map(int,input().split())
a = list()

for i in range(h):
  a.append(input())

h_blank = [False]*h
w_blank = [False]*w
for i in range(h):
  blank = True
  for j in range(w):
    if a[i][j] == '#':
      blank = False
      break
  if blank:
    h_blank[i] = True

for i in range(w):
  blank = True
  for j in range(h):
    if a[j][i] == '#':
      blank = False
      break
  if blank:
    w_blank[i] = True

for i in range(h):
  if h_blank[i]:
    continue
  for j in range(w):
    if w_blank[j]:
      continue
    print(a[i][j], end='')
  print('')

Measured memory_bytes: 4468
#include<iostream>

#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define lint long int

using namespace std;

int main(){
    int N, M;
    int K[30], A[30][30];
    cin >> N >> M;
    rep(i,N) { // i番目の人
        cin >> K[i];
        rep(j,K[i]) cin >> A[i][j]; // 好きなもの
    }
    int cnt=0;
    int hit=0;
    rep(i,M){ //i番目の食べ物
        rep(j,N){ //j番目の人に
            rep(k,K[j]) if(A[j][k]==i+1) hit++; //好きなものの中に
        }
        if(hit==N) cnt++; //最後までhitし続けたら
        hit=0;
    }
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256