akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,H,W;
	scanf("%d %d %d",&N,&H,&W);

	int check[N*W+1];
	for(int i = 0; i < N*W+1; i++)check[i] = 0;


	int tmp,left,right;
	for(int loop = 0; loop <= N-1; loop++){

		left = W*loop;
		right = W*(loop+1)-1;

		scanf("%d",&tmp);

		if(loop%2 == 0){
			check[left+tmp]++;
			check[right+tmp+1]--;
		}else{
			check[left-tmp]++;
			check[right-tmp+1]--;
		}
	}

	for(int i = 1; i <= N*W; i++)check[i] += check[i-1];

	int ans = 0;

	for(int i = 0; i < N*W; i++){
		if(check[i] == 0)ans++;
	}

	printf("%d\n",ans*H);

	return 0;
}

Measured memory_bytes: 3256
/**
 * @author: Jun
 * @date  : 03-18-2019
 **/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int n, arr[105];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
    }
    int mincost=1000000000;
    for(int i=-100;i<=100;i++){
        int res=0;
        for(int j=1;j<=n;j++){
            res += abs(i-arr[j])*abs(i-arr[j]);
        }
        if(res <= mincost){
            mincost = res;
        }
    }
    cout << mincost << el;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

const long long mod = 924844033;

int N, K;
vector<int> A[2020], B[2020]; bool chk[2020][2020];
long long fact[2020], prv[5020], nxt[5020], P[2020][2], Q[2020][2];

int main()
{
	scanf("%d %d", &N, &K);
	for (int i=1;i<=N;i++) for (int j=1;j<=N;j++){
		if (abs(i-j) == K){
			A[i].push_back(j);
			B[j].push_back(i);
			chk[i][j] = 1;
		}
	}

	prv[0] = 1;
	int deg = 0;
	for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) if (chk[i][j]){
		queue<pair<int, int> > que;
		que.push({ i,j }); chk[i][j] = 0;
		int L = 0;
		while (!que.empty()){
			auto p = que.front(); que.pop(); L++;
			for (int y : A[p.first]){
				int x = p.first;
				if (chk[x][y]){
					que.push({ x,y }); chk[x][y] = 0;
				}
			}
			for (int x : B[p.second]){
				int y = p.second;
				if (chk[x][y]){
					que.push({ x,y }); chk[x][y] = 0;
				}
			}
		}

		P[0][0] = 1;
		P[0][1] = 0;
		for (int k=1;k<=L;k++){
			for (int i=0;i<=k;i++) Q[i][0] = Q[i][1] = 0;
			for (int i=0;i<k;i++){
				Q[i][0] = (Q[i][0] + P[i][0] + P[i][1]) % mod;
				Q[i+1][1] = (Q[i+1][1] + P[i][0]) % mod;
			}
			for (int i=0;i<=k;i++) P[i][0] = Q[i][0], P[i][1] = Q[i][1];
		}

		for (int j=0;j<=deg+L;j++) nxt[j] = 0;
		for (int i=0;i<=deg;i++){
			for (int j=L;j>=0;j--){
				nxt[i+j] = (nxt[i+j] + prv[i] * (P[j][0] + P[j][1])) % mod;
			}
		}
		for (int j=0;j<=deg+L;j++) prv[j] = nxt[j];
		deg += L;
		while (deg > 0 && prv[deg] == 0) deg--;
	}

	fact[0] = 1;
	for (int i=1;i<=N;i++) fact[i] = fact[i-1] * i % mod;

	long long ans = 0, s = 1;
	for (int i=0;i<=N;i++){
		ans = (ans + fact[N-i] * prv[i] % mod * s + mod) % mod;
		s *= -1;
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 4480
def main():
  h,w,m = map(int, input().split())
  hl = [0] * h
  wl = [0] * w
  dic = set()
  for i in range(m):
    x,y = map(int, input().split())
    dic.add((x,y))
    hl[x-1] += 1
    wl[y-1] += 1

  h_max = max(hl)
  r = [i for i in range(h) if hl[i] == h_max]
  w_max = max(wl)
  c = [i for i in range(w) if wl[i] == w_max]

  flg = 0
  for rc in r:
    for cc in c:
      if (rc+1,cc+1) not in dic:
        print(h_max + w_max)
        return

  print(h_max + w_max - 1)
  
if __name__ == '__main__':
    main()

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

const int INF = 1e9;

int n, m, adjMat[105][105], dp[100005][105];

int main() {

    memset(dp, -1, sizeof(dp));

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j)
                adjMat[i][j] = 0;
            else
                adjMat[i][j] = INF;
        }
    }

    for (int i = 0, u, v, w; i < m; i++) {
        cin >> u >> v >> w;

        adjMat[u][v] = w;
    }

    // start tour at vertex (n - 1)
    int nn = n - 1;
    
    // base case
    for (int i = 0; i < nn; i++) {
        dp[1 << i][i] = adjMat[n - 1][i];
    }

    int num_states = 1 << nn;
    for (int i = 0; i < num_states; i++) {
        if (!(i & (i-1)))
            continue;
        for (int j = 0; j < nn; j++) {
            if (!((i >> j) & 1))
                continue;
            dp[i][j] = INF;
            for (int k = 0; k < nn; k++) {
                if (k == j || !((i >> k) & 1) || adjMat[k][j] == INF)
                    continue;
                dp[i][j] = min(dp[i][j], dp[i ^ (1 << j)][k] + adjMat[k][j]);
            }
        }
    }

    int ans = INF;
    for (int i = 0; i < nn; i++) {
        ans = min(ans, dp[num_states - 1][i] + adjMat[i][n - 1]);
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 44124
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);
using namespace std;

