akhauriyash/Code-Regression huggingface dataset:
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pb push_back
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(9);
    cerr << fixed << setprecision(9);
    static db D[1 << 20];
    int xa,ya,xb,yb;
    IOS;
    fi>>xa>>ya>>xb>>yb;
    int n;
    fi>>n;
    priority_queue < pair < db , int > , vector < pair < db , int > > , greater < pair < db , int > >  > Q;
    static int a[1 << 20];
    static int b[1 << 20];
    static int c[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>a[i]>>b[i]>>c[i],D[i] = max(0.0,sqrt(1ll * (xa - a[i]) * (xa - a[i]) + 1ll * (ya - b[i]) * (ya - b[i])) - c[i]),Q.push(mp(D[i],i));
    static int was[1 << 20];
    while (!Q.empty())
    {
        int node = Q.top().y;
        Q.pop();
        if (was[node])
            continue;
        was[node] = 1;
        for (int i = 1;i <= n;++i)
        if (i != node)
        {
            db nxt = D[node] + max(0.0,sqrt(1ll * (a[i] - a[node]) * (a[i] - a[node]) + 1ll * (b[i] - b[node]) * (b[i] - b[node])) - c[i] - c[node]);
            if (D[i] > nxt)
                D[i] = nxt,Q.push(mp(nxt,i));
        }
    }
    db ans = sqrt(1ll * (xa - xb) * (xa - xb) + 1ll * (ya - yb) * (ya - yb));
    for (int i = 1;i <= n;++i)
        ans = min(ans,D[i] + max(0.0,sqrt(1ll * (xb - a[i]) * (xb - a[i]) + 1ll * (yb - b[i]) * (yb - b[i])) - c[i]));
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Measured memory_bytes: 8684
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  map<int, ll> mp;

  rep(i, n) {
    mp[a[i]]++;
    mp[a[i] - 1]++;
    mp[a[i] + 1]++;
  }
  ll ans = 0;
  for (auto it : mp) {
    ans = max(ans, it.second);
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 9568
#include <iostream>

int update_money(int m) {
    int tmp = (int) (((double) m) * 1.05);
    double floating = (((double) tmp) / 1000.0) - (tmp / 1000);
    if (floating > 0) {
        tmp = ((int) (((double) tmp) / 1000) ) * 1000 + 1000;
    } else {
        tmp = ((int) ((double) tmp) / 1000) * 1000;
    }
    return tmp;
}

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

    for (int i=0; i<n; i++) {
        money = update_money(money);
    }
    std::cout << money << std::endl;

    return 0;
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define mod 1000000007
#define int long long

int solve2(vector<vector<int>> &dp, vector<vector<int>> &a, int c, int src, int par) {
	if (dp[src][c] != -1)return dp[src][c];
	int ans = 0;
	int c0 = 1, c1 = 1;
	for (auto x : a[src]) {
		if (x != par) {
			c0 = (c0 * (solve2(dp, a, 0, x, src) % mod) ) % mod;
		}
	}
	ans = (ans + c0) % mod;


	if (c == 0) {
		for (auto x : a[src]) {
			if (x != par) {
				c1 = (c1 * (solve2(dp, a, 1, x, src) % mod) ) % mod;
			}
		}
		ans = (ans + c1) % mod;
	}


	return dp[src][c] = ans % mod;
}

void solve() {
	int n;
	cin >> n;
	vector<vector<int>> a(n);
	int i, j;
	for (i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		a[u].push_back(v);
		a[v].push_back(u);
	}
	vector<vector<int>> dp(n, vector<int>(2));
	for (i = 0; i < n; i++) {
		for (j = 0; j < 2; j++)dp[i][j] = -1;
	}
	cout << solve2(dp, a, 0, 0, -1);
}

int32_t main() {

	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 22448
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())

ch -= 1
cw -= 1
dh -= 1
dw -= 1

s = []
for _ in range(h):
    s.append(input())

mtx = [[10 ** 9]*w for _ in range(h)]

cnt = -1
now = deque()
nxt = deque()
nxt.append((ch, cw))
mtx[ch][cw] = 0

while True:
    flag = False
    if not now:
        now = nxt
        cnt += 1
        nxt = deque()
        if not now:
            break
    h_ptr, w_ptr = now.pop()
    if h_ptr != 0:
        if s[h_ptr-1][w_ptr] == '.':
            if cnt < mtx[h_ptr-1][w_ptr]:
                mtx[h_ptr-1][w_ptr] = cnt
                now.append((h_ptr-1, w_ptr))
    if w_ptr != 0:
        if s[h_ptr][w_ptr-1] == '.':
            if cnt < mtx[h_ptr][w_ptr-1]:
                mtx[h_ptr][w_ptr-1] = cnt
                now.append((h_ptr, w_ptr-1))
    if h_ptr != h-1:
        if s[h_ptr+1][w_ptr] == '.':
            if cnt < mtx[h_ptr+1][w_ptr]:
                mtx[h_ptr+1][w_ptr] = cnt
                now.append((h_ptr+1, w_ptr))
    if w_ptr != w-1:
        if s[h_ptr][w_ptr+1] == '.':
            if cnt < mtx[h_ptr][w_ptr+1]:
                mtx[h_ptr][w_ptr+1] = cnt
                now.append((h_ptr, w_ptr+1))
    for i in range(h_ptr-2, h_ptr+3):
        for j in range(w_ptr-2, w_ptr+3):
            if 0 <= i < h and 0 <= j < w and s[i][j] == '.':
                if cnt + 1 < mtx[i][j]:
                    mtx[i][j] = cnt + 1
                    nxt.append((i, j))

ret = mtx[dh][dw]

if ret == 10 ** 9:
    print(-1)
else:
    print(ret)


Measured memory_bytes: 87492
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll k; cin>>k;
	if(k%2 == 0 || k%5==0) {
		cout<<"-1"<<endl;
		return 0;
	}
	
	ll count = 1;
	ll div = 7;
	while(true){
		if(div % k ==0) break;
		
		if(count>k) { cout<<"-1"<<endl; return 0; } 
		div = (div%k)*10+7;
		count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3544
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main{
 
  public static void main(String [] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int [] num = new int[51];
    for(int a = 0; a <= 9; a++)
      for(int b = 0; b <= 9; b++)
        for(int c = 0; c <= 9; c++)
          for(int d = 0; d <= 9; d++) 
             num[a+b+c+d]++;
    String ln ="";
    while((ln = br.readLine())!= null)
      System.out.println(num[Integer.parseInt(ln)]);    
        
     
    }
     
}  

Measured memory_bytes: 16860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100500;
ll arr[MAXN];
ll n;
ll a, b;
ll res;

int main()
{
        cin >> n >> a >> b;
        for (int i = 0; i < n; i++)
                cin >> arr[i];

        for (int i = 0; i < n - 1; i++)
                res += min(b, (arr[i + 1] - arr[i]) * a);

        cout << res;
        return 0;
}


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

int main(){
    int N;
    cin >> N;
    int x_cur = 0;
    int y_cur = 0;
    int t_cur = 0;
    for(int ii=0; ii<N; ii++){
        int t, x, y;
        cin >> t >> x >> y;
        int s = t - t_cur;
        for(; s>0; s-=2){
            if(abs(x-x_cur)+abs(y-y_cur)==s){
                break;
            }
        }
        if(s<=0){
            cout << "No" << endl;
            return 0;
        }
        x_cur = x;
        y_cur = y;
        t_cur = t;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>

using namespace std;

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

const int N = 5;
const long long MOD = 1e9 + 7;
const int BASE = 10;
const int INF = 1e9;

int g[N][N];

int main() {

	long long n, m;
	cin >> n >> m;

	if (abs(n - m) > 1)
		cout << 0;
	else {
		long long fn = 1;
		forn(i, n)
			fn = fn * (i + 1) % MOD;

		long long fm = 1;
		forn(i, m)
			fm = fm * (i + 1) % MOD;

		long long ans = fn * fm % MOD;

		if (n == m)
			ans = ans * 2 % MOD;

		cout << ans;
	}

	cout << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

string s;
cin>>s;

int mx=0;
for(int i=0;i<s.length();i++){
    int cnt=0;
    if(s[i]=='A' || s[i]=='T' || s[i]=='G' ||s[i]=='C'){
        cnt=1;
        for(int j=i+1;j<s.length();j++){
            if(s[j]=='A' || s[j]=='T' || s[j]=='G' ||s[j]=='C'){
                cnt+=1;
            }else{
                break;
            }
            mx=max(cnt,mx);
        }

    }
    mx=max(cnt,mx);
}

cout<<mx<<endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
 
int main(){
    int N;
    scanf("%d",&N);
    int num[N+1];
    int max=0;
    int max_N=1;
    for(int i=1;i<N+1;i++){
        int t=0;
        int k=i;
        while(k%2==0){
            t++;
            k=k/2;
        }
        if(t>max){
            max=t;
            max_N=i;
        }
    }
    cout << max_N<< endl;

    return 0;
    
}

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

vector<vector<pair<int, int>>> g;
vector<int> cost;

void dfs(int to, int from, int costo) {
	cost[to] = cost[from] + costo;
	for (auto p : g[to]) {
		if (p.first == from)continue;
		dfs(p.first, to, p.second);
	}
}

signed main() {
	int n;
	cin >> n;
	g.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		g[a].push_back({ b,c });
		g[b].push_back({ a,c });
	}
	int q, k;
	cin >> q >> k;
	--k;
	cost.resize(n);
	cost[k] = 0;
	dfs(k, k, 0);
	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		cout << cost[x] + cost[y] << endl;
	}
}

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

long double x;
int y;
std::string a, b;

int main() {
  std::cin >> a >> b;
  a += b;
  int t = std::stoi(a);
  x = std::sqrt(t);
  y = std::sqrt(t);
  if (x == y) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use proconio::input;

fn main() {
    input!{
        N: usize,
        M: usize,
        AB: [(usize,usize);M],
    }

    let mut d = Dsu::new(N);
    for (a, b) in AB{
        d.merge(a-1, b-1);
    }
    let ans = d.groups().len()-1;
    println!("{}",ans);
}

pub struct Dsu {
    n: usize,
    // root node: -1 * component size
    // otherwise: parent
    parent_or_size: Vec<i32>,
}

impl Dsu {
    // 0 <= size <= 10^8 is constrained.
    pub fn new(size: usize) -> Self {
        Self {
            n: size,
            parent_or_size: vec![-1; size],
        }
    }
    pub fn merge(&mut self, a: usize, b: usize) -> usize {
        assert!(a < self.n);
        assert!(b < self.n);
        let (mut x, mut y) = (self.leader(a), self.leader(b));
        if x == y {
            return x;
        }
        if -self.parent_or_size[x] < -self.parent_or_size[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.parent_or_size[x] += self.parent_or_size[y];
        self.parent_or_size[y] = x as i32;
        x
    }

    pub fn same(&mut self, a: usize, b: usize) -> bool {
        assert!(a < self.n);
        assert!(b < self.n);
        self.leader(a) == self.leader(b)
    }
    pub fn leader(&mut self, a: usize) -> usize {
        assert!(a < self.n);
        if self.parent_or_size[a] < 0 {
            return a;
        }
        self.parent_or_size[a] = self.leader(self.parent_or_size[a] as usize) as i32;
        self.parent_or_size[a] as usize
    }
    pub fn size(&mut self, a: usize) -> usize {
        assert!(a < self.n);
        let x = self.leader(a);
        -self.parent_or_size[x] as usize
    }
    pub fn groups(&mut self) -> Vec<Vec<usize>> {
        let mut leader_buf = vec![0; self.n];
        let mut group_size = vec![0; self.n];
        for i in 0..self.n {
            leader_buf[i] = self.leader(i);
            group_size[leader_buf[i]] += 1;
        }
        let mut result = vec![Vec::new(); self.n];
        for i in 0..self.n {
            result[i].reserve(group_size[i]);
        }
        for i in 0..self.n {
            result[leader_buf[i]].push(i);
        }
        result
            .into_iter()
            .filter(|x| !x.is_empty())
            .collect::<Vec<Vec<usize>>>()
    }
}


Measured memory_bytes: 10328
#include <stdio.h>
#include <string.h>
#define N_MAX 20

int main(void){
	int i; char a[N_MAX+1]; scanf("%s",a); /* N_MAXツつセツづOFツ暗ャツづェツづゥ */
	for(i=strlen(a)-1;i>=0;i--) printf("%c",a[i]);
	printf("\n");
	return 0;
}

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

using namespace std;
vector <char> v;
vector<int> num;
string s ;
int table[3][3];
int main(){
  int A,B,C,X,ans = 0;
  cin >>A>>B>>C>>X;
  for(int i= 0;i<A+1;i++){
    for(int j = 0;j < B +1;j++){
      for (int k =0 ;k < C+1;k++){
        if ((X-500*i-100*j-50*k) == 0){
          ans++;
        }
      }
    }
  }
  cout << ans <<endl;
  return 0;
}


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

#define ll long long
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int> >
#define vii vector<pair<int, int> >


int main(int argc, char * argv[])
{
    std::ios_base::sync_with_stdio(false);    
    std::cin.tie(NULL);

    int X, N;
    std::cin >> X >> N;

    std::unordered_set<int> v;
    for(int i = 0; i < N; ++i)
    {
	int temp;
	cin >> temp;
	v.insert(temp);
    }

    int y = 0;
    while(true)
    {
	if(v.count(X - y) == 0)
	{
	    cout << X - y << endl;
	    break;
	}
	else if(v.count(X + y) == 0)
	{
	    cout << X + y << endl;
	    break;
	}
	y++;
    }

    return 0;
}


Measured memory_bytes: 3664
program am
implicit none
integer::N
integer(16),allocatable,dimension(:)::A
integer(16),allocatable,dimension(:,:)::DP
integer(16)::i
read*,N
allocate(A(N))
read*,A
allocate(DP(N,3))
DP=-huge(i)/2
DP(1,1)=A(1)
DP(2,2)=A(2)
if(N>=3)DP(3,3)=A(3);DP(3,1)=A(1)+A(3)
do i=4,N
    DP(i,1)=DP(i-2,1)+A(i)
    DP(i,2)=max( DP(i-2,2)+A(i), DP(i-3,1)+A(i) )
    DP(i,3)=max( DP(i-2,3)+A(i), DP(i-3,2)+A(i), DP(i-4,1)+A(i) )
end do
if(mod(N,2)==0)then
    print"(i0)",max(DP(N,2),DP(N-1,1))
else
    print"(i0)",max(DP(N,3),DP(N-1,2),DP(N-2,1))
endif
end program am

Measured memory_bytes: 15680
N, M = map(int, input().split())
K, S = [], []
for _ in range(M):
    ks = list(map(int, input().split()))
    K.append(ks[0])
    S.append(ks[1:])
P = list(map(int, input().split()))
    
from itertools import product
pattern = list(product(*[[0, 1]]*N))

ans = 0
for patt in pattern:
    success = 1
    for k, s, p in zip(K, S, P):
        on = 0
        for i in range(k):
            on += patt[s[i] - 1]
        if on % 2 != p:
            success = 0
            break
    if success:
        ans += 1
print(ans)

Measured memory_bytes: 3188
Xs,Ys,Xt,Yt = map(int,input().split())
n = int(input())
p = [(Xs,Ys,0),(Xt,Yt,0)]
for i in range(2,n+2):
    p.append(tuple(map(int,input().split())))
cost = [[0]*(n+2)for i in range(n+2)]

for i in range(n+2):
    for j in range(i,n+2):
        cost[i][j] = cost[j][i] =  max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0)
n += 2
s = 0
#始点sから各頂点への最短距離
#n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
d = [float("inf")] * n
used = [False] * n
d[s] = 0
    
while True:
    v = -1
    #まだ使われてない頂点の中から最小の距離のものを探す
    for i in range(n):
        if (not used[i]) and (v == -1):
           v = i
        elif (not used[i]) and d[i] < d[v]:
            v = i
    if v == -1:
           break
    used[v] = True
           
    for j in range(n):
           d[j] = min(d[j],d[v]+cost[v][j])
print(d[1])


Measured memory_bytes: 25076
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt();
    var sum = 0.0
    
    for (i in 1..N) {
      val A = input.nextInt()
      
      sum += 1.0 / A
    }
    
    println (1 / sum)
  }
}

Measured memory_bytes: 36876
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var wq=arr.shift();
   if(wq=="0 0")break;
   wq=wq.split(" ").map(Number);
   var w=wq[0];
   var W=[];
   for(var i=0;i<w;i++)W[i]=true;
   var cat={};
   while(wq[1]--){
      var sw=arr.shift().split(" ");
      if(sw[0]=="s"){
         var id=sw[1];
         var width=sw[2]-0;
         var cnt=0;
         var ans="impossible";
         for(var i=0;i<w;i++){
            cnt=(W[i])?cnt+1:0;
            if(cnt==width){
              while(cnt--){W[i]=false;i--;}
               i++;
               cat[id]=[i,width];
               ans=i;
               break;
            }
         }
         console.log(ans);
      }
      if(sw[0]=="w"){
         var id=sw[1];
         var width=cat[id][1];
         var i=cat[id][0];
         while(width--){W[i]=true;i++;}
      }
   }
   console.log("END");
}

Measured memory_bytes: 16988
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N, M;
  int color[50][3] = {{}};
  const string temp = "WBR";
  
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    string S;
    cin >> S;
    for(char& c : S) color[i][temp.find(c)]++;
  }
  for(int i = 1; i < N; i++) {
    for(int j = 0; j < 3; j++) color[i][j] += color[i - 1][j];
  }

  int ret = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N - 1; j++) {
      ret = max(ret, color[i][0] + color[j][1] - color[i][1] + color[N - 1][2] - color[j][2]);
    }
  }
  cout << M * N - ret << endl;
}

