akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;

int main(){
	
 	long long int q;
	double x;
	
	while(cin>>q){
		if(q!=-1){
			x= (double)q/2;
			while(abs(pow(x,3)-q)>=0.00001*q){
				x=x-((pow(x,3)-q)/(3*pow(x,2)));
		}
			printf("%.6f\n",x);
	}
		
		else
			break;
	
	
}
}

Measured memory_bytes: 1188
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	int tmp = 0, ans = 0;
	for (int i = 0; i < (int)(S.length()); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') tmp++;
		else {
			ans = max(ans, tmp);
			tmp = 0;
		}
	}

	cout << max(ans, tmp);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 3e3 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, dp[maxn][maxn];
string s;
int add(int a, int b)
{
	if(a + b >= mod) return a + b - mod;
	else if(a + b < 0) return a + b + mod;
	else return a + b;
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    cin >> s;
    dp[1][1] = 1;
    for(int i = 2; i <= n; i++)
    {
    	vector<int>pref(i, 0);
    	for(int j = 1; j < i; j++)
    		pref[j] = add(dp[i - 1][j], pref[j - 1]);
    	for(int cur = 1; cur <= i; cur++)
    	{
    		if(s[i - 2] == '<')
    			dp[i][cur] = pref[cur - 1];
    		else 
    			dp[i][cur] = add(pref[i - 1], -pref[cur - 1]);
    	}
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    	ans = add(ans, dp[n][i]);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstring>
#include<cctype>
#define INF 0x3f3f3f3f
#define lb long double
#define LINF 0x3f3f3f3f3f3f3f3f
#define ull unsigned long long
#define random(x) (rand()%x)
#define rep(i, a, b) for(int i=a;i<b;i++)
#define req(j, a, b) for(int j=a;j<b;j++)
#define mem(a, b) memset(a, b, sizeof(a))
#define PI 3.14
#define K 20

using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const double eps = 1e-14;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const int hash_mod = 19260817;

inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline double dbread()
{
    double X=0,Y=1.0; int w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=X*10+(ch^48),ch=getchar();
    ch=getchar();//读入小数点
    while(isdigit(ch)) X+=(Y/=10)*(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

int v[maxn];
double w[maxn];
int dp[1005][1005];

int sum = 0;

ll gcd(ll a,ll b)//辗转相除法（欧几里德算法）求最大公约数
{
    return b ? gcd(b,a%b) : a;
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);//最小公倍数
}

string a[maxn];
string b[maxn];

int main()
{
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    int sum = 0;
    while(m--)
    {
        int x;
        string s;
        cin >> x >> s;
        if(s == "AC")
        {
            if(v[x] == 0)
            {
                cnt++;
                v[x] = 1;
                sum += w[x];
            }
            else if(v[x] == 1)
            {
                continue;
            }
        }
        else if(s == "WA")
        {
            if(v[x] == 0)
            {
                w[x]++;
            }
            else if(v[x] == 1)
            {
                continue;
            }
        }
    }
    cout << cnt << " " << sum << endl;
    return 0;
}





Measured memory_bytes: 4352
#include <iostream>

using namespace std;
#define BIG 999999997
int i,j,n;
string str;

int out[500][500];

int main(){
  int H,W,h,w;
  cin >> H >> W >> h >> w;
  if(H%h == 0 && W%w == 0){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  if(H%h == 0){
    for(i = 0;i < W;i++){
      if(i % w){
        out[0][i] = -(BIG/(w-1)+1);
      }
      else{
        out[0][i] = BIG;
      }
    }
    for(i = 1;i < H;i++){
      for(j = 0;j < W;j++){
        out[i][j] = out[0][j];
      }
    }
  }
  else{
    for(i = 0;i < H;i++){
      if(i % h){
        out[i][0] = -(BIG/(h-1)+1);
      }
      else{
        out[i][0] = BIG;
      }
    }
    for(i = 1;i < W;i++){
      for(j = 0;j < H;j++){
        out[j][i] = out[j][0];
      }
    }
  }
  for(i = 0;i < H;i++){
    for(j = 0;j < W;j++){
      cout << out[i][j] << ' ';
    }cout << endl;
  }
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;

int main() {
   set<int>s;
   int n;
   cin >> n;
   int cont=n;
   while(n--){
      int a;
      cin >> a;
      if(s.count(a) == 1 && !s.empty()) {
          cont -= 2;
          s.erase(a);
      }
      else
          s.insert(a);
   }
   cout<< cont << endl;
   return 0;
}

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

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

    int n, q;
    cin >> n >> q;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    while(q--){
        long long x;
        cin >> x;

        long long ans = 0;
        int right = 0;
        long long sum = 0;
        for(int left = 0; left < n; left++){
            while((right < n) && (sum + A[right] <= x)){
                sum += A[right];
                right++;
            }

            ans += (right - left);

            if(left == right){
                right++;
            }else{
                sum -= A[left];
            }
        }
        cout << ans << endl;

    }

    return 0;
}


Measured memory_bytes: 3640
process.stdin.resume();
process.stdin.setEncoding('utf8');

var stdin = '';
process.stdin.on('data', function (chunk) {
  stdin += chunk;
}).on('end', function() {
  var lines = stdin.trim().split('\n');
  var numStr = lines[0].split(' ');
  var num = numStr[0]
  var numLength = num.length;
  var total = 0;
  for(var i = 0; i < numLength; i++) {
    if('1' === num[i]) {
      total++;
    }
  }
  console.log(total);
});


Measured memory_bytes: 7500
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))

int count16bit(unsigned short v)
{
    unsigned short count = (v & 0x5555) + ((v >> 1) & 0x5555);
    count = (count & 0x3333) + ((count >> 2) & 0x3333);
    count = (count & 0x0f0f) + ((count >> 4) & 0x0f0f);
    return (count & 0x00ff) + ((count >> 8) & 0x00ff);
}

int main(void)
{
    int ans = 0;
    int n;

    scanf("%d", &n);
    int x[n][n], y[n][n], a[n];

    rep(i, n)
    {
        scanf("%d", &a[i]);
        rep(j, a[i])
            scanf("%d%d", &x[i][j], &y[i][j]);
    }

    rep(i, 1 << n)
    {
        //printf("iBit:%d ", count16bit(i));
        int tmp[n];
        rep(j, n)
            tmp[j] = 0;
        rep(j, n)
        {
            if (i >> j & 1)
            {
                tmp[j] = 1;
                //printf("j:%d ", j);
            }
        }

        int flag = 1;
        rep(j, n)
        {
            if (tmp[j])
                rep(k, a[j])
                {
                    if ((i >> (x[j][k] - 1) & 1) ^ y[j][k])
                    {
                        flag = 0;
                        //printf("j:%d,k:%d ", j, k);
                    }
                }
        }
        if (flag == 1)
            ans = max(ans, count16bit(i));

        //printf("\n");
    }

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

    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; i++) {
         for (int j = 1; j < n; j++) {
            if (i * j < n) {
                ans++;
            }
            else break;
         }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
import fractions
A,B,C,D = list(map(int, input().split()))
a=(A-1)//C
b=B//C
c=(A-1)//D
d=B//D
g = C*D//fractions.gcd(C,D)
e=(A-1)//(g)
f=B//(g)

print(B-A+1 - (b-a) - (d-c) + (f-e))

Measured memory_bytes: 5048
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int a[] = new int[n];
    int total = 0;
    int max = 0;
    for(int i = 0;i<n;i++){
      a[i] = sc.nextInt();
    }
    int dis[] = new int[n];
    for(int i = 0;i<n-1;i++){//最後の以外の距離をだす&totalとmaxの管理
      dis[i] = a[i+1] - a[i];
      total += dis[i];
      if(max < dis[i]){
        max = dis[i];
      }
    }
    //最後と最初の距離をだす&&totalとmaxの管理
    dis[n-1] = k - a[n-1] + a[0];
    total += dis[n-1];
    if(max < dis[n-1]){
      max = dis[n-1];
    }

    int ans = total - max;
    System.out.println(ans);


  }
}


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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
    int N;
    ll R = 0, G = 0, B = 0;
    string S;

    cin >> N >> S;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            R++;
        } else if (S[i] == 'G') {
            G++;
        } else if (S[i] == 'B') {
            B++;
        }
    }
    ll total = R * G * B;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int d = j - i;
            if (j + d < N) {
                if (S[i] != S[j]
                    && S[j] != S[j + d]
                    && S[j + d] != S[i]) {
                        total--;
                }
            }
        }
    }

    cout << total << endl;
    return 0;
}


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

