akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
    int a,b,i,tmp;
    scanf("%d%d",&a,&b);
    while (a%b!=0 && b%a!=0){
        if (a<b){
            tmp = b-a;
            b = tmp;
        }
        else {
            tmp = a-b;
            a = tmp;
        }
    }

    if (a<=b) printf("%d\n",a);
    else printf("%d\n",b);  // c언어 사용할 때에는 마지막줄에 \n하는거 까먹지말기.

    return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    char a, b;
    cin >> a >> b;
    if(a-'a' > b-'a')cout << ">" << endl;
    else if (a-'a' < b-'a')cout << "<" << endl;
    else cout << "=" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}

#pragma endregion



int main(void) {
	int a,b;

	i_cin2(a,b);
	
	if ((a<=0) && (b>=0)) { s_cout("Zero "); return 0; }
	if ((a>0&&b>0)||(b-a)%2) { s_cout("Positive "); return 0; }
	
	s_cout("Negative ");
	
	return 0;
}







Measured memory_bytes: 128
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    next :: Maybe Digits -> Maybe ([Int], Maybe Digits)
    next = fmap next'
      where
        next' :: Digits -> ([Int], Maybe Digits)
        next' = (,) <$> map snd . reverse <*> succDs
  mapM_ putStrLn . map (('a' :) . map toLEL) . unfoldr next . Just . zeroes $ n

type Digits = [(Int, Int)]

extend :: Digits -> Digits
extend [] = (1, 0) : []
extend ds@((m, k) : _) = (max m (succ k), 0) : ds

zeroes :: Int -> Digits
zeroes 1 = []
zeroes l  = extend . zeroes . pred $ l

succDs :: Digits -> Maybe Digits
succDs [] = Nothing
succDs ((m, k) : ds) | k < m = Just ((m, succ k) : ds)
succDs (_ : ds) = extend <$> succDs ds

showDs :: Digits -> String
showDs = ('a' :) . map (toLEL . snd) . reverse

toLEL :: Int -> Char
toLEL = toEnum . (fromEnum 'a' +)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll modulo=1000000007ll;

ll binpow(ll a, ll n)
{
	if(n==0)
		return 1;
	if(n%2==0)
	{
		return ((binpow(a,n/2))*binpow(a,n/2));
	}
	else
	{
		return binpow(a,n/2)*binpow(a,n/2)*a;
	}
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    	int h,n;
    	cin>>h>>n;
    	vector<ll> value(n),cost(n);
    	for(int i=0;i<n;++i)
    	{
    		ll a,b;
    		cin>>a>>b;
    		value[i]=a;
    		cost[i]=b;
    	}

    	vector<vector<ll> > dp(n+1,vector<ll>(h+1,0));
    	for(int i=1;i<=h;++i)
    	{
    		dp[0][i]=INT_MAX;
    	}

    	for(int i=1;i<=n;++i)
    	{
    		for(int j=1;j<=h;++j)
    		{
    			ll a=0;
    			int h=std::max(j-value[i-1],a);
    			dp[i][j]=min(dp[i][h]+cost[i-1],dp[i-1][j]);
    		
    		//cout<<dp[i][j]<<" ";
    		}
    		//cout<<endl;	
    	}


    	cout<<dp[n][h]<<endl;


    

}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll a[n];
    ll sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    sum /= 2;
    // cout << sum << endl;
    vector<ll> ans(n);
    // even
    ll rem = 0;
    for(int i=1;i<n;i+=2){
        rem += a[i];
    }
    for(int i=0;i<n;i+=2){
        // cout << rem << endl;
        if(i - 2 >= 0){
            rem -= a[i-1];
            rem += a[i-2];
        }
        ans[i] = sum - rem;
    }
    // odd
    rem = 0;
    for(int i=2;i<n;i+=2){
        rem += a[i];
    }
    for(int i=1;i<n;i+=2){
        if(i - 2 >= 0){
            rem -= a[i-1];
            rem += a[i-2];
        }
        ans[i] = sum - rem;
    }
    for(ll a: ans) cout << 2*a << " ";
    cout << endl;
}

Measured memory_bytes: 2944
#include <stdio.h>
int main(){
  int a, b, c, k, ans=0;
  scanf("%d %d %d %d", &a, &b, &c, &k);
  if(k>a){
    ans=a;
    k=k-a;
    if(k>b){
      k=k-b;
      ans-=k;
      printf("%d\n", ans);
    }
    else printf("%d\n", ans);
  }
  else printf("%d\n", k);
}

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