Measured memory_bytes: 3144
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int a, b;

int main() {
	cin >> a >> b;
	cout << (a % 2 && b % 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans=0;
        int t=0;
        for(int i=0;i<3;i++)
        {
            if(s[i]=='o') t++;
        }
        ans=t*100+700;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
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;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll A, ll B, ll C, ll X){
    ll cnt = 0;
    rep2(i, 0, A) rep2(j, 0, B) rep2(k, 0, C) cnt += (X == 500 * i + 100 * j + 50 * k);
    cout << cnt << "\n";
}

int main() {
    ll A;
    ignore_ret(scanf("%lld",&A));
    ll B;
    ignore_ret(scanf("%lld",&B));
    ll C;
    ignore_ret(scanf("%lld",&C));
    ll X;
    ignore_ret(scanf("%lld",&X));
    solve(A, B, C, X);
    return 0;
}

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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


  int main(){
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    REP(i, S.size()){
      if(i == A && S.at(i) != '-') {
        no;
        return 0;
      }
      if(i != A && S.at(i) == '-'){
        no;
        return 0;
      }

    }
    yes;
  }

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);

    let mut pref = vec![vec![]; N + 1];
    for i in 0..M {
        let (p, y) = read!(usize, i64);

        pref[p].push((y, i));
    }

    let mut numbers = vec![];

    for p in 1..N + 1 {
        pref[p].sort();

        numbers.extend(
            pref[p]
                .iter()
                .enumerate()
                .map(|(x, &(y, i))| (i, format!("{:>06}{:>06}", p, 1 + x))),
        );
    }

    numbers.sort();
    for (_, n) in numbers {
        println!("{}", n)
    }
}