#define ll long long
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ii pair < int, int >
#define vi vector < int > 
#define all(a) (a).begin(), (a).end()

using namespace std;

const int MOD = 1e9 + 7, MAXN = 2e5 + 10;

inline int mult( ll a, ll b ) {
	return ( a * b ) % MOD;
}

inline int pot( int n, int k ) {
	if ( k == 0 ) return 1;
	ll a = pot( n, k / 2 );
	a = mult( a, a );
	if ( k % 2 ) a = mult( a, n );
	return a;
}

int divide( int a, int b ) {
	return mult( a, pot( b, MOD - 2 ) );
}

inline int sub( int a, int b ) {
	if ( a - b >= 0 ) return a - b;
	return a - b + MOD;
}

inline int add( int a, int b ) {
	if ( a + b >= MOD ) return a + b - MOD;
	return a + b;
}

int fact[ MAXN ];

int choose( int n, int k ) {
	int ret = 1;
	for( int i = 1;i <= k;i++ ) {
		ret = mult( ret, divide( sub( add( n, 1 ), i ), i ) );
	}
	return ret;
}

void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = sub( pot( 2, n ), 1 );
	
	fact[ 0 ] = 1;
	for( int i = 1;i < MAXN;i++ ) fact[ i ] = mult( fact[ i - 1 ], i );
	ans = sub( ans, choose( n, a ) );
	ans = sub( ans, choose( n, b ) );
	cout << ans << "\n";
}