int main(){
	int n, s;
	int *a, *b;

	cin >> n;
	a = new int[n];
	b = new int[n];

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

	s = 0;
	for (int i=0; i<n; i++){
		if (a[i] > b[i]) 
			s += a[i] - b[i];
	}
	
	cout << s;
	}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();

    boolean [] a = new boolean[n];
    int [] g = new int[n];
    for (int t = 0;t<n;t++){
      a[t] = true;
      g[t] = 0;
    }

    for (int i=0; i<m; i++){
      int b = scan.nextInt();
      if (a[b-1] == false){
        int gg = scan.nextInt();
        if (gg != g[b-1]){
          System.out.println(-1);
          return;
        }
      }
      else{
        a[b-1] = false;
        int c = scan.nextInt();
        g[b-1] = c;
        if ((c == 0)&&(b == 1)&&(n != 1)){
          System.out.println(-1);
          return;
        }
      }
    }

    if ((g[0] == 0) && (n == 1)){
      System.out.println(0);
      return;
    }

    if (g[0] == 0){
      g[0] = 1;
    }

    for (int t = 0;t<n;t++){
      System.out.print(g[t]);
    }
    System.out.println("");
  }
}


Measured memory_bytes: 35804
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int N;
  ll x;
  cin >> N >> x;
  ll a[N];
  ll ans = 0;

  for(int i=0;i<N;i++){
  	cin >> a[i];
  	if(a[i]>x){
  		ans += a[i] - x;
  		a[i] = x;
  	}
  }

  

  for(int i=1;i<N;i++){
  	if(a[i]+a[i-1]>x){
  		ans += a[i]+a[i-1]-x;
  		a[i] -= a[i]+a[i-1]-x;
  	}
  }

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













Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll n,a,b; cin>> n>>a>>b;
  if(n==1){
    if(a==b){
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  ll min_v = (n-1) * a + b;
  ll max_v = (n-1) * b + a;
  cout << max(max_v - min_v + 1,0LL) << endl;
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
input=stdin.readline().rstrip().split()

N=int(input[0])
L=int(input[1])

aji_list=[L+i for i in range(N)]

min_abs=200
for j in aji_list:
    if abs(j)<abs(min_abs):
        min_abs=j

output=sum(aji_list)-min_abs
print(output)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    dic = {}
    for i in range(n):
        a = ''.join(sorted(input().rstrip()))
        if a in dic:
            dic[a] += 1
        else:
            dic[a] = 1
    su = 0
    for v in dic.values():
        su += v * (v - 1) // 2
    print(su)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17852
#include <bits/stdc++.h>
using namespace std;
 
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
void fastscan(int &x)
 {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    } 
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int inf = 2e18+5;
const int nax = 100010;
const int mod1 = 998244353;

signed main()
 {
   
   int n,k;
      cin>>n>>k;
      int ans = min(n%k,k - (n%k));
      cout<<ans;

      
     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
string n;
int k;
long long dp[120][4];//开头不为零
long long pd[120][4];//开头为零 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	int dig=n.size();
	n="?"+n;
	for(int i=1;i<=dig;i++){
		dp[i][1]=9LL;
		dp[i][2]=(long long)(i-1)*81LL;
		dp[i][3]=(long long)(i-1)*(long long)(i-2)/2LL*729LL;
	}
	for(int i=1;i<=dig;i++){
		pd[i][0]=1LL;
		for(int j=0;j<i;j++){//不为零的位数 
			pd[i][1]+=dp[j][1];
			pd[i][2]+=dp[j][2];
			pd[i][3]+=dp[j][3];
		}
	}
	int nzr=0;
	long long res=0LL;
	for(int i=1;i<=dig;i++){
		//1~i-1:same as n
		//i:<n
		if(n[i]!='0'){
			//1.==0
			res+=pd[dig-i+1][k-nzr];
			//2.!=0
			res+=dp[dig-i+1][k-nzr]/9LL*(long long)(n[i]-'0'-1);
			nzr++;
		}
		if(nzr>k)
			break;
	}
	if(nzr==k)
		res+=1LL;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:52 on 2019-08-24.
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll inf = ll(1e9);
const ll mod = inf + 7;
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];

    vl a0(n);
    rep(i, n - 1) {
        for (ll j = i + 1; j < n; ++j) {
            if (a[i] > a[j]) a0[i]++;
        }
    }
    vl vals(n);
    rep(i, n) {
        rep(j, n) {
            if (a[i] > a[j]) vals[i]++;
        }
    }
    ll ans = 0;
    rep(i, n) {
        ans += a0[i] * k % mod;
        ans += (vals[i] * (((k * (k - 1)) / 2 % mod) % mod)) % mod;
        ans %= mod;
    }

    cout << ans << '\n';

}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

int CalHeight(int Cx, int Cy, int H, int h, int x, int y) {
	if (h != 0)
		return abs(x - Cx) + abs(y - Cy) + h;
	else if (H <= abs(x - Cx) + abs(y - Cy)) return H;
	else return -1;
}

int main() {
	int N, cnt = 0, hs, xs, ys;
	cin >> N;
	int *x = new int[N];
	int *y = new int[N];
	int *h = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0) {
			hs = h[i];
			xs = x[i];
			ys = y[i];
		}
	}
	for (int Cx = 0; Cx <= 100; Cx++) {
		for (int Cy = 0; Cy <= 100; Cy++) {
			int H = abs(xs - Cx) + abs(ys - Cy) + hs;
			for (int i = 0; i < N; i++) {
				if (H != CalHeight(Cx, Cy, H, h[i], x[i], y[i]))break;
				if (i == N - 1) {
					cout << Cx << " " << Cy << " " << H << " " << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,q;
  cin>>n>>k>>q;
  vector<int > vec (n,0);
  int qq=q;
  while(q--)
  {
      int indx;
      cin>>indx;
      vec[indx-1]++;

  }

  for(int i=0;i<n;i++)
  {
      if(vec[i]-qq+k<=0)
      {
          cout<<"No"<<endl;
      }
      else
      {
          cout<<"Yes"<<endl;
      }
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
using namespace std;
string rez;
int V[5];
char C[10];
void btr(int pas,int sum)
{
    if(pas>4)
    {
        if(sum==7)
        {
            rez+="=7";
            cout<<rez;
            exit(0);
        }
        return ;
    }
    rez+="+";rez+=(V[pas]+'0');
    btr(pas+1,sum+V[pas]);
    rez[rez.size()-2]='-';
    btr(pas+1,sum-V[pas]);
    rez.pop_back();
    rez.pop_back();
}
int main()
{
    cin.getline(C+1,5);
    for(int i=1;i<5;i++)
        V[i]=C[i]-'0';
    rez+=(V[1]+'0');
    btr(2,V[1]);
    return 0;
}


Measured memory_bytes: 256
data = list(map(int, input().split()))

a = data[2]-data[0]
b = data[3]-data[1]

x3 = data[2]-b
y3 = data[3]+a
x4 = x3-a
y4 = y3-b
print(str(x3)+" "+str(y3)+" "+str(x4)+" "+str(+y4))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();

        int c = t /a;
        System.out.println(b * c);

    }

}


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

using namespace std;



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

	int num_choice = 1 << n;

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

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

	vector<int> p(num_choice);

	for (int i = 0; i < num_choice; i++)
	{
		int p_=0;
		for (int j = 0; j < n; j++) {
			//cout << i << '\t' << j << '\t' << (i & (1 << j)) << endl;
			if ((i & (1 << j)) != 0) {
				p_ += v[j] - c[j];
			}
		}
		p[i] = p_;
	}
	sort(p.begin(), p.end(), std::greater<int>());
	cout << p[0];
	return 0;
}

Measured memory_bytes: 4352
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

num_list = [i+1 for i in range(N)]

a = 1
for i in list(itertools.permutations(num_list)):
    if P==i:
        break
    else:
        a += 1
b = 1
for i in list(itertools.permutations(num_list)):
    if Q==i:
        break
    else:
        b += 1

if a-b>=0:
    print(a-b)
else:
    print(-a+b)

Measured memory_bytes: 13932
n = gets.to_i
a = gets.split.map(&:to_i)
sum = 0
a.each do |v|
  sum += v
end
avg = sum / n.to_f
minDiff = avg
ans = nil
n.times do |i|
  diff = (a[i] - avg).abs
  if diff < minDiff
    ans = i
    minDiff = diff
  end
end
p ans


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long ll;

int pw[50],N;

class UnionFind {
public:
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

class Edge
{
public:
	int src, dst;
	Edge(int src, int dst)
	:src(src),dst(dst)
	{}
};

typedef vector<vector<Edge> > Graph;

ll paint[40], rest[40];
ll relt;

ll dfs(int p, ll used, ll score, Graph& g, vector<int>& group)
{	
	if(p==group.size()) return score;
	if(used >> group[p] & 1) return dfs(p+1, used, score, g, group);
	if(score + rest[group[p]] <= relt) return 0;

	ll res = score;
	ll tmp = used | paint[group[p]];
	res = max(res, dfs(p+1, tmp, score+pw[group[p]], g, group));
	res = max(res, dfs(p+1, used, score, g, group));
	
	relt = max(res, relt);
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	while(cin >> N, N) {
		memset(rest, 0, sizeof(rest));

		int gcnt = 0;
		map<string, int> dic;
		Graph graph(N);
		UnionFind uf(N);

		for(int i=0; i<N; i++) {
			string src;
			cin >> src;

			if(!dic.count(src)) dic[src] = gcnt++;
			int s = dic[src];

			cin >> pw[s];
	
			int M;
			cin >> M;
			
			for(int i=0; i<M; i++) {
				string dst;
				cin >> dst;
				
				if(!dic.count(dst)) dic[dst] = gcnt++;
				int t = dic[dst];

				graph[s].push_back(Edge(s,t));
				uf.unionSet(s,t);
			}
		}

		for(int i=0; i<N; i++) {
			paint[i] = (1LL << i);
			for(int j=0; j<graph[i].size(); j++) {
				paint[i] |= (1LL << graph[i][j].dst);
			}
		}

		vector<vector<int> > groups(N);

		for(int i=0; i<N; i++) {
			groups[uf.root(i)].push_back(i);
			rest[uf.root(i)] += pw[i];
		}

		for(int i=0; i<N; i++) {
		for(int j=0; j<groups[i].size(); j++)
			rest[groups[i][j]] = rest[uf.root(groups[i][j])];
		}

		for(int i=0; i<groups.size(); i++) {
			for(int j=1; j<groups[i].size(); j++) {
				rest[groups[i][j]] = rest[groups[i][j-1]] - pw[groups[i][j-1]];
			}
		} 

		ll res = pw[0];
		ll init = paint[0];
		for(int i=0; i<groups.size(); i++) {
			if(groups[i].size() == 0) continue;
			relt = 0;
			res += dfs(0, init, 0, graph, groups[i]);
		} 

		cout << res << endl;
	}
}

Measured memory_bytes: 960
import java.util.Scanner;

public class Main {	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int d = scan.nextInt();
		int n = scan.nextInt();
		if (d == 0) {
			if (n == 100) {
				System.out.println(n+1);
			} else {
				System.out.println(n);
				return;			
			}
		}
		if (d == 1) {
			if (n == 100) {
				System.out.println((n+1)*100);
			} else {
				System.out.println(n*100);
				return;			
			}
		}
		if (d == 2) {
			if (n == 100) {
				System.out.println((n+1)*10000);
			} else {
				System.out.println(n*10000);
				return;			
			}
		}
	}
}


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

int main(int argc, char **argv)
{
	int N;
	scanf("%d", &N);
	char S[100], T[100];
	scanf("%s %s", S, T);
	for (int i = 0; i < N; i++)
		printf("%c%c", S[i], T[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
arr = Array.new
renge = (0..9).to_a
while n = gets
   arr << n.to_i
end
arr.each do |i|
   count = 0
   renge.repeated_permutation(4) do |a,b,c,d|
      if i == a + b + c + d
         count += 1
      end
   end
   puts count
end

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

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;

vector<string> Grid(402);
vector<vector<bool>> Visited(402, vector<bool>(402, false));
ll answer = 0;
ll n, m, i, j;
ll a[4] = {0,0,1,-1};
ll b[4] = {1,-1,0,0};

bool inside(pair<ll,ll> src)
{
    return (src.f<n) && (src.f>=0) && (src.s<m) && (src.s>=0) ;
}

pair<ll,ll> BFS(pair<ll, ll> src)
{
    pair<ll,ll>  t1(0,0);
    Visited[src.f][src.s] = true;
    if (Grid[src.f][src.s] == '#')
    {
        for(ll i=0;i<4;i++)
        {
            auto temp = mp(src.f+a[i],src.s+b[i]);
            // cout << temp.f << ' ' << temp.s << '\n';
            if (inside(temp) && (Grid[temp.f][temp.s] == '.' && !Visited[temp.f][temp.s])){
                temp = BFS(temp);
                t1.f += temp.f;
                t1.s += temp.s;
            }
        }
        t1.s++;
        return t1;
    }
    else
    {
        for(ll i=0;i<4;i++)
        {
            auto temp = mp(src.f+a[i],src.s+b[i]);
            // cout << temp.f << ' ' << temp.s << '\n';
            if (inside(temp) && (Grid[temp.f][temp.s] == '#' && !Visited[temp.f][temp.s])){
                temp = BFS(temp);
                t1.f += temp.f;
                t1.s += temp.s;
            }
        }
        t1.f++;
        return t1;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    cin >> n >> m;
    for (i = 0; i < n; i++)
        cin >> Grid[i];
    ll answer = 0;
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            if (!Visited[i][j]){
                auto temp = BFS(mp(i,j));
                answer += temp.f*temp.s;
            }
    cout << answer;
    return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define sz(v) (ll)v.size()
#define inf 100000000000000
#define vll vector<ll>
using namespace std;
const int N=25000099;
ll dp[N],dp2[N],mx;
ll a[N],b[N];

ll f(ll n)
{
	
	if(n==0)
		return 0;
	ll &ans=dp[n];
	if(ans!=-1)
		return ans;
	ans=n;
	ll i;
	for(i=0;i<3;i++)
	{
		if(n-a[i]>=0 && b[i]>a[i])
		
		{
			ans=max(ans,f(n-a[i])+b[i]);
		
			//ans=max(ans,dp2[f(n-a[i])+b[i]]);
		}
	}	
	return ans;
}
void solve()
{
	ll n,i,j;
	cin>>n;
	cin>>a[0]>>a[1]>>a[2];
	cin>>b[0]>>b[1]>>b[2];
	memset(dp,-1LL,sizeof dp);
	dp2[0]=0;
	for(i=1;i<=25000000;i++)
	{
		dp2[i]=i;
		for(j=0;j<3;j++)
			if(a[j]>b[j] && i-b[j]>=0)
				dp2[i]=max(dp2[i],dp2[i-b[j]]+a[j]);
	}

	cout<<dp2[f(n)];
	
 
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}


Measured memory_bytes: 394624
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


import fractions
def main():
    A, B = read_values()
    print(int(A * B / fractions.gcd(A, B)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5076
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> enum_div(int n)//nの約数を列挙
{
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
map<int, int> used;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v = enum_div(n);
    // REP(i, 1, n) {
    //     if(n / i == n % i) cout << i << " " << n / i << " " << n % i << endl;
    //     //cout << i << " " << n / i << " " << n % i << endl;
    // }
    int ans = 0;
    for(auto e: v) {
        int num1 = e - 1;
        int num2 = e + 1;
        if(!used[num1] && num1 > 0 && n / num1 == n % num1) ans += num1;
        if(!used[num2] && n / num2 == n % num2) ans += num2;
        used[num1] = true;
        used[num2] = true;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String[] map = new String[h];
    for (int i = 0; i < h; i++) {
      map[i] = sc.next();
    }
    int count_row = 0;
    int count_line = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (map[i].charAt(j) == '#') {
          count_row++;
          break;
        }
      }
    }
    int[] row = new int[count_row];
    int index_row = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        if(map[i].charAt(j) == '#') {
          row[index_row] = i;
          index_row++;
          break;
        }
      }
    }
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if (map[j].charAt(i) == '#') {
          count_line++;
          break;
        }
      }
    }
    int[] line = new int[count_line];
    int index_line = 0;
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if (map[j].charAt(i) == '#') {
          line[index_line] = i;
          index_line++;
          break;
        }
      }
    }
    for(int i = 0; i < index_row; i++) {
      for(int j = 0; j < index_line; j++) {
        System.out.print(map[row[i]].charAt(line[j]));
      }
      System.out.println("");
    }
  }
}


Measured memory_bytes: 26452
import sys

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

n = ni()
l = nil()
l.sort()

ans = 0
for i in range(0, 2*n-1, 2):
    if(l[i] > l[i+1]):
        ans += l[i+1]
    else:
        ans += l[i]

print(ans)



Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[20];
	scanf("%s",s);
	if(s[0] == 'S')
		printf("Cloudy\n");
	if(s[0] == 'C')
		printf("Rainy\n");
	if(s[0] == 'R')
		printf("Sunny\n");
	return(0);
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.HashSet;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		HashSet<Integer> set=new HashSet<>();
		for(int i=0;i<n;i++){
			int a=sc.nextInt();
			if(set.contains(a)){
				set.remove(a);
			}else{
				set.add(a);
			}
		}
		System.out.println(set.size());
	}
}


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

