akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) { //No MLE! CASH MONEY BABY!!!!
		Scanner input = new Scanner(System.in);
		int N = input.nextInt(); 
		long[][] dp;
		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextLong();
		}
		if (N%2==0) {
			dp = new long[N/2][2];
			for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 2; j++) {
					if (i==0&&j==0) {
						dp[i][j] = arr[i*2+j];
					}
					else if (j==0) {
						dp[i][j] = dp[i-1][j]+arr[i*2];
					}
					else if (i>0){
						dp[i][j] = dp[i][j-1];
						long curNum = arr[i*2+1];
						dp[i][j] = Math.max(dp[i][j], curNum+dp[i-1][j]);
					}else if (i==0) {
						dp[i][j] = Math.max(dp[i][j-1],arr[i*2+1]);
					}	
				}
			}
			/*for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 2; j++) {
					System.out.print(dp[i][j]+" ");
				}
				System.out.print("\n");
			}*/
			System.out.println(dp[N/2-1][1]);
		}
		else {
			dp = new long[N/2][3];
			for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 3; j++) {
					if (j==0&&i==0) dp[i][j] = dp[i][j] = arr[0];
					else if (j==0) {
						dp[i][j] = dp[i-1][j]+arr[i*2];
					}
					else if (i==0){
						dp[i][j] = Math.max(dp[i][j-1],arr[i*2+j]);
					}else if (i>0) {
						dp[i][j] = dp[i][j-1];
						long curNum = arr[i*2+j];
						dp[i][j] = Math.max(dp[i][j], dp[i-1][j]+curNum);
					}
				}
			}
			/*for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 3; j++) {
					System.out.print(dp[i][j]+" ");
				}
				System.out.print("\n");
			}*/
			System.out.println(dp[N/2-1][2]);
		}
	}
}

Measured memory_bytes: 54584
#include <iostream>
    #include <limits>
    #include <vector>
	#include <unordered_set>
     
    using namespace std;
     
    struct arc{
        int to, cost;
    };
     
    struct node{
        int value;
        vector<arc> arcs;
        node(int v) : value(v){}
    };
     
    class graph{
    protected:
        vector<node> nodes;
     
    public:
     
        graph(int N, int value) : nodes(N, value){};
     
        void addArc(int from, int to, int cost){
            nodes[from].arcs.push_back({to,cost});
        }
        void addEdge(int a, int b, int cost){
            addArc(a, b, cost);
            addArc(b, a, cost);
        }
        node& operator[](int index){
            return nodes[index];
        }
    };
     
    class bellmanford : public graph{
        int N;
        int changed;
     
        void r(unordered_set<int> froms, int termination){
     
            bool c = false;
            unordered_set<int> f;
            for (auto& from : froms){
                for (auto& i : nodes[from].arcs) {
                    if (nodes[i.to].value > i.cost + nodes[from].value) {
                        nodes[i.to].value = i.cost + nodes[from].value;
                        f.insert(i.to);
                        c = true;
                    }
                }
            }
          
            if (!c) return;
            if(!termination){
                changed = c;
                return;
            }
            r(move(f), termination-1);
        }
     
    public:
     
        bellmanford(int N): graph::graph(N, std::numeric_limits<int>::max()),
                            N(N), changed(false){}
        bool run(int start){
            nodes[start].value = 0;
            r({start}, N-1);
            return changed;
        }
        int getValue(int index){return nodes[index].value;}
     
    };
     
    int main(void){
     
        int N,M,P;
     
        cin >> N >> M >> P;
     
        graph visit(N, 0);
     
     
        for (int i = 0; i < M; ++i) {
            int a,b,c;
            cin >> a >> b >> c;
            visit.addArc(b-1, a-1, c);
        }
     
        visit[N-1].value = 1;
     
        vector<int> f = {N-1};
     
        for(int i = 0;i<N - 1 ; ++i){
            vector<int> tmp;
            for(auto &n : f){
                for(auto &a : visit[n].arcs){
                  if (visit[a.to].value) continue;
                    visit[a.to].value = 1;
                    tmp.push_back(a.to);
                }
            }
            f = move(tmp);
        }
     
        bellmanford g(N);
     
        for(int i = 0;i < N; ++i){
            if (visit[i].value == 1) {
                for(auto &a : visit[i].arcs){
                    g.addArc(a.to, i, P - a.cost);
                }
            }
        }
     
        cout << ((g.run(0))?-1:max(0, -g.getValue(N-1)));
     
     
        return 0;
    }

Measured memory_bytes: 106496
#include <iostream>

