akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MOD = 1e9+7;
int dp[3005][3005];
int sum[3005];

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

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

    dp[0][1]=1;

    FOR(i,n-1) {
        memset(sum, 0, sizeof sum);
        if(s[i]=='<') {
            RNG(k, 1, n) {
               sum[k] = (sum[k-1] + dp[i][k]) % MOD;
            }
            RNG(d,1,i+2) {
                dp[i+1][d] = sum[d-1] % MOD;
            }
        } else {
            REV(k, n, 1) {
                sum[k] = (sum[k+1] + dp[i][k]) % MOD;
            }
            RNG(d,1,i+2) {
                dp[i+1][d] = sum[d] % MOD;
            }
        }
    }

    cout<<accumulate(dp[n-1], dp[n-1]+n+1, 0LL)%MOD<<endl;



    return 0;
}



Measured memory_bytes: 34176
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    print(input().replace(',',' '))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#define endl '\n'
#define ll long long

using namespace std;

int K;
int *dist;

void bfs()
{
    deque<int> quu; quu.push_back(1); dist[1] = 1;
    while(!quu.empty())
    {
        auto cur = quu.front(); quu.pop_front();
        if(cur% K == 0)
            return;
        {
            auto next_value = cur * 10;
            next_value %= K;
            if(dist[next_value] > dist[cur])
            {
                dist[next_value] = dist[cur];
                quu.push_front(next_value);
            }
        }
        
        {
            auto next_value = cur + 1;
            next_value %= K;
            if(dist[next_value] > dist[cur] + 1)
            {
                dist[next_value] = dist[cur] + 1;
                quu.push_back(next_value);
            }
        }
        
    }
    
    return;
}

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> K;
    dist = new int[K+1]();
    for(int i = 0; i < K + 1; i++)
        dist[i] = INT_MAX;
    bfs();
    cout << dist[0] << endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
int A[18], B[18];

int dp[1<<18][51]; // 残り集合 最後の値がk