Measured memory_bytes: 23032
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int DP[101][10001];
int main(){
	int N,W;
	int v[100],w[100];
	cin>>N>>W;
	FOR(i,0,N){
		cin>>v[i]>>w[i];
	}
	FOR(i,0,N){
		FOR(j,0,W+1){
			DP[i+1][j]=max(DP[i+1][j],DP[i][j]);
			if(W-j>=w[i]){
				DP[i+1][j+w[i]]=max(DP[i+1][j+w[i]],DP[i][j]+v[i]);
			}
		}
	}
	cout<<DP[N][W]<<endl;
	return 0;
}


Measured memory_bytes: 7020
#include "iostream"
#include "string"
#include "cctype"


int main()
{
	std::string line, word;
	int count = 0;
	std::cin >> word;
	for (int i = 0; i < word.length(); i++)
		if (isupper(word[i]))
			word[i] = tolower(word[i]);

	while (1) {
		std::cin >> line;
		if (line == "END_OF_TEXT") break;
		for (int i = 0; i < line.length(); i++)
			if (isupper(line[i]))
				line[i] = tolower(line[i]);
		if (line == word)
			count++;
	}
	std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 3168
N = int(input())
As = list(map(int, input().split()))

cond1s = {}
cond2s = {}

for i in range(N):
	c1 = i + 1 - As[i]
	c2 = i + 1 + As[i]
	if c1 in cond1s:
		cond1s[c1] += 1
	else:
		cond1s[c1] = 1
	if c2 in cond2s:
		cond2s[c2] += 1
	else:
		cond2s[c2] = 1

ans = 0
for k in cond1s.keys():
	if k in cond2s:
		ans += cond1s[k] * cond2s[k]

print(ans)

Measured memory_bytes: 57292
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    long A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = K; i < N; i++)
    {
        if (A[i - K] < A[i])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 5108
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n, k;
	cin >> n >> k;
	bool d[10];
	REP(i, 10) d[i] = true;
	REP(i, k){
		cin >> tmp;
		d[tmp] = false;
	}
	bool ch = false;
	int keta = 1;
	REP1(i, 99999){
		if(i >= 10000) keta = 5;
		else if(i >= 1000) keta = 4;
		else if(i >= 100) keta = 3;
		else if(i >= 10) keta = 2;
		else keta = 1;
		if (i >= n && !ch){
			ch = true;
			ans = i;
			string hoge = to_string(i);
			REP(j, keta) if(!d[hoge[j]-'0']) ch = false;
		}
	}
	cout << ans << endl;
}

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