int main()
{
	int n, x, si = 0, mi = -1; std::cin >> n;
	for (int i = 1; i <= n; ++i) 
		std::cin >> x, si += x, mi = std::max(mi, x);
	std::cout << si - (mi >> 1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
int dp[100011] = {0};
int r, p, s;
int fu(char st){
	if(st=='r')return p;
	else if(st=='p') return s;
	else return r;
}
void solve(){
	int n, k, res=0;
	cin>>n>>k;
	cin>>r>>s>>p;
	string g;
	cin>>g;
	FOR(i, 0, k){
		res+=fu(g[i]);
		dp[i] = res;
	}
	//cout<<dp[k-1]<<endl;
	FOR(i, k, sz(g)){
		if(g[i-k]==g[i]){

			dp[i] = max(dp[i-k], dp[i-1]);
			g[i]='0';
		}
		else{
			dp[i] = dp[i-1]+fu(g[i]);
		}
		//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1];
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	return 0;
 
}


Measured memory_bytes: 1232
#include<stdio.h>

int main(){
	long x,y,x1,y1,total;
	scanf("%ld %ld",&x,&y);
	x1=(x<0)?-x:x;
	y1=(y<0)?-y:y;
	total=(x1>y1)?(x1-y1):(y1-x1);
	if(x==0 || y==0){
		if(x>y) total++;
		printf("%ld\n",total);
		return 0;
	}
	if((x1>y1 && x1/x==1) || (x1<y1 && x1/x==-1)) total++;
	if((x1>y1 && y1/y==1) || (x1<y1 && y1/y==-1) || x==-y) total++;
	printf("%ld\n",total);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define cq(i,s,n) for(int i=s;i<=n;i++)
using namespace std;
const double eps=1e-12;
struct Point{
    double x,y;
}a[500005];
Point o;
int n; 
double ri;
double dis(Point a,Point b){
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 
}

void tt(Point p1,Point p2,Point p3){
    double a,b,c,d,e,f;
    a=p2.y-p1.y;
    b=p3.y-p1.y;
    c=p2.x-p1.x;
    d=p3.x-p1.x;
    f=p3.x*p3.x+p3.y*p3.y-p1.x*p1.x-p1.y*p1.y;
    e=p2.x*p2.x+p2.y*p2.y-p1.x*p1.x-p1.y*p1.y;
    o.x=(a*f-b*e)/(2*a*d-2*b*c);
    o.y=(d*e-c*f)/(2*a*d-2*b*c);
    ri=dis(o,p1);
}

int main(){
    scanf("%d",&n);
    cq(i,1,n){
        scanf("%lf%lf",&a[i].x,&a[i].y);
    }
    random_shuffle(a+1,a+n+1);
    o=a[1];ri=0;
    cq(i,2,n){
        if(dis(a[i],o)>ri+eps){
            o=a[i];ri=0;
            cq(j,1,i-1){
                if(dis(o,a[j])>ri+eps){
                    o.x=(a[i].x+a[j].x)/2;
                    o.y=(a[i].y+a[j].y)/2;
                    ri=dis(o,a[j]);
                    cq(k,1,j-1){
                        if(dis(o,a[k])>ri+eps){
                            tt(a[i],a[j],a[k]);
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf",ri);
    return 0;
}


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

void b_shiritori(void) {
	int n;
	string s[100];
	string judge = "Yes";

	cin >> n;
	for (int i = 0; i < n; i++)cin >> s[i];

	for (int i = 1; i < n; i++) {
		string pre = s[i - 1];
		string now = s[i];
		if (pre[pre.size() - 1] != now[0]) {
			judge = "No";
			break;
		}
		for (int j = i - 1; j >= 0; j--) {
			if (s[j] == now) {
				judge = "No";
				break;
			}
		}
	}

	cout << judge << endl;
}

int main()
{
	b_shiritori();
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
 
struct st{int a,b,c;};
bool operator<(st&a,st&b){
	if(a.a!=b.a)return a.a<b.a;
	if(a.b!=b.b)return a.b<b.b;
	if(a.c!=b.c)return a.c<b.c;
	return false;
}
int main(){
	st a,b;cin>>a.a>>a.b>>a.c>>b.a>>b.b>>b.c;
	if(a<b)swap(a,b);
	if(P(a.b,a.c)<=P(b.b,b.c))cout<<a.a-b.a<<endl;
	else cout<<a.a-b.a+1<<endl;
}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x0 = sc.nextInt();
		int x1;
		for(int i=0; i<10; i++) {
			x1 = r * x0 - d;
			System.out.println(x1);
			x0 = x1;
		}
	}
}

Measured memory_bytes: 21716
a,b,c,d=map(int,input().split())

# Aまでの数で,C,Dの倍数
a_c=(a-1)//c
a_d=(a-1)//d
# Bまでの数で,C,Dの倍数
b_c=b//c
b_d=b//d
# C,Dの最小公倍数
import fractions
cd = (c*d)//fractions.gcd(c,d) 

a_cd = (a-1)//cd
b_cd = b//cd

print((b-a+1)-((b_c-a_c)+(b_d-a_d)-(b_cd-a_cd)))

Measured memory_bytes: 5332
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s,t,u;
  while(cin>>s>>t){
    u=(s.size()>t.size())?t:s;
    if(s==u) s=t;
    int c=u.size();
    int a=0,b=0;
    for(int i=0;i<c;++i){
      for(int j=0;j<s.size();++j){
	if(u[(j+i)%c]==s[j]){
	  ++b;
	  if((i+j)%c==c-1){
	    a=max(a,b);b=0;
	  }
	}
	else{
	  a=max(a,b);b=0;
	}
      }
      a=max(a,b);b=0;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <stack>
#include <algorithm>
#define H 8
#define W 8
using namespace std;

short h,w,c;

struct P {
  int a[H][W];
  int n;
};

void pr( P p ){
  for( int i=0;i<h;i++ ){
    for( int j=0;j<w;j++ ) cout << p.a[i][j] << " ";
    cout << endl;
  }
}

void change( int a[H][W],int i,int j,int c ){
  int b = a[i][j];
  if( a[i][j]==c ) return;
  a[i][j] = c;
  if( i-1>=0 && a[i-1][j]==b ) change( a,i-1,j,c );
  if( j-1>=0 && a[i][j-1]==b ) change( a,i,j-1,c );
  if( i+1<h && a[i+1][j]==b )  change( a,i+1,j,c );
  if( j+1<w && a[i][j+1]==b )  change( a,i,j+1,c );
}

int count( int a[H][W], int i, int j ){
  int r=1;
  if( i<0 || j<0 ) return 0;
  if( i>=h || j>=w ) return 0;

  if( a[i][j]!=c ) return 0;
  a[i][j] = -1;
  r += count( a,i+1,j );
  r += count( a,i-1,j );
  r += count( a,i,j+1 );
  r += count( a,i,j-1 );
  return r;
}


int main(){
  P p, q;
  stack<P> st;
  while( cin>>h>>w>>c && (h||w||c) ){
    for( int i=0;i<h;i++ )
      for( int j=0;j<w;j++ )
	cin >> p.a[i][j];
    p.n = 5;

    while( !st.empty() ) st.pop();
    st.push( p );

    int mx=0;
    while( !st.empty() ){
      p = st.top(); st.pop();
      if( p.n==0 ){
	int cnt = count(p.a,0,0);
	if( cnt>mx ){
	  //	  cout << "cnt=" << cnt << endl;
	  change( p.a,0,0,c );
	  //	  pr( p );
	}
	mx = max( mx,cnt );
      }else{
	for( int i=1;i<=6;i++ ){
	  q = p; q.n=p.n-1;
	  change( q.a,0,0,i );
	  st.push( q );
	}
      }
    }
    cout << mx << endl;
  }

  return 0;
}

Measured memory_bytes: 916
#include <iostream>
#include <string>

using namespace std;

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

    for (int i=0; i < 4; ++i) {
        if (s[i] == s[i+1]) {
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n;
int a[105000];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	vector<P> v;
	v.push_back(P(a[0],1));
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1])v[v.size() - 1].second++;
		else v.push_back(P(a[i], 1));
	}
	int even = 0;
	int odd = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i].second % 2 == 0)even++;
		else odd++;
	}
	if (even % 2 == 0)cout << odd + even << endl;
	else cout << odd + even - 1 << endl;

	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  string s; cin >> s;
	int tmp = 0;
	int ans = 0;
  FOR(i,0,2){
		if(s[i]=='R') ++tmp;
		else tmp = 0;
		chmax(ans,tmp);
  }
	cout << ans << endl;
}


Measured memory_bytes: 3604
import sys
input = sys.stdin.readline
import bisect
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
both = []
for i in range(n):
  both.extend(ab[i])
both.sort()
ans = 10**18
sm = sum(both[:n])
for i in range(n):
  ai = bisect.bisect_left(both,ab[i][0])
  bi = bisect.bisect_left(both,ab[i][1])
  if ai < n and bi < n:
    ans = min(ans,sm)
  elif ai < n-1:
    ans = min(ans,sm-both[n-1]+ab[i][1])
  elif ai == n-1:
    ans = min(ans,sm-both[n-2]+ab[i][1])
  elif bi < n-1:
    ans = min(ans,sm-both[n-1]+ab[i][0])
  elif bi == n-1:
    ans = min(ans,sm-both[n-2]+ab[i][0])
  else:
    ans = min(ans,sm-both[n-1]-both[n-2]+sum(ab[i]))
a,b = list(zip(*ab))
ans = min(ans,sum(a),sum(b))
print(ans)

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

typedef vector<int> vec;

int main() {
    int N;
    while(cin >> N, N) {
        vector<string> md(N), person(N);
        vec in(N, -1), out(N, -1);
        map<string,int> res;
        for(int i = 0; i < N; i++) {
            int h, m;
            char e, tmp;
            string q, MD;
            cin >> MD >> h >> tmp >> m >> e >> q;
            if(e == 'I')
                md[i] = MD, person[i] = q, in[i] = 60 * h + m;
            else
                md[i] = MD, person[i] = q, out[i] = 60 * h + m;
            res[q] = 0;
        }

        for(int i = 0; i < N; i++) {
            if(person[i] == "000" && in[i] >= 0) {
                int out0 = i + 1;
                while(person[out0] != "000") out0++;
                for(int j = 0; j < N; j++) {
                    if(person[j] != "000" && md[i] == md[j] && in[j] >= 0) {
                        int outX = j + 1;
                        while(person[outX] != person[j]) outX++;
                        if(!(out[outX] < in[i] || out[out0] < in[j])) {
                            res[person[j]] += min(out[out0], out[outX]) - max(in[j], in[i]);
                        }
                    }
                }
            }
        }
        int MAX = 0;
        for(auto i : res)
            MAX = max(MAX, i.second);

        cout << MAX << endl;
    }

    return 0;
}

Measured memory_bytes: 1376
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<17;


int main(){
    int N;
    cin >> N;
    vector<LL> a,b,c;
    for(int i=0;i<N;i++){
        LL t;
        cin >> t;
        a.push_back(-t);
    }
    for(int i=0;i<N;i++){
        LL t;
        cin >> t;
        b.push_back(t);
    }
    for(int i=0;i<N;i++){
        LL t;
        cin >> t;
        c.push_back(t);
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    LL ans=0;
    for(int i=0;i<N;i++){
        LL s=a.end()-upper_bound(a.begin(),a.end(),-b[i]);
        LL t=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        ans+=s*t;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

bool is_product_overflow(ll a, ll b) {
  ll prod = a * b;

  return (prod / b != a);
}

ll safeMultiply(ll left, ll right) {
  if (right > 0
        ? left > INT64_MAX / right || left < INT64_MIN / right
        : (right < -1 ? left > INT64_MIN / right || left < INT64_MAX / right : right == -1 && left == INT64_MIN)) {
    return -1;
  }
  return left * right;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  bool zero = false;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      zero = true;
    }
  }

  if (zero) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  rep(i, n) {
    ll cnt = 0;
    ll tmp = ans;

    while (tmp) {
      tmp /= 10;
      cnt++;
    }
    tmp = a[i];
    while (tmp) {
      tmp /= 10;
      cnt++;
    }

    // ans *= a[i];
    ans = safeMultiply(ans, a[i]);

    if (ans < 0 || ans > (long long)(1e18 + 1e-15)) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3992
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;
    int data[N][M][2]; F0R(i, N) F0R(j, M) {
        cin >> data[i][j][0];
    }
    F0R(i, N) F0R(j, M) cin >> data[i][j][1];

    bool dp[N][M][30000]; F0R(i, N) F0R(j, M) F0R(k, 30000) dp[i][j][k] = false;
    dp[0][0][data[0][0][0] - data[0][0][1] + 15000] = true;
    dp[0][0][data[0][0][1] - data[0][0][0] + 15000] = true;

    F0R(i, N) {
        F0R(j, M) {
            F0R(k, 30000) {
                if (!dp[i][j][k]) continue;
                if (i < N-1) {
                    dp[i+1][j][k+data[i+1][j][0] - data[i+1][j][1]] = true;
                    dp[i+1][j][k+data[i+1][j][1] - data[i+1][j][0]] = true;
                }
                if (j < M-1) {
                    dp[i][j+1][k+data[i][j+1][0] - data[i][j+1][1]] = true;
                    dp[i][j+1][k+data[i][j+1][1] - data[i][j+1][0]] = true;
                }
            }
        }
    }

    int ans = 100000;
    F0R(i, 30000) {
        if (dp[N-1][M-1][i]) {
            ans = min(ans, abs(15000-i));
        }
    }
    cout << ans << endl;


	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 187776
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stdio.h>
typedef long long ll;
const int maxn = 100010;
const ll inf = 10000000010;
#define cle(n) memset(n,0,sizeof(n))
using namespace std;

ll C[110][110];

int n,m;
int p;
int a[110];


int main()
{

       cle(C);
       for(int i=0;i<110;i++)
       {
           C[i][0]=1;
           for(int j=1;j<=i;j++)
            C[i][j]=C[i-1][j-1]+C[i-1][j];
       }


  scanf("%d%d",&n,&p);
   {
       cle(a);
       int jishu=0,oushu=0;

       for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            if(a[i]%2)jishu++;
            else  oushu++;
       }

      // if(oushu==0)oushu++;
       ll ans=0;
       if(p==0)
       {
           int jishulen=jishu;
           if(jishu%2) jishulen--;
           ll t1=0;
           t1++;
           for(int i=2;i<=jishulen;i=i+2)
           {
             t1+=C[jishu][i];
           }
           ll t2=0;
           for(int i=0;i<=oushu;i++)
           {
               t2+=C[oushu][i];
           }
//cout<<t2<<endl;
          // cout<<t1<<' '<<t2<<endl;
           ans=t1*t2;
       }

       else
       {
          // if(oushu==1)
           // oushu--;
          // if(jishu%2) jishulen--;
           ll t1=0;

           for(int i=1;i<=jishu;i=i+2)
           {
             t1+=C[jishu][i];
           }

           ll t2=0;

           for(int i=0;i<=oushu;i++)
           {
               t2+=C[oushu][i];
           }
           ans=t1*t2;
       }
       cout<<ans<<endl;
   }


   return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<string.h>
using namespace std;
const int maxn=200005;
vector<int> a[maxn];
int n,vis[maxn],dis[maxn];
void bfs(int st)
{
	vector<int>::iterator it;
	queue<int> b;
	for(it=a[st].begin();it!=a[st].end();it++)
	{
		b.push(*it);
		dis[*it]=1;
	}
	vis[st]=1;
	while(!b.empty())
	{
		st=b.front();
		for(it=a[st].begin();it!=a[st].end();it++)
		{
			if(!vis[*it])
			{
				dis[*it]=dis[st]+1;
				b.push(*it);
			}
		}
		vis[st]=1;
		b.pop();
	}
}
int main()
{
	int m,i,u,v;
	while(scanf("%d%d ",&n,&m)!=EOF)
	{
		for(i=1;i<=n;i++)
		{
			a[i].clear();
			vis[i]=0;
			dis[i]=0;
		}
		for(i=1;i<=m;i++)
		{
			scanf("%d%d",&u,&v);
			a[u].push_back(v);
			a[v].push_back(u);
		}
		bfs(1);
		//for(i=2;i<=n;i++)
		//cout<<dis[i]<<endl;
		if(dis[n]==2)
		printf("POSSIBLE\n");
		else
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

Measured memory_bytes: 14336
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		int time = 7200;
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int h = stdIn.nextInt();
			int m = stdIn.nextInt();
			int s = stdIn.nextInt();
			if(h == -1 && m == -1 && s == -1)
			{
				break;
			}
			int sum = time - (h * 3600 + m * 60 + s);
			int sum3 = sum * 3;
			h = sum / 3600;
			sum %= 3600;
			m = sum / 60;
			sum %= 60;
			s = sum;
			System.out.print("0" + h + ":");
			if(m < 10)
			{
				System.out.print("0" + m + ":");
			}
			else
			{
				System.out.print(m + ":");
			}
			if(s < 10)
			{
				System.out.println("0" + s);
			}
			else
			{
				System.out.println(s);
			}
			int h3, m3, s3;
			h3 = sum3 / 3600;
			sum3 %= 3600;
			m3 = sum3 / 60;
			sum3 %= 60;
			s3 = sum3;
			System.out.print("0" + h3 + ":");
			if(m3 < 10)
			{
				System.out.print("0" + m3 + ":");
			}
			else
			{
				System.out.print(m3 + ":");
			}
			if(s3 < 10)
			{
				System.out.println("0" + s3);
			}
			else
			{
				System.out.println(s3);
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  
  for (int i = 1; i <= 9; i += 1) {
    if (a % i == 0 && 1 <= a / i && a / i <= 9) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
#include<string>
#include<math.h>
#include<vector>
#include <iostream>
#include <algorithm>

using namespace std;
const long long int INF=1e9+5;

int main(){
    long long N;
    cin>>N;
    vector<long long>h(N);
    for(long long i=0;i<N;i++)
        cin>>h[i];
    vector<long long> dp(N,INF);
    dp[0]=0;
    for(long long i=0;i<N;i++){
        for(long long j=i+1;j<=i+2;j++){
            if(j<N){
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout<<dp[N-1];
    return 0;
}


Measured memory_bytes: 1792
from itertools import product

n, m = map(int, input().split())

switches = []
for i in range(m):
  k, *s = map(int, input().split())
  switches.append(s)

onoffs = list(map(int, input().split()))

patterns = product([0, 1], repeat=n)
cnt = 0
for pattern in patterns:
  for switch, onoff in zip(switches, onoffs):
    switch_ons = 0
    for switch_num in switch:
      if pattern[switch_num-1] == 1:
        switch_ons += 1
    if switch_ons % 2 != onoff:
      break
  else:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3064
import math
from functools import reduce

def getD(num):
    input_list = [2 if i % 2 == 0 else i for i in range(num+1)]
    input_list[0] = 0
    bool_list = [False if i % 2 == 0 else True for i in range(num+1)]
    sqrt = int(math.sqrt(num))
    
    for serial in range(3, sqrt + 1, 2):
        if bool_list[serial]:
            for s in range(serial ** 2, num+1, serial):
                if bool_list[s]:
                    input_list[s] = serial
                    bool_list[s] = False
    return input_list

N = int(input())
A = list(map(int, input().split()))

D = getD(max(A))
pairwise_coprime = True
use_divnum = set()
for k in A:
    while k != 1:
        div = D[k]
        if div in use_divnum:
            pairwise_coprime = False
            break
        else:
            use_divnum.add(div)
        
        while k % div == 0 and k > 1:
            k = k // div

if pairwise_coprime:
    print('pairwise coprime')
    exit()

if reduce(math.gcd, A) == 1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 127808
#!/usr/bin/env python3
import sys
import copy
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    x,y = MAP()
    if 0<=x<y:
        print(y-x)
    elif x<0<y:
        if abs(x) <= y:
            print(y-abs(x)+1)
        else:
            print(abs(x)-y+1)
    elif x<y<=0:
        print(y-x)
    elif 0<y<x:
        print(x+y)
    elif y<=0<x:
        if abs(y)<=x:
            print(x-abs(y)+1)
        else:
            print(abs(y)-x+1)
    elif y<x<0:
        print(x-y+2)
    elif y<x<=0:
        print(x-y+1)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    ll n,k;
    double ans=0;
    cin>>n>>k;
    ans+=max((n-k+1)/n,0ll);

    if(ans==0){
        for(int i=n;1<=i;i--)
        {
            ll cnt=0,x=i;
            while(x<k){
                x*=2;
                cnt++;
            }
            ans+=(double)1/((1ll<<cnt)*n);
            if((double)1/cnt < 1ll<<-9){
                break;
            }
        }
            
    }else{
        for(int i=k-1;1<=i;i--)
        {
            ll cnt=0,x=i;
            while(x<k){
                x*=2;
                cnt++;
            }
            ans+=(double)1/((1ll<<cnt)*n);
            if((double)1/cnt < 1ll<<-9){
                break;
            }
        }
    }



    cout << setprecision(14)<<ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long a, b, c,ans;

int main()
{
	cin >> a >> b >> c;
	long long ab = a * b, ac = a * c, bc = b * c;
	long long t = ab, h = c;
	if (t > ac) {
		t = ac, h = b;
	}
	if (t > bc) {
		t = bc, h = a;
	}
	long long half = h / 2;

	ans = t * (h-2*half);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>

#define MOD 1000000007
#define REP(i, a, b) for ( int i = (a); i < (b); i++ )

using namespace std;

typedef long long ll;

int N, M;
int A[100005];

int solve() {
	A[0] = 1;
	if (A[1] == -1) A[1] = 1;

	REP(i, 2, N + 1) {
		if ( A[i] == 0) continue;
		A[i] = (A[i - 1] + A[i - 2]) % MOD;
	}
	return A[N];
}

int main(void) {

	scanf("%d %d", &N, &M);

	REP(i, 0, N + 1) A[i] = -1;

	REP(i, 0, M) {
		int x;
		scanf("%d", &x);
		A[x] = 0;
	}

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

	return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
#define next asdnext
#define prev asdprev
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[110000], B[110000];
pint Ai[110000], Bi[110000];
int G[110000];
bool visited[110000];
int cnt = 0;
void dfs(int x) {
    if (visited[x]) { return; }
    cnt++;
    visited[x] = true;
    dfs(G[x]);
}
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i], Ai[i] = {A[i], i}; }
    rep(i, N) { cin >> B[i], Bi[i] = {B[i], i}; }
    sort(Ai, Ai + N);
    sort(Bi, Bi + N);
    rep(i, N) {
        if (Ai[i].first > Bi[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, N) {
        G[Ai[i].second] = Bi[i].second;
    }
    dfs(0);
    if (cnt != N) {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = 1; i < N; i++) {
        if (Ai[i].first <= Bi[i - 1].first) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
const int maxn=100;
typedef long long ll;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}
char s1[maxn+5],s2[maxn+5],s[maxn+5];
int n,m;
int main()
{
    scanf("%s%s",s1,s2);
    scanf("%d%d",&n,&m);
    scanf("%s",s);
    if (strcmp(s,s1)==0) printf("%d %d\n",n-1,m);
    else printf("%d %d\n",n,m-1);
    return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
 
public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }
 
    public static void hoge()
    {
        var vars = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var r = vars[0];
        
 
        System.Console.WriteLine(System.Math.PI * r * 2);
    }
}

Measured memory_bytes: 28312
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> sorted_x(n);
 
  int a;
  vector<vector<int>> mat(n,vector<int>(0));
  for(int i = 0; i < n;i++){
    cin >> x[i];
  }
  sorted_x = x;
  sort(sorted_x.begin(), sorted_x.end());
  
  int ma = sorted_x[n/2-1];
  int mb = sorted_x[n/2];
  for(int i = 0; i < n;i++){
    if(x[i] <= ma){
      cout << mb << endl;
    }else{
      cout << ma << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin>>N>>M;
    Graph G(N);

    int u[M],v[M];
    rep(i,M){
        cin>>u[i]>>v[i];
        u[i]--;
        v[i]--;
        G[u[i]].push_back(v[i]);
    }
    int S,T;
    cin>>S>>T;
    S--;
    T--;

    int dp[N][3];
    queue<pair<int,int>> q;
    q.push(make_pair(S,0));
    rep(i,N){
        rep(j,3){
            dp[i][j]=INF;
        }
    }
    dp[S][0]=0;
    while(!q.empty()){
        auto e=q.front();
        q.pop();
        int v=e.first;
        int d=e.second;
        for(auto nv:G[v]){
            int nd=(d+1)%3;
            if(dp[nv][nd]>dp[v][d]+1){
                dp[nv][nd]=dp[v][d]+1;
                q.push(make_pair(nv,nd));
            }
        }

    }
    if(dp[T][0]==INF){
        cout << -1 << endl;
    }else{
        cout << dp[T][0]/3 << endl;
    }


    



}


Measured memory_bytes: 12700
#include <stdio.h>
#define HILLS 10

int main(void){
	int i, t, a=0, b=0, c=0;
	
	for(i=HILLS;i--;){
		scanf("%d",&t); if(t>a) a=t;
		
		if(a>b) t=a, a=b, b=t;
		if(b>c) t=c, c=b, b=t;
	}
	
	printf("%d\n%d\n%d\n",c,b,a);
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
void solve(){
	cin >> n;
	
	cout << n * (n+1) / 2 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	int a[205], n, i, sum = 0, min;
	scanf("%d",&n);
	for(i = 0; i < 2*n; i++)
	scanf("%d",&a[i]);
	sort(a,a+2*n);
	for(i = 0; i < 2*n; i += 2)
	{
		min = a[i]>a[i+1]?a[i+1]:a[i];
		sum = sum + min;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10005]={};
int find(int x){
	if(a[x]==x)return a[x];
	else return (a[x]=find(a[x]));
}
int main(){
  int n,q;cin>>n>>q;
  for(int i=0;i<10005;i++)a[i]=i;
  for(int i=0;i<q;i++){
    int t,x,y;cin>>t>>x>>y;
    if(t==0){a[find(x)]=find(y);}
    if(t==1){cout<<(find(x)==find(y)?1:0)<<endl;}
  }
}

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

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl

ll a, b, c, d, res, lc;

int main () {
    cin >> a >> b >> c >> d;
    res=b-a+1;
    res-=(b/c-(a-1)/c)+(b/d-(a-1)/d);
    if (c/__gcd(c, d)*d>b) {
        cout << res;
    } else {
        lc=c/__gcd(c, d)*d;
        res+=b/lc-(a-1)/lc;
        cout << res;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
int main()
{
	int n,arr[105],total=0,kurang;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>arr[i],total+=arr[i];
	if(total%10==0)
	{
		kurang=total;
		for(int i=1;i<=n;i++)
		{
			if(arr[i]%10!=0)
				kurang=min(kurang,arr[i]);
		}
		total-=kurang;
	}
	cout<<total<<endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

const R: u64 = 1000000007;

fn main() {
    let n: usize = read();
    /*
    if n == 3 {
        println!("{}", 4 * 4 * 4 - 3);
        return;
    }

    let mut dp: Vec<Vec<Vec<Vec<Vec<u32>>>>> = vec![vec![vec![vec![vec![1; 4]; 4]; 4]; 4]; 101];
    for p in 0..4 {
        dp[4][p][0][2][1] = 0;
    }
    for s in 0..4 {
        dp[4][0][2][1][s] = 0;
    }
    for q in 0..4 {
        dp[4][0][q][2][1] = 0;
    }
    for p in 0..4 {
        dp[4][p][2][0][1] = 0;
    }
    for s in 0..4 {
        dp[4][2][0][1][s] = 0;
    }
    for p in 0..4 {
        dp[4][p][0][1][2] = 0;
    }
    for s in 0..4 {
        dp[4][0][1][2][s] = 0;
    }
    for r in 0..4 {
        dp[4][0][2][r][1] = 0;
    }

    for i in 5..(n + 1) {
        for p in 0..4 {
            for q in 0..4 {
                for r in 0..4 {
                    for s in 0..4 {}
                }
            }
        }
    }
    */

    let mut dp: Vec<Vec<Vec<Vec<u64>>>> = vec![vec![vec![vec![1; 4]; 4]; 4]; 101];
    dp[3][0][2][1] = 0;
    dp[3][2][0][1] = 0;
    dp[3][0][1][2] = 0;

    for i in 4..(n + 1) {
        for q in 0..4 {
            for r in 0..4 {
                for s in 0..4 {
                    if q == 0 && r == 2 && s == 1 {
                        dp[i][q][r][s] = 0;
                    } else if q == 2 && r == 0 && s == 1 {
                        dp[i][q][r][s] = 0;
                    } else if q == 0 && r == 1 && s == 2 {
                        dp[i][q][r][s] = 0;
                    } else if r == 2 && s == 1 || q == 2 && s == 1 {
                        dp[i][q][r][s] =
                            (dp[i - 1][1][q][r] + dp[i - 1][2][q][r] + dp[i - 1][3][q][r]) % R;
                    } else {
                        dp[i][q][r][s] = (dp[i - 1][0][q][r]
                            + dp[i - 1][1][q][r]
                            + dp[i - 1][2][q][r]
                            + dp[i - 1][3][q][r])
                            % R;
                    }
                }
            }
        }
    }

    let mut ans: u64 = 0;
    for q in 0..4 {
        for r in 0..4 {
            for s in 0..4 {
                ans = (ans + dp[n][q][r][s]) % R;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int64_t l_, int64_t r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

struct revrange {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int64_t l_, int64_t r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  u64 a;
  std::cin >> a;
  std::string s;
  std::cin >> s;
  u32 b = 0;
  for (auto c: s) {
    if (c == '.') {
      continue;
    }
    b = b * 10 + (c - '0');
  }
  std::cout << a * b / 100 << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>

using namespace std;

int main(void)
{
    int n;
    long long int count = 0;
    long long int a = 0;
    vector<int> v;

    cin>>n;

    for(int i = 0;i < n;i++)
    {
	int temp;

	cin>>temp;

	v.push_back(temp);
    }

    for(int i = 0;i < n;i++) {
	a += v[i];
	if(v[i] == 0)
	{
	    count += a/2;
	    a = 0;
	}
    }

    count += a/2;

    cout<<count<<endl;

    return 0;
}


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

int main() {
    int N, ans = 0;
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;

        bool flag = true;
        for (int j = 2; j * j <= a; ++j) {
            if (a % j == 0)
                flag = false;
        }
        if (flag)
            ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

int A, B, C, D;
int L;

int gcd(int a, int b) {
    while (b) {
        int t = a;
        a = b;
        b = t%b;
    }
    return a;
}

int lcm(int a, int b) {
    return a/gcd(a, b)*b;
}

int calc(int x) {
    return x/C+x/D-x/L;
}

signed main() {
    //cin.tie(0); ios::sync_with_stdio(false);
    cin >> A >> B >> C >> D;
    L = lcm(C, D);
    cout << B-A+1-(calc(B)-calc(A-1)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
int c[500100];
const int K=sqrt(500100)+1;
struct Q{
	int l;
	int r;
	int num;
	Q(int l, int r, int num):l(l),r(r),num(num){}
};
vector<Q> buckets[K];
int cnt[500100];
int ans[500100];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n, q;
	cin>>n>>q;
	rep(i,n)cin>>c[i];
	rep(i,q){
		int l,r;
		cin>>l>>r;
		l--;
		r--;
		buckets[l/K].eb(l,r,i);
	}
	for(int i=0;i<K;i++){
		sort(buckets[i].begin(),buckets[i].end(),[&](Q a, Q b){return a.r<b.r;});
		if(buckets[i].empty())continue;
		memset(cnt,0,sizeof(cnt));
		int cur=0;
		for(int j=buckets[i][0].l;j<=buckets[i][0].r;j++){
			cnt[c[j]]++;
			if(cnt[c[j]]==1)cur++;
		}
		ans[buckets[i][0].num]=cur;
		int pl=buckets[i][0].l;
		int pr=buckets[i][0].r;
		for(auto qr:buckets[i]){
			for(int j=pr+1;j<=qr.r;j++){
				cnt[c[j]]++;
				if(cnt[c[j]]==1)cur++;
			}
			pr=qr.r;
			for(int j=pl;j<qr.l;j++){
				cnt[c[j]]--;
				if(cnt[c[j]]==0)cur--;
			}
			for(int j=qr.l;j<pl;j++){
				cnt[c[j]]++;
				if(cnt[c[j]]==1)cur++;
			}
			pl=qr.l;	
			ans[qr.num]=cur;
		}
	}
	for(int i=0;i<q;i++){
		cout<<ans[i]<<'\n';
	}
}



Measured memory_bytes: 18648
#include <stdio.h>
#include <math.h>

double Dis(double x1, double y1, double x2, double y2);

int main(void){
	double xs, ys;
	double x, y;
	double xb, yb;
	double dis1 = -1;
	double dis2 = -1;
	double dis3 = -1;
	double ans = 0;

	scanf("%lf,%lf", &xs, &ys);
	int i = 0;
	while(scanf("%lf,%lf", &x, &y) != EOF){
		if(i == 0){
			dis1 = Dis(x, y, xs, ys);
			xb = x;
			yb = y;
			i++;
			continue;
		}
		dis2 = Dis(x, y, xs, ys);
		dis3 = Dis(x, y, xb, yb);
		double z = (dis1 + dis2 + dis3) / 2.0;
		double s = sqrt(z*(z-dis1)*(z-dis2)*(z-dis3));
		ans += s;
		dis1 = dis2;
		xb = x;
		yb = y;
	}

	printf("%.7f\n", ans);

	return 0;
}

double Dis(double x1, double y1, double x2, double y2){
	return sqrt((y2-y1)*(y2-y1) + (x2-x1)*(x2-x1));
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int a,b;
	cin>>a>>b;
	int l = 1;
	 int r = 1000000;

	 bool ok = false;
	 int ans;

	 for(int i=1;i<=1000000;i++){
	 	l = i*8, r = i*10;
	 	l = l/100, r = r/100;
	 	if(l==a && r==b){
	 		ans = i;
	 		ok = true;
	 		break;
	 	}
	 }
	 if(!ok){
	 	cout<<"-1";
	 }else{
	 	cout<<ans;
	 }
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll mod=1e9+7;

#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

ll gcd(ll a,ll b)
{
	return b? gcd(b,a%b):a;
}

ll pow(ll a, ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2) res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

int ugabuga()
{

	ll n,k;
	cin>>n>>k;
	ll dp[n+3][k+3];
	for(int i=0;i<=n;i++)
	for(int j=0;j<=k;j++) dp[i][j]=0;

	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll x,val;
		cin>>x>>val;
		for(int j=1;j<=k;j++)
		{
			if(j>=x) dp[i][j]=max(dp[i-1][j],dp[i-1][j-x]+val); else dp[i][j]=dp[i-1][j];
			ans=max(dp[i][j],ans);
		} 
	}

	cout<<ans;

	return 0;
}


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

    int t=1;
    //cin>>t;
    while(t--)
    {
        ugabuga();
    }

}

Measured memory_bytes: 80256
#include <stdio.h>

int main(){
    int S;
    int h, m, s;
    scanf("%d", &S);
    h = S / 3600;
    m = (S - 3600 * h) / 60;
    s = S - (3600 * h) - (60 * m);
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 592
#define S scanf("%d",&
c[];main(n,m,i,j,k){for(;S n),S m),n;printf("%d\n",j>m?i:j)){for(i=3;i--;)for(S j);j--;c[n-k]=i)S k);for(i=n;i--;k+=c[i])j-=pow(3,i)*abs(k*2%4-c[i]);j=fmin(~j,pow(3,n)+j);}}

Measured memory_bytes: 644