akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int cnt = 1;
    FOR(i, 1, n) {
        if (s[i - 1] != s[i])cnt++;
    }

    int size = max(1, cnt - k * 2);
    cout << n - size << "\n";
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	string s;
	cin >> s;
	int n=s.size();
	FOR(i,n-1){
		if(s[i]==s[min(i+1,n-1)]){
			cout << i+1 << " " << min(i+1,n-1)+1 << endl;
			return 0;
		}
		if(s[i]==s[min(i+2,n-1)]){
			cout << i+1 << " " << min(i+2,n-1)+1 << endl;
			return 0;
		}
	}

	cout << -1 << " " << -1 << endl;


}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    REP(i,n){
        cin >> p[i];
    }
    set<int> s;
    REP(i,k){
        s.insert(p[i]);
    }
    int ans = n - k + 1;
    for(int i = k; i < n; i++){
        auto itr = s.end();
        itr--;
        if(p[i - k] == *s.begin() && *itr < p[i]) ans--;
        s.erase(p[i - k]);
        s.insert(p[i]);
    }
    vector<int> sum(n);
    for(int i = 0; i < n - 1; i++){
        sum[i + 1] += sum[i] + (p[i] > p[i + 1]);
    }
    int cnt = 0;
    for(int i = 0; i <= n - k; i++){
        if((i == 0 || p[i - 1] > p[i]) && sum[i + k - 1] - sum[i] == 0) cnt++;
    }
    cnt--;
    cout << ans - max(0, cnt) << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int a,b;
    cin >> a>>b;
    int Max=0;
    Max=max(a+b,a-b);
    cout<<max(Max,a*b)<<endl;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,t;cin>>n>>t;
  int minus=0,former_time=0,now_time=0;
  REP(i,n){
    cin>>now_time;
    if(now_time-former_time>t){
      minus+=now_time-former_time-t;
    }
    former_time=now_time;
  }
  P(former_time+t-minus);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<ll, vector<ll>, greater<ll> > A;
    REP(i,N){
        ll a;
        cin >> a;
        A.push(a);
    }

    vector<pair<ll, int> > BC(M);
    REP(i,M){
        int b;
        ll c;
        cin >> b >> c;
        BC[i] = make_pair(c, b);
    }

    sort(BC.rbegin(), BC.rend());

    REP(i,M){
        auto p = BC[i];
        ll c;
        int b;
        c = p.first;
        b = p.second;

        bool next = true;
        while(b > 0){
            ll x = A.top();
            if(x < c){
                b--;
                A.pop();
                A.push(c);
            }
            else{
                next = false;
                break;
            }
        }

        if(!next) break;
    }

    ll ans = 0;
    while(!A.empty()){
        ll x = A.top();
        A.pop();
        ans += x;
    }

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


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX_H = 21;
const int MAX_W = 21;
int H, W;
char maze[MAX_H][MAX_W];
int cnt[MAX_H][MAX_W];

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze[i][j];
    }
  }

  int ans = 0;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      queue<P> q;
      if (maze[i][j] == '.') {
        q.push(P (i, j));
      }
      memset(cnt, -1, sizeof(cnt));
      cnt[i][j] = 0;
      while (!q.empty()) {
        P p = q.front(); q.pop();
        int x = p.first;
        int y = p.second;
        if (0 <= x+1 && x+1 < H && 0 <= y && y < W && cnt[x+1][y] == -1 && maze[x+1][y] == '.') {
          cnt[x+1][y] = cnt[x][y] + 1;
          ans = max(ans, cnt[x+1][y]);
          q.push(P (x+1, y));
        }
        if (0 <= x-1 && x-1 < H && 0 <= y && y < W && cnt[x-1][y] == -1 && maze[x-1][y] == '.') {
          cnt[x-1][y] = cnt[x][y] + 1;
          ans = max(ans, cnt[x-1][y]);
          q.push(P (x-1, y));
        }
        if (0 <= x && x < H && 0 <= y+1 && y+1 < W && cnt[x][y+1] == -1 && maze[x][y+1] == '.') {
          cnt[x][y+1] = cnt[x][y] + 1;
          ans = max(ans, cnt[x][y+1]);
          q.push(P (x, y+1));
        }
        if (0 <= x && x < H && 0 <= y-1 && y-1 < W && cnt[x][y-1] == -1 && maze[x][y-1] == '.') {
          cnt[x][y-1] = cnt[x][y] + 1;
          ans = max(ans, cnt[x][y-1]);
          q.push(P (x, y-1));
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.close();
		if(N <= 999) {
			System.out.println("ABC");
		}else {
			System.out.println("ABD");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>

#include <vector>

#include <algorithm>
#include <numeric>

using namespace std;

#define repeat(n) for(int _ = 1; _ <= n; _++)

int main()
{
	ios::sync_with_stdio(false);
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
#endif
	
	int n;
	cin >> n;
	
	int a[11];
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	int sum = accumulate(&a[1], &a[n]+1, 0);
	
	for(int i = 1; i <= n; i++)
		if(a[i] >= sum - a[i]) {
			cout << "No";
			return 0;
		}
	
	cout << "Yes";
}


Measured memory_bytes: 256
N, = map(int, input().split())
import sys;input=sys.stdin.readline
X = []
Y = []
for _ in range(N):
    s = input().strip()
    a, b = 0, 0
    for c in s:
        if c == "(":
            a += 1
        else:
            if a > 0:
                a -= 1
            else:
                b += 1
    if a >= b:
        X.append((a, b))
    else:
        Y.append((b, a))
X.sort(key=lambda x:x[1])
Y.sort(key=lambda x:x[1])

s = 0
for i in range(len(X)):
    a, b = X[i]
    if s >= b:
        s += a-b
    else:
        print("No")
        sys.exit()
s2 = 0
for i in range(len(Y)):
    a, b = Y[i]
    if s2 >= b:
        s2 += a-b
    else:
        print("No")
        sys.exit()
if s == s2:
    print("Yes")
else:
    print("No")


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

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

s = sum(a)
t = (s + (4 * m - 1)) // (4 * m)

cnt = 0
for i in a:
    if t <= i:
        cnt += 1

if m <= cnt:
    print('Yes')
else:
    print('No')


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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int x, y;
	cin >> x >> y;

	if (y & 1) {
		cout << "No";
	}

	else {
		int oC = 0 ;
		for (int i = 1 ; i <= x ; i++) {
			oC += 2;
		}

		int oT = 0 ;
		for (int i = 1 ; i <= x ; i++) {
			oT += 4;
		}

		if (y >= oC and y <= oT) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}

}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<int> p(A);
	vector<int> q(B);
	vector<int> r(C);

	for (auto& x : p) cin >> x;
	for (auto& x : q) cin >> x;
	for (auto& x : r) cin >> x;

	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.begin(), r.end());

	vector<int> v = r;
	v.insert(v.end(), p.begin(), p.begin() + X);
	v.insert(v.end(), q.begin(), q.begin() + Y);
	sort(v.rbegin(), v.rend());

	auto ans = accumulate(v.begin(), v.begin() + X + Y, 0LL);
	cout << ans << endl;
}


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

