akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int ans = (int)(N / 1.08);
            if ((int)(ans * 1.08) == N)
            {
                Console.WriteLine(ans);
                return;
            }
            if ((int)((ans-1) * 1.08) == N)
            {
                Console.WriteLine(ans-1);
                return;
            }
            if ((int)((ans+1) * 1.08) == N)
            {
                Console.WriteLine(ans+1);
                return;
            }
                Console.WriteLine(":(");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A.at(i);
	for (int i = 0; i < N; i++) cin >> B.at(i);


	int sum = A.at(0);
	for (int i = 0; i < N; i++) sum += B.at(i);
	vector<int> v = { sum };

	for (int i = 1; i < N; i++) {
		int n = v.at(i - 1);
		n = n - B.at(i - 1) + A.at(i);
		v.push_back(n);
	}
	sort(v.begin(), v.end());

	cout << v.at(v.size() - 1) << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

bool S[330][330];
vector<pair<int, int> > C;
int A[330][330];

int main(){
    ll H, W, K;
    cin >> H >> W >> K;
    REP(i,H){
        REP(j,W){
            char c;
            cin >> c;
            if(c == '#'){
                S[i][j] = true;
                C.emplace_back(i, j);
            }
            else
                S[i][j] = false;

        }
    }

    REP(k,K){
        auto c = C[k];
        int y = c.first;
        int x = c.second;
        if(A[0][x] != 0){
            REPi(i,y,H){
                A[i][x] = k+1;
            }
        }
        else{
            REP(i,H){
                A[i][x] = k+1;   
            }
        }
    }

    REP(i,H){
        int last = 0;
        for(int j = 0; j < W; j++){
            if(A[i][j] == 0)
                A[i][j] = last;
            last = A[i][j];
        }

        last = 0;
        for(int j = W-1; j >= 0; j--){
            if(A[i][j] == 0)
                A[i][j] = last;
            last = A[i][j];
        }
    }

    REP(i,H){
        REP(j,W){
            printf("%d ", A[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2036
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;

LL n, l, a[101010];
int main() {
	cin >> n >> l;
	REP(i, n) {
		cin >> a[i];
	}
	LL maxl = 0, maxpos = 0;
	REP(i, n - 1) {
		if (maxl < a[i] + a[i + 1]) {
			maxl = a[i] + a[i+1];
			maxpos = i;

		}
	}
	if (maxl < l) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		REP(i, maxpos)cout << i+1 << endl;
		for (int i = n - 2; i >= maxpos; i--)cout << i+1 << endl;
	}
	//system("pause");
}

Measured memory_bytes: 1664
N = int(input())
if set(list(str(N))) == {"9"}:
    print(9 * len(str(N)))
elif N < 10:
    print(N)
elif set(list(str(N)[1:])) == {"9"}:
    print(int(str(N)[0]) + 9 * len(str(N)[1:]))
else:
    print(9 * (len(str(N)) - 1) + int(str(N)[0]) - 1)


Measured memory_bytes: 3060
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    string S;
    bool easy = true;
    cin >> S;
    REP (i, S.length()) {
        if ((S[i] == 'R' && (i+1) % 2 == 0) || (S[i] == 'L' && (i+1) % 2 == 1)) {
            easy = false;
        }
    }
    if (easy) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



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

int main(void)
{

    int R;
    string contest = "AGC";

    cin >> R;
	
	if(R<1200) {
		contest = "ABC";
	}
	else if(R<2800) {
		contest = "ARC";
	}
	
	printf("%s",contest.c_str());
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, x; 
  cin >> N >> x;

  if(x == 1 || x == 2*N-1){
    No;
    return 0;
  }

  vector<int> ans(2*N-1);
  int p = 1;
  REP(i, 2*N-1){
    if(N-2 <= i && i <= N) continue;
    while(IN(x-1, p, x+2)) p++;
    ans[i] = p++;
  }

  ans[N-2] = x-1;
  ans[N-1] = x;
  ans[N+0] = x+1;

  Yes;
  REP(i, 2*N-1){
    cout << ans[i] << "\n";
  }

  return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    string s;
    cin>>s;
    int t[30]={};
    rep(i,s.size()){
        t[s[i]-'a']++;
    }
    rep(i,'z'-'a'+1){
        if(t[i]%2==1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

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

int main() {

  int n;
  cin >> n;
  
  int c[4]={0};
  string t[4] = {"AC", "WA", "TLE", "RE"}; 
  string s;
  REP(i,n) {
    cin >> s;
    REP(j,4) {
      if (s == t[j]) c[j]++;
    }
  }
  
  REP(i,4) {
    cout << t[i] << " x " << c[i] << endl;
  }  
  
}


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

int main() {
    int64_t N, K, c, a = 1;
    cin >> N >> K;
    double ans = 0.0, b;
    
    for (int i = 0; i < N; i++) {
        c = i + 1;
        while (c < K) {
            c *= 2;
            a *= 2;
        }
      b = a;
        ans += 1 / b;
        a = 1;
    }
    cout << setprecision(15) << ans / N << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n;
ll d[110][5][5][5];
ll res;
int main()
{
	cin >>n;
	d[0][4][4][4]=1;
	for (int t=1;t<=n;t++)
	{
		for (int i=0;i<5;i++)
		{
			for (int j=0;j<5;j++)
			{
				for (int k=0;k<5;k++)
				{
					for (int it=0;it<4;it++)
					{
						if (j==0 && k==1 && it==2) continue;
						if (j==0 && k==2 && it==1) continue;
						if (j==2 && k==0 && it==1) continue;
						if (i==0 && j==2 && it==1) continue;
						if (i==0 && k==2 && it==1) continue;
						d[t][j][k][it]=(d[t][j][k][it]+d[t-1][i][j][k])%(ll)(1e9+7);
					}
				}
			}
		}
	}
	for (int i=0;i<4;i++)
	{
		for (int j=0;j<4;j++)
		{
			for (int k=0;k<4;k++)
			{
				res+=d[n][i][j][k];
			}
		}
	}
	cout <<res%(ll)(1e9+7);
	return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	map<string, int>l;
	map<string, int>r;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		cin >> L >> R;
		l[s] = L;
		r[s] = R;
	}
	cin >> N;
	stack<bitset<256>>st;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		//cout << i << endl;
		//if (!st.empty())cout << st.top().to_string() << endl;
		if (s[0] == '+') {
			auto b = st.top();
			st.pop();
			auto a = st.top();
			st.pop();
			bitset<256>ret;
			for (int j = 0; j < 256; j++) {
				for (int k = 0; k < 256; k++) {
					if (a.test(j) && b.test(k)) {
						ret.set((j + k) % 256);
					}
				}
			}
			st.push(ret);
		}
		else if (s[0] == '-') {
			auto b = st.top();
			st.pop();
			auto a = st.top();
			st.pop();
			bitset<256>ret;
			for (int j = 0; j < 256; j++) {
				for (int k = 0; k < 256; k++) {
					if (a.test(j) && b.test(k)) {
						ret.set((j - k + 256) % 256);
					}
				}
			}
			st.push(ret);
		}
		else if (s[0] == '*') {
			auto b = st.top();
			st.pop();
			auto a = st.top();
			st.pop();
			bitset<256>ret;
			for (int j = 0; j < 256; j++) {
				for (int k = 0; k < 256; k++) {
					if (a.test(j) && b.test(k)) {
						ret.set((j * k) % 256);
					}
				}
			}
			st.push(ret);
		}
		else if(s[0]=='/'){
			auto b = st.top();
			st.pop();
			auto a = st.top();
			st.pop();
			bitset<256>ret;
			if (b.test(0)) {
				cout << "error" << endl;
				return 0;
			}
			for (int j = 0; j < 256; j++) {
				for (int k = 0; k < 256; k++) {
					if (a.test(j) && b.test(k)) {
						ret.set((j / k) % 256);
					}
				}
			}
			st.push(ret);
		}
		else if (s[0] <= '9'&&s[0] >= '0') {
			int num = stoi(s);
			bitset<256>ret;
			ret.set(num);
			st.push(ret);
		}
		else {
			bitset<256>ret;
			for (int i = l[s]; i <= r[s]; i++) {
				ret.set(i);
			}
			st.push(ret);
		}
	}
	cout << "correct" << endl;
}


Measured memory_bytes: 3248
// https://atcoder.jp/contests/agc037/submissions/6956246
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#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 chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define ceil(a, b) a / b + !!(a % b)
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h;
    while (cin >> h && h) {
        int w;
        cin >> w;
        char r[h][w];
        rep(i, h) rep(j, w) cin >> r[i][j];
        
        string str;
        cin >> str;
        
        int ans = 0;
        
        pii now = pii(0, 0);
        rep(k, sz(str)) {
            queue<pii> q;
            q.push(now);
            
            int reached[h][w];
            rep(i, h) rep(j, w) reached[i][j] = -1;
            reached[now.F][now.S] = 0;
            
            while (!q.empty()) {
                pii cur = q.front();
                q.pop();
                
                rep(i, 4) {
                    int ny = cur.F + dy[i];
                    int nx = cur.S + dx[i];
                    if (ny < 0 || ny >= h || nx < 0 || nx >= w || reached[ny][nx] != -1) continue;
                    reached[ny][nx] = reached[cur.F][cur.S] + 1;
                    q.push(pii(ny, nx));
                }
            }
            
            rep(i, h) rep(j, w) if (r[i][j] == str[k]) {
                ans += reached[i][j] + 1;
                now = pii(i, j);
            }
            
            // cout << endl; rep(i, h) { rep(j, w) cout << reached[i][j] << " "; cout << endl; }
            // cout << ans << endl;
        }
        
        cout << ans << endl;
    }
}




Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int n;
    scanf("%d", &n);
    vector<int> length(n);
    rep(i,n) scanf("%d", &length.at(i));
    sort(all(length));
    int sum = 0;
    rep(i,n-1) {
        sum += length.at(i);
    }
    if (length.at(length.size()-1) < sum) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
bool table[100];
using namespace std;
int main(void) {
	for (int i = 0; i < 28; i++) {
		int buf;
		cin >> buf;
		table[buf] = true;
	}
	int i=1;
	for (; table[i]; i++);
	cout << i++ << endl;
	for (; table[i]; i++);
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 1160
from math import gcd


def main():
    K = int(input())
    ans = 0

    for i in range(1, K+1):
        for j in range(1, K+1):
            temp = gcd(i, j)
            for l in range(1, K+1):
                ans += gcd(temp, l)
                
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9016
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a.at(i);
  int mi = n;
  int count=0;
  rep(i,n){
    if(mi>=a.at(i))count++;
    mi = min(mi,a.at(i));
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  vi lgcd(n),rgcd(n);
  lgcd[0] = a[0];
  for (int i = 1; i < n; i++) lgcd[i] = gcd(lgcd[i-1],a[i-1]);
  rgcd[n-1] = a[n-1];
  for (int i = n-2; i >= 0; i--) rgcd[i] = gcd(rgcd[i+1],a[i+1]);

  int ans = 0;
  chmax(ans,rgcd[0]);
  for(int i = 1; i < n-1; i++){
    chmax(ans, gcd(lgcd[i],rgcd[i]));
  }
  chmax(ans, lgcd[n-1]);
  
  std::cout << ans << '\n';
}


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

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  if(s.size() == a+b+1 && s.at(a) == '-' ){
    bool ans = true;
    for(int i = 0; i < a; i++){
      if(s.at(i) == '-' ){
        ans = false;
        break;
      }
    }
    for(int i = a+1; i < a+b+1; i++){
      if(s.at(i) =='-'){
        ans = false;
        break;
      }
    }
    if(ans && s.size() != 1){
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3644
import queue


def bfs(g, s=1):
    global q

    dist = [-1] * len(g)
    dist[1] = 0
    q = queue.Queue()
    q.put(s)

    while not q.empty():
        v = q.get()
        if not G[v][1]:
            continue
        for vi in G[v][2:]:
            if dist[vi] >= 0:
                continue
            q.put(vi)
            dist[vi] = dist[v] + 1

    return dist


n = int(input())
G = [None]
for i in range(n):
    G.append(list(map(int, input().split())))

d = bfs(G)
for i in range(1, n + 1):
    print('%d %d' % (i, d[i]))


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,A,B;
int P[5555];

int uku[5010][5010];

int dp[5555];

signed main(){
	cin>>N>>A>>B;
	rep(i,N)cin>>P[i+1],P[i+1]++;
	N+=2;
	P[0]=1;P[N-1]=N;
	rep(i,N){
		uku[i+1][P[i]]++;
		rep(j,N)uku[i+1][j+1]+=uku[i][j+1]+uku[i+1][j]-uku[i][j];
	}

	fill_n(dp,5555,INF);
	dp[0]=0;
	for(int i=1;i<N;i++){
		for(int j=0;j<i;j++){
			if(P[j]>P[i])continue;
			int tmp=dp[j];

			tmp+=(uku[i][N]-uku[i][P[i]]-uku[j+1][N]+uku[j+1][P[i]])*A;
			tmp+=(uku[i][P[i]]-uku[i][P[j]]-uku[j+1][P[i]]+uku[j+1][P[j]])*min(A,B);
			tmp+=(uku[i][P[j]]-uku[j+1][P[j]])*B;
			chmin(dp[i],tmp);
		}
	}
	cout<<dp[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 196096
from sys import stdin
N = int(stdin.readline().rstrip())

S = ""

if N == 0:
    print(0)
    
else:
    while N != 0:
        if N % (-2) == 0:
            S = "0" + S
        else:
            S = "1" + S
            N -= 1
        N = N / (-2)
    print(S)

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

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] x = new int[N];
            int[] y = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = in.nextInt();
                y[i] = in.nextInt();
            }

            int[] x2 = new int[N];
            int[] y2 = new int[N];
            for (int i = 0; i < N; i++) {
                x2[i] = x[i] + y[i];
                y2[i] = x[i] - y[i];
            }

            Arrays.sort(x2);
            Arrays.sort(y2);

            long min = Math.max(Math.abs(x2[0] - x2[N - 1]), Math.abs(y2[0] - y2[N - 1]));

            System.out.println(min);
        }
    }
}


Measured memory_bytes: 52648
#include<stdio.h>
#include<math.h>
double s,d[100010][35]={0};
double a[100010]={0};
int main(){
  int n,i,j;
  d[1][1]=1;
  for(i=1;i<100005;i++){
    a[i]=a[i-1];
    for(j=0;j<30;j++){//printf("%f ",d[i][j]);
      d[i+1][j+1]+=d[i][j]*(  1/pow(2.0,j));
      d[i+1][0  ]+=d[i][j]*(1-1/pow(2.0,j));
      if(j)a[i]+=d[i][j];
    }//printf("\n");
  }
  while(scanf("%d",&n),n)printf("%f\n",a[n]);
  return 0;
}

Measured memory_bytes: 28800
#include<stdio.h>

int parent(int);
int left(int);
int right(int);

int main(){
  int num,i,array[100001];
  scanf("%d",&num);

  for(i = 1;i <= num;i++){
    scanf("%d",&array[i]);
  }
  for(i = 1;i <= num;i++){
    printf("node %d: key = %d, ",i,array[i]);
    if(parent(i) >= 1){
      printf("parent key = %d, ",array[parent(i)]);
    }
    if(left(i) <= num){
      printf("left key = %d, ",array[left(i)]);
    }
    if(right(i) <= num){
      printf("right key = %d, ",array[right(i)]);
    }
    printf("\n");
}
return 0;
}

int parent(int i){
  return i / 2;
}
int left(int i){
  return 2 * i;
}
int right(int i){
  return 2 * i + 1;
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[][] result = new int[3][N];
        for (int j = 0; j < 3; j++) {
            for (int i = 0; i < N; i++) {
                if (j == 2 && i == N - 1) break;
                result[j][i] = Integer.parseInt(sc.next());
            }
        }

        int answer = 0;
        int preIndex = -1;
        for (int i = 0; i < N; i++) {
            answer += result[1][result[0][i] - 1];
            if ((result[0][i] - preIndex) == 1) {
                answer += result[2][preIndex - 1];
            }
            preIndex = result[0][i];
        }

        System.out.println(answer);
    }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    if (abs(a - b) % 2)
    {
        cout << "IMPOSSIBLE" << '\n';
    }
    else
    {
        cout << abs(min(a, b) + abs(a - b) / 2) << '\n';
    }
    return 0;
}


Measured memory_bytes: 3636
void solve(){
}
void main(){
	string s = instr();
	(700+s.count('o')*100).writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
alias instr = () => readln().chomp();
T inelm(T= int)(){ return to!(T)( readln().chomp() ); }
T[] inary(T = int)(){ return readln().chomp().split().to!(T[])(); }



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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<int> A(N);
  REP(i,N) {
    cin>>A[i];
  }
  int cnt = 1;
  int ans = 0;
  REP(i,N) {
    if(A[i] == cnt) {
      ans ++;
      cnt ++;
    }
  }
  if(ans == 0) {
    cout << -1 << endl;
  } else {
    cout << N - (cnt - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  int k, count1 = 0, count2 = 0;
  cin >> k;
  for(int i = 1; i <= k; i++){
    if(i % 2 == 0)
      count1 += 1;
    else
      count2 += 1;
  }
  cout << count1 * count2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int n;
  cin >> n;
  lol sum = 0, i = 1;
  while(sum < n){
    sum += i;
    i ++;
  }
  reps(j, i - 1){
    if(j != sum - n){
      cout << j << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
n=len(bin(b))-2

d=b-a+1
if d%2==0:
    ans=(d//2)%2
else:
    if b%2==0:
        ans=(d//2)%2
    else:
        ans=(d//2+1)%2

for i in range(1,n):
    now=2**(i+1)
    ra=a%now
    rb=b%now
    c=2**i
    cnt=0
    if rb-c>=0:
        cnt+=rb-c+1
    if ra-c>0:
        cnt+=now-ra
    else:
        cnt+=now-c
    ans+=(cnt%2)*c
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
typedef long long lint;
const int N=302;
const int mod=1e9+7;
int n,m,dp[2][N][N];
struct limit{
	int l,r,x;
	bool operator < (const limit b) const {
		return r<b.r;
	}
}lt[N];

inline void twk(int &x){
	if(x>=mod) x-=mod;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10+c-48,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
#ifndef ONLINE_JUDGE
//	freopen("a.in","r",stdin);
#endif
	n=nxi(),m=nxi();
	for(int i=1;i<=m;++i){
		lt[i].l=nxi();
		lt[i].r=nxi();
		lt[i].x=nxi();
	}
	std::sort(lt+1,lt+m+1);
	dp[1][0][0]=1;
	for(int q=1,i=1;i<n;++i){
		int p=i&1;
		memset(dp[p^1],0,sizeof(dp[p^1]));
		while(lt[q].r<i&&q<=m) ++q;
		for(int j=0;j<=i;++j){
//			for(int k=0;k<j;++k) printf("x ");
			for(int k=j;k<=i;++k){
//				printf("%d ",dp[p][j][k]);
				int tp=q,f=0;
				while(lt[tp].r==i){
					if((k>=lt[tp].l)+(j>=lt[tp].l)+1!=lt[tp].x){
						f=1;
						break;
					}
					++tp;
				}
				if(f==1) continue;
				int cur=dp[p][j][k];
				twk(dp[p^1][j][k]+=cur);
				twk(dp[p^1][j][i]+=cur);
				if(j!=k) twk(dp[p^1][k][i]+=cur);
			}
//			puts("");
		}
//		puts("\n-----\n");
	}
/*	for(int i=0;i<=n;++i){
		for(int j=0;j<i;++j) printf("x ");
		for(int j=i;j<=n;++j) printf("%d ",dp[n&1][i][j]);
		puts("");
	}
	puts("---");*/
	for(int j=0;j<=n;++j){
		for(int k=j;k<=n;++k){
			int tp=m,f=0;
			while(lt[tp].r==n){
				if((k>=lt[tp].l)+(j>=lt[tp].l)+1!=lt[tp].x){
					f=1;
					break;
				}
				--tp;
			}
			if(f) dp[n&1][j][k]=0;
		}
	}
	int ans=0;
	for(int i=0;i<=n;++i){
//		for(int j=0;j<i;++j) printf("x ");
		for(int j=i;j<=n;++j){
//			printf("%d ",dp[n&1][i][j]);
			if(i==0&&j==0) ans=(ans+(lint)dp[n&1][i][j]*3)%mod;
//			else if(i==0||j==0) ans=(ans+(lint)dp[n&1][i][j]*2)%mod;
			else ans=(ans+(lint)dp[n&1][i][j]*6)%mod;
		}
//		puts("");
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    string N;
    cin >> N;
    bool ok = true;
    rep(i, 3)
    {
        if (N[i] == '7')
        {
            ok = false;
        }
    }
    if (ok)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
 
  vector<int>num(N,0);
  for(int i=0;i<N;i++){
    cin >> num[i];
  }
 
  sort(num.begin(),num.end());
 
  long a = 0;
  long b = 0;
 
  for(int i=0;i<N-1;i++){
    if(num[i] == num[i + 1] && num[i] > a){
      b = a;
      a = num[i];
      num[i + 1] = 0;
    }
    else if(num[i] == num[i + 1] && num[i] > b){
      b = num[i];
      num[i + 1] = 0;
    }
  }
 
  cout << a * b << endl;
 
  return 0;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
tmp = -1
c = []
for _ in range(N):
	C = INT()
	if C != tmp:
		c.append(C)
	tmp = C

n = len(c)
dic = defaultdict(int)

dp = [0]*(n+1)
dp[0] = 1

for i in range(n):
	dp[i+1] = (dp[i] + dic[c[i]])%mod
	dic[c[i]] = (dic[c[i]] + dp[i])%mod

print(dp[-1])


Measured memory_bytes: 34612
#include <iostream>

using namespace std;

int main()
{
    string x,y,c;
    cin>>x>>y;
    int a,s;
    cin>>a>>s;
    cin >>c;
    if (c==x)
        a--;
    else
        s--;
    cout << a<<" "<<s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

double ans[100][100], x[100], y[100];

vector <int> v;

int main () {
    to_pray();

    int n;
    cin >> n;
    
    for (int i = 1; i <= n; ++ i) {
    	cin >> x[i] >> y[i];
    }
    
    for (int i = 1; i <= n; ++ i) {
    	for (int j = 1; j <= n; ++ j) {
    		if (i == j)
    			continue;
    		ans[i][j] = double(sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i])));
    	}
    }
    
    for (int i = 1; i <= n; ++ i) {
    	v.eb(i);
    }
    
    double res = 0;
    
    int cnt = 0;
    
    do {
    	double sum = 0;
    	for (int i = 0; i < sz(v) - 1; ++ i) {
    		sum += ans[v[i]][v[i + 1]];
    	}
    	res += sum;
    	++cnt;
    }while(next_permutation(all(v)));
    
    cout << fixed << setprecision(9) << double(res / cnt);
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    ll n, x; cin >> n >> x;
    ll res;
    REP(i, n) {
        ll tmp;
        cin >> tmp;
        if (i == 0) {
            res = abs(tmp - x);
        } else {
            res = gcd(res, abs(tmp - x));
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3616
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Pair = Tuple!(long, "flag", long, "num");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

auto dp = new long[100_100];
void main()
{
    long n, k;
    scan(n, k);
    auto h = aryread();
    dp[] = INF;
    dp[0] = 0, dp[1] = abs(h[1] - h[0]);
    foreach (i; iota(2, n))
    {
        foreach (j; iota(1, min(i, k) + 1))
        {
            dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]);
        }
    }
    dp[n - 1].writeln();
}


Measured memory_bytes: 5176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String ans = "";

        char[] alphabet = {'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'};
        StringBuilder elem = new StringBuilder();

        for (int i = 0; i < alphabet.length; i++) {
            if (!s.contains(String.valueOf(alphabet[i]))) {
                elem.append(alphabet[i]);
                break;
            }
        }

        if (elem.length() == 0) {
            ans = "None";
        } else {
            ans = elem.toString();
        }


        System.out.println(ans);
    }
}

Measured memory_bytes: 22632
import java.util.*;

class Main{
 
    void solve(){
        Scanner sc = new Scanner(System.in);
         
        int max = 1200;
        boolean[] p = new boolean[max];
        for(int i=2; i<max; i++) p[i] = true;
        for(int i=2; i<Math.sqrt(max); i++){
            if(!p[i*i]) continue;
            for(int j=i*i; j<max; j+=i) p[j] = false;
        }

        int[][] dp = new int[max][15];
        dp[0][0] = 1;
        for(int k=1; k<max; k++){
            if(!p[k]) continue;
            for(int i=max-1; i>=0; i--){
                if(i-k<0) continue;
                for(int j=14; j>=1; j--){
                    dp[i][j] += dp[i-k][j-1];
                }
            }
        }
 
        while(true){
            int n = sc.nextInt(), K = sc.nextInt();
            if(n==0 && K==0) break;
            System.out.println(dp[n][K]);
        }
    }
 
    public static void main(String[] args){
        new Main().solve();
    }
}

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

int main(){
  long long A, B, K, ans1,ans2;
  cin >> A >>B >>K;

  if(A >= K){
      ans1=A-K;
      ans2=B;

  }
  else{
      ans1=0;
      ans2=A+B-K;
  }

  if(ans1<0){
    ans1=0;
  }
  if(ans2<0){
    ans2=0;
  }
  cout << ans1 <<" "<<  ans2;
  return 0;
}


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

const int mod = 1000000007;
int dp[10001][2][101] = {};

int main(){
    string s;
    int d;
    cin >> s >> d;
    int n = s.length();
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k <= d; k++){
                for(int l = 0; l <= 9; l++){
                    if(j == 0 && l > s[i]-'0')  continue;
                    int ni = i+1;
                    int nj = j|(l<s[i]-'0');
                    int nk = (k+l)%d;
                    dp[ni][nj][nk] += dp[i][j][k];
                    dp[ni][nj][nk] %= mod;
                }
            }
        }
    }
    cout << (dp[n][0][0]+dp[n][1][0]-1+mod)%mod << endl; // overflow?
    return 0;
}

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

static class CodeJam
{
    static long Solve(int N, int M, Tuple<long, int>[] shops)
    {
        long ans = 0;
        Array.Sort(shops);
        foreach (var shop in shops)
        {
            int m = Math.Min(shop.Item2, M);
            ans += shop.Item1 * m;
            M -= m;
            if (M == 0) { break; }
        }
        return ans;
    }

    static void Main(string[] args)
    {
        int[] V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = V1[0], M = V1[1];
        var shops = new Tuple<long, int>[N];
        for (int i = 0; i < N; ++i)
        {
            long[] V2 = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            shops[i] = new Tuple<long, int>(V2[0], (int)V2[1]);
        }
        Console.WriteLine(Solve(N, M, shops));
    }
}


Measured memory_bytes: 21164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] A = new int[N+2];
        A[0] = 0;
        A[N+1] = 0;
        for (int i = 1; i <= N; i++) {
            A[i] = scan.nextInt();
        }
        long answer = 0;
        for (int i = 1; i <= N+1; i++) {
            answer += Math.abs(A[i] - A[i-1]);
        }
        for (int i = 1; i <= N; i++) {
            int x = Math.abs(A[i]   - A[i-1]) + Math.abs(A[i+1] - A[i]);
            int y = Math.abs(A[i+1] - A[i-1]);
            System.out.println(answer - (x-y));
        }
    }
}

Measured memory_bytes: 63800
#include<iostream>
#include<cstring>
using namespace std;
typedef long long int LL;
int path[100005][2];
LL s[100005];
LL num[100005];
int root[100005];

int check_root(int a){
	if(root[a]==-1)return a;
	return root[a]=check_root(root[a]);
}

int main(){
	LL n,m;
	LL a,b,c;
	int i,j,k;
	memset(root,-1,sizeof(root));
	for(i=0;i<1e5+5;i++){num[i]=1;}
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>path[i][0]>>path[i][1];
		path[i][0]--,path[i][1]--;
	}
	s[m]=n*(n-1)/2;
	for(i=m-1;i>=0;i--){
		s[i]=s[i+1];
		a=check_root(path[i][0]),b=check_root(path[i][1]);
		if(a==b)continue;
		s[i]-=num[a]*num[b];
		num[a]+=num[b];
		root[b]=a;
	}
	for(i=1;i<=m;i++){
		cout<<s[i]<<endl;
	}
	return 0;
}
	


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int maxn=3005;
const long long inf=0x3f3f3f3f;
long long dp[maxn][maxn][5];
long long b[maxn][maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    memset(b,-inf,sizeof(b));
    long long n,m,x;
    cin>>n>>m>>x;
    for(long long i=1;i<=x;i++)
    {
    	int r,c,v;
    	cin>>r>>c>>v;
  		b[r][c]=v;
    }
    for(long long i=0;i<=n;i++)
    {
    	for(long long j=0;j<=m;j++)
    	{
    		for(long long k=0;k<=3;k++)
    		{
    			if(i-1>=0)
    			{
    				dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
    				dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+b[i][j]);
				}
				if(j-1>=0)
				{
					dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
					if(k-1>=0)
						dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+b[i][j]);
				}
			}
		}
	}
	long long ans=0;
	for(long long k=0;k<=3;k++)
		ans=max(dp[n][m][k],ans);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 426376
#include <bits/stdc++.h>
using namespace std;
int main (){
  int i;
  int n;
  cin>>n;
  vector <int> a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  int f=1,c=0,j;
  for(i=0;i<n;i++){
    if(a[i]==f)
    f++;
    else{
      c++;
    }
    
  }
  if(c==n)
  cout<<-1;
  else
  cout<<c;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main(void){
    int n,ans = 0;
    cin >> n;
    vector<int> w(n),rui(n+1);
    for(int i = 0;i < n;i++){
        cin >> w[i];
        ans += w[i];
    }
    for(int i = 1;i <= n;i++){
        rui[i] = rui[i-1]+w[i-1];
    }
    for(int i = 0;i < n;i++){
        ans = min(ans,abs(rui[i+1]-(rui[n]-rui[i+1])));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  string S;
  cin >> S;
  int L = S.size();
  string ans = "AC";
  if(S[0] != 'A') ans = "WA";
  int cnt = 0;
  for(int i = 1;i < L ;i++){
    if(isupper(S[i])){
      if(i == 1 || i == L - 1 || S[i] != 'C'){
        ans = "WA";
      } 
      cnt++;
    }
  }
  if(cnt != 1 && !(isupper(S[L-1])) && !(isupper(S[1]))){
    ans = "WA";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();

		
		int[] t = new int[n];
		for(int i = 0; i < n; i++){
			t[i] = scn.nextInt();
		}
		int sum = 0;
		int y = 0;
		
		int m = scn.nextInt();
		for(int i = 0; i < m; i++){
			int x = scn.nextInt();
			y = t[x-1];
			t[x-1] = scn.nextInt();
			for(int j = 0; j < n; j++){
				sum += t[j];
			}
			System.out.println(sum);
			sum = 0;
			t[x-1] = y;
		}
	}
}

Measured memory_bytes: 10252
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 


signed main(){
  fio;

    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
    if(month[m1-1] == d1){
        cout<<"1";
    }
    else{
        cout<<"0";
    }

  rr;
}

Measured memory_bytes: 256
a, b, k = gets.chomp.split(" ").map(&:to_i)

if b - a <= 2 * k - 2 then
    for i in a..b do
        puts i
    end
else
    for i in a..(a+k-1) do
        puts i
    end
    for i in (b-k+1)..b do
        puts i
    end
end

Measured memory_bytes: 1788
package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)

	for {
		C = C - B
		if C <= 0 {
			fmt.Println("Yes")
            break
		}
		A = A - D
		if A <= 0 {
			fmt.Println("No")
            break
		}
	}
}

Measured memory_bytes: 1748
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;
const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    ll n,k;
    cin>>n>>k;
    ll tmp=n/k;
    ll tmp1=pow(tmp,3);//tmp*tmp*tmp;
    if(k%2!=0){
        cout<<tmp1<<endl;
    }else{
        ll tmp2=(n+k/2)/k;
        tmp1+=pow(tmp2,3);//tmp2*tmp2*tmp2;
        cout<<tmp1<<endl;
    }
}

Measured memory_bytes: 4032