int N, M;
list<pair<int, int>> E[200010];
bool possible = true;
long D[100010];

void dfs(int u, long x) {
  D[u] = x;
  for (auto p : E[u]) {
    int v = p.first, dist = p.second;
    if (D[v] != (1L<<60)) { if (D[v] != x + dist) possible = false; }
    else {
      dfs(v, x + dist);
    }
  } 
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int l, r, d; cin >> l >> r >> d;
    l--; r--;
    E[l].push_back({r, d});
    E[r].push_back({l, -d});
  }
  for (int i = 0; i < N; i++) D[i] = (1L<<60);
  for (int i = 0; i < N; i++) if (D[i] == (1L<<60)) dfs(i, 0);
  cout << (possible ? "Yes" : "No") << endl;
}

Measured memory_bytes: 24284
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int a = x2 - x1, b = y2 - y1;
  swap(a, b); a = -a;
  x2 += a; y2 += b;
  cout << x2 << ' ' << y2 << ' ';
  swap(a, b); a = -a;
  x2 += a; y2 += b;
  cout << x2 << ' ' << y2;
}
#endif


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[100001],b[100000];
	cin>>n;
	for(int i=0;i<n+1;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	long long ans=0;
	for(int i=0;i<n;i++){
		ans+=min(a[i]+a[i+1],b[i]);
		a[i+1]-=min(max(b[i]-a[i],0),a[i+1]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <numeric>
using namespace std;

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

	for (int i = 1; i <= 3; i++)
	{
		if (a != i && b != i)
		{
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 5;
typedef pair<int,int> P;

// 辺に重みをつける場合 
struct Edge{
  int to;
  int cost;
  int time;
  Edge(int t,int c, int r) : to(t), cost(c), time(r) { }
};

using Graph = vector<vector<Edge>>;

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


	int N, M, S;
	cin >> N >> M >> S;
	if(S >= 2500) S = 2499;
	Graph G1(N);
	rep(i,M){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		--a; --b;
		G1[a].push_back(Edge(b, c, d));
    	G1[b].push_back(Edge(a, c, d));
	}

	P p[N];
	rep(i,N) cin >> p[i].first >> p[i].second;

	int dist1[N][2501];
	rep(i,N){
		rep(j,2501){
			dist1[i][j] = INF;
		}
	}

 
    priority_queue<pair<P, int>, vector<pair<P, int>>, greater<pair<P, int>>> que1;
	dist1[0][S] = 0;
    que1.push({P(0, 0), S});

    while(!que1.empty()){
        auto l = que1.top();
        que1.pop();
        int t = l.first.first;
        int u = l.first.second;
		int c = l.second;

		if(c >= 2500) continue;
		if(t > dist1[u][c]) continue;

		dist1[u][c] = t;

		for(int i = 0; i < G1[u].size(); ++i){
			int v = G1[u][i].to;
			int d1 = G1[u][i].cost;
			int d2 = G1[u][i].time;

			if(c-d1 < 0) continue;
			if(dist1[v][c-d1] > dist1[u][c] + d2){
				dist1[v][c-d1] = dist1[u][c] + d2;
				que1.push({P(t+d2, v), c-d1});
			}
		}

		
		int t1 = t + p[u].second;
		int c1 = c + p[u].first;
		
		if(c1 >= 2500) continue;
		if(dist1[u][c1] > t1){
				dist1[u][c1] = t1;
				que1.push({P(t1, u), c1});
			}
    }

	for(int i=1;i<N;i++){
		int ans = INF;
		for(int j=0;j<2500;j++){
			ans = min(ans, dist1[i][j]);
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 7244
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);


int main()
{
    string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    constexpr int LEN = 26;

    int n;
    string s;
    cin >> n >> s;

    Rep(i, s.size())
    {
        s[i] = al[(al.find(s[i]) + n) % 26];
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;

/*
  let's try computer shogi!
 */


int main(){
  ll K;
  vector<ll> A;
  cin >> K;
  A.resize(K);
  for(ll i=0;i<K;++i){
    cin >>A[i];
  }

  ll minn = 2;
  ll maxn = 3;
  if(A[K-1] != 2){
    cout << "-1"<<endl;
    return 0;
  }
  for(ll i=K-2; i>=0; --i){
    minn += (A[i] - (minn % A[i]))%A[i];
    maxn += A[i] - (maxn % A[i]) -1;
    cerr <<"sim" <<minn << ","<<maxn<<endl;
    if(minn > maxn){
      cout << "-1"<<endl;
      return 0;
    }
  }
  cout<<minn<<" "<<maxn<<endl;
  return 0;
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>




#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

int n;
vector<double> v;
vector<double> l;
vector<double> r;
double speed(double t) {
	double ret = 100;
	rep(0, n + 2) {
		double reti = 0;
		if (t <= l[i]) reti = v[i] + l[i] - t;
		else if (r[i] <= t) reti = v[i] + t - r[i];
		else reti = v[i];
		ret = min(ret, reti);
	}
	return ret;
}

//D

int main(void) {

	cin >> n;
	v = vector<double>(n + 2);
	l = vector<double>(n + 2);
	r = vector<double>(n + 2);
	v[0] = 0; l[0] = 0; r[0] = 0;
	v[n + 1] = 0;
	int T = 0;
	rep(1, n + 1) {
		int ti = 0;
		cin >> ti;
		r[i] = r[i - 1] + ti;
		l[i] = r[i - 1];
		T += ti;
	}
	l[n] = r[n - 1];
	rep(1, n + 1) {
		cin >> v[i];
	}
	l[n + 1] = T; r[n + 1] = T;
	double ans = 0;
	for (double i = 0; i < T; i += 0.5) {
		double s1 = speed(i);
		double s2 = speed(i + 0.5);
		ans += 0.25*(s1 + s2);
	}
	cout << fixed << setprecision(3) << ans << endl;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> t(n);
  REP (i, n) cin >> t[i];
  int m;
  cin >> m;
  vector< pair<int, int> > p(m);
  REP (i, m) cin >> p[i].first >> p[i].second;
  REP (i, m) {
    int sum = 0;
    REP (j, n) {
      if (j + 1 == p[i].first) sum += p[i].second;
      else sum += t[j];
    }
    cout << sum << endl;
  }
  return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> c(n);
    rep(i,k){
        int d;
        cin >> d;
        vector<int> x(d);
        rep(j,d){
            cin >> x[j];
            c[x[j]-1]=1;
        }
    }
    int counter=0;
    rep(i,n){
        if(c[i]==0){
            ++counter;
        }
    }
    cout << counter << "\n";
    return 0;
}

Measured memory_bytes: 3608
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(k, n):
        prev = A[i - k]
        now = A[i]
        print("Yes" if prev < now else "No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31608
n = int(input())
i = 1
ssum = 0
while n > ssum + 26**i:
    ssum += 26**i
    i += 1
alp = ['z'] + [chr(i) for i in range(97,97+26)]
ans = ''
import math
for j in range(1,i):
    n -= 26**j
for j in range(1,i+1):
    
    
    ans +=alp[n%26]
    ss = alp[n%26]
    
    n += 26-n%26
    n //= 26
    if ss == 'z':
        n -= 1

print(ans[::-1])


Measured memory_bytes: 9168
#include<iostream>
using namespace std;
const int BUF = 200005;


int N, D;
int pt[BUF][2];

void read() {
    cin >> N >> D;
    for (int i = 0; i < N; ++i) {
        cin >> pt[i][0] >> pt[i][1];
    }
}


void work() {
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        cnt += 1LL * pt[i][0] * pt[i][0] + 1LL * pt[i][1] * pt[i][1] <= 1LL * D * D;
    }
    cout << cnt << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

int main() 
{
	long long int a, b, c, d;
	long long ans;
	scanf("%lld", &a);
	scanf("%lld", &b);
	scanf("%lld", &c);
	scanf("%lld", &d);
	ans = (a * c > a * d) ? a * c : a * d;
	ans = (ans > b * c) ? ans : b * c;
	ans = (ans > b * d) ? ans : b * d;

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1736
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int a,b;
  cin>>a>>b;
  int ans=b/2;
  if(a<6) ans=0;
  if(a>12) ans=b;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
	　var line = Console.ReadLine().Trim();
      var N = int.Parse(line);
      line = Console.ReadLine().Trim();
      var ArrA = Array.ConvertAll<string, int>(line.Split(' '), new Converter<string, int>(s => int.Parse(s)));
		
      for(var i = 0; i < N; i++)
      {
        ArrA[i] -= (i + 1);
      }
      Array.Sort(ArrA);

      var ArrB = new int[2];
      var exist2patternflg = false;
      if (N % 2 == 0)
      {
        ArrB[0] = ArrA[N / 2 - 1];
        ArrB[1] = ArrA[N / 2];
        exist2patternflg = true;
      }
      else
      {
        ArrB[0] = ArrA[N / 2];
      }

      var sumSad = 0L;
      for(var i = 0; i < N; i++)
      {
        sumSad += Math.Abs(ArrA[i] - ArrB[0]);
      }
      WriteLine(sumSad);
      return;
	}
}

Measured memory_bytes: 30684
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector<int> vip(n+1);
    for(int i = 1; i < n+1; i++){
        scanf("%d", &vip[i]);
    }
    vector<int> viq(n+1);  //p_iの逆写像
    for(int i = 1; i < n+1; i++){
        viq[vip[i]] = i;
    }
    for(int i = 1; i < n+1; i++){
        printf("%d ", i * n + viq[i]);
    }
    printf("\n");
    for(int i = 1; i < n+1; i++){
        printf("%d ", (n - i) * n + 1);
    }
    return 0;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

int dp[2009];


void test_case()
{
    int n;
    cin>>n;

    for(int i=0; i<=2000; i++) {
        dp[i] = 0;
    }
    dp[0] = 1;
   
   for(int i=3; i<=n; i++) {
       for(int j=i; j>=3; j--) {
           dp[i] += dp[i-j];
           dp[i] = dp[i] % mod;
       }
   }

   cout<<dp[n]<<endl;
   
    
    
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

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

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 
#define inf          1e18
#define pre(y,x)        fixed<<setprecision(y)<<x
#define debug(x)        cerr << "[" << #x << ": " << (x) << "]\n";
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
		FIO;
//		ll t; cin>>t;
//		while(t--)
//		{
			int n; cin>>n;
			cout<<(1000-n%1000)%1000;
//		}
		return 0; 
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 nibab
#define y1 kebab
#define int ll

int n,a[100005],ans;

map <int,int> cnt;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i],cnt[a[i]]++;
    for(int i=1;i<=n;i++){
        if(cnt[a[i]]){
            if(cnt[a[i]]<a[i]) ans+=cnt[a[i]];
            else ans+=cnt[a[i]]-a[i];
            cnt[a[i]]=0;
        }
    }
    cout << ans;
}


Measured memory_bytes: 7040
using System;

public class Program
{
    private int N;
    private int[] L;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        L = sc.IntArray();
        Array.Sort(L);
        long cnt = 0;
        for (int i = 0; i < N - 1; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                int ab = L[i] + L[j];
                // abcが三角形
                // a+b > c
                // cが最大
                int ok = j;
                int ng = N;
                while (ng - ok > 1)
                {
                    int med = (ok + ng) / 2;
                    if (L[med] < ab)
                    {
                        ok = med;
                    }
                    else
                    {
                        ng = med;
                    }
                }

                // [j+1,ok]がcの候補
               // Console.WriteLine($"{i} {j} {ok}");
                cnt += ok - j;
            }

           
        }
        Console.WriteLine(cnt);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}


class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13184
#include<iostream>
using namespace std;
int main(){
  int n;
  int array[200005];
  int steps[200005]={0};
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>array[i];
  }
  
  for(int i=1;i<=n;i++){
    int idx=i-array[i]+1;
    if(idx>0){
      steps[idx]++;
    }
  }
  
  long long ans=0;
  for(int i=1;i<=n;i++){
    if(i+array[i]+1<=n){
      ans+=steps[i+array[i]+1];
    }
  }

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

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string t;
  cin>>t;
  int x;
  x= t.size();

  if(t.at(0)=='?'){
    t.at(0)='D';
  }
  for(int i=1;i<x;i++){
    if(t.at(i)=='?'){
      t.at(i)='D';
    }
  }
  cout<<t<<endl;
}

Measured memory_bytes: 3752