int main() {
  string b;
  cin >> b;
  int len = b.size();
  int score, nowscore = 0;
  bool flag = false;
  for (int i = 0; i < len; i++){
    if(!flag){
      if ((b.at(i) == 'A')||(b.at(i) == 'T')||(b.at(i) == 'G')||(b.at(i) == 'C')){
        flag = true;
        nowscore = 1;
      }
    }
    else{
      if ((b.at(i) == 'A')||(b.at(i) == 'T')||(b.at(i) == 'G')||(b.at(i) == 'C')){
        nowscore++;
      }
      else{
        flag = false;
        if (nowscore > score){
          score = nowscore;
        }
      }
    }
  }
  if (nowscore < score)
  cout << score << endl;
  else
  cout << nowscore << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T;cin>>N>>T;
  vector<int> S(N),A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  A[0]=S[0];
  B[N-1]=S[N-1];
  for(int i=1;i<N;i++){
    if(S[i]<A[i-1]) A[i]=S[i];
    else A[i]=A[i-1];
  }
  for(int i=N-2;i>=0;i--){
    if(S[i]>B[i+1]) B[i]=S[i];
    else B[i]=B[i+1];
  }
  int rieki=0,cnt=0,x=0,y=0;
  for(int i=0;i<N-1;i++){
    if(B[i+1]-A[i]>rieki){
      rieki=B[i+1]-A[i];
      cnt=1;
    }
    else if(B[i+1]-A[i]==rieki&&!(A[i]==A[i-1]&&B[i+1]==B[i])) cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	string S;
	cin >> S;
	int D;
	cin >> D;
	int N = S.size();

	ll mod = 1e9 + 7;
	ll dp1[10001][101] = {};
	ll dp2[10001][101] = {};
	dp1[0][0] = 1;

	rep(i, N) {
		int C = S[i] - '0';

		rep(j, 10) {
			if (j < C) {
				rep(k, D) {
					dp2[i + 1][(j + k) % D] += dp1[i][k];
					dp2[i + 1][(j + k) % D] %= mod;
				}
			}
			if (j == C) {
				rep(k, D) {
					dp1[i + 1][(j + k) % D] += dp1[i][k];
					dp1[i + 1][(j + k) % D] %= mod;
				}
			}
			rep(k, D) {
				dp2[i + 1][(j + k) % D] += dp2[i][k];
				dp2[i + 1][(j + k) % D] %= mod;
			}
		}
	}

	co((dp1[N][0] + dp2[N][0] - 1 + mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] weight =new int[N];
		int min =Integer.MAX_VALUE;

		for(int i=0;i<N;i++) {
			weight[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			int sum1=0;
			int sum2=0;
			for(int j=0;j<=i;j++) {
				sum1+=weight[j];
			}
			for(int k=i+1;k<N;k++) {
				sum2+=weight[k];
			}
			int dif = Math.abs(sum1-sum2);
			if(dif<min) {
				min=dif;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 23636
W, H, N = map(int, input().split())
x = [0, W]
y = [0, H]
a = []

for i in range(N):
  A = list(map(int, input().split()))
  a.append(A)

for j in a:
  if j[2] == 1:
    x[0] = max(x[0], j[0])
  elif j[2] == 2:
    x[1] = min(x[1], j[0])
  elif j[2] == 3:
    y[0] = max(y[0], j[1])
  else:
    y[1] = min(y[1], j[1])
    
if x[0] >= x[1] or y[0] >= y[1]:
  print('0')
else:
  ans = (x[1] - x[0]) * (y[1] - y[0])
  print(int(ans))

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;

public class Main{
	String name;
	int time;
	static int totalTime = 0;


	

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		String line = in.nextLine(); 
		String[] words = line.split(" ");
		Problem currentItem;
		Queue<Problem> myQueue = new LinkedList<Problem>();
		int pro = Integer.parseInt(words[0]);
		int Required = Integer.parseInt(words[1]);

		for(int i = 0; i < pro; i++) {
			line = in.nextLine(); 
			words = line.split(" ");
			myQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));
			//System.out.println("added to queue: " + words[0]);
		}
		in.close();


		//System.out.println("StartQueue");
		while(!myQueue.isEmpty()) {
			//System.out.println("Queue Not Empty");
			if(((Problem) myQueue.peek()).time > 0){
				//System.out.println("IF1");
				if(((Problem) myQueue.peek()).time > Required){
					//System.out.println("IF2");
					currentItem = ((Problem) myQueue.peek()); 
					myQueue.remove();
					currentItem.time -= Required;
					totalTime += Required;
					myQueue.offer(currentItem);
				}else {
					currentItem = ((Problem) myQueue.peek()); 
					myQueue.remove();
					totalTime += currentItem.time;
					System.out.println(currentItem.name + " " + totalTime);
				}
			}else {
				System.out.println(((Problem) myQueue.peek()).name + " " + totalTime);
				myQueue.remove();

			}
		}


	}
}
	class Problem {
	String name;
	int time;
	public Problem(String name, int time){
		this.name = name;
		this.time = time;
	}
	}


Measured memory_bytes: 106352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int q;
  cin >> q;

  ll y = 0;
  ll sum1 = 0, sum2 = 0;
  priority_queue<ll,vector<ll>,greater<ll>> q1;
  priority_queue<ll> q2;

  while(q--){
    int type; cin >> type;
    if(type==1){
      ll a,b; cin >> a >> b;
      y += b;
      if(q2.empty() || a <= q2.top()){
        q2.push(a);
        sum2 += a;
        if(q2.size()>q1.size()+1){
          int tmp = q2.top(); q2.pop();
          q1.push(tmp);
          sum2 -= tmp; sum1 += tmp;
        }
      } else {
        q1.push(a);
        sum1 += a;
        if(q1.size()>q2.size()){
          int tmp = q1.top(); q1.pop();
          q2.push(tmp);
          sum2 += tmp;  sum1 -= tmp;
        }
      }
    } else {
      ll ans1 = q2.top();
      ll ans2 = y + (sum1-ans1*q1.size()) + (ans1*q2.size()-sum2);
      cout << ans1 << " " << ans2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3828
#include <stdio.h>
#include <math.h>

int main()
{
    int n, t=0;
    scanf("%d", &n);
    n+=1;
    while(n--)
    {
        if(((int)log10(n)+1)%2 == 1)
            t++;
    }
    printf("%d\n", t);

    return 0;
}


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


int main() {
    string s;
    cin >> s;
    bool odd = (s.size() % 2) == 1;
    if (odd) {
        if ((s[0] == s.back())) printf("Second\n");
        else printf("First\n");
    } else {
        if ((s[0] == s.back())) printf("First\n");
        else printf("Second\n");      
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long long int lli;

vector<vector<int> > g;

int depth(int s) {
  if (g[s].size() == 0) return 0;
  vector<int> v;
  for (auto index : g[s]) {
    v.push_back(depth(index));
  }

  sort(v.begin(), v.end(), greater<int>());

  int ans = 0;
  REP (i, 1, v.size() + 1) {
    ans = max(ans, v[i - 1] + i);
  }
  return ans;
}


int main(){
  lli N;
  cin >> N;
  g.resize(N);
  REP (i, 1, N) {
    int temp;
    cin >> temp;
    g[temp - 1].push_back(i);
  }

  cout << depth(0) << endl;
  
  return 0;
}


Measured memory_bytes: 13568
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] l = new int[n];
			for (int i = 0; i < n; i++) {
				l[i] = sc.nextInt();
			}
			Arrays.sort(l);
			int result = 0;
			for (int i = 0; i < n - 2; i++) {
				for (int j = i + 1; j < n - 1; j++) {
					for (int k = j + 1; k < n; k++) {
						if (check(l[i], l[j], l[k])) {
							result++;
						} else {
							break;
						}
					}
				}
			}
			System.out.println(result);
		}
	}

	private static boolean check(int a, int b, int c) {
		return a + b > c && b + c > a && c + a > b;
	}
}


Measured memory_bytes: 28612
#include <stdio.h>
#define AMAX 20
#define MIMAX 2000
int main(){
  int i, j;
  int n, q, num;
  int one[MIMAX+1] = {0};
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%d", &num);
    for(j = MIMAX-num; 0 < j; j--){
      if(one[j]){
        one[j+num] = 1;
} }
    one[num] = 1;
  }
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &num);
    if(one[num]){
      printf("yes\n");
    }
    else printf("no\n");
  }
return 0; }