int main() {
	cin >> N;
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> B[i];
	
	fill(dp[0], dp[1<<18], INF);
	
	dp[(1<<N)-1][0] = 0;
	
	for (int s = (1<<N)-1; s >= 0; --s) {
		REP(k, 51) {
			if (dp[s][k] == INF) continue;
			int cnt = 0;
			REP(j, N) if (s >> j & 1 ^ 1) ++cnt;
			// cnt番目に置く
			
			int c = 0;
			REP(j, N) {
				if (s >> j & 1) {
					int dif = abs(cnt - j);
					int cur = dif & 1 ? B[j] : A[j];
					if (cur >= k) chmin(dp[s^(1<<j)][cur], dp[s][k] + c);
					++c;
				}
			}
		}
	}
	
	int ans = INF;
	REP(i, 51) chmin(ans, dp[0][i]);
	if (ans == INF) ans = -1;
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

int main() {

  int N;
  cin >> N;
  for (int i = 1; i < 10; ++i) {
    if (111 * i >= N) {
      cout << 111 * i << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int n, k, arr[100];

void solve() {
	for(int x = n; ; ++x){
		int tmp = x;
		int flag = 1;
		while(tmp) {
			int num = tmp % 10;
			for(int i = 1; i <= k; ++i){
				if(num == arr[i]){
					flag = 0;
					break;
				}
			}
			tmp = tmp / 10;
			if(!flag) break;
		}
		if(flag){
			printf("%d\n", x);
			return ;
		}
	}
}

int main() {
	while(~scanf("%d %d", &n, &k)) {
		for(int i = 1; i <= k; ++i) scanf("%d", arr + i);
		solve(); 
	} 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0) solve(n);
	}
    }

    static void solve(int n){
	int[] t = new int[n];
	int i;
	for(i=0; i<n; i++)
	    t[i] = kbd.nextInt();

	int pen = 0;
	int ans = 0;
	Arrays.sort(t);

	for(i=0; i<n; i++){
	    ans += pen+t[i];
	    pen += t[i];
	}
	System.out.println(ans);
    }
}

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

int main() {
  int n,m; cin >>n >>m;
  int l = 1, r = 100000;
  int bufl, bufr;
  for (int i=0; i<m; i++){
    cin >>bufl >>bufr;
    l = max(l,bufl); r = min(r,bufr);
  }
  
  int ans;
  if (r-l<0) ans = 0;
  else{
    ans = max(0, min(n,r)-l+1);
  }
  
  cout <<ans;
  cout <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3010][3010];
int coinChange(int coin[],int n,int x,int y,int val)
{
    //cout<<"a"<<endl;
    if(x>=n)
    {
        if(y==val)
            return 1;
        else
     return 0;
    }
    if(dp[x][y]!=-1)
        return dp[x][y];
    int ret1=0,ret2=0;
    if(y+coin[x]<=val)
        ret1=coinChange(coin,n,x,y+coin[x],val);
        ret2=coinChange(coin,n,x+1,y,val);
        return dp[x][y]= ret1 + ret2;
}
int main()
{
    int n,val;

    int coin[30];

    memset(dp,-1,sizeof(dp));
    for(int i=0;i<3;i++)
    {
        cin>>coin[i];
    }
    cin>>val;
    int  k=coinChange(coin,3,0,0,val);
    cout<<k<<endl;
}


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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n, q;
std::string s;
int num[100005];
int main()
{
	std::cin >> n >> q;
	std::cin >> s;

	for (size_t i = 0, end = s.size() - 1; i < end; ++i) {
		num[i + 2] = num[i + 1];
		if (s[i] == 'A'&&s[i + 1] == 'C')
			++num[i + 2];
	}

	for (int i = 0; i < q; ++i) {
		int l, r;
		std::cin >> l >> r;
		std::cout << num[r] - num[l] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <map>
#include <regex>
#include <sstream>
#include <utility>
#include <list>
#include <unordered_set>
#include <unordered_map>
#define endl	'\n'
#define MOD 1000000

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
int dx[] = { 0,1,0,-1 };
int dy[] = { -1,0,1,0 };
int dz[] = { 0,0,0,0,1,-1 };
const int INF = 1000000000;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n; 
	vector<int> v(n);

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

	for (int i = n - 1; i > 0; i--) {
		if(v[i] >= v[i - 1]) {
         	 
        }
      	else {
        	if(v[i - 1] - 1 == v[i]) v[i - 1] -= 1; 
          	else {
              cout << "No";
              return 0;
            }
        }
      
	}

	cout << "Yes";
}


Measured memory_bytes: 640
x1, y1, x2, y2 = gets.split.map(&:to_i)

def dist(x1, y1, x2, y2)
  dy = y2 - y1
  dx = x2 - x1
  Math.sqrt(dy ** 2 + dx ** 2)
end

l = dist(x1, y1, x2, y2)

candA = []
candB = []

(-300..300).each do |y|
  (-300..300).each do |x|
    if (x1 != x || y1 != y) && l == dist(x, y, x2, y2)
      candA << [x, y]
    end

    if (x2 != x || y2 != y) && l == dist(x, y, x1, y1)
      candB << [x, y]
    end
  end
end

candA.each do |a, b|
  next if (a - x2) * (y1 - y2) - (x1 - x2) * (b - y2) < 0

  candB.each do |c, d|
    if l == dist(a, b, c, d) && dist(a, b, x1, y1) == dist(c, d, x2, y2)
      puts [a, b, c, d].join(' ')
      # exit
    end
  end
end


Measured memory_bytes: 1916
n,m=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(str(input())))
for i in range(m):
    if a[0][i]!='#':
        a[0][i]=1
    else:
        j=i
        while(j<m):
            a[0][j]=0
            j+=1
        break
for i in range(n):
    if a[i][0]!='#':
        a[i][0]=1
    else:
        j=i
        while(j<n):
            a[j][0]=0
            j+=1
        break
for i in range(1,n):
    for j in range(1,m):
        if a[i][j]!='#':
            a[i][j]=a[i-1][j]+a[i][j-1]
        else:
            a[i][j]=0
print(a[-1][-1]%((10**9)+7))

Measured memory_bytes: 256684
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner scanner = new Scanner(System.in);
        long k = scanner.nextLong();
        int n = scanner.nextInt();
        long [] d = new long[n];
        for (int i = 0; i < n; ++i) {
            d[i] = scanner.nextLong();
        }
        long ans = k;
        for (int i = 0; i < n; ++i) {
            int left = (i - 1 + n) % n;
            int right = (i + 1) % n;
            long dLeft = i == 0
                    ? k - d[n - 1] + d[i]
                    : Math.abs(d[left] - d[i]);
            long dRight = i == n - 1
                    ? k - d[i] + d[right]
                    : Math.abs(d[right] - d[i]);
            long current = k - Math.max(dLeft, dRight);
//            System.out.println("i: " + i);
//            System.out.println("left: " + left + " dleft: " + dLeft);
//            System.out.println("right: " + right + " dright: " + dRight);
//            System.out.println("current: " + current);
            ans = Math.min(ans, current);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 87720
r,c = gets.split(" ").map{|x| x.to_i}
arr =Array.new()
r_sum = Array.new(r)
c_sum = Array.new(c)
r.times do |i|
    arr[i] = gets.split(" ").map{|x| x.to_i}
end
r.times do |i|
    r_sum[i] = 0
end
c.times do |i|
    c_sum[i] = 0
end

rc_sum=0
r.times do |i|
    c.times do |j|
        r_sum[i] += arr[i][j]
        c_sum[j] += arr[i][j]
        rc_sum+=arr[i][j]
    end
end
r.times do |i|
    c.times do |j|
        print arr[i][j]," "
    end
    print r_sum[i]
    puts
end
c.times do |j|
        print c_sum[j]," "
    end
    print rc_sum
    puts

Measured memory_bytes: 8852
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 200005;
int main(){
  int n;cin>>n;
  ll a[MAX_N];
  for(int i=1;i<=n;i++) cin >> a[i];
  vector<int> ids;
  if(n % 2 == 0){
    for(int i=1;i<=int(n/2);i++){
      int temp = n - 2*(i-1);
      ids.push_back(temp);
    }
    for(int i=1;i<=int(n/2);i++){
      ids.push_back(1+2*(i-1));
    }
  }else{
    for(int i=1;i<=int(n/2);i++){
      int temp = n - 2*(i-1);
      ids.push_back(temp);
    }
    ids.push_back(1);
    for(int i=1;i<=int(n/2);i++){
      ids.push_back(2*i);
    }
  }
  for(int i=0;i<n;i++){
    cout << a[ids[i]] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4596
#include<iostream>
#define MAX 1000000007
using namespace std;
int a[1005];
int main(){
	int n;
	int i,j,k;
	long long int s=1;
	cin>>n;
	for(i=1;i<=n;i++){
		j=2,k=i;
		while(k!=1){
			if(k%j==0){
				k/=j;
				a[j]++;
			}else j++;
		}
	}
	for(i=0;i<=n;i++){
		s*=(a[i]+1);
		if(s>=MAX)s%=MAX;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
constexpr ll MOD = 998244353;
ll a[3030], dp[3][3030][3030];

int main() {
	int n, s;
	scanf("%d %d", &n, &s);
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

	dp[0][0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= s; ++j) {
			(dp[0][i + 1][j] += dp[0][i][j]) %= MOD;
			(dp[1][i + 1][j] += dp[0][i][j] + dp[1][i][j]) %= MOD;
			(dp[2][i + 1][j] += dp[0][i][j] + dp[1][i][j] + dp[2][i][j]) %= MOD;
			if (j + a[i] <= s) {
				(dp[1][i + 1][j + a[i]] += dp[0][i][j] + dp[1][i][j]) %= MOD;
				(dp[2][i + 1][j + a[i]] += dp[0][i][j] + dp[1][i][j]) %= MOD;
			}
		}
	}
	printf("%d", dp[2][n][s]);
	return 0;
}

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

int main() {
    string s;
    std::cin >> s;
    ll n = s.length();
    
    ll res = 0;
    for (int i = 0; i < n/2; i++) {
        if(s[i] != s[n-i-1]){
            res++;
        }
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<ll,ll>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;cin >> n;
    vi h(n);
    rep(i,n) cin >> h[i];

    vl dp(n+1,LINF);
    dp[0] = 0;
    rep(i,n){
        if(i+2<n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
        if(i+1<n) dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
const int maxn = 1e9;

int main()
{
    int n;cin>>n;
    for(int j=111;j<=999;j+=111)
    {
        if(n<=j)
        {
            printf("%d\n",j);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
  int c=0;
  long long int n,nt;
  scanf("%lld",&n );
  nt=n;
  while (n!=0) {
    c+=n%10;
    n=n/10;
  }
  if(nt%c==0)
  printf("Yes" );
  else
  printf("No" );
}


Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

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

    string s,t;
    for(int i=0;i<b;i++){
        s += '0'+a;
    }
    for(int i=0;i<a;i++){
        t += '0'+b;
    }

    if(s>=t){
        cout << t << endl;
    }else{
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int H, W, D;

    scanf("%d%d%d", &H, &W, &D);

    int s[H*W+1][2];

    int A[H][W];

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            scanf("%d", &A[i][j]);
            s[A[i][j]][0] = i;
            s[A[i][j]][1] = j;
        }
    }

    int d[H*W+1];

    for(int i = 1; i <= D; i++){
        d[i] = 0;
    }

    for(int i = D+1; i <= H*W; i++){
        d[i] = d[i-D] + abs(s[i][0] - s[i-D][0]) + abs(s[i][1] - s[i-D][1]);
    }

    int Q;

    scanf("%d", &Q);

    int L[Q], R[Q];

    for(int i = 0; i < Q; i++){
        scanf("%d%d", &L[i], &R[i]);
    }

    for(int i = 0; i < Q; i++){
        printf("%d\n", d[R[i]] - d[L[i]]);
    }

    return 0;
}

Measured memory_bytes: 3868
#include<stdio.h>

int main()
{
	int K;
	int X;
	scanf("%d %d",&K,&X);
	K = K*500;
	if(K>=X){
		printf("Yes");
	}
	if(K<X){
		printf("No");
	}
	
	return 0;	
}
	

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

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


using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> C(h, vector<int>(w, 0));
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    if (c=='1') {
      C[i][j] = 1;
    }
  }

  // init
  vector<vector<int>> T(h+1, vector<int>(w+1, 0));
  REP(i, 1, h+1) REP(j, 1, w+1) T[i][j] = C[i-1][j-1] + T[i-1][j] + T[i][j-1] - T[i-1][j-1];


  int ans = 1e9;
  vector<int> E;
  rep(n, 1 << (h-1)) {
    E = vector<int>(1, 0);
    rep(i, h-1) if ((n >> i) & 1) E.push_back(i+1);
    E.push_back(h);
    bool dame = false;
    int count = E.size() - 2;
    int a = 0, b = 0;
    int i = 1;
    int sz = E.size();
    while(i <= w ) {
      bool flag = true;
      REP(j, 1, sz) {
        if (T[E[j]][i] + T[E[j-1]][a] - T[E[j-1]][i] - T[E[j]][a] > k) {
          flag = false;
          break;
        }
      }
      if (!flag) {
        if (a==i-1) {dame = true; break;}
        a = i - 1;
        count++;
        continue;
      }
      i++;
    }
    if (dame) continue;
    ans = min(ans, count);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,sum=0;
	while(cin>>a>>b)
	{
			 if(a<=0&&b>=0)cout<<"Zero"<<endl;
		else if(a>0&&b>0)  cout<<"Positive"<<endl;
		else if(a<0&&b<0)
		{
			for(int i=a;i<=b;i++)
			{
				if(i<=b)sum++;
			}
			if(sum%2==0)cout<<"Positive"<<endl;
			else		cout<<"Negative"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
int gcd(int A,int B){
  if(A<B)
    swap(A,B);
  while(1){
    int C=A%B;
    if(C==0)
      return B;
    A=B;
    B=C;
  }
}
signed main(){
  int A,B; cin>>A>>B;
  cout<<A*B/gcd(A,B)<<endl;
  }



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[]={500,100,50,5,1};
int main()
{
    int n ;
    cin >> n ;
    int ans = n / 500 *(2*500);
    n =  ( n %500);
    ans += (n-n%5);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;

int main()
{
	cin >> n >> m;

	double p = pow(0.5, m);
	double q = 1 - p;
	double h = (100 * (n - m) + 1900 * m);
	double sum = 0.0;

	for (int k = 0;k < 1000000;k++) {
		sum = sum + (k + 1) * h * pow(q,k)* p;
	}

	cout << (int) (sum + 0.5) << endl;

	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    double a,b,h,m;cin>>a>>b>>h>>m;
    double ax = a*cos(-1*(h/12+m/(60*12))*M_PI*2);
    double ay = a*sin(-1*(h/12+m/(60*12))*M_PI*2);
    double bx = b*cos(-1*(m/60)*M_PI*2);
    double by = b*sin(-1*(m/60)*M_PI*2);
    double ans = sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
    printf("%.12f\n", ans);
}


Measured memory_bytes: 4148
#include <stdio.h>

#define N 30

//
int a[N+1], c, count = 0;
int i=1;

int main(void)
{
    while (count++ < 28) {
        scanf("%d",&c);
        a[c] = 1;
    }
    for (; i < N + 1; i++) {
        if (a[i] == 0) {
            printf("%d\n", i);
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
struct UnionFind{
  int n,num;
  vector<int> r,p,e;
  UnionFind(){}
  UnionFind(int sz):n(sz),num(sz),e(sz,0),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) {e[x]++;return;}
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];e[x]+=e[y]+1;
    p[y]=x;
    num--;
  }
  int size(int x){  //頂点数
    return r[find(x)];
  }
  int size2(int x){  //辺の数
    return e[find(x)];
  }
  int count() const{
    return num;
  }
};
//main
signed main(){
  int N,H,W;cin>>N>>H>>W;
  typedef pair<int,int> P;
  typedef pair<int,P> PP;
  priority_queue<PP> que;
  for(int i=0;i<N;i++){
    int r,c,a;cin>>r>>c>>a;r--;c--;
    que.push(PP(a,P(r,c+100000)));
  }
  int ans=0;
  UnionFind uf(200000);
  while(que.size()){
    PP p=que.top();que.pop();
    int a=p.first,u=p.second.first,v=p.second.second;
    if(uf.same(u,v)){
      if(uf.size2(u)<uf.size(v)){
        uf.unite(u,v);
        ans+=a;
      }
    }
    else{
      int p=uf.size(u)+uf.size(v);
      int e=uf.size2(u)+uf.size2(v);
      if(e<p){
        uf.unite(u,v);
        ans+=a;
      }
    }
  }
  cout<<ans<<endl;
}

/*
解説AC
重みでソートして貪欲にやるとダメなのは明らか
でもよく考えると一番でかいのをr,c両方で取らないことも有り得ない
と言うわけで解法は「でかいのから取れるなら取る、ただし必要に迫られるまでr,cのどちらで取るかは確定させない」になる
あとはこれをどう実装するか
rとcでグラフ作ると各連結成分ごとに点と辺の数の関係に持っていける
この言い換えが苦手なのでしっかりしとめる
葉から順番に決めていくイメージのはず、新しいのを受け入れる為にみんなが場所を開けようとするイメージも
フローとしての解釈も習ったのでそこも覚えておく
*/


Measured memory_bytes: 8048
fun main() {
    val n = readLine()!!.toInt()
    val s = readLine()!!.toCharArray()
    val r = s.count { it == 'R' }.toLong()
    val g = s.count { it == 'G' }.toLong()
    val b = s.count { it == 'B' }.toLong()

    var result = r * g * b
    (0 until n).forEach { i ->
        (0 until n).forEach { d ->
            val j = i + d + 1
            val k = j + d + 1
            if (k <= n - 1 && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                result--
            }
        }
    }

    println(result)
}

Measured memory_bytes: 36760
object Main extends App {

  def substrList(s: String)(startindex: Int): Seq[String] =
    (startindex + 1 to s.length).take(5).map(l => s.slice(startindex, l))

  val (s, k) = (readLine, readInt)
  val ans = s.zipWithIndex
    .groupBy(_._1)
    .toSeq
    .sortBy(_._1)
    .toStream
    .flatMap {
      case (_: Char, indices: Seq[(Char, Int)]) =>
        indices
          .map(_._2)
          .flatMap(substrList(s))
          .distinct
          .sorted
          .toStream
    }
    .take(k)
    .last

  val ans2 = s.zipWithIndex
    .groupBy(_._1)
    .toSeq
    .sortBy(_._1)
    .toStream
    .flatMap {
      case (_: Char, indices: Seq[(Char, Int)]) =>
        indices
          .map(_._2)
          .flatMap(substrList(s))
          .distinct
          .sorted
          .toStream
    }
    .take(k)
    .last

  println(ans2)
}

Measured memory_bytes: 37960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var r = ReadLineInt();
            var g = ReadLineInt();

            Console.WriteLine(2*g - r);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    ll sum = 0;
    rep(i, n) sum += a[i];
    
    map<ll, int> mp;
    rep(i, n) mp[a[i]]++;
    
    int Q;
    cin >> Q;
    while (Q--) {
        ll b, c;
        cin >> b >> c;
        sum -= mp[b] * b;
        mp[c] += mp[b];
        sum += mp[b] * c;
        mp[b] = 0;
        cout << sum << endl;
    }
}


Measured memory_bytes: 9996
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        StringBuilder sb = new StringBuilder();
        for(int i = 0 ; i < s.length() ; i++){
        	char c = s.charAt(i);
        	if(97 <= c && c <= 122){
        		sb.append((char)(c-32));
        	}else{
        		sb.append(c);
        	}
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 17320
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<int> x(10010);
    vector<int> y(10010);
    int se = 0;
    for(int i = 0; i < x.size(); i++) {
        int tmp_x;
        int tmp_y;
        cin >> tmp_x >> tmp_y;
        if(tmp_x == 0 && tmp_y == 0) {
            se = i;
            break;
        }
        x[i] = tmp_x;
        y[i] = tmp_y;
    }
    for(int i = 0; i<se;i++) {
        if(x[i] > y[i]) {
            cout << y[i] << " " << x[i] << endl;
        } else {
            cout << x[i] << " " << y[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B, C := getInt(), getInt(), getInt()

	ans := "NO"

	for i := 0; i <= B; i++ {
		if i*A%B == C {
			ans = "YES"
			break
		}
	}

	out(ans)
}


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

typedef long long ll;

int main()
{
    double  w , h, x, y;
    cin>>w>>h>>x>>y;
    double ans =( w  * h )/2;
    cout.precision(15);
    cout<<ans<<" ";
    if( w/2 == x && h/2 == y )
    {
        cout<<1;
    }
    else cout<<0;
}

Measured memory_bytes: 3796
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	//D
	//	=
	//	25
	//	なら Christmas,
	//	D
	//	=
	//	24
	//	なら Christmas Eve,
	//	D
	//	=
	//	23
	//	なら Christmas Eve Eve,
	//	D
	//	=
	//	22
	//	なら Christmas Eve Eve Eve
	int D;
	cin >> D;
	switch (D) {
	case 25:
		cout << "Christmas" << endl;
		break;
	case 24:
		cout << "Christmas Eve" << endl;
		break;
	case 23:
		cout << "Christmas Eve Eve" << endl;
		break;
	case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;
	}
	return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import numpy as np

def solve():
    H, W = list(map(int, input().split()))
    S = []
    for i in range(H):
        S.append(list(input()))
    grid = (np.array(S) == ".") * 1  # ランプをおける:1, 障害物:0

    L = np.zeros((H,W), dtype=int)
    R = np.zeros((H,W), dtype=int)
    U = np.zeros((H,W), dtype=int)
    D = np.zeros((H,W), dtype=int)

    for j in range(W):
        if j==0:
            L[:,j] = grid[:,j]
        else:
            L[:,j] = (L[:,j-1]+1) * grid[:,j]
    
    for j in range(W-1, -1, -1):
        if j==(W-1):
            R[:,j] = grid[:,j]
        else:
            R[:,j] = (R[:,j+1] + 1) * grid[:, j]
    
    for i in range(H):
        if i==0:
            U[i,:] = grid[i,:]
        else:
            U[i,:] = (U[i-1,:]+1)*grid[i,:]
    
    for i in range(H-1, -1, -1):
        if i==(H-1):
            D[i,:] = grid[i,:]
        else:
            D[i,:] = (D[i+1,:]+1)*grid[i,:]
    
    ans = np.max(L+R+U+D-3)
    print(ans)

if __name__ == "__main__":
    solve()


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

#define INF 2147483647
#define RMQ_SIZE 262144

using namespace std;

void update(int pos, int value);
int getMin(int right, int left);
int dfs(int a,int b,int k,int l,int r);

int tree[RMQ_SIZE];

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

    for (int i = 0; i <= n; i++) {
        update(i, INF);
    }
    for (int i = 0; i < q; i++) {
        int tmp, a, b;
        cin >> tmp >> a >> b;
        if (tmp) {
            cout << getMin(a, b+1) << endl;
        } else {
            update(a, b);
        }
    }
            
    return 0;
}


int dfs(int a,int b,int k,int l,int r)
{
    //* ????±????????????????????????¬???????????¢?´¢.
    if (r <= a || b <= l) {
        return INF;
    }
    //* ??¨?????¬?????????????±?????????\???????????????.
    if (a <= l && r <= b) {
        return tree[k];
    }
    int m = (l+r)/2;
    return min(dfs(a, b, k*2+1, l, m), dfs(a, b, k*2+2, m, r));
}

int getMin(int right, int left)
{
    return dfs(right, left, 0, 0, RMQ_SIZE/2);
}

void update(int pos, int value)
{
    pos += (RMQ_SIZE/2 -1);
    tree[pos] = value;
    while (pos) {
        pos = (pos-1)/2;
        tree[pos] = min(tree[pos*2+1], tree[pos*2+2]);
    }
}

Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
#define re register
#define ll long long
#define get getchar()
#define in inline
#define db double
#define mian main
in int read()
{
	int t=0; char ch=get;
	while(ch<'0' || ch>'9') ch=get;
	while (ch<='9' && ch>='0') t=t*10+ch-'0', ch=get;
	return t;
}
const int _=3010;
const int mod=1e9+7;
ll n,m,f[_][_];
int main()
{
	n=read(),m=read();
	for (re int i=0;i<=n;i++)f[0][i]=1;
	ll ans=0;
	for (re int i=1; i<=m; i++)
		for (re int j=0; j<=n; j++)
		{
			//	f[i][j]=(f[i-1][j]*2)%mod;
			if(j>0)
				f[i][j]=(f[i][j]+f[i-1][j-1]+f[i-1][j])%mod;
			if(j<n)
				f[i][j]=(f[i][j]+f[i-1][j+1]+f[i-1][j])%mod;
		}
	for (re int i=0; i<=n; i++) ans=(ans+f[m][i])%mod;
	ll ans1=0;
	memset(f,0,sizeof(f));
	for (re int i=0;i<=n-1;i++)f[0][i]=1;
	for (re int i=1; i<=m; i++)
		for (re int j=0; j<=n-1; j++)
		{
			//		f[i][j]=(f[i-1][j]*2)%mod;
			if(j>0)
				f[i][j]=(f[i][j]+f[i-1][j-1]+f[i-1][j])%mod;
			if(j<n-1)
				f[i][j]=(f[i][j]+f[i-1][j+1]+f[i-1][j])%mod;
		}
	for (re int i=0; i<=n-1; i++) ans1=(ans1+f[m][i])%mod;
	cout<<((ans-ans1)+mod)%mod;
}


Measured memory_bytes: 71040
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }


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

  ll a[100000],b[100000],suma=0,sumb=0,ans=0;
  rep(i,n){
    cin>>a[i];
    suma+=a[i];
  }
  rep(i,n){
    cin>>b[i];
    sumb+=b[i];
  }

  ll fusoku=0;
  priority_queue<ll> que;
  rep(i,n){
    if(a[i]<b[i]) fusoku+=(b[i]-a[i]),ans++;
    else que.push(a[i]-b[i]);
  }

  if(suma<sumb) ans=-1;
  else if(!fusoku) ans=0;
  else{
    while(fusoku>=0){
      fusoku-=que.top();
      que.pop();
      ans++;
    }
  }


  cout<<ans<<endl;
}

Measured memory_bytes: 2936
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
    static class Reader {
        private BufferedReader br;
        private StringTokenizer token;

        protected Reader(InputStream obj) {
            br = new BufferedReader(new InputStreamReader(obj));
            token = null;
        }
        protected String next() {
            while (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {e.printStackTrace();}
            }
            return token.nextToken();
        }
        protected int[] nextIntArr(int n) {
            int[] arr = new int[n];
            for (int i=0; i<n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        protected int nextInt() {return Integer.parseInt(next());}
    }


    public static void main(String[] args) throws IOException {
        Reader in = new Reader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String s1 = in.next(), s2 = in.next();
        double num = Integer.parseInt(""+s1+s2);
        if (Math.floor(Math.sqrt(num)) == Math.sqrt(num)) out.printf("%s\n", "Yes");
        else out.printf("%s\n", "No");
        out.close();
    }
}

Measured memory_bytes: 21332
def dist(a, b)
  Math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)
end

n = gets.to_i
xys = n.times.map { gets.split.map(&:to_i) }

routes = [*0..n - 1].permutation
ans = 0

routes.each do |r|
  (n - 1).times do |i|
    a = r[i]
    b = r[i + 1]
    ans += dist(xys[a], xys[b])
  end
end

puts ans / 1.upto(n).inject(:*)


Measured memory_bytes: 2172
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>


/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/




#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()



using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;


const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;

mt19937 rnd;

int z[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    str s;
    if (n == 0) {
        cout << 0;
        return 0;
    }
    cin >> s;
    int l = 0;
    int r = n;
    while (r - l > 1) {
        int mid = (r + l) >> 1;
        bool good = false;
        fi(0, n) {
            memset(z, 0, sizeof(int) * n);
            z[i] = 0;
            int left = i;
            int right = i - 1;
            fj(i + 1, n) {
                z[j] = max(0, min(right - j + 1, z[j - left + i]));
                while (j + z[j] < n && s[j + z[j]] == s[i + z[j]])
                    ++z[j];
                if (z[j] >= mid && j - i >= mid)
                    good = true;
                if (j + z[j] - 1 > right) {
                    right = j + z[j] - 1;
                    left = j;
                }
            }
        }
        if (good)
            l = mid;
        else
            r = mid;
    }
    cout << l;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("trapv")
#define I inline void 

using namespace std ; 
using ll = long long ; 
using ld = long double ; 
	
const int N = 2e5 + 7 , mod = 1e9 + 7 ; 

// How interesting!
	
int n , m; 

ll a[N] ; 
	
int main(){	
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 

	int n ; 
	cin >> n ; 
	ll ans = 0 ; 

	for(int i = 0 ;i < n;i++){
		ll x , y; 
		cin >> x >> y ;
	      ans+= 9 * y + x * y ;
	}
	cout<< (ans - 10) / 9 ; 
	return 0 ; 
	
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int d,u,l;

	cin >> d;
	u = d / 100;
	l = d % 100;

	if ((1 <= u) && (u <= 12))
	{
		// upper MM or YY
		if ((1 <= l) && (l <= 12))
		{
			cout << "AMBIGUOUS";
		}
		else
		{
			cout << "MMYY";
		}
	}
	else
	{
		// upper YY
		if ((1 <= l) && (l <= 12))
		{
			cout << "YYMM";
		}
		else
		{
			cout << "NA";
		}

	}
	return 0;
}


Measured memory_bytes: 256
// seabreeeze //
 
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli unsigned long long
lli MOD=1e9+7;
 
#define MAXN 2000006 
 
// Template function //
lli powermod(lli x, lli y)  
{  
    lli res = 1;  
    x = x % MOD;
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % MOD;  
        y = y>>1;   
        x = (x*x) % MOD;  
    }  
    return res;  
}
lli modinv(lli x)
{
    return powermod(x,MOD-2);
}
// Template functions end //
 
// Custom funtions //
void preprocess()
{

}

int mex(int a[],int n)
{
    vector<int> c(n+1,0);
    for(int i=0;i<n;i++)
    {
        c[a[i]]=1;
    }
    for(int i=0;i<n+1;i++)
    {
        if(c[i]==0)
        return i;
    }
    return 0;
}
 
// Custom functions end //
 
int main()
{
    lli q=1;
    // cin>>q;
    time_t start, end;
    time(&start);
    preprocess();
    for(lli tc=1;tc<=q;tc++)
    {
        // Start solution //
        int n;
        cin>>n;
        lli a[n];
        lli ans = 0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        if(n==2)
        {
            cout<<a[1]<<endl;
            goto end;
        }
        for( int i=0;i<n/2;i++)
        {
            ans+=a[i+n/2]*2;
        }
        if(n%2)
        {
            ans+=a[n-1];
            ans-=a[n/2];
        }
        else ans-=a[n-1];
        cout<<ans<<endl;
        // lli a;
        // vector<lli> v[2];
        // for(int i=0;i<n;i++)
        // {
        //     cin>>a;
        //     if(a>=0)
        //     v[0].push_back(a);
        //     else v[1].push_back(abs(a));
        // }
        // sort(v[0].begin(),v[0].end());
        // sort(v[1],begin(),v[1].end());
        // lli ans = INT_MIN;
        // reverse(v[0].begin(),v[0].end());
        // reverse(v[1].begin(),v[1].end());
        // for(int i=0;i<min((int)v[1].size(),k);i+=2)
        // {
            
        // }
        
        // End Solution //
        end:;
    }
    
    time(&end);
    // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
    return 0;
}

Measured memory_bytes: 5196
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++)
    cin>>a[i];
  sort(a.begin(),a.end());
  int num=a[0]+a[1];
  cout<<num<<endl;
  return 0;
}



Measured memory_bytes: 256
n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }

a = a.map.with_index{|t,i| [t,i] }.sort_by{|(t,_)| -t }

dp = Array.new(n+1){ [0] * (n+1) }

a.each_with_index do |(a, k),i|
  (i+1).times do |j|
    dp[i+1][j+1] =                  dp[i][j] + (k      -j) * a
    dp[i+1][j]   = [ dp[i+1][j],    dp[i][j] + (n-i+j-1-k) * a ].max
  end
end

puts dp[-1].max

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



int main(void){
    int n, x, y;
    std::cin >> n >> x >> y;
    std::stack<int> go;
    std::vector<std::vector<int>> cand(n);
    std::vector<bool> flag(n, false);
    std::vector<int> tmpd(n, 0);
    std::vector<int> d(n, 0);
    std::vector<int> sum(n, 0);
    //cand.resize(n);


    cand.at(0).push_back(1);
    cand.at(n-1).push_back(n-2);
    for(int i = 1; i < n-1; i++){
        cand.at(i).push_back(i-1);
        cand.at(i).push_back(i+1);
    }

    cand.at(x-1).push_back(y-1);
    cand.at(y-1).push_back(x-1);

    for(int i = 0; i < n; i++){
        go.push(i);
        flag[i] = true;
        for(int j = 0; j < n; j++){
            while(!go.empty()){
                int a = go.top();
                go.pop();
                
                for(auto k : cand[a]){
                    //if(k == i) break;
                    //std::cout << k << " " << 
                    if(!flag[k]){
                        tmpd[k] = tmpd[a] + 1; 
                        flag[k] = true;
                        go.push(k);
                    }else if(tmpd[k] >= tmpd[a] + 1){
                        tmpd[k] = tmpd[a] + 1;
                        go.push(k);
                    }
                    
                }       

            }
        }
        
        //std::cout << std::endl;
        
        /*
        std::cout << i << std::endl;
        for(int j = 0; j < n; j++){
            std::cout << tmpd[j] << " ";
        }
        */
        for(int j = i; j < n; j++){
            if(tmpd[j] == 0) continue;
            sum[tmpd[j] - 1]++;
        }

        //std::cout << std::endl;
        for(int j = 0; j < n; j++){
            tmpd[j] = 0;
            flag[j] = false;
        }


    }

    for(int i = 0; i < n - 1; i++){
        std::cout << sum[i] << std::endl;
    }

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
 int a, b, c;
 int d;
 
 int main(){ 

  cin >> a >> b;
  
  if (b < 10) c = a*10+b;
   else if ((b >= 10) && (b < 100)) c = a*100+b;
   else if (b==100) c = a*1000+b;
 
  d = sqrt(c);
  
  if (c == d*d) cout  << "Yes" << endl;
   else cout << "No" << endl;

 return 0;
}


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

int main(){
    int n;
    int taroP = 0;
    int hanakoP = 0;
    string taroC,hanakoC;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> taroC >> hanakoC;
        if(taroC < hanakoC){
            hanakoP += 3;
        }else if(taroC > hanakoC){
            taroP += 3;
        }else{
            taroP++; hanakoP++;
        }
    }
    cout << taroP << " " << hanakoP << endl;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
string s[6];
void u(){
  char p;p=s[0][2];s[0][2]=s[1][2];s[1][2]=s[1][3];s[1][3]=s[0][3];s[0][3]=p;
  char c[2];
  c[0]=s[2][0],c[1]=s[2][1];
  s[2][0]=s[2][2],s[2][1]=s[2][3];
  s[2][2]=s[2][4],s[2][3]=s[2][5];
  s[2][4]=s[2][6],s[2][5]=s[2][7];
  s[2][6]=c[0],s[2][7]=c[1];
}
void f(){
  char p;p=s[2][2];s[2][2]=s[3][2];s[3][2]=s[3][3];s[3][3]=s[2][3];s[2][3]=p;
  char c[2];
  c[0]=s[1][2],c[1]=s[1][3];
  s[1][2]=s[3][1],s[1][3]=s[2][1];
  s[2][1]=s[4][2],s[3][1]=s[4][3];
  s[4][2]=s[3][4],s[4][3]=s[2][4];
  s[3][4]=c[1],s[2][4]=c[0];
}
void r(){
  char p;p=s[2][4];s[2][4]=s[3][4];s[3][4]=s[3][5];s[3][5]=s[2][5];s[2][5]=p;
  char c[2];
  c[0]=s[3][6],c[1]=s[2][6];
  s[2][6]=s[1][3],s[3][6]=s[0][3];
  s[0][3]=s[2][3],s[1][3]=s[3][3];
  s[3][3]=s[5][3],s[2][3]=s[4][3];
  s[4][3]=c[0],s[5][3]=c[1];
}
void d(){
  char p;p=s[4][2];s[4][2]=s[5][2];s[5][2]=s[5][3];s[5][3]=s[4][3];s[4][3]=p;
  char c[2];
  c[0]=s[3][0],c[1]=s[3][1];
  s[3][0]=s[3][6],s[3][1]=s[3][7];
  s[3][6]=s[3][4],s[3][7]=s[3][5];
  s[3][4]=s[3][2],s[3][5]=s[3][3];
  s[3][2]=c[0],s[3][3]=c[1];
}
void b(){
  char p;p=s[2][6];s[2][6]=s[3][6];s[3][6]=s[3][7];s[3][7]=s[2][7];s[2][7]=p;
  char c[2];
  c[0]=s[0][2],c[1]=s[0][3];
  s[0][2]=s[2][5],s[0][3]=s[3][5];
  s[2][5]=s[5][3],s[3][5]=s[5][2];
  s[5][3]=s[3][0],s[5][2]=s[2][0];
  s[3][0]=c[0],s[2][0]=c[1];
}
void l(){
  char p;p=s[2][0];s[2][0]=s[3][0];s[3][0]=s[3][1];s[3][1]=s[2][1];s[2][1]=p;
  char c[2];
  c[0]=s[0][2],c[1]=s[1][2];
  s[0][2]=s[3][7],s[1][2]=s[2][7];
  s[3][7]=s[4][2],s[2][7]=s[5][2];
  s[4][2]=s[2][2],s[5][2]=s[3][2];
  s[2][2]=c[0],s[3][2]=c[1];
}
 
int main(){
  s[0]="..rr....";
  s[1]="..rr....";
  s[2]="ggyybbww";
  s[3]="ggyybbww";
  s[4]="..oo....";
  s[5]="..oo....";
  string t;
  cin>>t;
  for(int i=0;i<t.size();i++){
    if(t[i]=='U')u();
    if(t[i]=='F')f();
    if(t[i]=='R')r();
    if(t[i]=='D')d();
    if(t[i]=='B')b();
    if(t[i]=='L')l();
  }
  for(int i=0;i<6;i++)
    cout<<s[i]<<endl;
}

Measured memory_bytes: 3228