int main() {
	int t = 1;
	//cin >> t;
	while ( t-- ) solve();
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int r = 0;
  for (int i = 0; i < n; i++) {
	  r += (s[i] == 'R');
	}
  if (r > n - r) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
h,w,m=map(int,input().split())
A=[0]*h ; B=[0]*w ;G=[]
for i in range(m):
    x,y=map(int,input().split())
    A[x-1]+=1 ; B[y-1]+=1
    G.append([x-1,y-1])

q=max(A) ; e=max(B)
Q=[i for i in range(h) if A[i]==q] 
W=[j for j in range(w) if B[j]==e];#print(A,B,Q,W)
cnt=len(Q)*len(W)



for i in range(m):
    x,y=G[i]
    if A[x]==q and B[y]==e:
        cnt-=1
#print(grid)
if cnt==0:
    print(q+e-1)
else:
    print(q+e)


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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s, t; cin >> s >> t;

  vector<string> se;
  rep(i, si(s) - si(t) + 1) {
    bool ok = true;
    rep(j, si(t)) if (s[i + j] != t[j] && s[i + j] != '?') ok = false;

    string tmp = s;
    if (ok) {
      rep(j, si(t)) tmp[i + j] = t[j];
      rep(j, si(s)) if (tmp[j] == '?') tmp[j] = 'a';

      se.emplace_back(tmp);
    }
  }

  if (se.empty()) cout << "UNRESTORABLE" << endl;
  else cout << *min_element(all(se)) << endl;
  
  return (0);
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main() {
  int n;
  cin>>n;
  ll a[100005];
  ll s=0;
  ll s_e=0;
  for (int i=0; i<n; i++) {
    cin>>a[i];
    s+=a[i];
    if (i%2==0) s_e+=a[i];
  }
  s_e*=2;
  ll x[100005];
  x[0]=s_e-s;
  for (int i=0; i<n-1; i++) {
    x[i+1]=2*a[i]-x[i];
  }
  for (int i=0; i<n; i++) {
    cout<<x[i];
    if (i==n-1) cout<<endl;
    else cout<<' ';
  }
  return 0;
}

Measured memory_bytes: 2816
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	string s;
	cin >> s;
	auto a = s.find_first_of( 'C' );
	auto b = s.find_last_of( 'F' );

	if( a != string::npos && b != string::npos && a < b ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); i++)

using namespace std;
typedef long long ll;
const int MAX_N = 100000;
const int MAX_W = 1000000000;
static const int INF = 1<<29;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
    // 追加２, 以降 cin の入力元が 'input.txt' になる
    //提出時に消す！！


    int N;
    cin >> N;
    int A[MAX_N],X[MAX_N];
    rep(i,N) cin >> A[i];
    int sum=0;
    rep(i,N) sum+=A[i];
    int sum2=0;
    for(int i=1;i<N;i=i+2){
        sum2+=A[i];
    }
    int x1=sum-2*sum2;
    X[0]=x1;
    for(int i=1;i<N;i++){
        int a=2*A[i-1]-X[i-1];
        X[i]=a;
    }
    rep(i,N) cout << X[i] << " ";
    
    cout << endl;

    return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

void answerNo() {
    cout << "No";
    exit(0);
}

int main() {
    ios_base::sync_with_stdio(0);
    
    int h, w;
    cin >> h >> w;
    
    const int ALPH = 'z' - 'a' + 1;
    VI cnt(ALPH, 0);
    
    FOR(i,0,h-1) FOR(j,0,w-1) {
        char c;
        cin >> c;
        
        cnt[c - 'a']++;
    }
    
    VI vals(5, 0);
    
    for (int i = 0; i <= h - 1 - i; i++) {
        for (int j = 0; j <= w - 1 - j; j++) {
            set <pii> fields;
            
            FOR(x,0,1) FOR(y,0,1) {
                int pi = (x ? i : h - 1 - i);
                int pj = (y ? j : w - 1 - j);
                
                fields.insert({pi, pj});
            }
            
            int s = fields.size();
            vals[s]++;
        }
    }
    
    FOR(i,0,ALPH-1) if (cnt[i] % 2) {
        if (!vals[1]) answerNo();
        
        cnt[i]--;
        vals[1]--;
    }
    
    if (vals[1]) answerNo();
    
    FOR(i,0,ALPH-1) cnt[i] /= 2;
    
    FOR(i,0,ALPH-1) if (cnt[i] % 2) {
        if (!vals[2]) answerNo();
        
        cnt[i]--;
        vals[2]--;
    }
    
    if (vals[2] % 2) answerNo();
    
    cout << "Yes";

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[]){
		int n=0,q=0;
		String S_String="", T_String = "";
		int[] S,T;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			n = Integer.parseInt(br.readLine());
			S_String = br.readLine();
			q = Integer.parseInt(br.readLine());
			T_String = br.readLine();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		S = StringToArray(S_String,n);
		T = StringToArray(T_String,q);
		int result = counter(n,q,S,T);
		System.out.println(result);
	}
	private static int counter(int n,int q, int[] S,int[] T){
		int[] temp;
		int buf;
		int counter = 0;
		Arrays.sort(S);
		Arrays.sort(T);
		if(n<q){
			temp=S;
			S = T;
			T = temp;
			buf = n;
			n=q;
			q=buf;
		}
		buf = 0;
		for(int i=0;i<q;i++){
			for(int j=buf;j<n;j++){
				if(S[j]==T[i]){
					counter++;
					break;
				}else if (S[j]>T[i]){
					buf = j;
					break;
				}
			}
		}
		return counter;
	}
	private static int[] StringToArray(String input,int number){
		int[] output = new int[number];
		StringTokenizer st = new StringTokenizer(input," ");
		for(int i=0;i<number;i++){
			output[i] = Integer.parseInt(st.nextToken());
		}
		return output;
	}
}

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