Measured memory_bytes: 2104
const processData = (lines) => {
  const k = +lines[0]
  const [a, b] = lines[1].split(' ').map(x => +x)

  const aK = Math.floor(a/k)
  const bK = Math.floor(b/k)

  if (aK !== bK) {
    console.log('OK')
  } else {
    if(a%k === 0 || b%k === 0) {
      console.log('OK')
    } else {
      console.log('NG')
    }
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


Measured memory_bytes: 29872
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, A;
    cin >> X >> A;
    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ///////////////////
  map<ll,ll> m;
  rep(i,n){
  	
  	m[a[i]]++;
  }
  ll cnt=0;
   rep(i,n){
     ll x=m[i+1];
     cnt+= x*(x-1)/2;
   }
  rep(i,n){
  ll ans=cnt;
  ll v=m[a[i]];  //何個あるか
  ans-=v*(v-1)/2;
    v--;
    ans+=v*(v-1)/2;
  cout<<ans<<endl;
  }
}



Measured memory_bytes: 16896
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int a[200010]={};
	int ans[200010]={};

	cin >> N;
	for(int i=1;i<=N;i++)
		cin >> a[i];
	
	for(int i=N;i>0;i--)
	{
		int Sum=0;
		for(int j=i;j<=N;j+=i)
			Sum+=ans[j];
		if(Sum%2!=a[i])
			ans[i]=1;
	}

	vector<int> vec;
	for(int i=1;i<=N;i++)
		if(ans[i]==1)
			vec.push_back(i);
	
	cout << vec.size() << endl;
	for(int i=0;i<vec.size();i++)
	{
		cout << vec[i];
		if(i==vec.size()-1)
			cout << endl;
		else 
			cout << " ";
	}
	return 0;
}


