akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int count = 0;
        int i = 0;
		for(i = 0;i < N; i++){
          A[i] = sc.nextInt();
        }
        for(i = 0;i < N; i++){
          if(i + 1 ==  A[A[i] - 1] ){
            count += 1;
          }
        }
        count = count /2;
		System.out.println(count);            
    }
}

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

using namespace std;
using ll = long long;

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

  const ll mod = 1e9 + 7;

  ll s;
  cin >> s;

  vector<ll> dp(s + 1);
  dp[0] = 1;
  for (int i = 3; i <= s; i++) {
    for (int j = 3; j <= i; j++) {
      dp[i] += dp[i - j];
      dp[i] %= mod;
    }
  }
  cout << dp[s] << endl;

  return 0;
}


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

const int MAX = 2100000;

int main() {
  int N;
  cin >> N;
  vector<long long> v(MAX, 0);
  for (int i = 0; i < N; ++i) {
    long long a;
    cin >> a;
    v[a]++;
  }
  for (int d = 1; d < MAX; ++d) {
      if (v[d] == 0) continue;
      if (v[d] > 1) v[d] = 0;
    for (int e = d * 2; e < MAX; e += d) {
      v[e] = 0;
    }
  }
  long long res = 0;
  for (int d = 1; d < MAX; ++d) res += v[d];
  cout << res << endl;
}


Measured memory_bytes: 19632
// review
#include <iostream>

using namespace std;
typedef long long ll;
const ll INF = 1e16+7;
const int MAXN = 1010;

int n, m;
ll a[MAXN * 2], b[MAXN * 2], c[MAXN * 2];
ll dist[MAXN];
void solve() {
  for (int i=0;i<n;i++) {
    dist[i] = INF;
  }
  dist[0] = 0;

  for (int i=0;i<n;i++) {
    for (int j=0;j<m;j++) {
      if (dist[b[j] - 1] > dist[a[j] - 1] + c[j]) {
        dist[b[j] - 1] = dist[a[j] - 1] + c[j];
        if (i == n - 1 && b[j] == n) {
          cout << "inf" << endl;
          return;
        }
      }
    }
  }
  cout << -dist[n-1] << endl;
}

int main() {
  cin >> n >> m;
  for (int i=0;i<m;i++) {
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }
  solve();
}


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

#define rep(j,n) for(int j=0;j<n;j++)
#define ll long long
#define MAX 100001

#define pb .push_back

using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    rep(i,3){
        if(s[i]==t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final int MOD = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int kk = sc.nextInt();
		long[][] dp = new long[h + 1][w];
		dp[0][0] = 1;
		for (int i = 1; i <= h; i++) {
	        for (int k = 0; k < Math.pow(2, w - 1); k++) {
	            boolean[] bars = toBitArray(k, w - 1);
	            if (bars == null) {
	                continue;
	            }
    		    for (int j = 0; j < w; j++) {
		            if (j != 0 && bars[j - 1]) {
		                dp[i][j] += dp[i - 1][j - 1];
		            } else if (j != w - 1 && bars[j]) {
		                dp[i][j] += dp[i - 1][j + 1];
		            } else {
		                dp[i][j] += dp[i - 1][j];
		            }
		            dp[i][j] %= MOD;
		        }
		    }
		}
		System.out.println(dp[h][kk - 1]);
	}
	
	static boolean[] toBitArray(int x, int size) {
	    boolean[] ans = new boolean[size];
	    boolean prev = false;
	    int idx = 0;
	    while (x > 0) {
	        ans[idx] = (x % 2 == 1);
	        if (ans[idx] && prev) {
	            return null;
	        }
	        prev = ans[idx];
	        x /= 2;
	        idx++;
	    }
	    return ans;
	}
	
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans;
	cin >> n;
	vector<long long> a(n), b(n), c(n);
	ans = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		c[i] = a[i] + b[i];
		ans -= b[i];
	}
	sort(c.rbegin(), c.rend());
	for (i = 0; i < n; i+= 2) ans += c[i];
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a[110];
    for (int i = 0; i < N; i++)cin >> a[i];
    reverse(a, a + N);
    for (int i = 0; i < N; i++) {
        if (i == N - 1)cout << a[i] << endl;
        else cout << a[i] << ' ';
    }
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 Scanner s = new Scanner(System.in);
		 int rate = s.nextInt();
		 if(rate < 1200){
			System.out.println("ABC"); 
		 }else{
			 System.out.println("ARC"); 
		 }
	}

}


