akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int main(){
	int n,x,y; cin >> n >> x >> y;
	x--;y--;
	vector<int> a(n), b(n), ans(n);
	rip(i,n,0){
		a[i] = abs(x-i);
		b[i] = abs(y-i);
	}
	rip(i,n-1,0){
		rip(j,n,i+1){
			ans[min({abs(i-j), a[i]+b[j]+1, a[j]+b[i]+1})]++;
			// ans[min({a[i]+b[j] + 1, a[j]+b[i] + 1,abs(i-j), abs(i-x)+b[j]+1, abs(i-y)+b[j], abs(j-x)+a[i], abs(j-y)+b[i]})]++;
		}
	}
	rip(i,n,1) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define INF 1e9
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int h[100001];
    for (int i = 0; i < n; i++)
    {
        cin>>h[i];
    }
    
    vector<vector<int>> G(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    int ans=0;
    for (int i = 0; i < n; i++)
    {
        bool isBreak=false;
        for (auto j : G[i])
        {
            if(h[i]<=h[j]){
                isBreak=true;
                break;
            }
        }
        if(!isBreak){
            ans++;
        }
    }
    
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 8808
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

const ll MOD=1e9+7;
signed main() {
    ll n;
    cin>>n;
    vl t(n),a(n),m(n);
    cin>>t>>a;
    if(t[n-1]!=a[0]) {
        cout<<0<<endl;
        return 0;
    }
    if(n<=2) {
        cout<<1<<endl;
        return 0;
    }

    ll M=0;
    REP(i,n) {
        m[i]=min(t[i],a[i]);
        M=max(M,m[i]);
    }
    if(M!=a[0]) {
        cout<<0<<endl;
        return 0;
    }

    ll ans=1;
    FOR(i,1,n-1) {
        if(m[i-1]<m[i] || m[i]>m[i+1]) continue;
        ans*=m[i];
        ans%=MOD;
    }
    cout<<(ans%MOD)<<endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {

    static class Data implements Comparable<Data>{
        long q;
        long p;
        Data(long q, long p) {
            this.q = q;
            this.p = p;
        }

        long getValue() {
            return p * 200 / q;
        }

        @Override
        public int compareTo(Data o) {
            return Long.compare(this.getValue(), o.getValue());
        }

        @Override
        public String toString() {
            return "Data{" +
                    "q=" + q +
                    ", p=" + p +
                    '}';
        }
    }

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

        long q = sc.nextLong() * 100;
        long h = sc.nextLong() * 100;
        long s = sc.nextLong() * 100;
        long d = sc.nextLong() * 100;

        List<Data> nums = new ArrayList<>();
        nums.add(new Data(25, q));
        nums.add(new Data(50, h));
        nums.add(new Data(100, s));
        nums.add(new Data(200, d));

        Collections.sort(nums);


        long n = sc.nextLong() * 100;
        long price = 0;

        Iterator<Data> iter = nums.iterator();
        while(iter.hasNext() && n > 0) {
            Data data = iter.next();
            long quantity = n / data.q;
            n %= data.q;
            price += quantity * data.p;
        }

        System.out.println(price / 100);

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;
const int MAX_P = 55555+1;

int digitsum(int n){
    int ret = 0;
    while(n>0){
        ret += n%10;
        n /= 10;
    }
    return ret;
}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N;
    cin >>N;
    //cout << digitsum(N) << endl;
    int ans = INF;
    repeat(i, N/2){
        int A = i+1;
        int B = N-A;
        ans = min(ans,digitsum(A)+digitsum(B));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 764
//OnestrokePath.cpp (C)
#include <iostream>
#include <string>
using namespace std;

bool graph[8][8];

int dfs(int v, int N, bool visited[8]);

int main(){
  int N,M,A,B;
  cin >> N >> M;
  bool visited[10];
  for(int i = 0; i < M; i++){
    cin >> A >> B;
    graph[A-1][B-1] = graph[B-1][A-1] = true;
  }

  for(int i = 0; i < N; i++) visited[i] = false;
  visited[0] = true;

  printf("%d\n",dfs(0,N,visited));
  return 0;
}

int dfs(int v, int N, bool visited[8]){
  bool allvisited = true;
  for(int i = 0; i < N; i++){
    if(visited[i]==false) allvisited = false;
  }
  if(allvisited) return 1;

  int ret = 0;

  for(int i = 0; i < N; i++){
    if(visited[i]) continue;
    if(graph[v][i]==false) continue;

    visited[i] = true;
    ret += dfs(i,N,visited);
    visited[i] = false;
  }
  return ret;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  int c;
  int d;
  cin >> a >> b >> c >> d;
  
  if (abs(a-c)<=d) {
    cout << "Yes";
  }
  else if ((abs(a-b)<=d) && (abs(b-c)<=d)) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=100005;
const int inf=0x3f3f3f3f;
long long n,w,k,dp[maxn],a[maxn],v[maxn],sum;
int main()
{
	memset(dp,inf,sizeof(dp));
	cin>>n>>w;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>v[i];
	}
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1e5;j>=v[i];j--)
		{
			dp[j]=min(dp[j],dp[j-v[i]]+a[i]);
		}
	}
	for(int i=1;i<=1e5;i++)
	{
		if(dp[i]<=w)
		{
			sum=i;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h,w,k,cnt=0; cin>>h>>w>>k;
  char c[h][w];
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>c[i][j];
  for(int maskR=0;maskR<(1<<h);maskR++){
    for(int maskC=0;maskC<(1<<w);maskC++){
      int black=0;
      for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(!((maskR>>i)&1)&&!((maskC>>j)&1)&&c[i][j]=='#') black++;
      if(black==k) cnt++;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 3624
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define ld long double
#define F first
#define S second
#define mem(v) memset(v,0,sizeof(v))
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define hell 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; 
if (m == 1) {return 0;} 
while (a > 1) { ll q = a / m; ll t = m;  m = a % m, a = t; t = y; y = x - q * y; x = t; } 
if (x < 0) {x += m0;} return x; } 
inline ll add(ll a, ll b) { return (((a >= hell) ? a % hell : a) + ((b >= hell) ? b % hell : b) + hell) % hell; }
inline ll subt(ll a, ll b) { return (a - b + hell) % hell; }
inline ll mult(ll a, ll b) { return (1ll * ((a >= hell) ? a % hell : a) * ((b >= hell) ? b % hell : b)) % hell; }
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll mylog(ll n,ll b)
{ll i = 1;ll ans = 0;
while(1)
{if(i>n/b){break;} i = i*b;ans++;}return ans;
}
bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
if (a.first == b.first)
{return a.second<b.second;} 
return a.first<b.first;
}
bool comparerev(const pair<ll,ll> &a,const pair<ll,ll> &b){
if(a.first == b.first)
{return a.second>b.second;}
return a.first>b.first;
}
int main()
{
    fast
    ll t = 1;
   // cin>>t;
    while(t--){
    ll sum = 0;
    ll k;
    cin>>k;
    for(ll i = 1;i<=k;i++)
    {
        for(ll j = 1;j<=k;j++)
        {
            ll val = gcd(i,j);
            for(ll r = 1;r<=k;r++)
            {
                sum += gcd(val,r);
            }
        }
    }
    cout<<sum<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#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> vec(N);
    rep(i, N) {
        cin >> vec.at(i);
    }

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

    int alice = 0;
    int bob = 0;

    rep(i, N) {
        if (i % 2 == 0) {
            alice += vec.at(i);
        } else {
            bob += vec.at(i);
        }
    }

    cout << alice - bob << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long x = scanner.nextLong();
			System.out.println((int) Math.ceil((Math.sqrt(8 * x + 1) - 1.0) / 2.0));
		}
	}
}


Measured memory_bytes: 35660
n = gets.to_i

h,t = 0,0

n.times do
  input = gets.split(" ")
  if input[0] == input[1]
    h += 1
    t += 1
    next
  end
  if input[0] > input[1]
    h += 3
  else
    t += 3
  end
end

puts "#{h} #{t}"



Measured memory_bytes: 6876
#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);
  }
  int count = 0;
  bool judge = true;
  while(judge){
    for(int i = 0; i < N; i++){
      if(A.at(i) % 2 == 1) judge = false;
      if(A.at(i) % 2 == 0) A.at(i) /= 2;  
    } 
    if(judge == true)count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    ans += min(T, t[i+1] - t[i])
ans += T
print(ans)


Measured memory_bytes: 103428
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      int suti = scan.nextInt();
      int a = 0,b = 0,c = 0,d = 0,check = 0;
      int roop[] = new int[4];

      for (roop[0] = 0;roop[0] <= 9 ;roop[0]++ ) {
        for (roop[1] = 0;roop[1] <= 9 ;roop[1]++ ) {
          for (roop[2] = 0;roop[2] <= 9 ;roop[2]++ ) {
            for (roop[3] = 0;roop[3] <= 9 ;roop[3]++ ) {
              check = 1000*roop[0] + 100*roop[1] + 10*roop[2] + roop[3];
              if(check == suti){
                a = roop[0];
                b = roop[1];
                c = roop[2];
                d = roop[3];
              }
            }
          }
        }
      }
      int kotae[] = new int[8];
      kotae[0] = a + b + c + d;
      boolean judge = false;
      if(kotae[0] == 7 && judge == false){
        System.out.println(a + "+" + b + "+" + c + "+" + d + "=" + kotae[0]);
        judge = true;
      }
      kotae[1] = a + b + c - d;
      if(kotae[1] == 7 && judge == false){
        System.out.println(a + "+" + b + "+" + c + "-" + d + "=" + kotae[1]);
        judge = true;
      }
      kotae[2] = a + b - c + d;
      if(kotae[2] == 7 && judge == false){
        System.out.println(a + "+" + b + "-" + c + "+" + d + "=" + kotae[2]);
        judge = true;
      }
      kotae[3] = a + b - c - d;
      if(kotae[3] == 7 && judge == false){
        System.out.println(a + "+" + b + "-" + c + "-" + d + "=" + kotae[3]);
        judge = true;
      }
      kotae[4] = a - b + c + d;
      if(kotae[4] == 7 && judge == false){
        System.out.println(a + "-" + b + "+" + c + "+" + d + "=" + kotae[4]);
        judge = true;
      }
      kotae[5] = a - b + c - d;
      if(kotae[5] == 7 && judge == false){
        System.out.println(a + "-" + b + "+" + c + "-" + d + "=" + kotae[5]);
        judge = true;
      }
      kotae[6] = a - b - c + d;
      if(kotae[6] == 7 && judge == false){
        System.out.println(a + "-" + b + "-" + c + "+" + d + "=" + kotae[6]);
        judge = true;
      }
      kotae[7] = a - b - c - d;
      if(kotae[7] == 7 && judge == false){
        System.out.println(a + "-" + b + "-" + c + "-" + d + "=" + kotae[7]);
        judge = true;
      }
  }
}

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

public class Main {

    public static void main(String[] args) throws IOException {
	    Scanner s = new Scanner(System.in);
        int n = 5;
        int i = 1;
        while(i<=5){
            int x = s.nextInt();
            if(x==0) {
                System.out.println(i);
                break;
            }
            i++;
        }
    }
}





class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}


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

#define rep(i,n) for(int i=0;i<(n);i++)

int main() {
	int n,q,c=0;
	int S[100000];
	int T[100000];
	cin >> n;
	rep(i, n) cin >> S[i];
	cin >> q;
	rep(i, q) cin >> T[i];
	rep(i, q) {
		rep(j, n) {
			if (S[j] == T[i]) {
				c++;
				break;
			}
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3080
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    string s;
    cin >> s;
    char c = s[0];
    int cnt = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] != c) {
            cnt++;
            c = s[i];
        }
    }
    cout << cnt;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<queue>
//#include<time.h>
//#include<complex>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int n;
#define maxn 200011
int a[maxn],b[maxn],na[maxn],nb[maxn];
int main()
{
	scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&a[i]); for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	int ans=0;
	for (int i=0;i<=28;i++)
	{
		for (int j=1;j<=n;j++) na[j]=a[j]&((1<<(i+1))-1),nb[j]=b[j]&((1<<(i+1))-1);
		sort(nb+1,nb+1+n); int t1=1<<i,t2=2*t1,t3=3*t1,t4=4*t1;
		int now=0;
		for (int j=1;j<=n;j++)
		{
			now^=(lower_bound(nb+1,nb+1+n,t2-na[j])-lower_bound(nb+1,nb+1+n,t1-na[j]))&1;
			now^=(lower_bound(nb+1,nb+1+n,t4-na[j])-lower_bound(nb+1,nb+1+n,t3-na[j]))&1;
		}
		ans|=now<<i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    string s;

    cin >> s;

    if (s.size() == 3) reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))
dic = {}
allsum = 0
for i in range(n):
  dic.setdefault(lst[i], 0)
  dic[lst[i]] += 1
  if dic[lst[i]] >= 2:
    allsum += (dic[lst[i]] - 1)
for i in range(n):
  a = dic[lst[i]]
  temp = allsum - ((a * (a - 1)) // 2)
  if a - 1 >= 2:
    b = a - 1
    temp += ((b * (b - 1)) // 2)
  print(temp)

Measured memory_bytes: 32228
#include<stdio.h>
#define  N 100
 
int main() {
  int n,p[N+1], m[N+1][N+1];
  scanf("%d",&n);
  for (int i = 1;i <=n; i++) {
    scanf("%d %d",&p[i-1],&p[i]);
  }
  for (int i = 1; i <= n; i++) m[i][i] = 0;
  for (int l = 2; l <= n; l++){
    for (int i=1;i <=n-l+1; i++){
    int j = i + l -1;
    m[i][j] = 10000000;
    for (int k = i;k <= j -1;k++) {
      if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
      m[i][j] = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
 
  printf("%d\n",m[1][n]);
  return 0;
}

Measured memory_bytes: 1820
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    cout << ((n % 10) == (n / 100) ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < max(a, b); i++) {
        cout << min(a, b);
    }
    cout << endl;
}



Measured memory_bytes: 3480
n = int(input())
MOD = 10**9+7
from math import gcd
zero = 0
cnt = {}
for i in range(n):
    a,b = map(int,input().split())
    if a ==0 and b==0:
        zero += 1
        continue
    g = gcd(a,b)
    a//=g
    b//=g
    if b<0:
        a*=-1
        b*=-1
    if b==0 and a<0:
        a *= -1
    if a<=0:
        a,b = b,-a
        if (a,b) in cnt:
            cnt[(a,b)][0] += 1
        else:
            cnt[(a,b)] = [1,0]
    else:
        if (a,b) in cnt:
            cnt[(a,b)][1] += 1
        else:
            cnt[(a,b)] = [0,1]
ans = 1
for i,v in cnt.items():
    ans *= 1 + pow(2,v[0],MOD)-1 + pow(2,v[1],MOD)-1
    ans %= MOD
print((zero-1+ans)%MOD)

Measured memory_bytes: 136504
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    if (n <= k)
        cout << min(n, k - n);
    else
    {
        ll t = (n - k - 1) / k + 1;
        n = n - t * k;
        cout << min(n, k - n);
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var abk = ReadInts();
            var takahashi = abk[0];
            var aoki = abk[1];

            for (int i = 0; i < abk[2]; i++)
            {
                if (i % 2 == 0)
                {
                    if (takahashi % 2 == 0)
                    {
                        aoki += takahashi / 2;
                        takahashi = takahashi / 2;
                    }
                    else
                    {
                        takahashi = takahashi - 1;
                        aoki += takahashi / 2;
                        takahashi = takahashi / 2;
                    }
                }
                else
                {
                    if (aoki % 2 == 0)
                    {
                        takahashi += aoki / 2;
                        aoki = aoki / 2;
                    }
                    else
                    {
                        aoki = aoki - 1;
                        takahashi += aoki / 2;
                        aoki = aoki / 2;
                    }
                }
            }
            WriteLine(takahashi + " " + aoki);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


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

int main(){
    //入力
    int N,a[10000],b[10000];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=0;i<N;i++){
        cin >> b[i];
    }

    long long ap=0,bp=0;//a,bそれぞれ足される回数
    for(int i=0;i<N;i++){
        if(a[i]<b[i]){
            ap+=(b[i]-a[i])/2;
        }
        if(a[i]>b[i]){
            bp+=a[i]-b[i];
        }
    }

    if(ap>=bp){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

    return 0;
}

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

int main()
{
  int N,K,i;
  cin >> N >> K;
  char s[100];
  for( i = 0; i < N; i++ )
  {
    cin >> s[i];
  }
  if(s[K-1] == 'A')
  {
    s[K-1] = 'a';
  }else if(s[K-1] == 'B')
  {
    s[K-1] = 'b';
  }else if(s[K-1] == 'C')
  {
    s[K-1] = 'c';
  }
  for( i = 0; i < N; i++ )
  {
    cout << s[i];
  }
  cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

const double eps = 1e-7;
const int MOD = 1000000007;
const int MOD_MAX = 200000;

using ll = long long;
using vi = vector<int>; using vi2 = vector<vi>; using vi3 = vector<vi2>;
using vll = vector<ll>; using vll2 = vector<vll>; using vll3 = vector<vll2>;
using vd = vector<double>; using vd2 = vector<vd>; using vd3 = vector<vd2>;
using pi = pair<int, int>; using pll = pair<ll, ll>;
using vpi = vector<pi>; using vpll = vector<pll>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)
#define rloopi(i, a, b) for(int i = (int)a - 1; i >= (int)b; i--)
#define rloop(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define rloopeq(i, n) for (int i = (int)n - 1; i >= 1; i--)
#define rloopll(i, n) for (int i = (ll)n - 1; i >= 0; i--)
#define rlooplleq(i, n) for (int i = (ll)n - 1; i >= 1; i--)
#define all(a) (a).begin(), (a).end()

bool feq(float x, float y) { return abs(x-y) <= eps; }
bool deq(double x, double y) { return abs(x-y) <= eps; }
int ceillog2(ll x) { return int (ceil(log2(x))); }
int floorlog2(ll x) { return int (floor(log2(x))); }
template<class T> T reversed (T container) { reverse(container.begin(), container.end()); return container; }
template<class T> T sort (T container) { sort(container.begin(), container.end()); return container; }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

int main() {
	int n, m; cin >> n >> m;
	int all = 0;
	vi a(n, 0); loop(i,n) { cin >> a[i]; all += a[i]; }
	int ans = 0;
	loop(i, n) { if (a[i] * 4 * m >= all) ans++; }
	if (ans >= m) cout << "Yes" << endl;
	else cout << "No" << 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() {
	
	string s;
	cin >> s;
	
	if(s > "2019/04/30") puts("TBD");
	else puts("Heisei");
	
	return 0;
}

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

namespace ConsoleApp15
{
    class Class395
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());

            var G = new List<int>[N];
            for (int i = 0; i < N; i++) G[i] = new List<int>();
            for(int i = 0; i < N - 1; i++)
            {
                var ab = Console.ReadLine().Split().Select(_=>int.Parse(_)-1).ToArray();
                G[ab[0]].Add(ab[1]);
                G[ab[1]].Add(ab[0]);
            }

            int[] frags = Enumerable.Repeat(-1, N).ToArray();
            frags[0] = 0;
            frags[N - 1] = 1;
            var que = new Queue<Tuple<int, int>>();
            que.Enqueue(Tuple.Create(0, 0));
            que.Enqueue(Tuple.Create(N - 1, 1));

            while (que.Count > 0)
            {
                var t = que.Dequeue();
                var now = t.Item1;
                var color = t.Item2;

                foreach (var i in G[now])
                {
                    if (frags[i] == -1)
                    {
                        frags[i] = color;
                        que.Enqueue(Tuple.Create(i, color));
                    }
                }
            }

            int fnk = frags.Count(_ => _ == 0);
            int snk = N - fnk;
            Console.WriteLine(fnk>snk?"Fennec":"Snuke");
        }
    }
}


Measured memory_bytes: 50308
#include<iostream>
int main(){
    int a,b; 
    std::cin>>a>>b; 
    int c = a * b;
    if(c%2 == 0){
        std::cout << "Even" << std::endl; 
    }else{ 
        std::cout << "Odd" << std::endl;
    }
     return 0; 
}

Measured memory_bytes: 256
n = int(input())
a_count_list = [0 for i in range(10**5+1)]
for i in input().split(" "):
    x = int(i)
    a_count_list[x-1]+=1
total = sum([(i+1)*x for i,x in enumerate(a_count_list)])

q = int(input())
for i in range(q):
    b, c = input().split(" ")
    b = int(b)
    c = int(c)
    total+=a_count_list[b-1] * c
    total-=a_count_list[b-1] * b
    a_count_list[c-1] += a_count_list[b-1]
    a_count_list[b-1] = 0
    print(total)


Measured memory_bytes: 17704
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line);
    let mut line = line.split_whitespace();
    let a = line.next().unwrap().parse::<i64>().unwrap();
    let b = line.next().unwrap().parse::<i64>().unwrap();

    let sum = a + b;
    if 10 <= sum {
        println!("error");
    }
    else {
        println!("{}", sum);
    }
}

Measured memory_bytes: 4352
from heapq import heappop, heappush, heapify

N, M = map(int, input().split())
A = list(map(int, input().split()))
heapify(A)
BC = []

for i in range(M):
  b, c = map(int, input().split())
  heappush(BC, (-c, b))

for i in range(M):
  mc, b = heappop(BC)
  c = -mc
  end = False

  for j in range(b):
    min = heappop(A)
    if c <= min:
      heappush(A, min)
      end = True
      break
    else:
      heappush(A, c)

  if end:
    break

print(sum(A))

Measured memory_bytes: 20900
using System;
using System.Collections.Generic;

public class S
{
    public static void Main()
    {

        var input = Array.ConvertAll(Console.ReadLine().Split('/'), int.Parse);

        if(input[0] == 2019){
            if(input[1] <= 4){
                Console.WriteLine("Heisei");
            }else{
                Console.WriteLine("TBD");
            }
        }else{
            if(input[0] < 2019){
                Console.WriteLine("Heisei");
            }else{
                Console.WriteLine("TBD");
            }
        }

    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>
#include <algorithm>

int main(){
  char S[100000];scanf("%s",S);
  int b=0,r=0;
  for(int i=0;i<strlen(S);i++){
    S[i]=='1'?b++:r++;
  }
  printf("%d",2*std::min(b,r));
  return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


map<string,bool> MAP;
string line;
int ans = 0;

void recursive(string tmp){

	if(tmp.length() == 1)return;

	auto at = MAP.find(tmp);
	if(at != MAP.end())return;

	string left = tmp.substr(0,tmp.size()/2);
	string right = tmp.substr(tmp.size()/2);

	if(left == right){
		recursive(left);
	}else{
		MAP[tmp] = true;
		ans++;
		recursive(left);
		recursive(right);
	}
}

int main(){

	int N;
	scanf("%d",&N);
	getchar();
	getline(cin,line);

	recursive(line);

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

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

int main()
{
	string S;
	cin >> S;
	if (S[0] == S[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[map(int,raw_input().split()) for i in range(n)]
bd_lists=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for b in a:
    if bd_lists[b[0]-1][b[1]-1][b[2]-1]+b[3]>=0:
        bd_lists[b[0]-1][b[1]-1][b[2]-1]+=b[3]
for i in range(4):
    for j in range(3):
        ln=""
        for k in range(10):
            ln+=" "+str(bd_lists[i][j][k])
        print ln
    if i!=3:
        print("#"*20)


Measured memory_bytes: 4684
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);
    const nums = args.slice(1, N + 1);
    const isValid = nums.every((n) => {
        var ns = n.split(' ');
        var t = parseInt(ns[0], 10),
            x = parseInt(ns[1], 10),
            y = parseInt(ns[2], 10);
        var sum = x + y;
        
        return (t >= sum) && ((t % 2) === (sum % 2));
    });

    if (isValid) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int h, w, n;
    cin >> h >> w >> n;

    int sr, sc;
    cin >> sr >> sc;
    sr--; sc--;

    string s, t;
    cin >> s >> t;

    int p = sc;
    REP(i, n){
        if(s[i] == 'L') p--;
        if(p < 0){
            cout << "NO" << endl;
            return 0;
        }
        if(t[i] == 'R') p = min(w - 1, p + 1);
    }

    p = sc;
    REP(i, n){
        if(s[i] == 'R') p++;
        if(p >= w){
            cout << "NO" << endl;
            return 0;
        }
        if(t[i] == 'L') p = max(0, p - 1);
    }

    p = sr;
    REP(i, n){
        if(s[i] == 'U') p--;
        if(p < 0){
            cout << "NO" << endl;
            return 0;
        }
        if(t[i] == 'D') p = min(h - 1, p + 1);
    }

    p = sr;
    REP(i, n){
        if(s[i] == 'D') p++;
        if(p >= h){
            cout << "NO" << endl;
            return 0;
        }
        if(t[i] == 'U') p = max(0, p - 1);
    }

    cout << "YES" << endl;
    return 0;
    
}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[m];
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int num = sc.nextInt();
                arr[num - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (arr[i] == n) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
N, K = map(int, input().split())
Trick = [1] * N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in A:
        if Trick[j-1] == 1:
            Trick[j-1] = 0

print(sum(Trick))

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

struct UnionFind {
  vector<int> r;

  UnionFind(int N) {
    r = vector<int>(N, -1);
  }

  int getRoot(int x) {
    if (r[x] < 0) return x;
    return r[x] = getRoot(r[x]);
  }

  void unite(int x, int y) {
    int rx = getRoot(x);
    int ry = getRoot(y);
    if (rx == ry) return;

    r[rx] += r[ry];
    r[ry] = rx;
  }

  int size(int x) {
    return -r[getRoot(x)];
  }
};

int main() {
  int N,M,i,a,b;
  cin>>N>>M;
  UnionFind UF(N);
  for (i=0;i<M;i++) {
    cin>>a>>b;
    UF.unite(a-1,b-1);
  }
  int ans=0;
  for (i=0;i<N;i++) {
    ans = max(ans,UF.size(i));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3964
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  int  D, T, S;
  cin >> D >> T >> S;
  int time = (D+S-1)/S;
  if(time > T) cout << "No" << endl;
  else cout << "Yes" << endl;

  

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
//#include <array>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <stack>
//#include <queue>
using ll = long long;
using namespace std;
#include <vector>
#include <unordered_map>

std::vector<bool> primes;

using namespace std;

void sieve_of_eratosthenes(int n) {
	//primes : [0, n] の配列で，primes[i] != 0 iff i は素数
	//O(n log n)
	primes.assign(n + 1, true);
	for (int i = 0; i <= 1; ++i)
		primes[i] = false;
	for (int i = 2; i*i <= n; ++i)
		if (primes[i])
			for (int j = i * i; j <= n; j += i)
				primes[j] = false;
	return;
}

bool is_prime(const int n, const bool is_using_primes) {
	if (n <= 1)
		return false;
	for (int i = 2; i*i <= n; i++) {
		if (is_using_primes && !primes[i])
			continue;
		if (n % i == 0)
			return false;
	}
	return true;
}

vector<int> make_divisors(const int n) {
	vector<int> ans;
	for (int i = 1; i*i <= n; i++)
	{
		if (n%i == 0) {
			ans.emplace_back(i);
			if (n / i != i)
				ans.emplace_back(n / i);
		}
	}
	return ans;
}

unordered_map<int, int> make_prime_factor(int n, const bool is_using_primes) {
	unordered_map<int, int> ans;
	for (int i = 2; i*i <= n; i++) {
		if (is_using_primes && !primes[i])
			continue;
		while (n % i == 0) {
			++ans[i];
			n /= i;
		}
	}
	if (n != 1)
		++ans[n];
	return ans;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> divisors = make_divisors(M);
	sort(divisors.begin(), divisors.end());
	int gcd = 1;
	for (const auto &e : divisors) {
		if (M / e >= N) {
			gcd = e;
		}
		else {
			break;
		}
	}
	cout << gcd << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>N;
    A.resize(N);
    rep(i,0,N-1){
        cin>>A[i];
    }

}
//=============================
void func(){}
//=============================
void solve()
{
    sort(all(A));
    reverse(all(A));

    int a=0;
    int b=0;
    rep(i,0,N-1){
        if (i%2){
            b += A[i];
        }
        else a += A[i];
    }

    cout<<a-b<<endl;


}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cost = (a[0] == 0)
c = a[0] + (a[0] == 0)
for i in a[1:]:
	if c > 0:
		if c + i >= 0:
			cost += c + i + 1
			c = -1
		else:
			c += i
	else:
		if c + i <= 0:
			cost += 1 - c - i
			c = 1
		else:
			c += i
tmp = cost
cost = 0
if a[0] >= 0:
	cost = a[0] + 1
	c = -1
else:
	cost = -a[0] + 1
	c = 1
for i in a[1:]:
	if c > 0:
		if c + i >= 0:
			cost += c + i + 1
			c = -1
		else:
			c += i
	else:
		if c + i <= 0:
			cost += 1 - c - i
			c = 1
		else:
			c += i
print(int(min(tmp, cost)))


Measured memory_bytes: 86220
#include <iostream>
#include <set>
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N; cin >> N;
	set<int> d;
	rep(i, 0, N) {
		int tmp; cin >> tmp;
		d.insert(tmp);
	}
	cout << d.size() << endl;


	return 0;
}

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

int main(void){
  double xa,ya,xb,yb,xc,yc,xd,yd;
  int n;
  cin >> n;
  while( --n >=0){
    cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd;

    if( (yb - ya)/(xb - xa) == (yd - yc)/(xd - xc))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

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

int N;
bool seen[100002];

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

  cin >> N;
  seen[0] = true;
  for (int i = 0; i <= N; ++i) {
    if (!seen[i]) {
      continue;
    }
    for (int dd = 100; dd <= 105; ++dd) {
      if (i + dd <= N) {
        seen[i + dd] = true;
      }
    }
  }

  cout << seen[N] << '\n';
}

Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#include<string>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int q;
  cin>>q;
  int i,j,k,num;
  rep(i,q){
    string s;
    cin>>s;
    rep(num,100000){
      if(s.size()==1){
	cout<<num<<endl;
	break;
      }
      ll ans=0LL;
      rep(j,s.size()-1){
	int n1=0,n2=0;
	int a=1;
	for(k=j;k>=0;k--){
	  n1+=a*(s[k]-'0');
	  a*=10;
	}
	a=1;
	for(k=s.size()-1;k>j;k--){
	  n2+=a*(s[k]-'0');
	  a*=10;
	}
	ans=max(ans,(ll)n1*n2);
      }//rep
      stringstream ss;
      ss<<ans;
      s=ss.str();
    }
    if(num>100000)cout<<"-1"<<endl;
  }
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);

int n;


signed main(){
    cin >> n;
    vec(a,n);
    input(a,n);
    twovec(dp,n,40001);
    dp[0][a[0]] = 1;
    FOR(i,1,n){
        dp[i][a[i]] = 1;
        REP(j,40001){
            if(dp[i-1][j] == 1){
                dp[i][j] = 1;
                dp[i][j+a[i]] = 1;
            }
        }
    }
    int m;
    cin >> m;
    vec(b,m);
    input(b,m);
    REP(i,m){
        (dp[n-1][b[i]] == 1)? print("yes"):print("no");
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}




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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

string s;
int main(){
    cin >> s;

    ll pos = 0;
    ll ans = 0;
    ll l_a_count = 0;
    ll r_bc_count = 0;
    ll s_length = s.length();
    ll ind = 0;

    while(ind < s_length){
        if(s[ind] == 'A'){
            ll i = ind+1;
            ll a_num = 1;
            ll bc_num = 0;
            ll mem = 0;
            while(i < s_length){
                if(s[i] == 'B' && s[i+1] == 'C'){
                    ++bc_num;
                    i += 2;
                }
                else if(s[i] == 'A'){
                    mem += a_num*bc_num;
                    bc_num = 0;
                    ++a_num;
                    ++i;
                }
                else{
                    break;
                }
            }
            ind = i;
            mem += a_num*bc_num;
            ans += mem;
        }
        else{
            ++ind;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
n,m = map(int,input().split())
a = list(map(int,input().split()))

s = sum(a)
a.sort()
a.reverse()
d = s / 4.0 / m

c = 0
for i in range(n):
    if(a[i] >= d):c+=1
    if(c == m):
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3188