using namespace std;

const int maxn = 1e5;
int n, m, res, t[maxn+2], dp[maxn+2];
bool ok[maxn+2];
vector<int>G[maxn+2];

int dfs(int nod)
{
    if(ok[nod])
    {
        return dp[nod];
    }
    ok[nod]=true;
    for(auto it:G[nod])
    {
        dp[nod]=max(dp[nod],dfs(it)+1);
    }
    return dp[nod];
}

int main()
{
    int x, y;
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        cin>>x>>y;
        G[x].push_back(y);
    }
    for(int i=1; i<=n; i++)
    {
        res=max(res,dfs(i));
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 7552
function Main(input) {
	let arg = input.split("\n");
  	console.log('AC x %d',arg.filter(function(x){return x==='AC'}).length);
  	console.log('WA x %d',arg.filter(function(x){return x==='WA'}).length);
  	console.log('TLE x %d',arg.filter(function(x){return x==='TLE'}).length);
  	console.log('RE x %d',arg.filter(function(x){return x==='RE'}).length);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 40256
// http://kmjp.hatenablog.jp/entry/2018/03/20/0900

#include <bits/stdc++.h>

using namespace std;

const int MAX = 200000;
int N;
int A[202020];
int B[202020];
int C[602020];


int main() {
    int i,x,y;
    string s;

    cin>>N;
    for (i = 0; i < N; i++) cin>>A[i];
    for (i = 0; i < N; i++) cin>>B[i];

    int ret=0;
    for (i = 0; i < 29; i++) {
        for (x = 0; x < N; x++) C[x]=B[x]&((1<<(i+1))-1);
        sort(C,C+N);
        for (x = 0; x < 2 * N; x++) C[N+x]=C[x]+(1<<(i+1));
        long long tot=0;
        for (x = 0; x < N; x++) {
            y=A[x]&((1<<(i+1))-1);
            tot += lower_bound(C,C+3*N,(4<<i)-y)-lower_bound(C,C+3*N,(3<<i)-y);
        }
        if(tot%2) ret+=1<<i;
    }

    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 4096
N, M = map(int, input().split())
A=[[0]]*N
for i in range(N):
  A[i]=list(map(int, input().split()))
  A[i].pop(0)

ans_list = A[0]
for i in range(N):
  ans_list = set(ans_list) & set(A[i])
print(len(ans_list))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    cin >> n;
    vector<vector<int>> graph(n);
    for(int i = 0; i < n; ++i){
        int u, k;
        cin >> u >> k;
        --u;
        for(int j = 0; j < k; ++j){
            int v;
            cin >> v;
            --v;
            graph[u].emplace_back(v);
        }
    }

    vector<int> dist(n, INF);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while(!que.empty()){
        int from = que.front();
        que.pop();
        for(int to : graph[from]){
            if(chmin(dist[to], dist[from] + 1)){
                que.push(to);
            }
        }
    }

    for(int i = 0; i < n; ++i){
        if(dist[i] == INF)  dist[i] = -1;
        cout << i + 1 << ' ' << dist[i] << '\n';
    }
}


Measured memory_bytes: 3168
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: i64 = scan(tokens);
    let q: i64 = scan(tokens);
    let mut score = vec![k - q; n];
    for _ in 0..q {
        let a: usize = scan(tokens);
        score[a - 1] += 1;
    }
    for i in 0..n {
        if score[i] > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


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

int main(){
  int N;
  cin >>N;
  int A[N+100];
  for (int i=0;i<N;i++){
    cin>>A[i];
  }
  int flag=1;
  int count=0;
  while (flag==1){
     for (int i=0;i<N;i++){
       if(!(A[i]%2==0)){
         flag=0;
         break;
       }
       A[i]=A[i]/2;
     }
    count++;
  }
  cout<<count-1<<endl;
  return 0;
}




  

Measured memory_bytes: 256
/**
*   @Author : MeGaCrazy
*   @InitTime : Fri Jan 04 17:26:25 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
  int n;
  vector<int>v;
  cin>>n;
  int sum=0;
  int a;

  for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
        sum+=a;
 }
  	sort(v.begin(),v.end());
  	if(sum%10!=0){
  		cout<<sum<<endl;
  		return 0;
  	}
  	for(int i=0;i<n;i++){
  		if((sum-v[i])%10!=0){
  			cout<<sum-v[i]<<endl;
  			return 0;
  		}
  	}
  	cout<<0<<endl;
  	



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == '?') S[i] = 'D';
        cout << S[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3804
program cuboid
  implicit none
  integer(8) :: A, B, C
  read(*,*) A, B, C
  if (mod(A,2) == 0 .or. mod(B,2) == 0 .or. mod(C,2) == 0) then
     write(*,*) 0
  else
     write(*,*) min(A*B, B*C, C*A)
  end if
  stop
end program cuboid

Measured memory_bytes: 256
S = input()

if (S[0]==S[1] and S[2]==S[3] and S[1]!=S[2])or (S[1]==S[2] and S[0]==S[3] and S[0]!=S[1])or (S[0]==S[2] and S[1]==S[3] and S[1]!=S[2]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
s=input()

sAray=[]

x=0
for i in s:
  if i=="x":
    x+=1
  else:
    sAray.append(x)
    sAray.append(i)
    x=0
sAray.append(x)

cnt=0
half=(-(-len(sAray)//2))

for i in range(half):
  if sAray[i]!=sAray[-i-1]:
    if isinstance(sAray[i], int) and isinstance(sAray[-1-i], int) :
      cnt+=abs(sAray[i]-sAray[-i-1])
    else:
      print(-1)
      exit()

print(cnt)


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

#define int long long

auto main() -> signed {
    int a, b, c;
    cin >> a >> b >> c;
    if(c>=a&&c<=b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a,b;
    cin>>a>>b;
    if(a=='H')
        cout<<b<<endl;
    else
    {
        if(b=='H')
            cout<<"D\n";
        else
            cout<<"H\n";
    }
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	char s[5];

	scanf("%s", &s);

	for (i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			printf("Bad\n");
			return 0;
		}
	}

	printf("Good\n");

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int x;
	cin >> x;
	int ans = 1;
	for (int i = 2; i <= x; i++) {
		int b = i*i;
		for (int j = 2;; j++) {
			if (b > x)break;
			ans = max(ans, b);
			b *= i;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

bool solve() {
  int n, m;

  cin >> n >> m;

  if (n == 0) return false;

  int sum = 0;
  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    sum += min(a, m / n);
  }

  cout << sum << endl;

  return true;
}

int main(){

  while(solve());

  return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>
int main(void){
    int n,m,l,i,j,k;
    scanf("%d %d %d",&n,&m,&l);
    int a[n][m],b[m][l];
    long ans[n][l];
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            ans[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
               ans[i][j]+=a[i][k]*b[k][j]; 
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            if(j!=l-1){
                printf("%ld ",ans[i][j]);
            }
            else{
                printf("%ld\n",ans[i][j]);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2144
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<P>ab(n),cd(n);
rep(i,n){
    cin >> ab[i].first >> ab[i].second;
}
rep(i,n){
    cin >> cd[i].first >> cd[i].second;
}
vector<bool> e(n,true);
sort(ab.begin(),ab.end());
sort(cd.begin(),cd.end());
ll cnt = 0;
for(int i = 0; i < n; i++){
    vector<tuple<ll,ll,ll>> k;
    for(int j = 0; j < n; j++){
        if(e[j] && ab[j].first < cd[i].first && ab[j].second < cd[i].second){
            k.emplace_back(make_tuple(ab[j].second,ab[j].first,j));
        }
    }
    if(k.size() > 0) {
        sort(k.begin(), k.end());
        e[get<2>(k.back())] = false;
        cnt++;
    }
}
cout << cnt << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

class UnionFind {
  vector<int> par, rank, potential;
public:
  UnionFind(int n) {
    par.resize(n, -1);
    rank.resize(n, 0);
    potential.resize(n, 0);
  }
  int root(int x) {
    if (par[x] < 0)
      return x;
    int r = root(par[x]);
    potential[x] += potential[par[x]];
    return par[x] = r;
  }
  int size(int x) {
    return -par[root(x)];
  }
  int weight(int x) {
    root(x);
    return potential[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y, int w = 0) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if (x == y) {
      return false;
    }
    if (rank[x] < rank[y]) {
      swap(x, y);
      w = -w;
    }
    if (rank[x] == rank[y])
      rank[x]++;
    par[x] += par[y];
    par[y] = x;
    potential[y] = w;
    return true;
  }
  int diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  UnionFind uf(12);
  uf.unite(0, 2);
  uf.unite(0, 4);
  uf.unite(0, 6);
  uf.unite(0, 7);
  uf.unite(0, 9);
  uf.unite(0, 11);
  uf.unite(3, 5);
  uf.unite(3, 8);
  uf.unite(3, 10);
  int a, b;
  cin >> a >> b;
  --a, --b;
  if (uf.same(a, b))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main() {
    int n, n_origin, s, keta;
    cin >> n;
    n_origin = n;
    s = 0;
    keta = 10;

    while (n >= 1) {
        s += n%10;
        n /= keta;
    }

    if (n_origin%s == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define PPB pop_back
#define MP make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define loop(i,start,end) for(ll i=start; i<end; i++)
#define rloop(j,start,end) for(ll j=start-1; j>=end; j--)

int main()
{   
    IOS;

    ll n,k;
    cin>>n>>k;

    ll a[n],i,j,dp[n+1]={0},mini=INT_MAX;
    loop(i,0,n)
        cin>>a[i];

    if(k>=n)
    {
        d1(abs(a[n-1]-a[0]));
        return 0;
    }
    if(n==2)
    {   
        d1(abs(a[1]-a[0]));
        return 0;
    }

    dp[n-1]=0;
    for(i=n-2; i>=n-k-1; i--)
        dp[i]=abs(a[n-1]-a[i]);

    for(i=n-k-2; i>=0; i--)
    {
        mini=INT_MAX;
        for(j=i+1; j<i+k+1; j++)
            mini=min(mini,dp[j]+abs(a[j]-a[i]));
        dp[i]=mini;
    }
    
    d1(dp[0]);
}

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

vector<int>P;

int dp(int n){
    vector<vector<int>> D(n,vector<int>(n));
    rep(j,n){
        for(int i = j;i>=0;--i){
            if(i==j)D[i][j]=0;
            else{
                int mini = INF;
                for(int k = i;k<j;++k){
                    int rel = D[i][k]+D[k+1][j]+P[i]*P[k+1]*P[j+1];
                    mini = min(mini,rel);
                }
                D[i][j]=mini;
            }
        }
    }
    return D[0][n-1];
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        int x,y;cin >> x>>y;
        if(i==0){
            P.push_back(x);
            P.push_back(y);
        }
        else{
            P.push_back(y);
        }
    }
    cout << dp(n) << endl;
    return 0;
}


Measured memory_bytes: 3176
import itertools
def solve(n, a1_list, a2_list):

    a1_acc = itertools.accumulate(a1_list)
    a2_acc = reversed(list(itertools.accumulate(reversed(a2_list))))

    ans = max([i + j for i, j in zip(a1_acc, a2_acc)])

    return ans

if __name__ == "__main__":
    n = int(input())
    a1_list = [int(i) for i in input().split()]
    a2_list = [int(i) for i in input().split()]
    print(solve(n, a1_list, a2_list))


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int Q;
    Scd(Q);

    ll minima = 0;

    multiset<int> sl,sr;
    sl.insert(-INF);
    sr.insert(INF);

    int q;
    int a,b;
    Rep(i,Q){
        Scd(q);
        if( q == 1 ){
            Scd2(a,b);

            auto itlr = --(sl.end());
            auto itrl = (sr.begin());
            ll lr = *(itlr);
            ll rl = *(itrl);

            if( lr <= a && a <= rl ){
            }else{
                minima += min( abs(a-lr), abs(a-rl) );
            }
            minima += b;

            if( lr <= a && a <= rl ){
                sl.insert(a);
                sr.insert(a);
            }else if( lr > a ){
                sl.erase(itlr);
                sr.insert(lr);
                sl.insert(a);
                sl.insert(a);
            }else{
                sr.erase(itrl);
                sl.insert(rl);
                sr.insert(a);
                sr.insert(a);
            }
        }else{
            auto itlr = --(sl.end());
            ll lr = *(itlr);
            printf ("%lld %lld\n", lr, minima );
        }
    }

    return 0;
}





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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<pii>v(N); rep(i, 0, N) { cin >> v[i]; }
	sort(all(v), [](pii a, pii b) {return min(b.first, a.first - b.second) < min(a.first, b.first - a.second); });
	vector<vector<int>>dp(N + 1, vector<int>(N + 1, INF));

	dp[0][0] = 0;
	rep(i, 1, N + 1) {
		rep(j, 0, i + 1) {
			dp[i][j] = dp[i - 1][j];
			if (j > 0 and dp[i - 1][j - 1] <= v[i - 1].first) {
				chmin(dp[i][j], dp[i - 1][j - 1] + v[i - 1].second);
			}
		}
	}
	int ans = 0;
	rep(i, 0, N + 1) {
		if (dp[N][i] < INF)ans = i;
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 195968
/* 
 * Project: AtCoder Beginners Contest 157 A - Duplex Printing
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/03/01
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

    int n;
    cin >> n;

    if (n & 1) {
        cout << n / 2 + 1 << endl;
    } else {
        cout << n / 2  << endl;
    }

}


Measured memory_bytes: 256
package main

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

var BR uint64 = 9973
var BC uint64 = 100000007

func main() {
	var h,w,r,c int
	fmt.Scan(&h)
	fmt.Scan(&w)

	field := make([][]rune, h)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < h; i++ {
		sc.Scan()
		field[i] = []rune(sc.Text())
	}
	sc.Scan()
	r, _ = strconv.Atoi(sc.Text())
	sc.Scan()
	c, _ = strconv.Atoi(sc.Text())

	if h < r || w < c {
		return
	}

	pattern := make([][]rune, r)
	for i := 0; i < r; i++ {
		sc.Scan()
		pattern[i] = []rune(sc.Text())
	}

	ph1 := make([]uint64, r)
	var ph2 uint64 = 0
	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			ph1[i] = uint64(pattern[i][j]) + ph1[i]*BR
		}
		ph2 = ph1[i] + ph2*BC
	}

	var brc,bcr uint64 = 1,1
	for i := 0; i < c; i++ {
		brc *= BR
	}
	for i := 0; i < r; i++ {
		bcr *= BC
	}

	fh1 := make([][]uint64, h)
	for i := 0; i < h; i++ {
		fh1[i] = make([]uint64, w-c+1)
		for j := 0; j < c; j++ {
			fh1[i][0] = uint64(field[i][j]) + fh1[i][0]*BR
		}
		for j := 1; j <= w-c; j++ {
			fh1[i][j] = fh1[i][j-1]*BR + uint64(field[i][j+c-1]) - uint64(field[i][j-1])*brc
		}
	}

	fh2 := make([][]uint64, h-r+1)
	for j := 0; j <= w-c; j++ {
		if j == 0 {
			fh2[0] = make([]uint64, w-c+1)
		}
		for i := 0; i < r; i++ {
			fh2[0][j] = fh1[i][j] + fh2[0][j]*BC
		}
		for i := 1; i <= h-r; i++ {
			if j == 0 {
				fh2[i] = make([]uint64, w-c+1)
			}
			fh2[i][j] = fh2[i-1][j]*BC + fh1[i+r-1][j] - fh1[i-1][j]*bcr
		}
	}

	wr := bufio.NewWriter(os.Stdout)
	for i := 0; i <= h-r; i++ {
		for j := 0; j <= w-c; j++ {
			if fh2[i][j] == ph2 {
				wr.WriteString(strconv.Itoa(i) + " " + strconv.Itoa(j) + "\n")
			}
		}
	}
	wr.Flush()
}


Measured memory_bytes: 22432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


ll fun(ll i,ll j,ll k)
{
    return i*i+j*j+k*k+i*j+i*k+k*j;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    ll aa[10007];
    memset(aa,0,sizeof(aa));
    for(i=1;i<101;i++)
    {
        for(j=1;j<101;j++)
        {
            for(k=1;k<101;k++)
            {
                x=fun(i,j,k);
                if(x>10002)break;
                aa[x]++;
            }
        }
    }
    cin>>n;
    for1(n)
    {
        cout<<aa[i]<<endl;
    }
}



Measured memory_bytes: 3684
#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>;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

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

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);  // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

// 通路
struct corridor {
    int a, b;  // 繋がっているcell
    ll len;    // 通路の長さ
    corridor(int a, int b, ll len) : a(a), b(b), len(len) {}

    // ソート用
    bool operator<(const corridor& rhs) const {
        if (len != rhs.len) {
            return len < rhs.len;
        }
        if (a != rhs.a) {
            return a < rhs.a;
        }
        return b < rhs.b;
    }
};

int main() {
    //三次元座標
    int N;
    cin >> N;
    vector<ll> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    vector<P> v1, v2;
    rep(i, N) v1.push_back(make_pair(x[i], i));
    rep(i, N) v2.push_back(make_pair(y[i], i));

    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    // 全ての通路を長さでソートする
    vector<corridor> cor;
    for (int i = 0; i < N - 1; i++) {
        ll dx, dy, w;
        int s, t;

        s = v1[i].second, t = v1[i + 1].second;
        dx = abs(x[s] - x[t]);
        dy = abs(y[s] - y[t]);
        w = min(dx, dy);
        cor.push_back(corridor(s, t, w));
        cor.push_back(corridor(t, s, w));

        s = v2[i].second, t = v2[i + 1].second;
        dx = abs(x[s] - x[t]);
        dy = abs(y[s] - y[t]);
        w = min(dx, dy);
        cor.push_back(corridor(s, t, w));
        cor.push_back(corridor(t, s, w));
    }
    sort(cor.begin(), cor.end());

    UnionFind uf(N);
    ll ans = 0;     // 通路の長さの総和
    int count = 0;  // 選んだ通路の数

    for (vector<corridor>::iterator itr = cor.begin(); count < N - 1; ++itr) {
        // aとbが別々の集合に属しているならばその通路を採用する
        if (uf.merge(itr->a, itr->b)) {
            ans += itr->len;
            ++count;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 14764
h,w,d = [int (i) for i in input().split()]
index = [[0,0] for i in range(h*w)]
sum = 0
for i in range(h):
    temp = [int(i) for i in input().split()]
    for j in range(w):
        index[temp[j]-1][0] = i
        index[temp[j]-1][1] = j
q = int(input())
dick = [0 for i in range (h*w)]
for i in range (d,h*w):
    dick[i] = dick[i-d] + abs(index[i][0]-index[i-d][0])+abs(index[i][1]-index[i-d][1])
for i in range(q):
    a,b = [int(i) for i in input().split()]
    print(dick[b-1] - dick[a-1])

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

int main() {
    int a;
    string s;
    cin >> a >> s;
    a >= 3200 ? cout << s << endl : cout << "red" << endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    for (int i = S.size() - 2; S.size() - i > 0; i = i - 2) {
        string tmp = S.substr(0, i);
        if (tmp.substr(0, tmp.size()/2) == tmp.substr(tmp.size()/2)) {cout << tmp.size() << endl; return 0;}
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



signed main() {
	int n;cin>>n;
	cout << n * n * n << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;

int main(){
  int n; cin>>n;
  vector<pair<int,int>> p(n); 
  
REP(i,n){
  int a; cin>>a;
  p[i].second=i;
  p[i].first=a;
}
  sort(ALL(p));
 REP(i,n)cout<<p[i].second+1<<' ';
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n,a;
    int cnt[100100];
    memset(cnt,0, sizeof(cnt));
    cin>>n;
    REP(i,n){
        cin>>a;
        cnt[a]++;
    }
    int ans=0;
    REP(i,100100)ans+=max(0,cnt[i]-1);
    cout<<n-(ans+1)/2*2<<endl;
}

Measured memory_bytes: 640
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range;

void main() {
    auto tmp = readln.split.to!(int[]);
    foreach (i; tmp[0]..tmp[1]+1) {
        if (i < tmp[0] + tmp[2] || i > tmp[1] - tmp[2]) {
            writeln(i);
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll bfs(vector<vector<ll>>&a,ll x,vector<ll> &vst)
{

	// cout<<x<<endl;
	ll i,s=0;
	// if(vst[x]==1)
	// 	return 0;
	vst[x]=1;

	// for(i=1;i<a.size();i++)
	// 	cout<<vst[i]<<" ";
	// cout<<endl;

	// for(i=0;i<a[x].size();i++)
	// 	cout<<a[x][i]<<" ";
	// cout<<endl;

	for(i=0;i<a[x].size();i++)
	{
		if(vst[a[x][i]]==0)
			{s+=bfs(a,a[x][i],vst);}
	}
	return 1+s;
}
int main()
{
	ll n,m,i,x,y,s,j;
	cin>>n>>m;
	vector<ll> vst(n+1,0);
	vector<vector<ll>>a(n+1);
	for(i=0;i<m;i++)
		{
			cin>>x>>y;
			a[x].push_back(y);
			a[y].push_back(x);
		}
	s=0;
	for(i=1;i<=n;i++)
	{
		if(vst[i]==0)
		{
			s++;
			bfs(a,i,vst);
		}
	}
		// for(i=1;i<=n;i++)
		// {
		// 	for(j=0;j<a[i].size();j++)
		// 		cout<<a[i][j]<<" ";
		// 	cout<<endl;
		// }
	cout<<s-1<<endl;
}

Measured memory_bytes: 11180
// #include <ext/pb_ds/assoc_container.hpp> 
    // #include <ext/pb_ds/tree_policy.hpp> 
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <unordered_set>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define trace(x) cerr << #x << ": " << x << " " << endl;
     
    typedef int64_t ll;
     
    #define endl '\n'
    #define int ll
    ll mod=1e18;
    ll mod1=1e9+5;
     
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }
     
    // using namespace __gnu_pbds;
    // #define ordered_set tree<pair<int,pair<int,int>>, null_type,less<pair<int,pair<int,int>>>, rb_tree_tag,tree_order_statistics_node_update>
    //find_by_order(k)  returns iterator to kth element starting from 0;
    //order_of_key(k) returns count of elements strictly smaller than k;
    //erase,insert same as normal set
    
    
    
    int32_t main()
    {
        IOS
    
        
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;++i)
      {
        cin>>a[i];
        if(a[i]%2)
            continue;
        if(a[i]%3==0)
        {
            continue;
            
        }
        if(a[i]%5==0)
            continue;
        cout<<"DENIED";
            return 0;
      }
      cout<<"APPROVED";

    }       

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc120/tasks/abc120_b


def calc(a, b, k):
    ans = 0
    hit = 0
    for i in range(max(a, b), 0, -1):
        if a % i == 0 and b % i == 0:
            hit += 1
            if hit == k:
                ans = i
                break
    return ans


a, b, k = map(int, input().split())

print(calc(a, b, k))


Measured memory_bytes: 2940
import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  val n = cin.nextInt()

  var sn: Int = 0

  var t = n;
  while (t > 0) {
    sn += t % 10
    t /= 10
  }

  if (n % sn == 0) {
    println("Yes")
  } else {
    println("No")
  }
  println()
  cin.close()
}

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

int main(){
    ll N, M;
    cin>>N>>M;
    ll ln = pow(10,9)+7;
    //abs(N-M)>1のときは並べ方がないのでおしまい
    if(abs(N-M)>1){
        cout<<0<<endl;
    }else if(N==M){
        //この時には左端にサルと犬の両方が来ることになる。
        ll dog_combi=1;
        rep(i,N+1){
            if (i==0)continue;
            dog_combi = dog_combi*i%ln;
        }
        ll output = (dog_combi*dog_combi*2)%ln;
        cout<<output<<endl;
    }else{
        ll dog_combi=1;
        rep(i,N+1){
            if (i==0)continue;
            dog_combi = dog_combi*i%ln;
        }
        ll monkey_combi=1;
        rep(i,M+1){
            if (i==0)continue;
            monkey_combi =monkey_combi*i%ln;
        }
        ll output = dog_combi*monkey_combi%ln;
        cout<<output<<endl;

    }


return 0;

}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int k,x;
int main(){
	cin>>x>>k;
	for(int i=k-x+1;i<=k+x-1;i++)
		cout<<i<<' ';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
long long s[][11]={{0,1,2,7,45,512,9925,321381,15870550,1069877351,},{1,0,4,14,90,1024,19850,642762,31741100,2139754702,},{2,4,0,28,180,2048,39700,1285524,63482200,4279509404,},{7,14,28,0,315,3584,69475,2249667,111093850,7489141457,},{45,90,180,315,0,6144,119100,3856572,190446600,12838528212,},{512,1024,2048,3584,6144,0,198500,6427620,317411000,21397547020,},{9925,19850,39700,69475,119100,198500,0,9320049,460245950,31026443179,},{321381,642762,1285524,2249667,3856572,6427620,9320049,0,603080900,40655339338,},{15870550,31741100,63482200,111093850,190446600,317411000,460245950,603080900,0,55633622252,},{1069877351,2139754702,4279509404,7489141457,12838528212,21397547020,31026443179,40655339338,55633622252,0,}};
int main(){
	int n;scanf("%d",&n);
	for(int i=0;i<n;++i){for(int j=0;j<n;++j)printf("%lld ",s[i][j]);puts("");}
	return 0;
}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

k = int(input())

diff = 0

ant_list = []

ant_list.append(a)
ant_list.append(b)
ant_list.append(c)
ant_list.append(d)
ant_list.append(e)

judge = True

for i in range(len(ant_list) - 1):

    for j in range(5-i):
        diff  = ant_list[4-j] - ant_list[i]

        if diff > k:
            judge = False
            break
    else:
        continue

if judge:
    print('Yay!')
else:
    print(':(')

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

int main()
{
    int x, y;
    cin >> x >> y;
    const int dict[] = {
    //  1  2  3  4  5  6  7  8  9 10 11 12
        0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0,
    };
    if (dict[x - 1] == dict[y - 1]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int count=A;
		int sum=1;
		
		if(B==1) {
			System.out.println(0);
			System.exit(0);
		}
		
		for(sum=1;count<B;sum++) {
			count+=(A-1);
		}
		System.out.print(sum);
	}
}


Measured memory_bytes: 21972