Measured memory_bytes: 9044
#include <iostream>
#include <stdio.h>
#include <unordered_set>

using namespace std;

int A[3][3];
int C[8]{};

int main() {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  bool flg = false;
  for (int i = 0; i < N; ++i) {
    int b;
    cin >> b;
    if (flg) {
      continue;
    }
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (A[i][j] == b) {
          ++C[i];
          ++C[j + 3];
          C[6] += i + j == 2;
          C[7] += i == j;
          for (int k = 0; k < 8; ++k) {
            if (C[k] >= 3) {
              flg = true;
              break;
            }
          }
        }
      }
    }
  }
  if (flg) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3096
// unihernandez22 & Vicfred
// https://atcoder.jp/contests/abc162/tasks/abc162_e
// math
import std.algorithm;
import std.stdio;

long binpow(long a, long b, long m) {
    a %= m;
    long ans = 1;
    while(b > 0) {
        if(b & 1)
            ans = (ans * a)%m;
        a = (a * a)%m;
        b >>= 1;
    }
    return ans;
}

void main() {
    long n, k;
    readf("%s %s\n", &n, &k);

    const long mod = 10^^9+7;
    long[] GCD = new long[k+1];

    for(long x = k; x > 0; x--)
        GCD[x] = binpow(k/x, n, mod);

    for(long x = k; x > 0; x--) {
        for(long j = 2*x; j <= k; j += x) {
            GCD[x] -= GCD[j];
            GCD[x] %= mod;
        }
    }

    long ans = 0;
    for(int x = 1; x <= k; x++) {
        ans += GCD[x]*x;
        ans %= mod;
    }

    writefln("%s", ans);
}



Measured memory_bytes: 3428
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 s: String = scan(tokens);
    let s = s.as_bytes();
    let n = s.len();
    let mut limit = vec![None; n];
    for i in 1..n {
        if s[i - 1] == b'R' && s[i] == b'L' {
            limit[i - 1] = Some((i - 1, i));
            limit[i] = Some((i, i - 1));
        }
    }
    fn dfs(i: usize, s: &[u8], limit: &mut [Option<(usize, usize)>]) -> (usize, usize) {
        if limit[i].is_none() {
            let (x, y) = if s[i] == b'L' {
                dfs(i - 1, s, limit)
            } else {
                dfs(i + 1, s, limit)
            };
            limit[i] = Some((y, x));
        }
        limit[i].unwrap()
    }
    for i in 0..n {
        dfs(i, &s, &mut limit);
    }
    let mut count: Vec<usize> = vec![0; n];
    for i in 0..n {
        count[limit[i].unwrap().0] += 1;
    }
    for i in 0..n {
        if i != 0 {
            print!(" ");
        }
        print!("{}", count[i]);
    }
    println!("");
}