signed main(){
    map<int, int> mp;
    int n;
    cin >> n;
    for(int i = 0; i < 26; i++){
        mp[i] = inf;
    }
    vector<string> sv;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        sv.push_back(s);
    }
    
    for(int i = 0; i < n; i++){
        vector<int> v(26, 0);
        for(int j = 0; j < sv[i].size(); j++){
            v[sv[i][j] - (int)('a')]++;
        }
        for(int j = 0; j < 26; j++){
            if(mp[j] > v[j]){
                mp[j] = v[j];
            }
        }
    }
    
    char alf[26] = {
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
        'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
    };
    
    string s = "";
    
    for(int i = 0; i < 26; i++){
        if(mp[i] != inf && mp[i] != 0){
            for(int j = 0; j < mp[i]; j++){
                s += alf[i];
            }
        }
    }
    cout << s;
}

Measured memory_bytes: 256
#include <iostream>

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

    for(int i = 1; i <= 10; i++){
        if(1000*i - n >= 0 && 1000*i - n < 1000){
            std::cout << 1000*i - n << std::endl;
            break;
        }
    }
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] lots = new int[N];
		for(int i = 0;i < N;i++) {
			lots[i] = sc.nextInt();
		}
		Arrays.sort(lots);
		int ans = 0;
		for(int i = N;i > N - K;i--) {
			ans += lots[i-1];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#define M 1000000
int main(){
  int n,s,i,j,a;
  while(scanf("%d",&n),n){
    int d[11]={0};
    for(i=0;i<n;i++){
      s=0;
      for(j=0;j<n;j++){
	scanf("%5d",&a);
	d[j]+=a;
	s+=a;
	printf("%5d",a);
      }
      printf("%5d\n",s);
    }
    for(i=s=0;i<n;i++){
      s+=d[i];
      printf("%5d",d[i]);
    }
    printf("%5d\n",s);
  }
  return 0;
}

Measured memory_bytes: 612
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
#include<random>
using namespace std;
int main() {
	uint32_t N;
	int32_t sumA;
	vector<int32_t> A;
	cin >> N;
	A.resize(N);
	cin >> A[0];
	sumA = abs(A[0]);
	for (uint32_t i = 1; i < N; i++)
	{
		cin >> A[i];
		sumA += abs(A[i] - A[i - 1]);
	}
	sumA += abs(A[N - 1]);

	int32_t before, current, next;
	before = 0;
	current = A[0];
	for (size_t i = 0; i < N - 1; i++)
	{
		next = A[i + 1];
		cout << sumA - abs(current - next) - abs(current - before) + abs(next - before) << endl;
		before = current;
		current = next;
	}
	next = 0;
	cout << sumA - abs(current - next) - abs(current - before) + abs(next - before) << endl;
	return 0;
}

Measured memory_bytes: 1664
import math

n = int(input())
xy = []
for i in range(n):
  l = list(map(int, input().split()))
  xy.append(l)
d = 0
  
for i in range(n-1):
  for j in range(i+1, n):
    d += ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5

print(d*2*math.factorial(n-1)/math.factorial(n))

Measured memory_bytes: 3188
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T> inline T gcd(T&a,T&b){return b==0?a:gcd(b,a%b);}
template<typename T> inline T lcm(T&a,T&b){return a/gcd(a,b)*b;}
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n,m;
int main(){
    read(n),read(m);
    if (n<m) puts("0");
    else printf("%d\n",n-m);
    return 0;
}


Measured memory_bytes: 768
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

LL bin(LL a, LL b, LL p) {
	LL res = 1;
	for (a%=p; b; b>>=1, a=a*a%p)
		if (b & 1)
			res = res * a % p;
	return res;
}

const int N = 2e3+50;
#define int long long
vector<int> a, p;
vector<vector<int>> dp;
vector<pair<int, int>> dat;
int n;

inline void update(int &a, int b) {
    a = max(a, b);
}

signed main() {
    // code
    scanf("%lld", &n);
    a = vector<int>(n);
    for (int i=0; i<n; ++i) {
        scanf("%lld", &a[i]);
        dat.emplace_back(a[i], i);
    }

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

        
    dp = vector<vector<int>>(n+1, vector<int>(n+1, 0));
    for (int i=0; i<n; ++i) {
        dbg(dat[i].first, dat[i].second);
        for (int j=0; j<=i; ++j) {
            dbg(i, j, dat[i].second, n, i, j, dat[i].second - (n - (i-j) - 1));
            update(dp[i+1][j], dp[i][j] + abs(dat[i].second - (n-(i-j)-1)) * dat[i].first);
            update(dp[i+1][j+1], dp[i][j] + abs(dat[i].second - j) * dat[i].first);
        }
    }

    dbg(dp[2][1]);

    printf("%lld\n", *max_element(dp[n].begin(), dp[n].end()));
    
    return 0;
}

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

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

  if(a + b == 15){
    cout << "+" << endl;
  }else if(a * b == 15){
    cout << "*" << endl;
  }else{
    cout << "x" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007 
#define ff first
#define ss second
#define pb push_back  
#define INF 1000000000000
									//nestedcode



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


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll i,j,h,k,ans,fans = 0;
    cin>>k;
    for(i=1;i<=k;i++){
    	for(j=1;j<=k;j++){
    		for(h=1;h<=k;h++){
    			ans = __gcd(i,j);
    			ans = __gcd(ans,h);
    			fans += ans;
			}
		}
	}
	cout<<fans;
    
}


Measured memory_bytes: 3648
n = gets.chomp.to_i
s = gets.chomp

b = 0
w = 0
n.times do |i|
  if s[i] == "#"
    b += 1
  else
    w += 1
  end
end

ans = w
left = 0
right = w
n.times do |i|
  if s[i] == "#"
    left += 1
  else
    right -= 1
  end
  ans = [ans, left + right].min
end
puts ans

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b==c||b+c==a||c+a==b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
      
       




Measured memory_bytes: 3540
from collections import *
H,W = map(int,input().split())
S = [(W+2)*["#"]]+list(["#"]+list(input())+["#"] for h in range(H))+[(W+2)*["#"]]
S[1][1] = 1
Q = deque([[1,1]])
D = [[1,0],[-1,0],[0,1],[0,-1]]

while Q:
  x,y = Q.popleft()
  for dx,dy in D:
    if S[x+dx][y+dy]==".":
      S[x+dx][y+dy] = S[x][y]+1
      Q.append([x+dx,y+dy])

if S[H][W]==".":
  print(-1)
else:
  print((H+2)*(W+2)-sum(s.count("#") for s in S)-S[H][W])

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<ll> vint;
int main() {
  ll a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  
  double max=0;
  ll sugwat=100*a,sugar=0;
  for (ll i=0;i<=f/100/a;i++) {
    for (ll j=0;j<=(f/100-a*i)/b;j++) {
      for (ll k=0;k<=(f-100*(a*i+b*j))/c;k++) {
        for (ll l=0;l<=(f-k*c-100*(a*i+b*j))/d;l++) {
          if (k+l != 0) {
            double x = 1.0*(c*k+d*l)/(double)((c*k+d*l)+100*(a*i+b*j));
            if (max<x && (100+e)*x<=e) {
              max = 1.0*(c*k+d*l)/(double)((c*k+d*l)+100*(a*i+b*j));
              sugar = c*k+d*l;
              sugwat = sugar + 100*(a*i+b*j);
            }
          }
        }
      }
    }
  }
  
  cout << sugwat << ' ' << sugar;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if(n==i*j)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int n,u,v;
vector<vector<int>> tree;
vector<int> udist,vdist;

void udfs(int now = u,int p = -1,int d = 0) {
    udist[now] = d;
    for(int i : tree[now]) {
        if(i == p) continue;
        udfs(i,now,d+1);
    }
}

void vdfs(int now = v,int p = -1,int d = 0) {
    vdist[now] = d;
    for(int i : tree[now]) {
        if(i == p) continue;
        vdfs(i,now,d+1);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> u >> v;
    u--; v--;
    tree.resize(n);
    udist.resize(n);
    vdist.resize(n);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    udfs();
    vdfs();
    int ans = 0;
    rep(i,n) {
        if(udist[i] >= vdist[i]) continue;
        chmax(ans,vdist[i]-1);
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll n,m,k;
vector<ll> d;
vector<ll> id;
vector<vector<ll>> v;

ll solve(){
	ll res = 0;
	queue<P> que;
	vector<bool> used(1LL << m,false);
	que.push(P((1LL << m) - 1,0));
	while(que.size()){
		P p = que.front();
		que.pop();
		ll now = p.first;
		ll cnt = p.second;
		// cout << "!" << now << endl;
		if(used[now])continue;
		used[now] = true;
		if(now == 0){
			res = cnt;
			break;
		}
		rep(i,k){
			ll nxt = 0;
			rep(j,m){
				if(now & (1LL << j)){
					ll to = v[d[j]][i];
					if(id[to] == -1)continue;
					nxt |= (1LL << id[to]);
				}
			}
			que.push(P(nxt,cnt+1));
		}
	}
	return res;
}

int main(){
	cin >> n >> m >> k;
	d.resize(m);
	id.resize(n,-1);
	rep(i,m){
		cin >> d[i];
		d[i]--;
		id[d[i]] = i;
	}
	v.resize(n);
	rep(i,n){
		v[i].resize(k);
		rep(j,k){
			cin >> v[i][j];
			v[i][j]--;
		}
	}
	cout << solve() << endl;
}


Measured memory_bytes: 61800
N, M = map(int, input().split())

def calc(n, m):
    if n < 1 or m < 1:
        return 0
    elif n == 1 and m != 1:
        return m-2
    elif n != 1 and m == 1:
        return n-2
    else:
        return n * m -(2 * (m + n - 2))
print(calc(N,M))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
 long long int n;
 cin>>n;
 long long int a[n];
 map<long long int ,long long int> m;
 for(long long int i=0;i<n;i++)
 {
     cin>>a[i];
     if(m.find(a[i])==m.end())
     m[a[i]]=1;
     else m[a[i]]++;
 }
 long long int count=0,ans=0;
 for(auto it=m.begin();it!=m.end();it++)
 {
  if(it->second>=2)
  {
      long long int p=it->second;
      ans+=(p*(p-1))/2;
  }
 }
 for(long long int i=0;i<n;i++)
 {
     m[a[i]]--;
     cout<<ans-m[a[i]]<<endl;
     if(m.find(a[i])==m.end())
     m[a[i]]=1;
     else
     m[a[i]]++;
 }
   return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll H, N;
        cin >> H >> N;
        vll A(N), B(N);
        rep(i, 0, N) cin >> A[i] >> B[i];

        vll dp(10101, inf);
        dp[0] = 0;

        rep(i, 0, 10101) {
                rep(j, 0, N) {
                        if (i - A[j] >= 0) {
                                chmin(dp[i], dp[i - A[j]] + B[j]);
                        }
                }
        }
        cout << *min_element(dp.begin()+H, dp.end()) << endl;
}


Measured memory_bytes: 3720
#include<stdio.h>
#include<string.h>
int  main(){
char s[20];
scanf("%s",s);
if(strcmp(s,"Sunny")==0){
printf("Cloudy\n");
}
else if(strcmp(s,"Cloudy")==0){
printf("Rainy\n");
}
else if(strcmp(s,"Rainy")==0){
printf("Sunny\n");
}
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
#define MAX 100005
int main(){
    vector<int> num(MAX,0), ans(MAX,0);
    for(int i = 1; i < MAX; i++){
        for(int j = 1; i*j < MAX; j++)num[i*j]++;
    }
    for(int i = 1; i < MAX; i++){
        ans[i] = ans[i-1] + (num[i] >=5);
    }
    int q;
    cin >> q;
    while(q--){
        int n;
        cin >> n;
        cout << ans[n] << endl;
    }
}



Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1003,INF=1<<29;

int main(){
    
    int N,Q;cin>>N>>Q;
    multiset<ll> minus,plus;
    vector<ll> A(2*N),B(2*N);
    
    ll ans=0;
    
    for(int i=0;i<2*N;i++) cin>>A[i];
    for(int i=0;i<2*N;i++) cin>>B[i];
    
    for(int i=0;i<2*N;i++){
        ll a,b;
        a=A[i];
        b=B[i];
        if(i==0||i==2*N-1){
            ans+=a;
        }else{
            if(a>b){
                plus.insert(a-b);
                ans+=(a-b);
            }
            else minus.insert(a-b);
            
            ans+=b;
        }
    }
    
    while(Q){
        ll p,a,b;cin>>p>>a>>b;
        p--;
        if(p==0||p==2*N-1){
            ans-=A[p];
            ans+=a;
            A[p]=a;
        }else{
            if(A[p]>B[p]){
                ans-=A[p];
                ans+=b;
                auto it=plus.lower_bound(A[p]-B[p]);
                plus.erase(it);
                
                A[p]=a;B[p]=b;
                if(a>b){
                    plus.insert(a-b);
                    ans+=(a-b);
                }
                else minus.insert(a-b);
            }else{
                ans-=B[p];
                ans+=b;
                auto it=minus.lower_bound(A[p]-B[p]);
                minus.erase(it);
                
                A[p]=a;B[p]=b;
                if(a>b){
                    plus.insert(a-b);
                    ans+=(a-b);
                }
                else minus.insert(a-b);
            }
        }
        
        if(int(plus.size())%2==1){
            ll ans1=ans,ans2=ans;
            ans1-=*plus.begin();
            ans2+=*minus.rbegin();
            
            cout<<max(ans1,ans2)<<endl;
        }else cout<<ans<<endl;
        
        Q--;
    }
}




Measured memory_bytes: 14208
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)


Measured memory_bytes: 122968
#include<cstdio>
#include<iostream>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    
    
    if(a==b and b==c and a==c)
    {
        cout << "1";
    }
    else if(a==b or a==c or b==c)
    {
        cout << "2";
    }
    else
    {
        cout << "3";
    }
    
}




Measured memory_bytes: 3024
A,B,C,X,Y=map(int,input().split())

#すべて単品, min(X,Y)をABで賄い不足を単品, すべてAB(超過は問題ない)
total=[0,0,0]
#case1
total[0]=A*X+B*Y
#case2
if X>=Y:
    cost=A
else:
    cost=B
total[1]=min(X,Y)*2*C+(max(X,Y)-min(X,Y))*cost
#case3
total[2]=max(X,Y)*2*C

print(min(total))


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

int main(){
  int N;
  cin >> N;
  string c;
  cin >> c;
  int revR, revW=0, ans;
  for(int i=0; i<N; i++){
    if(c[i] == 'R') revR++;
  }
  ans = revR;
  for(int i=1; i<=N; i++){
    if(c[i-1] == 'R') revR--;
    else revW++;
    if(revR > revW) ans = min(ans, revR);
    else ans = min(ans, revW);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3744
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        int w = Integer.parseInt(ss[0]);
        int h = Integer.parseInt(ss[1]);
        int x = Integer.parseInt(ss[2]);
        int y = Integer.parseInt(ss[3]);
        int r = Integer.parseInt(ss[4]);
        if (x - r < 0 || y - r < 0) {
            System.out.println("No");
            return;
        }
        if (x + r > w || y + r > h) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }
}


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

typedef pair<int, int> P;

int N;
vector<P> jobs;

int main() {
  cin >> N;
  int a, b;
  rep(i, N) {
    cin >> a >> b;
    jobs.push_back(make_pair(b, a));
  }
  sort(jobs.begin(), jobs.end());
  long long t=0;
  rep(i, N) {
    t+=jobs[i].second;
    if(t > jobs[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 2548
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    long double a, b, x;
    std::cin >> a >> b >> x;

    if (x > a * a * b / 2) {
        long double a_tan = atan((a * a * a) / (2 * (a * a * b - x)));
        long double degree = a_tan * 180.0 / 3.141592653589793;

        printf("%.12Lf\n", 90 - degree);
        return 0;
    } else {
        long double a_tan = atan(2 * x / (a * b * b));
        long double degree = a_tan * 180.0 / 3.141592653589793;

        printf("%.12Lf\n", 90 - degree);
    }
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[n],b[n],ans[n],an[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int c,d;
    cin>>c>>d;
    for(int k=0;k<n;k++){
        ans[k]=abs(a[k]-c)+abs(b[k]-d);
        an[k]=1;
    }
    for(int i=1;i<m;i++){
        cin>>c>>d;
        for(int k=0;k<n;k++){
            if(abs(a[k]-c)+abs(b[k]-d)<ans[k]){
                ans[k]=abs(a[k]-c)+abs(b[k]-d);
                an[k]=i+1;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<an[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int a, b;
    char op;
    while (1) {
        cin >> a >> op >> b;
        if (op == '?') {
            break;
        }
        else if (op == '+') {
            cout << a + b << '\n';
        }
        else if (op == '-') {
            cout << a - b << '\n';
        }
        else if (op == '*') {
            cout << a * b << '\n';
        }
        else if (op == '/') {
            cout << a / b << '\n';
        }
    }

}



Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int bb = 0, pass = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'c') cout << "No" << '\n';
    if (s[i] == 'a') {
      if (pass < a + b) {
        cout << "Yes" << '\n';
        pass++;
      } else {
        cout << "No" << '\n';
      }
    }
    if (s[i] == 'b') {
      if (pass < a + b && bb < b) {
        cout << "Yes" << '\n';
        pass++;
        bb++;
      } else {
        cout << "No" << '\n';
      }
    }
  }
  return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    string S,T; cin >> S >> T;
    print(T+S);
    return 0;
}

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

int main()
{
  string s;
  cin>>s;
  int n = s.length();
  if(s[n-1] != 's'){
  	s += 's';
  }
  else if(s[n-1] == 's'){
  	s += "es";
  }
  cout<<s<<endl;

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,n,L;
	cin>>n>>L;

	k=0;
	for(i=1;i<=n;i++){
		k+=(L+i-1);
	}

	ll mn=1e18,an;
	for(i=1;i<=n;i++){
		j=(k-(L+i-1));
		if(abs(j-k)<mn){
			mn=abs(j-k);
			an=j;
		}
	}
	cout<<an;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n > 0) { 
		sum += n % 10; n /= 10; }
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int k;
	cin >> k;

	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
		1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	cout << a[k - 1] << rt;

	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000007;
#define PI 3.14159265
int main()
{
    fastio;
    int n,m;
    cin>>n>>m;
    int cnt = 0;
    vector<int>a;
    for(int i=1;i<=n;i++)
    {
        a.pb(i);
    }
    for(int i=1;i<=(n/2);i++)
    {
        cout<<i<<" "<<a.back()<<endl;
        cnt++;
        if((n%2)==0 && cnt==(m/2 + m%2))a.pop_back();
        a.pop_back();    
        if(cnt==m)break;
    }
    return 0;
}

Measured memory_bytes: 4212
//be naame khodaa

#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

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

int in(){ int x; scanf("%d", &x); return x; }


const int maxn = 10 * 1000 + 5;

int a[maxn], b[maxn];

int main()
{
	ios::sync_with_stdio(false);
	int n = in();
	ll C = 0, L = 0;
	for (int i = 0; i < n; i++)
		a[i] = in();
	for (int i = 0; i < n; i++){
		b[i] = in();
		C += b[i]-a[i];
		L += max(0, (b[i]-a[i]+1)/2);
	}
	if (L <= C)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        String S;
        S = sc.next();
        solve(S);
    }

    static void solve(String S){
        for (int i = 0; i < S.length(); i++) {
            System.out.print("x");
        }
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
//#include<bits/stdc++.h>
using namespace std;
#define Base1   101LL
#define Base2   10000079LL
#define Base3   10000103LL
#define MOD1    1000000007LL
#define MOD2    1000000009LL
#define MOD3    1000000021LL
#define mx 100000//Number of charter of main string
#define mx1 25000// Number off character of total charcater
#define mx2 500// Number of pattern and number of ch of each pattern

int main(){

   ll n,m;
   cin>>n>>m;
   string fi;
   for(int i = 1;i<=n;i++)fi = (fi  +(char)(m + '0'));
   string se;
   for(int i=1;i<=m;i++)se = (se  +(char)(n + '0'));
   cout<<min(fi,se)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	long long N, i, j, k, ans=0;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> j; cin >> k;
		ans += (k - j) + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		//データセット数
		int dataSetCount = sc.nextInt();
		for(int i = 0;i<dataSetCount;i++) {
			//比較対象の2つのブロック
			int currentBlock;
			int nextBlock;
			//出力する最大の上りと下り
			int climbUp = 0;
			int climbDown = 0;
			//ブロックの数
			int blockCount = sc.nextInt();
			currentBlock = sc.nextInt();
			for(int j = 1;j< blockCount;j++) {
				nextBlock = sc.nextInt();
				//段差
				int climb = currentBlock - nextBlock;
				//段差がプラスかマイナスかで上りか下りかを判別
				//最大である場合、更新する
				if(climb > 0) {
					if(climb > climbUp) {
						climbUp = climb;
					}
				}else {
					if(climb < climbDown) {
						climbDown = climb;
					}
				}
				//ブロックを更新
				currentBlock = nextBlock;
			}
			//マイナスを絶対値へ変更し、出力
			System.out.println(Math.abs(climbDown) + " " + climbUp);
			
		}
	}
}



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

const int DIM = 1e2 + 5;

int arr[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    sort( arr + 1, arr + n + 1 );
    cout << arr[n] - arr[1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
const int INF=1e9+7;
using namespace std;
typedef  long long ll;
int a[205];
int main()
{
    int n,l,sum=0,ans=0,Max=INF;
    cin>>n>>l;
    for(int i=0;i<n;i++)
    {
    	a[i]=i+l;
    	sum+=a[i];
    }
    for(int i=0;i<n;i++)
    {
    	int k;
    	k=sum-a[i];
    	if(abs(sum-k)<Max)
    	{
    		Max=abs(sum-k);
    		ans=k;
    	}
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()
#define ld long double
void solve();
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}
void solve()
{
	ll x, k, d; cin >> x >> k >> d;
	if (k > llabs(x) / d )
	{
		x = llabs(x);
		ll y = x / d;
		ll dif = (k - y);
		ll d1 = x - y * d;
		ll d2 = (y + 1) * d - x;
		if (dif & 1) cout << d2;
		else cout << d1;
	}
	else
	{
		cout << llabs(x) - k*d;
	}
	return ;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define REP(i,x) for(int i=0;i<(int)(x);i++)
    #define REPS(i,x) for(int i=1;i<=(int)(x);i++)
    #define mp(a,b) make_pair(a, b)
    #define pb push_back
    #define eb emplace_back
    #define ll long long
    #define MAX 10000000
    int main()
    { int n;
    cin>>n; int ar[n]; ll s=0;
    REP(i,n)
    {
        cin>>ar[i];
        if(i>=1 && ar[i]<ar[i-1]) { int c=abs(ar[i]-ar[i-1]); s+=c; ar[i]+=c;}
    }
    cout<<s<<endl;
    }

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

typedef vector<ll> Edges;
typedef vector<Edges> Graph;

const ll V_MAX = 101010; // !! SHOULD BE EDITTED !!
vector<ll> ts(V_MAX, -1);

int topologicalSortLength(Graph &G){
	ll V = G.size();
	vector<ll> indeg(V, 0);
	queue<ll> qu;

	REP(i, V){
		REP(j, G[i].size()){
			indeg[G[i][j]]++;
		}
	}
	REP(i, V){
		if(!indeg[i]) qu.push(i);
	}

	ll depth = 0;
	while(!qu.empty()){
		ll s = qu.size();
		REP(i, s){
			ll now = qu.front();qu.pop();
			ts[now] = depth;
			REP(j, G[now].size()){
				ll next = G[now][j];
				indeg[next]--;
				if(!indeg[next]) qu.push(next);
			}
		}
		depth++;
	}

	REP(i, V){
		if(ts[i] == -1) return -1;
	}
	return depth;
}

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

    ll N, M;
    cin >> N >> M;

    Graph G(N);
    REP(i, M){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	G[a].push_back(b);
    }

    cout << topologicalSortLength(G)-1 << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	long long int X, Y;
	cin >> X;
	cin >> Y;
	if (X * Y <=1000000000000000000 &&X%Y!=0) {
		cout << X;

	}
	else {
		cout << "-1";
	}
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int ma[2][101];
	for (int i = 0; i < n; ++i) {
		cin >> ma[0][i] >> ma[1][i];
	}

	long counts[101][101];
	long k1, k2;
	long mins1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i <= j) {
				counts[i][j] = 0;
			}
		}
	}

	for (int l = 0; l < n; ++l) {
		for (int i = 0; i < n-l; ++i) {
		
			int j = i +l+1;
			mins1 = 100000000;
			for (int k = i; k < j; ++k) {
				k1 = counts[i][k] + counts[k+1][j] + ma[0][i] * ma[1][k] * ma[1][j];
				if (mins1 > k1) {
					mins1 = k1;
				}
			}
			counts[i][j] = mins1;
			
		}
	}
	cout << counts[0][n - 1] << endl;
	return 0;
}


Measured memory_bytes: 3164