int main(){

    int N;
    cin >> N;

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

    vector<int> invX(N, 0);
    for(int i = 0; i < N; i++){
        invX.at(i) = pow(-1, i);
    }

    int X1 = 0;
    // mountain 1
    for(int i = 0; i < N; i++){
            X1 += invX.at(i) * A.at(i);
    }
    cout << X1 << " ";

    // Xi, i=2,3,...
    int Xi = X1;
    for(int i = 1; i < N; i++){
        Xi = 2*A.at(i-1) - Xi;
        cout << Xi;
        if( i != N - 1){
            cout << " ";
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int skl(int a){
  a%=10;
  return a!=0?10-a:0;
}

int main(){
  int n;cin>>n;
  int h[n];
  fol(i,n)cin>>h[i];
  int ans = 0;
  int mx = 0;
  fol(i,n){
    if(mx<=h[i]){
      ans++;
    }
    mx = max(mx,h[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;
int main(){
  int train[10],n,i;
  n = 0;
  int order[100],intrain[10];
  for( i = 1;i <= 10;i++){
    train[i] = i;
  }
  for(i=0;i<100;i++)
    order[i] = 11;
  i = 0;
  while(scanf("%d",&order[i]) != EOF){i++;}
  for(i = 0;order[i] != 11;i++){
    if(order[i] != 0){
      intrain[n] = order[i]; n++;}else if(order[i] == 0){
      n--;      cout << intrain[n] << endl;}
  }
}
 

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int N;
    string S,T,ans="";
    cin>>N>>S>>T;

    for(int i=0;i<N;i++){
        ans+=S[i];
        ans+=T[i];
    }

    cout<< ans<<endl;
    return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

int main()
{
    int n;
    cin >>n;
    int d;
    if(n%2==0){
        d=n/2;
    }
    else {
        d=(n/2)+1;
    }
    double ans=(double)d/n;
    cout << setprecision(20)<< ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
const int N=25;
queue<pii>q;
char c[N][N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dist[N][N],ans,n,m;
void bfs(int x,int y)
{
	q.push(mp(x,y));for(int i=0;i<N;i++)for(int j=0;j<N;j++)dist[i][j]=-1;
	dist[x][y]=0;
	while(!q.empty())
	{
		x=q.front().F;
		y=q.front().S;
		q.pop();
//		cout<<x<<' '<<y<<endl;
		ans=max(ans,dist[x][y]);
		for(int i=0;i<4;i++)
		{
			int x2=x+dx[i];
			int y2=y+dy[i];
			if(x2<0||y2<0||x2>=n||y2>=m||c[x2][y2]=='#')continue;
			if(dist[x2][y2]==-1)
			{
				dist[x2][y2]=dist[x][y]+1;
				q.push(mp(x2,y2));
			}
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(c[i][j]!='#')
			bfs(i,j);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

N,M=map(int,input().split())
XYZ=[list(map(int,input().split())) for i in range(M)]

Group=[i for i in range(N+1)]#グループ分け.Group[i]=jのときiとjは同じグループ

def find(x):#find(a)=find(b)のとき同じグループ
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):  # xとyが同じグループになるよう更新
    if find(x) != find(y):
        Group[find(y)]=Group[find(x)]=min(find(y),find(x))

for x,y,z in XYZ:
    Union(x,y)

ANS=[find(i) for i in range(1,N+1)]
print(len(set(ANS)))


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const int maxN = 200010;
const int MAXM = 310;
const int MAXK = 17;
const int MOD = 1000000007;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;
int n;
int c[maxN];
int last[maxN];
int vis[maxN];
ll f[maxN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[c[i]])
		{
			vis[c[i]] = i;
		}
		else
		{
			last[i] = vis[c[i]];
			vis[c[i]] = i;
		}
	}
	f[1] = 1ll;
	for(int i=2;i<=n;i++)
	{
		f[i] = f[i-1];
		if(last[i]>0 && last[i]<i-1)
		{
			f[i] += f[last[i]];
		}
		f[i] %= MOD;
	}
	cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 4096
use proconio::{input, fastout};
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input!{
        n:usize,
        m:usize,
        ab: [(Usize1, Usize1) ; m]
    }
    let mut graph = vec![vec![]; n];
    let mut seen = vec![false; n];
    for &(a, b) in &ab {
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut stack = Vec::new();

    let mut max_vnum = 0;
    for i in 0..n {
        if seen[i] {
            continue;
        }
        seen[i] = true;
        let mut vnum = 1;
        stack.push(i);
        while let Some(v) = stack.pop() {
            for &next in &graph[v] { 
                if seen[next] {
                    continue;
                }
                seen[next] = true;
                stack.push(next);
                vnum += 1;
            }
        }
        max_vnum = max_vnum.max(vnum);
    }
    println!("{}", max_vnum);
}


Measured memory_bytes: 21152
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    int A;
    cin >> A;
    cout << N * N - A << endl;
    return 0;
}


Measured memory_bytes: 3500
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
	int a,b,c,x,i,j,k,ans=0,sum;
	cin >> a >> b >> c >> x;
	for(i=0;i<=a;i++)		//枚举 
	{
		for(j=0;j<=b;j++)
		{
			for(k=0;k<=c;k++)
			{
				sum=i*500+j*100+k*50;
				if(sum==x)
				ans++;
				else if(sum>x)
				break;
			}	
			if(i*500+j*100>x)
			break;
		}
		if(i*500>x)
		break;	
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S; cin >> S;
	int X, Y; cin >> X >> Y;
	queue<int>x, y;
	int N = S.size();
	int cnt = 0;
	int t = 0;
	REP(i, N) {
		if (S[i] == 'F') cnt++;
		if (i == N - 1 || S[i] == 'T') {
			
			if (x.empty() && y.empty()) {
				x.push(cnt);
				y.push(0);
			}
			else if (t % 2) {
				queue<int>tmp;
				map<int, bool>mp;
				while (!y.empty()) {
					if (!mp[y.front() - cnt]) {
						tmp.push(y.front() - cnt);
						mp[y.front() - cnt] = 1;
					}
					if (!mp[y.front() + cnt]) {
						tmp.push(y.front() + cnt);
						mp[y.front() + cnt] = 1;
					}
					y.pop();
				}
				y = tmp;
			}
			else {
				queue<int>tmp;
				map<int, bool>mp;
				while (!x.empty()) {
					if (!mp[x.front() - cnt]) {
						tmp.push(x.front() - cnt);
						mp[x.front() - cnt] = 1;
					}
					if (!mp[x.front() + cnt]) {
						tmp.push(x.front() + cnt);
						mp[x.front() + cnt] = 1;
					}
					x.pop();
				}
				x = tmp;
			}
			t++;
			cnt = 0;
		}

	}

	int F = 0;
	while (!x.empty()) {
		if (x.front() == X)F++;
		//cout << x.front() << endl;
		x.pop();
	}
	//cout << endl;
	while (!y.empty()) {
		if (y.front() == Y)F++;
		//cout << y.front() << endl;
		y.pop();
	}
	if (F == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;
int h, w, n, ans;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int dp[50][50];
string m[50];

void init()
{
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            dp[i][j] = INF;
        }
    }
}

void bfs(P s, P g)
{
    init();
    queue<P> que;
    que.push(s);
    dp[s.first][s.second] = 0;
    while (!que.empty())
    {
        P p = que.front();
        que.pop();
        if (p == g)
        {
            ans += dp[p.first][p.second];
            return;
        }
        else
        {
            for (int i = 0; i < 4; i++)
            {
                if (p.first + dx[i] >= h || p.second + dy[i] >= w)
                    continue;
                if (p.first + dx[i] < 0 || p.second + dy[i] < 0)
                    continue;
                if (m[p.first + dx[i]][p.second + dy[i]] == '#')
                    continue;
                if (dp[p.first + dx[i]][p.second + dy[i]] == INF)
                {
                    dp[p.first + dx[i]][p.second + dy[i]] = dp[p.first][p.second] + 1;
                    que.push(P(p.first + dx[i], p.second + dy[i]));
                }
            }
        }
    }
    ans = -1;
    return;
}

int main()
{
    cin >> h >> w;
    int cnt = 0;
    for (int i = 0; i < h; i++)
    {
        cin >> m[i];
        for (int j = 0; j < w; j++)
        {
            if (m[i][j] == '#')
            {
                cnt++;
            }
        }
    }
    bfs(P(0, 0), P(h - 1, w - 1));
    if (ans == -1)
    {
        cout << ans << endl;
    }
    else
    {
        cout << h * w - ans - cnt - 1 << endl;
    }
    return 0;
}

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

int main(){
  int A, B, count=0;
  string c;
  cin >> A >> B;
  for (int i = A; i<=B; i++){
    c = to_string(i);
    if (c.at(0) == c.at(4) && c.at(1) == c.at(3)) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
void Judgetriangle(int a, int b, int c);
void judge(int a, int b, int c);
int a, b, c;
bool flag = false;
int main(void)
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        {
            flag = false;
            scanf("%d %d %d", &a, &b, &c);
            Judgetriangle(a, b, c);
        }
    return 0;
}

void Judgetriangle(int a, int b, int c)
{
    judge (a, b, c);
    judge (a, c, b);
    judge (b, c, a);
    if (flag == true) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}

void judge(int a, int b, int c)
{
    if (a*a + b*b == c*c) {
        flag = true;
    }
}
    

Measured memory_bytes: 1008
#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"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 998244353;

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

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

	cin >> N >> M >> K;
	for (int i = 1000; i >= 1; i--) {
		if (N%i == 0 && M%i == 0) {
			K--;
			if (!K) {
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int N;
        int num[];
        String line;

        Scanner scan=new Scanner(System.in);

        line=scan.next();
        N=Integer.parseInt(line);

        if(N<1||100<N){
            return;
        }
        
        num=new int[N];

        for(int i=0;i<N;i++){
            num[i]=Integer.parseInt(scan.next());
            if(num[i]<0||num[i]>100){
                return;
            }
        }

        //バブルソート
        int swap_num=0;
        for(int i=0;i<N-1;i++){
            for(int j=N-1;j>i;j--){
                if(num[j]<num[j-1]){
                    int temp=num[j];
                    num[j]=num[j-1];
                    num[j-1]=temp;

                    swap_num++;
                }
            }
        }

        for(int i=0;i<N;i++){
             if(i==N-1)System.out.print(num[i]);
             else System.out.print(num[i]+" ");

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


Measured memory_bytes: 26320
#include<bits/stdc++.h>
using namespace std;
int n,ma,mb,a[100],b[100],c[100],x,y,les=1e6;
int arr[505][505];
int main(){
	memset(arr,0,sizeof arr);
	scanf("%d%d%d",&n,&ma,&mb);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	for(int i=0;i<=400;i++){
		for(int j=0;j<=400;j++){
			arr[i][j] = 1e6;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=400;j>=1;j--){
			for(int k=400;k>=1;k--){
				if(arr[j][k] != 0){
					arr[j+a[i]][k+b[i]] = min(arr[j][k] + c[i],arr[j+a[i]][k+b[i]]);
				}
			}
		}
		arr[a[i]][b[i]] = min(c[i],arr[a[i]][b[i]]);
	}
	x = 1;
	y = 1;
	while(ma*x <= 400 && mb*y <= 400){
		if(arr[ma*x][mb*y] < les && arr[ma*x][mb*y] != 0){
			les = arr[ma*x][mb*y];
		}
		x++;
		y++;
	}
	if(les == 1e6){
		les = -1;
	}
	printf("%d\n",les);
}

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

#define M 1000003
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
  int key,i=0,h;

  key = getKey(str);
  while(1){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
    i++;
  }
  return 0;
}

int insert(char str[]){
  int key,i=0,h;

  key = getKey(str);
    while(1){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
    i++;
    }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15420
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL a,b;
LL cross(LL s,LL t,LL l,LL r)
{
	return t-s+1+r-l+1-max(0LL,min(r,t)-max(s,l)+1LL);
}
int main()
{
	int i; LL T,P;
	cin>>a>>b;
	if(a==b){ printf("1"); return 0;}
	for(i=59;i>=0;i--)
		if(((a>>i)&1)^((b>>i)&1)) break;
	a&=(1LL<<(i+1))-1;
	b&=(1LL<<(i+1))-1;
	for(T=1;T<=b/2;T<<=1);
	for(P=1;P+T<=b;P<<=1);
	b=max(b,T+P-1);
	cout<<cross(a,b,T+a,2*T-1);
	return 0;
}


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



int main() {
	

	string s;
	cin >> s;

	if (s[0] == s[1] && s[1] == s[2])
	{
		cout << "No" << endl;


	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}




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

int main() {
	int n;
	cin >> n;
	int f[110] = {};
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 10;j++) {
			int a;
			cin >> a;
			f[i] += a << (9 - j);
		}
	}
	int p[n][11];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j <= 10;j++) {
			cin >> p[i][j];
		}
	}
	int ans = -1e9;
	for (int i = 1;i < (1 << 10);i++) {
		int cost = 0;
		for (int j = 0;j < n;j++) {
			cost += p[j][__builtin_popcount(f[j] & i)];
		}
		ans = max(ans, cost);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, K=map(int, input().split())
H=list(map(int, input().split()))
MAXV=10**9
dp=[MAXV for _ in range(N)]
dp[0]=0
for i in range(1, N):
  minv=MAXV
  dp[i]=min([dp[j]+abs(H[j]-H[i]) if j>=0 else MAXV for j in range(i-K, i)])
print(dp[-1])

Measured memory_bytes: 56288
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const Int mod = 998244353;
const int MN = 200000+10;

template <class T>
class BIT {
    T bit[MN];
    int n;
    public:
    BIT() {
        n = MN;
        memset(bit,0,sizeof(bit));
    }

    T sum(int i) {
        ++i;
        T s = 0;
        while(i > 0) {
            s += bit[i];
            i -= i & (-i);
        }
        return s;
    }

    void add(int i,T x) {
        ++i;
        while(i < n) {
            bit[i] += x;
            i += i & (-i);
        }
    }
};

int num[MN][4];
Int p2[MN];

void init(void) {
    p2[0] = 1;
    for(int i = 1;i < MN;i++) {
        p2[i] = p2[i-1] * 2 % mod;
    }
}

int main(void) {
    init();

    int N;cin>>N;
    vector<pii> vec(N);
    vi xs,ys;

    for(int i = 0;i < N;i++) {
        int x,y;
        cin>>x>>y;
        vec[i] = make_pair(x,y);
        xs.push_back(x);
        ys.push_back(y);
    }

    sort(xs.begin(),xs.end());
    sort(ys.begin(),ys.end());
    for(int i = 0;i < N;i++) {
        int x = vec[i].first;
        int y = vec[i].second;

        x = lower_bound(xs.begin(),xs.end(),x) - xs.begin();
        y = lower_bound(ys.begin(),ys.end(),y) - ys.begin();
        vec[i] = make_pair(x,y);
    }

    sort(vec.begin(),vec.end());

    for(int t = 0;t < 2;t++) {
        BIT<int> T;

        for(int i = 0;i < N;i++) {
            int a = T.sum(vec[i].second - 1), b = i - T.sum(vec[i].second);
            if(t == 0) {
                num[i][0] = a;
                num[i][1] = b;
            } else {
                num[N-i-1][2] = a;
                num[N-i-1][3] = b;
            }
            T.add(vec[i].second,1);
        }

        reverse(vec.begin(),vec.end());
    }

    Int ans = 0;
    for(int i = 0;i < N;i++) {
        Int a = (p2[num[i][0]] + p2[num[i][3]]-1) % mod;
        Int b = (p2[num[i][1]] + p2[num[i][2]]-1) % mod;

        Int v = (p2[N]-a*b) % mod;
        if(v < 0)
            v += mod;
        ans = (ans+v) % mod;

    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 9068
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => {
        if $ x > $ y {
            $ x = $ y;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize,
        w: [i64;n]
    }
    let cum = Cum::new(&w);
    let mut ret = 1i64 << 60;
    for i in 1..n {
        chmin!(ret, (cum.sum(0, i) - cum.sum(i, n)).abs());
    }
    println!("{}", ret);
}

#[derive(Debug)]
#[allow(dead_code)]
struct Cum {
    s: Vec<i64>,
}
#[allow(dead_code)]
impl Cum {
    fn new(a: &Vec<i64>) -> Cum {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
            s[i + 1] = s[i] + a[i];
        }
        Cum { s: s }
    }
    #[doc = " [l,r)"]
    fn sum(&self, l: usize, r: usize) -> i64 {
        self.s[r] - self.s[l]
    }
}

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

using lint = long long int;

int main(){
    lint N,A[200002],B[200002];
    lint temp;

    cin >> N;
    for(lint i=0;i<N;i++){
        cin >> temp;
        A[i] = temp;
        B[i] = temp;
    }
    sort(B,B+N);

    lint left = B[N/2 - 1];
    lint right = B[N/2];

    for(lint i=0;i<N;i++){
        if(A[i]<=left){
            cout << right << "\n";
        }
        else{
            cout << left << "\n";
        }
    }
    
    return 0;
}

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

signed main(){
  int N,Q;
  cin>>N;
  Q=N/15;
  cout<<N*800-Q*200<<endl;
  return 0;
}

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

int main()
{
	int N,M;
	
	cin >> N >> M;
	
	int L[M],R[M];
	int ansL=1,ansR=N;
	
	for(int i = 0;i < M;i++){
		cin >> L[i] >> R[i];
		if(ansL < L[i]){
			ansL = L[i];
		}
		if(ansR > R[i]){
			ansR = R[i];
		}
	}
	
	if(ansL <= ansR){
		cout << ansR - ansL + 1;
	} else {
		cout << 0;
	}
	return 0;
}


Measured memory_bytes: 1024
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = 300;

int n, D1, D2;

inline void input()
{
	n = read<int>(), D1 = read<int>(), D2 = read<int>();
}

int vis[MAXN * 2][MAXN * 2];

inline void color(int D)
{
	int d = 0;
	while(D % 4 == 0) D /= 4, ++d;

	if(D % 4 == 1)
	{
		for(int i = 0; i < 2 * n; ++i)
			for(int j = 0; j < 2 * n; ++j)
				if((i >> d & 1) ^ (j >> d & 1)) vis[i][j] = 1;
	}
	else
	{
		for(int i = 0; i < 2 * n; ++i)
			for(int j = 0; j < 2 * n; ++j)
				if((i >> d & 1)) vis[i][j] = 1;
	}
}

inline void solve()
{
	color(D1);
	color(D2);

	int cnt = n * n;
	for(int i = 0; i < 2 * n; ++i)
		for(int j = 0; j < 2 * n; ++j)
			if(!vis[i][j])
			{
				printf("%d %d\n", i, j);
				if(--cnt == 0) return;
			}
}

int main()
{
#ifdef K_ON
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>
int cmp_int(const void* v1, const void* v2)
{
  const int _v1 = *((const int*)v1);
  const int _v2 = *((const int*)v2);

  if ( _v1 > _v2 ) {
    return -1;
  } else if ( _v1 < _v2 ) {
    return 1;
  } else {
    return 0;
  }
}

int main(void)
{
  int N, s[105], i, ad=0, flag=0;
  scanf("%d", &N);

  for(i = 0; i < N; i++){
    scanf("%d", &s[i]);
    if(s[i]%10 == 0) flag++;
  }
  if(flag == N){
    printf("0\n");
    return 0;
  }

  qsort(s, N, sizeof(int), cmp_int);

  for(i = 0; i < N; i++) ad += s[i];

  while(ad%10 == 0){
    if(s[N-1]%10 != 0){
      ad -= s[N-1];
      N--;
    }
    else N--;
    if(ad == 0) break;
  }
  printf("%d\n", ad);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  int index = 0;
  while (A.at(N-2) != 0) {
    for (int i = 0; i < N; i++) {
      if (A.at(i) != 0) {
        index = i;
        break;
      }
    }
    for (int i = index + 1; i < N; i++) A.at(i) %= A.at(index);
    sort(A.begin(), A.end());
  }
  cout << A.at(N-1) << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>

using namespace std;
using ll = long long;
ll res = 1000000007;


ll RepeatSquaring(ll n, ll r) {
	if (r == 0)
		return 1;
	if (r % 2 == 0) {
		ll t = RepeatSquaring(n, r / 2);
		return t * t % res;
	}
	return n * RepeatSquaring(n, r - 1) % res;
}

ll nCr(ll n, ll r) {
	ll  sum_m = 1, sum_c = 1;
	for (int i = 0; i < r; i++) {
		sum_c = sum_c*(n - i) % res;
		sum_m = sum_m*(r - i) % res;
	}
	return sum_c * RepeatSquaring(sum_m, res - 2) % res;
}

int main() {

	ll n,a,b, sum1=0,sum2=0,sum3=0,sum4=0;
	cin >> n >> a >> b;
	sum1 = (RepeatSquaring(2, n) - 1) % res;
	sum2 = nCr(n, a);
	sum3 = nCr(n, b);
	sum4 = sum1 - (sum2+sum3)%res;
	if (sum4 < 0)
		sum4 += res;
	cout << sum4 << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 101
#define INF 1000000
#define NIL -2
#define WHITE 0
#define BLACK 1

int main() {
  int n, i, j, u, k, v, w[MAX][MAX], d[MAX], pi[MAX], c[MAX], mincost, answer=0;
  
  scanf( "%d" , &n );
  for ( i=0; i<n; i++ ) for ( j=0; j<n; j++ ) w[i][j] = -1;
  for ( i=0; i<n; i++ ) {
    scanf( "%d %d" , &u , &k );
    for ( j=0; j<k; j++ ) {
      scanf( "%d" , &v );
      scanf( "%d" , &w[u][v] );
    }
    if ( i == 0 ) d[i] = 0; else d[i] = INF;
    pi[i] = NIL;
    c[i] = WHITE;
  }
 
  while ( 1 ) {
    mincost = INF;
    for ( i=0; i<n; i++ )
      if ( (c[i] != BLACK) && (d[i] < mincost) ) {
	mincost = d[i];
	u = i;
      }
    if ( mincost == INF ) break;
    c[u] = BLACK;
    for ( v=0; v<n; v++ )
      if ( (w[u][v] != -1) && (c[v] != BLACK) && ((d[u]+w[u][v]) < d[v]) ) {
	pi[v] = u;
	d[v] = d[u] + w[u][v];
      }
  }

  for ( i=0; i<n; i++ ) printf( "%d %d\n" , i , d[i] );
  
  return 0;
}



Measured memory_bytes: 2104