Measured memory_bytes: 14844
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n;cin>>n;
  set<string> s;
  vector<string> z(n);
  for(int i = 0; n > i; i++){
    cin>>z[i];
    if(s.find(z[i]) != s.end()){
      cout << "No" << endl;
      return 0;
    }
    if(i && z[i-1][z[i-1].size()-1] != z[i][0]){
      cout << "No" << endl;
      return 0;
    }
    s.insert(z[i]);
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package here;

/**
 *
 * @author sokumar
 */
import java.util.*;
import java.io.*;
public class Main {
   
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int n = sc.nextInt();
        long []a = new long[n+1];
        for(int i=1;i<=n;i++)
        {
            a[i] = sc.nextLong();
        }
        Student [][]dp = new Student[n+1][n+1];
        
        for(int i=1;i<=n;i++)
        {
            dp[i][i] = new Student(a[i],0l);
            
        }
       int i=1;
       int j=2;
       int y = 2;
        for(int k=1;k<n;k++)
        {
            for(int l=k+1;l<=n;l++)
            {
                long t1 = 0;
                long t2 = 0;
                t1 = Math.max(a[j] + dp[i][j-1].sec,a[i]+dp[i+1][j].sec);
                if(a[j] + dp[i][j-1].sec > a[i]+dp[i+1][j].sec)
                    t2 = dp[i][j-1].first;
                else
                    t2 = dp[i+1][j].first;
                dp[i][j] = new Student(t1,t2);
                i++;j++;
            }
            y++;
            j = y;
            i = 1;
            
        }
        
        
        w.println(dp[1][n].first - dp[1][n].sec);
         
            
        w.close();
    }
    
    static class Student{
        long first;
        long sec;
        Student(long first ,long sec)
        {
            this.first = first;
            this.sec = sec;
        }
    }
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
int max_n = 2001;
signed main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    double count1,count2;
    count1 = count2 = 0;
    count1 = (B+(C-1))/B;
    count2 = (D+(A-1))/D;
    if(count1<=count2){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 3720
n = int(input())
a_array = list(map(int, input().split()))

i = 0

for a in a_array:
    i = max(i, a)

j = 0


for a in a_array:
    if a == i:
        continue
    if abs(j - i/2) > abs(a - i/2):
        j = a

print(i, j)


Measured memory_bytes: 62704
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
int n,k;
vector<int>g[2005];
int dfs(int x,int p,int deepth,int mx)
{
	int s=1;
	if(deepth!=mx)
		for(int y=0;y<g[x].size();y++)
		{
			if(g[x][y]==p)
				continue;
			s+=dfs(g[x][y],x,deepth+1,mx);
		}
	return s;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	int ans=0;
	if(k%2==0)
		for(int v=1;v<=n;v++)
			ans=max(ans,dfs(v,-1,0,k/2));
	else
		for(int v=1;v<=n;v++)
			for(int u=0;u<g[v].size();u++)
				ans=max(ans,dfs(v,g[v][u],0,k/2)+dfs(g[v][u],v,0,k/2));
	cout<<n-ans;
	return 0;
}

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

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> A;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    for(int j=0; j<a; j++){
      A.push_back(i+1);
    }
  }
  for(int i=0; i<H; i++){
    if(i%2==0){
      for(int j=0; j<W; j++){
          cout << A[i*W+j] << " ";
      }
    }
    else{
      for(int j=W-1; j>=0; j--){
        cout << A[i*W+j] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;

	ll sum = 0;
	vector<int> ans;
	int rm = -1;
	for(int i=1; i<=n; i++){
		sum += i;
		ans.pb(i);
		if(sum >= n){
			rm = sum - n;
			break;
		}
	}

	for(int i=0; i<ans.size(); i++){
		if(ans[i] != rm){
			cout << ans[i] << endl;
		}
	}
	
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    if(n < 105) cout << 0 << endl;
    else if(105 <= n && n < 135) cout << 1 << endl;
    else if(135 <= n && n < 165) cout << 2 << endl;
    else if(165 <= n && n < 189) cout << 3 << endl;
    else if(189 <= n && n < 195) cout << 4 << endl;
    else if(195 <= n) cout << 5 << endl;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,*A = get_all_int()

children = defaultdict(int)
for i,a in enumerate(A):
    children[a] += 1

for i in range(1, n+1):
    print(children[i])


Measured memory_bytes: 123800
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

DP = [float("inf")]*(N+K)
DP[0] = 0

for i in range(N-1):
    for j in range(1, min(K+1, N-i)):
        DP[i+j] = min(DP[i+j], DP[i] + abs(h[i] - h[i+j]))
print(DP[N-1])

Measured memory_bytes: 55008
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<vi> a(n, vi(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	vector<ll> b(1 << n, 0);
	for (int m = 1; m < (1 << n); m++) {
		for (int i = 0; i < n; i++) {
			if (m >> i & 1) {
				for (int j = i + 1; j < n; j++) {
					if (m >> j & 1) {
						b[m] += a[i][j];
					}
				}
			}
		}
	}
	const ll inf = 1e18 + 228;
	vector<ll> dp(1 << n, -inf);
	dp[0] = 0;
	for (int m = 1; m < (1 << n); m++) {
		dp[m] = b[m];
		for (int g = (m - 1) & m; g > 0; g = (g - 1) & m) {
			dp[m] = max(dp[m], b[g] + dp[m ^ g]);
		}
	}
	cout << dp.back();
}


Measured memory_bytes: 1280
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

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

   bool turn = false;

   while(true){
       if(!turn){
           c -= b;
           if(c <= 0){
               cout<<"Yes\n";
               return 0;
           }
          
       }else{
           a -= d;
           if(a <= 0){
               cout<<"No\n";
               return 0;
           }
       }
        turn ^= 1;
   }

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3620
my $input = <STDIN>;
chomp $input;
my ($N, $M) = split / /, $input;
my $S = <STDIN>;
chomp $S;
my $T = <STDIN>;
chomp $T;
my $gcd;
my $lcm;
my $n = $N;
my $m = $M;
while ($m>0 && $n>0) {
  $n = $n % $m;
  if ($n>0) {
    $m = $m % $n;
  }
}
if ($n==0) {
  $gcd = $m;
} else {
  $gcd = $n;
}
$lcm = $N * $M / $gcd;
my $res = $lcm;
my $nn = $N / $gcd;
my $mm = $M / $gcd;
for ($i=0; $i<$gcd; $i++) {
  if (substr($S,$i*$nn,1) ne substr($T,$i*$mm,1)) {
    $res = -1;
    last;
  }
}
print $res . "\n";

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> pll;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
const int MOD = 1000000007;
// constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
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;
}

// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)
// vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(w + 1, vector<int>(k+1, 0)));


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vl a(n);
    rep(i,n) {
        cin >> a[i];
    }
    sort(all(a));
    print(a[n-1]-a[0]);



    return 0;
}


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

typedef long long int ll;

int main()
{
	ll n;
	cin>>n;
	ll d=26;
	ll cnt=0;
	vector<char> v;
	while(n>0)
	{
		v.push_back(97+(n-1)%26);
		n=(n-1)/26;
	}
	for(ll i=v.size()-1;i>=0;i--)
		printf("%c",v[i]);
	printf("\n");
}





Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

char c[2000];
double dp[2000];
double next[2000];

int main() {
  int n,t;
  while(cin>>n>>t,n||t) {
    REP(i,n) cin>>c[i];
    memset(dp,0,sizeof(dp));
    REP(i,n) if (c[i]=='R') dp[i] = 1;
    REP(i,t) {
      memset(next,0,sizeof(next));
      REP(j,n) REP(k,6)
        next[(j+k+1)%n] += dp[j]/6;
      memcpy(dp,next,sizeof(next));
    }
    printf("%.10f\n", *max_element(dp,dp+n));
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll  long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<ll>

#define sz(x) ((int) (x).size())
#define pll pair<long long,long long>
#define mp make_pair
#define F first
#define S second
#define T int tt; cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);

#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define display(x) for(auto i : x) cout << i << " "; cout << '\n';
#define input(x) for(int i = 0; i < n; i++) cin >> x[i];
#define make(x,y) fill(all(x), y)
#define FO(i,startLoop,n) for (int i = startLoop; i < n; i++)

#define mod 1000000007
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define ITFO(myiterator, mymap) for(auto myiterator = mymap.begin(); myiterator!=mymap.end(); ++myiterator)
using namespace std;


int main()
{
	fastio
	cin.tie(NULL); cout.tie(0);




	ll n, wei; cin >> n >> wei;
	vi w(1, 0), val(1, 0);

	ll max_val = 0;
	FO(i, 0, n)
	{
		int x, y; cin >> x >> y;
		w.pb(x), val.pb(y);
		max_val += y;
	}
	// cout << max_val;
	vector<vector<ll>>dp(n + 1, vector<ll>( max_val  + 1, INT_MAX));
	for (int i = 0; i <= n; i++)
		dp[i][0] = 0;
	FO(i, 1, n + 1)
	{
		FO(j, 1, max_val + 1)
		{
			if (j - val[i] >= 0)
				dp[i][j] = min(dp[i - 1][j - val[i]] + w[i], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];

			// cout << dp[i][j] << " ";
		}
		// cout << endl;
	}
	ll ans = 0;
	FO(j, 1, max_val + 1)
	{
		if (dp[n][j] <= wei)
			ans = max(ans, 1LL * j);
	}
	cout << ans << endl;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 80256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    S = S[:-1]
    for _ in range(len(S)):
        l = len(S)
        if l % 2 == 0 and S[:l // 2] == S[l // 2:]:
            print(len(S))
            exit()
        else:
            S = S[:-1]


if __name__ == '__main__':
    main()


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

#define INF -100000000

int main(){
  

  int dataSets;

  while(true){
    vector<int> a;
    cin >> dataSets;
    if(dataSets==0){break;}
    for(int i=0;i<dataSets;i++){
      int tmpa;
      cin >> tmpa;
      a.push_back(tmpa);

    }

    int tmax=INF;
    // i?????§????????§?????????????????????
    vector<int> tmpMax(dataSets + 1,0);
    tmpMax[0] = 0;
    for(int i=1;i<dataSets+1;i++){
      tmpMax[i] += tmpMax[i-1] + a[i-1];
    }

    for(int i=0;i<dataSets;i++){
      for(int j=i+1;j<dataSets+1;j++){
	tmax = max(tmax, tmpMax[j]-tmpMax[i]);
      }
    }
    
    // for(int i=0;i<dataSets+1;i++){
      // for(int j=i;j<dataSets;j++){
	// tmax = max(tmax, tmpMax[j+1] - tmpMax[i]);
      // }
    // }
    
    cout << tmax << endl;
    
  }

  return 0;

}
  

Measured memory_bytes: 1244
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with

#A = int(input())
#A,B= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
S= str(input())

dict = list('abcdefghijklmnopqrstuvwxyz')
for i in range(len(S)):
    for s in dict:
        if s==S[i]:
            dict.remove(s)

            continue
if dict:
    print(dict[0])

else:
    print('None')


Measured memory_bytes: 3188
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
    string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
    int n = int.Parse(input[0]);
    int k = int.Parse(input[1]);
    string s = Console.ReadLine();
    char[] c = s.ToCharArray();
    if(c[k-1] == 'A') c[k-1] = 'a';
    if(c[k-1] == 'B') c[k-1] = 'b';
    if(c[k-1] == 'C') c[k-1] = 'c';
    Console.WriteLine(c);
	}
}

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

#define int long long

int n;
int x[110];
int y[110];
//time
struct Timer {
    chrono::high_resolution_clock::time_point st;

    Timer() { reset(); }

    void reset() {
        st = chrono::high_resolution_clock::now();
    }

    chrono::milliseconds::rep elapsed() {
        auto ed = chrono::high_resolution_clock::now();
        return chrono::duration_cast< chrono::milliseconds >(ed - st).count();
    }
};

//rand
struct RandomNumberGenerator {
    mt19937 mt;

    RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

    int operator()(int a, int b) { // [a, b)
        uniform_int_distribution< int > dist(a, b - 1);
        return dist(mt);
    }

    int operator()(int b) { // [0, b)
        return (*this)(0, b);
    }
};

#define SIMULATE_TIME 1990

double C = SIMULATE_TIME * 10000;


signed main(){
    Timer timer;
    RandomNumberGenerator getRand;

    cin >> n;
    for(int i = 0;i < n;i++) cin >> x[i] >> y[i];

    bitset<100> used[110] = {};

    int ans = 0;
    int ma = 0;
    int xx = 0;
    int yy = 0;

    int ct = 0;

    do{
        for(int p = 0;p < 10;p++){
            int i = getRand(n);
            if(used[i] == 0){
                xx += x[i];
                yy += y[i];
                int now = xx*xx + yy*yy;

                if(now >= ans || (getRand(2000) >= ct)){
                    ans = now;
                    used[i] = 1;
                    ma = max(ma, ans);
                }else{
                    xx -= x[i];
                    yy -= y[i];
                }
            }else{
                xx -= x[i];
                yy -= y[i];
                int now = xx*xx + yy*yy;

                if(now >= ans || (getRand(2000) >= ct)){
                    ans = now;
                    used[i] = 0;
                    ma = max(ma, ans);
                }else{
                    xx += x[i];
                    yy += y[i];
                }
            }
        }
    }while((ct = timer.elapsed()) <= SIMULATE_TIME);
    printf("%.20lf\n", sqrt(ma));

    return 0;
}

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

int main(void)
{
    int n;
    std::cin >> n;

    std::vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> p[i];
    }
    int cnt = 0;
    std::vector<int> buf(3);
    for (int i = 1; i < n - 1; i++)
    {
        std::copy(p.begin() + i - 1, p.begin() + 2 + i, buf.begin());
        // for (auto x : buf)
        //     std::cout << x << " ";
        // std::cout << std::endl;

        std::sort(buf.begin(), buf.end());
        if (buf[1] == p[i])
            cnt++;
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string s;
  cin >> s;

  int a = 0, b = 0;
  rep(i,s.size()){
    if(s[i] == '0') a++;
    else b++;
  }

  cout << min(a,b)*2 << endl;
  
  return 0;
}




Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Debug(s) debug("The massage in line %d, Function %s: %s\n", __LINE__, __FUNCTION__, s)
typedef long long LL;
typedef long double LD;
int read() {
    char ch = getchar();
    int x = 0, flag = 1;
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') flag *= -1;
    for(;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x * flag;
}
void write(LL x) {
    if(x < 0) putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + 48);
}

const int Mod = 1e9 + 7, Maxk = 1e5 + 9, Maxn = 109;

template <int N> struct BIT {
	LL c[N + 9];
	void init() { clar(c, 0); }
#define lowbit(x) ((x) & -(x))
	void plus(int pos, LL val) {
		++pos;
		for (; pos <= N; pos += lowbit(pos)) (c[pos] += val) %= Mod;
	}
	LL sum(int pos) {
		++pos;
		LL res = 0;
		for (; pos; pos -= lowbit(pos)) 
			(res += c[pos]) %= Mod;
		return res;
	}
	LL sum(int l, int r) {
		if (l > r) return 0;
		if (l == 0) return sum(r);
		return (sum(r) - sum(l - 1) + Mod) % Mod;
	}
#undef lowbit
};
BIT <Maxk> lst, now;

int a[Maxn], n, k;
static int dp[Maxn][Maxk];

void init() {
	n = read(); k = read();
	rep (i, 1, n) a[i] = read();
}

void solve() {
	dp[0][0] = 1;  now.plus(0, 1);
	rep (i, 1, n) {
		swap(lst, now), now.init();
		rep (j, 0, k) {
			dp[i][j] = lst.sum(j - min(a[i], j), j);
			now.plus(j, dp[i][j]);
		}
	}
	cout << dp[n][k] << endl;
}

int main() {
   // freopen("AtcoderDpM.in", "r", stdin);
   // freopen("AtcoderDpM.out", "w", stdout);

    init();
    solve();

#ifdef Qrsikno
    debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
    return 0;
}



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

// ------ graph ------ //
using Weight = long long;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
struct Graph {
    vector<Edges> adj;
    Graph(int n) : adj(n) { }
    int size() { return adj.size(); }
    Edges operator [] (int v) { return adj[v]; }
    void add_edge(int a, int b, Weight w = 1) { // graph
        adj[a].emplace_back(a, b, w);
        adj[b].emplace_back(b, a, w);
    }
    void add_arc(int a, int b, Weight w = 1) {  // digraph
        adj[a].emplace_back(a, b, w);
    }
};
using Array = vector<Weight>;
using Matrix = vector<Array>;
using UnweightedGraph = vector<vector<int>>;

// ------ StronglyConnectedComponents ------ //
struct StronglyConnectedComponents {
    const UnweightedGraph &g;
    UnweightedGraph rg;
    vector<int> comp, order, seen;
    StronglyConnectedComponents(const UnweightedGraph &g)
    : g(g), rg(g.size()), comp(g.size(), -1), seen(g.size()) {
        for (int u = 0; u < g.size(); ++u) {
            for (int v: g[u]) {
                rg[v].emplace_back(u);
            }
        }
    }
    int operator[](int k) { return comp[k]; }
    void dfs(int u) {
        seen[u] = true;
        for (int v: g[u]) if (!seen[v]) dfs(v);
        order.emplace_back(u);
    }
    void rdfs(int u, int id) {
        comp[u] = id;
        for (int v: rg[u]) if (comp[v] == -1) rdfs(v, id);
    }
    UnweightedGraph build() {
        for (int u = 0; u < g.size(); ++u) if (!seen[u]) dfs(u);
        reverse(begin(order), end(order));
        int id = 0;
        for (int u: order) if (comp[u] == -1) rdfs(u, id++);
        UnweightedGraph g_comp(id);
        for (int u = 0; u < g.size(); ++u) for (int v: g[u]) {
            int x = comp[u], y = comp[v];
            if (x != y) g_comp[x].push_back(y);
        }
        return g_comp;
    }
};

int main() {
    int V, E; cin >> V >> E;
    UnweightedGraph g(V);
    while (E--) {
        int s, t; cin >> s >> t;
        g[s].emplace_back(t);
    }
    StronglyConnectedComponents scc(g);
    scc.build();
    int Q; cin >> Q;
    while (Q--) {
        int u, v; cin >> u >> v;
        cout << (scc[u] == scc[v]) << endl;
    }
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    ll L, R; cin >> L >> R;

    ll res = 2018;
    if(R - L < 2019) {
        for(ll l = L; l < R; ++l) {
            for(ll r = l + 1; r <= R; ++r) {
                ll cnt = (l * r) % 2019;

                if(res > cnt) {
                    res = cnt;
                }
            }
        }
    } else {
        res = 0;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int max_size = 1000000;

vector<long long> fac(max_size+1), ifac(max_size+1);

long long pow_mod(long long x, long long n){
    long long ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

long long comb(long long a, long long b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    long long tmp = ifac[a-b] * ifac[b] % mod;
    return tmp * fac[a] % mod;
}


int main(){
    int n,k;
    cin >> n >> k;
    long long a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    fac[0] = 1;
    ifac[0] = 1;
    for(long long i = 0; i < max_size; i++){
        fac[i+1] = fac[i]*(i+1) % mod;
        ifac[i+1] = ifac[i]*pow_mod(i+1,mod-2) % mod;
    }
    long long ans = 0;
    for(int i=k-1; i<n; i++){
        long long com = comb(i,k-1);
        ans += (a[i]*com)%mod;
        ans -= (a[n-1-i]*com)%mod;
    }
    cout << ans%mod << endl;
    return 0;
}


Measured memory_bytes: 16640
using System;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var dif = ToInt32(input[0]);
        if (ToInt32(input[1]) == 100) WriteLine(Math.Pow(100, dif) * ToInt32(input[1]) + Math.Pow(100, dif));
        else WriteLine(Math.Pow(100,dif) * ToInt32(input[1]));
    }
}



Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;

int main(void){
	int n;
	cin >> n;
	vector<int> p(n);

	for (int i = 0; i < n; i++){
		cin >> p[i];
	}

	int ans = 0;
	for (int i = 0; i < n - 2; i++){
		int largest = 0;
		int smallest = 1e9;
		for (int j = i; j < i + 3; j++){
			largest = max(largest, p[j]);
			smallest = min(smallest, p[j]);
		}
		if (p[i + 1] != largest && p[i + 1] != smallest){
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    forn (i, n) {
        int x;
        cin >> x;
        v.emplace_back(x, 1);
    }
    forn (i, n) {
        int x;
        cin >> x;
        v.emplace_back(x, -1);
    }
    sort(v.begin(), v.end());

    const int mod = 1e9 + 7;
    ll res = 1;
    int bal = 0;
    for (auto p: v) {
        int y = p.second;
        if (y == 1 && bal < 0) {
            res = res * -bal;
            res %= mod;
        } else if (y == -1 && bal > 0) {
            res = res * bal;
            res %= mod;
        }
        bal += y;
    }
    cout << res << '\n';
}


Measured memory_bytes: 2420
public class Main {
  private static void solve() {
    int n = ni();
    int[] h = na(n);

    int now = h[0];
    int cnt = 0;
    int ret = 0;
    for (int i = 1; i < n; i++) {
      if (h[i] <= now) {
        cnt++;
      } else {
        ret = Math.max(cnt, ret);
        cnt = 0;
      }
      now = h[i];
    }
    ret = Math.max(cnt, ret);
    System.out.println(ret);

  }

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

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

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

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

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

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

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

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

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

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

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

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


Measured memory_bytes: 41988
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define mem(a) memset(a,0,sizeof a)
#define ll long long 
int n;
int a[100005];

int main() {

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] == i) {
			swap(a[i], a[i + 1]);
			cnt++;
		}
	}
	printf("%d\n", cnt);
	//system("pause");

	return 0;
}

/*
100
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 

*/

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int count = 0;
    for(int a = 0;  a <= A; a++){
        for(int b = 0; b <= B; b++){
            for(int c = 0; c <= C; c++){
                if(500 * a + 100 * b + 50 * c == X) count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if(N==1) {
			System.out.println("Hello World");
		}else {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println(A+B);
		}


		


	}

}

Measured memory_bytes: 23252
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){

	
	
	int x,y,z;
	while(1){
		cin>>x>>y>>z;
			if(x==-1&&y==-1&&z==-1)break;
	int a=0,b=0,c=0;
	int D=120*60;
	int dd=0;
	dd+=3600*x+60*y+z;
	D-=dd;
	int G=3*D;

	a=D/3600;D=D%3600;
	b=D/60;D=D%60;
	c=D;
	if(a<10)cout<<"0";
	cout<<a<<":";
	if(b<10)cout<<"0";
	cout<<b<<":";
	if(c<10)cout<<"0";
	cout<<c<<endl;
	

	a=G/3600;G=G%3600;
	b=G/60;G=G%60;
	c=G;
	if(a<10)cout<<"0";
	cout<<a<<":";
	if(b<10)cout<<"0";
	cout<<b<<":";
	if(c<10)cout<<"0";
	cout<<c<<endl;

	}
	return 0;
}

Measured memory_bytes: 1160
N,K=map(int,input().split())
a=[int(i) for i in input().split()]
mod=10**9+7
dp=[[0]*(K+1) for i in range(N+1)]
dp[0][0]=1
dp_sum=[[0]*(K+2) for i in range(N+1)]
dp_sum[0]=[0]+[1]*(K+1)
for i in range(N):
  for k in range(K+1):
    dp[i+1][k]=(dp_sum[i][k+1]-dp_sum[i][max(k-a[i],0)])%mod
    dp_sum[i+1][k+1]=(dp_sum[i+1][k]+dp[i+1][k])%mod
print(dp[N][K])


Measured memory_bytes: 193672
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(void) {
    int n;
    cin>>n;
    int ary[n];
    for(int i=0; i<n; i++){
        cin>>ary[i];
    }

    float ave = 0;
    float avesub = 0;
    int aidx = 0;

    for(int i=0; i<n; i++){
        ave += ary[i];
    }
    ave = ave/n;
    avesub = abs(ary[0] - ave);
    for(int i=1; i<n; i++){
        if(abs(ary[i] - ave) < avesub){
            avesub = abs(ary[i] - ave);
            aidx = i;
        }
    }
    cout<<aidx<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
	ll N,K;
	cin >> N >> K;
	vl h(N);
	REP(i, N){
		cin >> h[i];
	}
	ll ans = 100000000000;
	sort(h.begin(), h.end());
	REP(i, N-K+1){
		if(h[i+K-1] - h[i] < ans){
			ans = h[i+K-1] - h[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a[200009],b[200009],c[200009],d,e,n,k,m,pas;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>k;
	if(k>n*3){
		cout<<0;
		return 0;
	}
  if(k>n){
    if(k%2==1){
      cout<<0;
    }else{
      if(k/2<=n){
        cout<<1;
      }else{
        cout<<0;
      }
    }
    return 0;
  }
	if(k==1){
		cout<<n*n*n;
		return 0;
	}
	if(k%2==1){
		d=n/k;
		cout<<d*d*d;
	}else{
		d=n/k;
		pas=pas+d*d*d;
		d=(n-k/2)/k+1;
		pas=pas+d*d*d;
		cout<<pas;
	}
	return 0;
}

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


int main(void){
  int n,i,a[100005],ng,ok,mid;
  ll t;
  
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i];
  
  sort(a,a+n);
  
  ng=-1;
  ok=n-1;
  while (ok-ng>1){
    
    mid=(ng+ok+1)/2;
    t=a[mid];
    
    for (i=0;i<n;i++){
      if (i!=mid){
        if (a[i]<=t*2) t+=a[i];
        else break;
      }
    }
    
    if (i==n) ok=mid;
    else ng=mid;
    
  }
  
  cout << n-ok << endl;
  
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.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; }
using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
const ll MOD = 1e9+7; ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0}; vi d4y = {0, 1, 0, -1};
//---------------------------------------

int main(){
    int n; cin>>n;
    vector<int> d(n);
    rep(i,n) cin>>d[i];
    sort(all(d));
    if(d[n/2-1]==d[n/2]){
        cout<<0<<endl;
        return 0;
    }
    cout<<d[n/2]-d[n/2-1]<<endl;
    return 0;
}

Measured memory_bytes: 640