Measured memory_bytes: 3320
qq = concat $ map qqset [1..9]  -- the set of all QQ lines
qqset a = map (qqline a) [1..9] -- the set of QQ lines for a given factor a
qqline a b = (show a) ++ "x" ++ (show b) ++ "=" ++ (show (a * b))

main = putStr $ unlines qq

Measured memory_bytes: 3408
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  int x, y;  cin >> x >> y;

  rep (i, x + 1) {
    if (i * 2 + (x - i) * 4 == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}

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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int n;
set<int> u[100005];
set<int> v[100005];
int rp[100005];

int gl(int i) {
    return i == rp[i] ? i : rp[i] = gl(rp[i]);
}

int main() {
    scanf("%d", &n);
    FO(i,0,n-1) {
        int x, y;
        scanf("%d %d", &x, &y);
        u[x].insert(y);
        u[y].insert(x);
    }
    FO(i,0,n-1) {
        int x, y;
        scanf("%d %d", &x, &y);
        v[x].insert(y);
        v[y].insert(x);
    }
    FO(i,1,n+1) rp[i] = i;
    queue<pair<int,int> > q;
    FO(i,0,n) {
        for (int j : u[i]) if (v[i].count(j)) q.emplace(i,j);
    }
    int nm = 0;
    while (sz(q)) {
        int i, j; tie(i,j) = q.front(); q.pop();
        i = gl(i); j = gl(j);
        if (i == j) continue;
        if (sz(u[i])+sz(v[i]) > sz(u[j])+sz(v[j])) swap(i,j);
        for (int k : u[i]) {
            if (k == i || k == j) continue;
            u[k].erase(i);
            u[k].insert(j);
            if (v[j].count(k)) q.emplace(j,k);
            u[j].insert(k);
        }
        for (int k : v[i]) {
            if (k == i || k == j) continue;
            v[k].erase(i);
            v[k].insert(j);
            if (u[j].count(k)) q.emplace(j,k);
            v[j].insert(k);
        }
        u[i].clear(); v[i].clear();
        rp[i] = j;
        nm++;
    }
    if (nm == n-1) puts("YES");
    else puts("NO");
}



Measured memory_bytes: 29796
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;
using ull = unsigned long long;

vector<int> v;

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

    int n;
    cin >> n;
    rep(i, n){
        int w; cin >> w;
        v.push_back(w);
    }

    int ans = 1000000000;
    rep(i, n){
        int sum1 = 0, sum2 = 0;

        for(int j = 0; j <= i; ++j){
            sum1 += v[j];
        }

        for(int j = i + 1; j < n; ++j){
            sum2 += v[j];
        }
        
        int sub = abs(sum1 - sum2);
        ans = std::min(ans, sub);
    }

    cout << ans << next;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main()
{
    int k, x;
    cin >> k >> x;

    int l = x - k + 1;
    int r = x + k - 1;

    for (int i = l; i <= r; i++)
    {
        if (i == r)
        {
            cout << i << endl;;
        }
        else
        {
            cout << i << " ";
        }
    }
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement
N,M,Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
values = set(i for i in range(1,M+1))
ans = 0
for A in combinations_with_replacement(values, N):
    cnt = 0
    for a,b,c,d in abcd:
        if A[b-1] - A[a-1] == c:
            cnt += d
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 9132
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
c1 = sorted(list(dict(Counter(v[::2])).items()), key=lambda x: x[1])
c2 = sorted(list(dict(Counter(v[1::2])).items()), key=lambda x: x[1])
if c1[-1][0] != c2[-1][0]:
    print(n-c1[-1][1]-c2[-1][1])
elif len(c1) == len(c2) == 1:
    print(n//2)
elif len(c1) == 1:
    print(n//2-c2[-2][1])
elif len(c2) == 1:
    print(n//2-c1[-2][1])
else:
    print(min(n-c1[-1][1]-c2[-2][1], n-c1[-2][1]-c2[-1][1]))


Measured memory_bytes: 70380
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        int N = sc.nextInt();
        int K = sc.nextInt();

        if (K == 1) {
            out.println(0);
        } else {
            out.println(N-K);
        }

        out.flush();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int N) {
            int a[] = new int[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextInt();
            }

            return a;
        }

        long[] nextLongArray(int N) {
            long a[] = new long[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextLong();
            }

            return a;
        }

        double[] nextDoubleArray(int N) {
            double a[] = new double[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextDouble();
            }

            return a;
        }

        String[] nextTokenArray(int N) {
            String a[] = new String[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextToken();
            }

            return a;
        }
    }
}

Measured memory_bytes: 22996