akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b)cout<<c;
    else if (b==c)cout<<a;
    else cout<<b;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
	int temp_a,temp_b,n,i,a_m,b_m,ans;
	vector<int>a;
	vector<int>b;
	cin >> n;
	for (i=0;i<n;i++) {
		cin >> temp_a >> temp_b;
		a.push_back(temp_a);
		b.push_back(temp_b);
	}
	std::sort(a.begin(), a.end());
	std::sort(b.begin(), b.end());
	if (n%2 == 0){
		a_m = a[int(n/2)-1] + a[int(n/2)];
		b_m = b[int(n/2)-1] + b[int(n/2)];
	} else {
		a_m = a[int(n/2)];
		b_m = b[int(n/2)];
	}
	ans = b_m - a_m + 1;
	cout << ans << '\n';
}


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

int main() {
  int S;
  cin >> S;
  int h = 0, m = 0;
  h = S / 3600;
  S %= 3600;
  m = S / 60;
  S %= 60;
  cout << h << ':' << m << ':' << S << "\n";
}


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

long long MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    long long a[m];

    for(int j = 0; j < m; j++) cin >> a[j];

    int j = 0;
    long long ans[n + 1];
    ans[0] = 1;
    if(a[0] == 1) {
        ans[1] = 0;
        j++;
    }
    else ans[1] = 1;

    for(long long i = 2; i <= n; i++) {
        if(j < m) { 
            if(i == a[j]) {
            ans[i] = 0;
            j++;
            continue;
            }
        }
        ans[i] = (ans[i - 2] + ans[i - 1]) % MOD;
        // cout << i << ": " << ans[i] << endl;
    }

    cout << ans[n] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ms(x, t) memset(x, t, sizeof(x))
typedef long long int ll;
typedef unsigned long long int ull;
#define ff first
#define ss second
const int limit= 1e7+1;
const int inf = 1e7;
double p[limit];
void dp(int n){
    double m[n+1][n+1];
    ms(m, 0);
    m[0][0] = 1;
    for(int i = 1; i<= n; i++){
        for(int j=0; j<=i; j++){
            if(j){
                m[i][j] = m[i-1][j] * (1-p[i-1]) + m[i-1][j-1] * p[i-1];
            }
            else{
                m[i][j] = m[i-1][j] * (1- p[i-1]);
            }
        }
    }

    int i=n;
    double sum=0;
    for(int j=(n+1)/2; j<=n; j++){
        sum+= m[i][j];
    }
    cout<<setprecision(15)<<sum<<endl;
}
int main(){
    int n;
    cin>>n;

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

    dp(n);

    return 0;
}

Measured memory_bytes: 70528
n = gets.to_i
A = gets.split().map(&:to_i)

B = A.sort!.reverse!
a = []
t = -1

B.each do |x|
  if t == x
    t = -1
    a.push(x)
    break if a.size > 1
  else
    t = x
  end
end

puts a.size > 1 ? a[0]*a[1] : 0

Measured memory_bytes: 9328
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        int count = 0;
        for(int i=0;i<s.length();i++){
          if((i%2==0 && s.charAt(i)=='0')||(i%2==1 && s.charAt(i)=='1')){count++;}}
        ans = Math.min(count,s.length()-count);
		System.out.println(ans);
  }
}


Measured memory_bytes: 25840
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int A, B;
    cin >> A >> B;
    for(int i = 1; i < 100000; i++) {
        if(i * 8 / 100 == A && i * 10 / 100 == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 2; i <= 100; i ++) {
        for(int j = 2; j <= 10; j ++) {
            if(pow(i, j) <= x)
                ans = max(ans, (int) pow(i, j));
            else
                break;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    long long dp[N + 10];
    long long height[N];

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

    fill_n(dp, N + 10, 100000000000);

    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(height[i] - height[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(height[i] - height[i + 2]));
    }

    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll mod=1e9+7;

vector<int> adj[100001];
ll m;
int n;
vector<ll> dp1(100001),dp2(100001);
int vis[100001];
void solve1(int i)
{
  vis[i]=1;
  dp1[i]=1;
  for(int x: adj[i])
  {
    if(!vis[x])
    {
      solve1(x);
      dp1[i]=(dp1[i]*(1+dp1[x]))%m;
    }
  }
}
void solve2(int i,ll parans)
{
  vis[i]=1;
  dp2[i]=(dp1[i]*(1+parans))%m;
  vector<ll> prefix;
  vector<ll> suffix;
  for(int ch: adj[i])
  {
    if(!vis[ch]){
    prefix.push_back(dp1[ch]+1);
    suffix.push_back(dp1[ch]+1);
    }
  }
  for(int j=1;j<prefix.size();j++)
  {
    prefix[j]=(prefix[j]*prefix[j-1])%m;
  }
  for(int j=suffix.size()-2;j>=0;j--)
  {
    suffix[j]=(suffix[j]*suffix[j+1])%m;
  }
  int cno=0;
  for(int ch: adj[i])
  {
    if(!vis[ch])
    {
      ll ways=(1+parans);
      ll x=(cno>0)?(prefix[cno-1]):1;
      ll y=(cno<suffix.size()-1)?(suffix[cno+1]):1;
      ways=(((ways*x)%m)*y)%m;
      solve2(ch,ways);
      cno++;
    }
  }
}
int main()
{
  cin>>n;
  cin>>m;
  for(int i=1;i<n;i++)
  {
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  memset(vis,0,sizeof(vis));
  solve1(1);
  memset(vis,0,sizeof(vis));
  solve2(1,0);
  for(int i=1;i<=n;i++)
  cout<<dp2[i]<<endl;
  return 0;
}


Measured memory_bytes: 26484
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


int main(){
	
	int N;
	int sum = 0;
	int C[50], V[50];
	cin >> N;
	for (int i = 0; i < N; i++)		cin >> V[i];
	for (int i = 0; i < N; i++)		cin >> C[i];
	for (int i = 0; i < N; i++) {
		if (V[i] > C[i]) sum = sum + V[i] - C[i];
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    d =[]
    cnt = 0
    ans = 'No'
    for i in range(n):
        d1 = list(map(int,input().split()))
        if d1[0] == d1[1]:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            ans = 'Yes'
        d.append(d1)
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 9172
import java.util.Scanner;
import java.math.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int a, b;
		a = scan.nextInt();
		b = scan.nextInt();

		// ???????°???°?????°??¨?????\???????????¨???
		double d;
		d = 0.0;

		// a??b ?????´??°???????¨????
		System.out.print(Integer.toString(a / b) + " ");
		// a??b????????? ?????´??°???????¨????
		System.out.print(Integer.toString(a % b) + " ");
		// a??b??????????°???°?????°???????¨????
		// a????????????.0???????????????
		d = Double.parseDouble(Integer.toString(a) + ".0");

		BigDecimal x = new BigDecimal(d / b);

		System.out.print(x.setScale(5, BigDecimal.ROUND_HALF_UP));

	}
}

Measured memory_bytes: 26660
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


ll N;
ll cnt;
ll v[] = {3, 5, 7};

void saiki(ll num, bool III, bool V, bool VII){
  if(num <= N){
    if(III && V && VII) cnt++;
    saiki(num*10 + 3, 1, V, VII);
    saiki(num*10 + 5, III, 1, VII);
    saiki(num*10 + 7, III, V, 1);
  }
}

int main() {
  cin >> N;
  cnt = 0;
  saiki(3, 1, 0, 0);
  saiki(5, 0, 1, 0);
  saiki(7, 0, 0, 1);

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int64 A, B, N;
    cin >> A >> B >> N;

    int64 x = min(N, B - 1);
    cout << A * x / B - A * (x / B) << endl;

    return 0;
}



Measured memory_bytes: 3096
import java.util.Arrays;
import java.util.TreeSet;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author ogiekako
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		MyPrintWriter out = new MyPrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, MyScanner in, MyPrintWriter out) {
        int n = in.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[in.nextInt()-1] = i;
        }
        TreeSet<Integer> seen = new TreeSet<>();
        seen.add(-1);
        seen.add(n);
        long res = 0;
        for (int i = 0; i < n; i++) {
            res += (long)(p[i] - seen.lower(p[i])) * (seen.higher(p[i]) - p[i]) * (i+1);
            seen.add(p[i]);
        }
        out.println(res);
    }
}

class MyScanner {
    private final InputStream in;

    public MyScanner(InputStream in) {
        this.in = in;
    }

    private static final int BUFSIZE = 65536;
    int bufLen;
    int bufPtr;
    byte[] buf = new byte[BUFSIZE];

    public int read() {
        if (bufLen == -1)
            throw new InputMismatchException();
        if (bufPtr >= bufLen) {
            bufPtr = 0;
            try {
                bufLen = in.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (bufLen <= 0)
                return -1;
        }
        return buf[bufPtr++];
    }

    public int nextInt() {
        int c = read();
        if (c == -1) throw new NoSuchElementException();
        while (c != '-' && (c < '0' || '9' < c)) {
            c = read();
            if (c == -1) throw new NoSuchElementException();
        }
        if (c == '-') return -nextInt();
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while ('0' <= c && c <= '9');
        return res;
    }

}

class MyPrintWriter {
    PrintWriter out;

    public MyPrintWriter(OutputStream outputStream) {
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void println(Object... os) {
        if (os.length == 0) {
            out.println();
            return;
        }
        for (int i = 0; i < os.length - 1; i++) {
            out.print(os[i]);
            out.print(' ');
        }
        out.println(os[os.length - 1]);
    }

    public void close() {
        out.close();
    }

}



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

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N)cin >> A[i];

    vector<int> B(N+1);
    REP(i, N){
        B[A[i]]++;
        B[A[i]+1]++;
    }

    bool ok = false;
    REP(c, N+1){
        if(B[c]!=N)continue;
        int one_cat = 0;
        REP(i, N){
            if(A[i]+1==c)one_cat++;
        }
        int two_cat = N - one_cat;
        int rem_color = c - one_cat;
        //cerr << c << " " << one_cat << " " << two_cat << " " << rem_color << endl;
        if(two_cat==0 && rem_color==0)ok = true;
        if(two_cat==0 || rem_color==0)continue;
        if(rem_color < 0)continue;
        if(two_cat >= rem_color*2)ok = true;
    }

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long A = sc.nextLong();
			final long B = sc.nextLong();
			final long C = sc.nextLong();
			final long K = sc.nextLong();
			
			long rest = K, answer = 0;
			answer += Math.min(rest, A);
			rest -= Math.min(rest, A);
			
			rest -= Math.min(rest, B);
			
			answer -= Math.min(rest, C);
			rest -= Math.min(rest, C);
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32624
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

void main() {
    int n = read();
    int[] a = reads();
    int ans = int.max;
    foreach (i; 1..n) {
        int d = abs(a[0..i].sum - a[i..$].sum);
        ans = min(ans, d);
    }
    writeln(ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 1000000000
int CO[100010];
int MIN(int a,int b){return a<b?a:b;}
int R=1,C=1,H[2000010],N[2000010];
//????????¢??°????????????MAX???
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//?????\??¢??°
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//??????????????¢??°
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
  int ta[10010],to[100010],co[100010],nt[100010],ca[100010],u[10010];
int mifl(int v,int e,int f,int s,int t,int *a,int *b,int *c,int *d){
  int i,j,k,min,mi,ans=0,id[100010],fre[100010],frv[100010];
  int h[1000010]={0};
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    ca[i  ]=c[i];
    ca[i+e]=0;
    co[ta[a[i]]=i  ]= d[i];
    co[ta[b[i]]=i+e]=-d[i];
  }
  while(f>0){
    /*for(i=0;i<v;i++){
      printf("%d %d::",i,h[i]);
      for(j=ta[i];j+1;j=nt[j])printf("%d %d %d:",to[j],ca[j],co[j]);
      printf("\n");
      }printf("\n");//*/
    for(i=0;i<v;i++)CO[i]=M;
    for(i=0;i<v;i++)u[i]=0;
    R=C=1;
    frv[s]=fre[s]=-1;
    CO[mi=s]=0;
    while(u[mi]-1){
      u[mi]=1;//printf("%d %d::",mi,CO[mi]);
      for(i=ta[mi];i+1;i=nt[i]){
	//printf("%d %d:",CO[to[i]],CO[mi]+co[i]+h[mi]-h[to[i]]);
	if(ca[i]&&  CO[to[i]]>CO[mi]+co[i]+h[mi]-h[to[i]]){
	  hin(CO[id[R]=to[i]]=CO[mi]+co[i]+h[mi]-h[to[i]]);
	  fre[to[i]]=i;
	  frv[to[i]]=mi;
	}
      }//printf("\n");
      while(u[mi]&&C-1)mi=id[hout()];
    }
    /*for(i=0;i<v;i++){
      printf("%d %d %d %d\n",i,CO[i],frv[i],fre[i]);
      }
      printf("\n");//*/
    if(CO[t]==M)return -1;
    for(i=0;i<v;i++)h[i]+=CO[i];
    min=f;
    for(i=t;i-s;i=frv[i])min=MIN(min,ca[fre[i]]);
    f-=min;
    ans+=h[t]*min;//printf("%d\n\n",ans);
    for(i=t;i-s;i=frv[i]){
      ca[fre[i]]-=min;
      ca[(fre[i]+e)%(2*e)]+=min;
    }
  }
  return ans;
}

  
int main(){
  int v,e,m,i,a[100010],b[100010],c[100010],d[100010];
  scanf("%d %d %d",&v,&e,&m);
  for(i=0;i<e;i++)scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
  printf("%d\n",mifl(v,e,m,0,v-1,a,b,c,d));
  return 0;
}

Measured memory_bytes: 9724
#include <iostream>
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  int D, N;
  cin >> D >> N;
  int ret = N;
  if (D == 0) {
    if (N == 100) ret++;
  } else if (D == 1) {
    if (N == 100) ret++;
    ret *= 100;
  } else {
    if (N == 100) ret++;
    ret *= 100 * 100;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  int d, g, r = 1;
  cin >> d >> g;
  g /= 100;
  REP(i, d){
    r *= 2;
  }
  vector<int> p(d), c(d), num(d);
  int n = 0;
  REP(i, d){
    cin >> p[i] >> c[i];
    n += p[i];
    c[i] /= 100;
    num[i] = i + 1;
  }
  REP(i, n){
    int mx = 0;
    REP(j, r){
      int sum = 0, cnt = i + 1;
      bool used[d] = {};
      for(int k = j, l = 0; l < d; k /= 2, l++){
        if(k % 2 == 1){
          sum += p[l] * num[l] + c[l];
          cnt -= p[l];
          used[l] = true;
        }
      }
      if(cnt < 0)continue;
      for(int k = d - 1; k > -1; k--){
        if(used[k])continue;
        if(cnt >= p[k])break;
        sum += cnt * num[k];
        break;
      }
      if(sum > mx)mx = sum;
    }
    if(mx >= g){
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}

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

public class Main {
	public static void main(String args[]) {
		Solution solution = new Solution();
		solution.compute();
	}
}

class Solution {
	void compute() {
		Scanner scanner = new Scanner(new BufferedInputStream(System.in));
		
		Dijkstra graph = new Dijkstra(10000);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if (n == 0 && m == 0) {
				break;
			}
			graph.initialize(n);
			for (int i = 0; i < m; i++) {
				int u = scanner.nextInt();
				int v = scanner.nextInt();
				int d = scanner.nextInt();
				int c = scanner.nextInt();
				u--;
				v--;
				graph.addEdge(u, v, d, c);
				graph.addEdge(v, u, d, c);
			}
			int ans = graph.dijkstra(0);
			System.out.println(ans);
		}

		scanner.close();
	}
}

class Dijkstra {
	final int INFINITY = 0x3f3f3f3f;
	final int MAX_N;

	class Edge implements Comparable<Edge> {
		int to;
		int cost;
		int money;

		Edge(int to, int cost, int money) {
			this.to = to;
			this.cost = cost;
			this.money = money;
		}

		@Override
		public int compareTo(Edge that) {
			int ans = this.cost - that.cost;
			if (ans != 0) {
				return ans;
			}
			return this.money - that.money;
		}
	}

	Vector<Edge>[] graph;
	int[] distance;
	boolean[] visit;
	int n;

	@SuppressWarnings("unchecked")
	Dijkstra(int MAX_N) {
		this.MAX_N = MAX_N;
		graph = (Vector<Edge>[]) new Vector[MAX_N];
		for (int i = 0; i < MAX_N; i++) {
			graph[i] = new Vector<Edge>();
		}
		distance = new int[MAX_N];
		visit = new boolean[MAX_N];
	}

	void initialize(int n) {
		this.n = n;
		for (int i = 0; i < n; i++) {
			graph[i].clear();
		}
		Arrays.fill(distance, INFINITY);
		Arrays.fill(visit, false);
	}

	void addEdge(int from, int to, int cost, int money) {
		graph[from].addElement(new Edge(to, cost, money));
	}

	int dijkstra(int start) {
		int ans = 0;
		
		Queue<Edge> que = new PriorityQueue<Edge>();
		distance[start] = 0;
		que.add(new Edge(start, 0, 0));
		while (!que.isEmpty()) {
			Edge node = que.poll();
			int from = node.to;
			if (visit[from]) {
				continue;
			}
			visit[from] = true;
			ans += node.money;
			for (Edge e : graph[from]) {
				int to = e.to;
				int cost = e.cost;
				if (!visit[to] && distance[to] >= distance[from] + cost) {
					distance[to] = distance[from] + cost;
					que.add(new Edge(to, distance[to], e.money));
				}
			}
		}
		return ans;
	}
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

template <typename T>
struct Edge {
  int src, dst; T weight;

  Edge(int src, int dst, T weight) : src(src), dst(dst), weight(weight) { }

  bool operator < (const Edge<T> &e) const {
    return weight < e.weight;
  }
};

template <typename T>
struct Graph {
  int V;
  vector<Edge<T>> E;

  Graph(int V) : V(V) { }

  void add_edge(int src, int dst, T weight) {
    E.emplace_back(src, dst, weight);
  }
};

struct DisjointSet {
  vector<int> parent, rank;

  DisjointSet(int N) {
    parent.resize(N), rank.resize(N, 0);
    for (int i = 0; i < N; i++) parent[i] = i;
  }

  int find(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return ;
    if (rank[x] < rank[y]) {
      parent[x] = y;
    } else {
      parent[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }
};

template <typename T>
struct MinimumSpanningTree {
  Graph<T> g;
  vector<Edge<T>> mst;
  T mincost;

  MinimumSpanningTree(const Graph<T> &g) : g(g) { }

  T run() {
    mincost = 0;
    sort(g.E.begin(), g.E.end());

    DisjointSet uf(g.V);

    for (int i = 0, edge_count = g.V - 1; edge_count; i++) {
      assert(i < (int)g.E.size());
      Edge<T> e = g.E[i];
      if (!uf.same(e.src, e.dst)) {
        uf.unite(e.src, e.dst);
        mst.emplace_back(e);
        mincost += e.weight;
        edge_count--;
      }
    }
    return mincost;
  }
};

ll max_cost[4010][4010];
vector<pair<int, ll>> edge[4010];

void dfs(int v, int p, int s, ll cost) {
  max_cost[s][v] = cost;
  for (auto e : edge[v]) {
    int n; ll c; tie(n, c) = e;
    if (n != p) dfs(n, v, s, max(cost, c));
  }
}


int main() {

  int N, M; scanf("%d %d", &N, &M);
  Graph<ll> g(N);
  REP(i, M) {
    int a, b, c; scanf("%d %d %d", &a, &b, &c); a--, b--;
    g.add_edge(a, b, c);
    g.add_edge(b, a, c);
  }
  MinimumSpanningTree<ll> mst(g);
  mst.run();

  for (auto e : mst.mst) {
    edge[e.src].emplace_back(e.dst, e.weight);
    edge[e.dst].emplace_back(e.src, e.weight);
  }

  REP(i, N) dfs(i, -1, i, 0);

  int Q; scanf("%d", &Q);

  REP(i, Q) {
    int s, t; scanf("%d %d", &s, &t); s--, t--;
    printf("%lld\n", mst.mincost - max_cost[s][t]);
  }

  return 0;
}


Measured memory_bytes: 152036
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <bits/stdc++.h>

using namespace std;


int main(){
    //int n, k, t, h;
    int n, A, next_add_i, last_i, cur_last_A;
    next_add_i = 0;
    cin >> n;
    vector<int> sort_curs(n);
    
     for (int i=0; i<n; i++){
        cin >> A;

        if (i == 0){
            sort_curs.at(i) = A;
            next_add_i++;
            last_i = i;
        } else{
            if (sort_curs.at(last_i) >= A){
                last_i++;
                sort_curs.at(last_i) = A;
                next_add_i++;
            } else{
                for (int sort_i=0; sort_i<=last_i; sort_i++) {
                    cur_last_A = sort_curs.at(sort_i);
                    if (cur_last_A < A){
                        sort_curs.at(sort_i) = A;
                        break;
                    }
                }
            }
        }
    }

    cout << next_add_i << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

const int MAX_V = 100000, MAX_LOG_V = 18;
int N, Q;
std::vector<int> G[MAX_V];
int parent[MAX_LOG_V][MAX_V], depth[MAX_V];

void dfs(int v, int p, int d){
    parent[0][v] = p;
    depth[v] = d;
    REP(i, G[v].size()){
        if(G[v][i] != p){
            dfs(G[v][i], v, d+1);
        }
    }
}

void init(){
    dfs(0, -1, 0);
    for(int i=0;i+1<MAX_LOG_V;i++){
        REP(v, N){
            if(parent[i][v] == -1){parent[i+1][v] = -1;}
            else{parent[i+1][v] = parent[i][parent[i][v]];}
        }
    }
}

int lca(int u, int v){
    if(depth[u] > depth[v]){std::swap(u, v);}
    for(int i=0;i<MAX_LOG_V;i++){
        if((depth[v]-depth[u]) >> i & 1){
            v = parent[i][v];
        }
    }
    if(u == v){return u;}
    for(int i=MAX_LOG_V-1;i>=0;i--){
        if(parent[i][u] != parent[i][v]){
            u = parent[i][u];
            v = parent[i][v];
        }
    }
    return parent[0][u];
}

int main(){
    std::cin >> N;
    REP(i, N){
        int k;
        std::cin >> k;
        REP(j, k){
            int c;
            std::cin >> c;
            G[i].push_back(c);
        }
    }

    init();

    std::cin >> Q;
    REP(i, Q){
        int u, v;
        std::cin >> u >> v;
        std::cout << lca(u, v) << std::endl;
    }
}

Measured memory_bytes: 18768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

int main(){
  ll n;
  cin>>n;
  ll x[111],y[111],h[111];
  for(int i=0;i<n;i++)
	cin>>x[i]>>y[i]>>h[i];
  for(ll i=0;i<101;i++)
	for(ll j=0;j<101;j++){
	  ll H;
	  for(ll k=0;k<n;k++){
		if(h[k]==0)continue;
		H=h[k]+abs(i-x[k])+abs(j-y[k]);
		break;
	  }
	  int f=0;
	  for(int k=0;k<n;k++){
		ll tmp=max(H-abs(i-x[k])-abs(j-y[k]),0LL);
		if(tmp!=h[k])f=1;
	  }
	  if(f)continue;
	  cout<<i<<" "<<j<<" "<<H<<endl;
	  return 0;
	}
  return 0;
}


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

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

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

    int ans = 0;

    for (int i = 0; i < n; i++) {
        if ((i + 1) % 2 && a[i] % 2) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

typedef struct {
	data *obj;
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key < h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key < h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, M;
	data d[100001];
	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) scanf("%d %d", &(d[i].key), &(d[i].id));
	merge_sort(d, N);
	
	int j, ans = 0;
	min_heap h;
	h.size = 0;
	h.obj = (data*)malloc(sizeof(data) * (N + 1));
	for (j = N - 1; j >= 0 && d[j].key > M; j--);
	for (i = M; i >= 1; i--) {
		for (; j >= 0 && d[j].key == i; j--) {
			d[j].key += d[j].id;
			d[j].id = d[j].key - d[j].id;
			d[j].key -= d[j].id;
			push(d[j], &h);
		}
		while (h.size > M - i + 1) pop(&h);
	}
	while (h.size > 0) ans += pop(&h).key;
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4000
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	
	static BufferedReader reader;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(readLine());
		long[] A = new long[N];
		String[] s = readLine().split(" ");
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(s[i]);
		}
		long gcd = A[0];
		for(int i=1;i<N;i++){
			gcd = gcd(gcd,A[i]);
		}
		System.out.println(gcd);
		return;
	}

	private static String readLine(){
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	}
	
	private static long gcd(long a, long b){
		if(b==0){return a;}
		if(a==b){return a;}
		if(a<b){return gcd(b,a);}
		return gcd(b,a%b);
	}
}


Measured memory_bytes: 50220
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	N := oneInt()
  if N%2==0 {
    	fmt.Print(N/2 - 1)
    return
  }
  fmt.Print(N/2)
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

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

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int a;cin>>a;

  cout<<a*a*3<<endl;

 

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")
#define pb(s) push_back(s)
#define SZ(x) ((int)(x).size())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll N; 
    cin >> N;

    ll sum = N * (N+1) / 2;
    ll ans = sum - N;
    p(ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <map>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << "1" << endl;
	}
	else if (a == b || b == c||a==c) {
		cout << "2" << endl;
	}
	else {
		cout << "3" << endl;
	}
}


Measured memory_bytes: 256
def solve():
    data = read()
    result = think(data)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)

def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    n = len(data)
    total = 0
    for i in range(n):
        for j in range(i + 1, n):
            total += data[i] * data[j]
    return total


def write(result):
    print(result)


if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    # import sys
    # sys.setrecursionlimit(10000)
    solve()


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b; 
int x=0;
if(a>b)
x=a-1;
if(a<b)
x=a;
if(a==b)
x=a; 
cout<<x;
system ("pause");
return 0;
}

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

int main() {
	ll a,b;
	cin >> a >> b;
	ll xa = 0,xb = 0;
	ll p = b;
	ll cnt = 0;
	while (p > 0) {
		ll bit = (b + 1)/((ll)1 << (cnt+1))*((ll)1 << cnt);
		if ((b+1) % ((ll)1 << (cnt + 1))-((ll)1 << cnt) > 0) bit += (b+1) % ((ll)1 << (cnt + 1))-((ll)1 << cnt);
		xb += ((ll)1 << cnt) * (bit%2);
		cnt++;p/=2;
	}
	p = a-1;
	cnt = 0;
	while (p > 0) {
		ll bit = a/((ll)1 << (cnt+1))*((ll)1 << cnt);
		if (a % ((ll)1 << (cnt + (ll)1))-((ll)1 << cnt) > 0) bit += a % ((ll)1 << (cnt + 1))-((ll)1 << cnt);
		xa += ((ll)1 << cnt) * (bit%2);
		cnt++;p/=2;
	}
	cout << (xb ^ xa) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long ans = 1;
void mul(int x) {
	ans *= x;
	ans %= mod;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < m; i++) {
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for(int i = 1; i < n; i++) {
		if(a[i] == a[i - 1]) {
			cout << 0 << endl;
			return 0;
		}
	}
	for(int i = 1; i < m; i++) {
		if(b[i] == b[i - 1]) {
			cout << 0 << endl;
			return 0;
		}
	}
	int cnt = 0;
	for(int i = m * n; i > 0; i--) {
		auto x = lower_bound(a.begin(), a.end(), i);
		auto y = lower_bound(b.begin(), b.end(), i);
		int xx = a.end() - x;
		int yy = b.end() - y;
		if(*x == i && *y == i) {
			cnt++;
			continue;
		}
		if(*x == i) {
			mul(yy);
			cnt++;
			continue;
		}
		if(*y == i) {
			mul(xx);
			cnt++;
			continue;
		}
		mul(xx * yy - cnt);
		cnt++;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int number,*values;
	
	while(cin >> number)
	{
		if(number == 0) break;

		values = new int[number];
		int max = -100001;

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

		for(int i = 0;i<number ; i++)
		{
			int sum = 0;
			for( int j = i; j < number ;j++)
			{
				sum += values[j];
				if(max < sum)
				{
					max = sum;
				}
			}
		}

		cout << max << endl;
	}

	delete [] values;

	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    for(int i=0;i<3000;i++){cin>>x>>y;
        if(x==0&&y==0){break;}
        if(x<y){cout<<x<<" "<<y<<endl;}else{cout<<y<<" "<<x<<endl;}
    }
}



Measured memory_bytes: 3092
#include <cstdint>
#include <cstdio>
#include <algorithm>

int main() {
    uint64_t N,A,B;
    scanf("%ld %ld %ld",&N,&A,&B);
    
    printf("%ld",N/(A+B)*A+std::min(N%(A+B),A));
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int N,K; cin>>N>>K;
  ll a[N+1];
  for(int i=1;i<=N;++i){
    cin >> a[i];
    if(i>=K+1){
      ll pre = a[i-K];
      if(pre<a[i]){
        cout << Liny;
      }else{
        cout << Linn;
      }
    }
  }
  
}

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

using namespace std;

typedef long long ll;

const int N = 1e5 + 5;

ll x[N], h[N];
int n;

int main() {
  int a, b; cin >> a >> b;
  int x = b - a;
  cout << (x * (x + 1)) / 2 - b << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

char dang[32][34];
int memo[1<<8][32][32];

int main(){
  int w,h;
  while(scanf("%d%d ",&w,&h), w+h){
    int sx,sy,gx,gy;
    int mapping[128];
    int cnt = 0;
    REP(i,128) mapping[i] = -1;
    REP(i,h) fgets(dang[i],sizeof(dang[i]),stdin);
    memset(memo,0,sizeof(memo));
    REP(i,h) REP(j,w){
      if(dang[i][j] == '@'){
        sx = j; sy = i;
        dang[i][j] = '.';
      }else if(dang[i][j] == '<' || dang[i][j] == '>'){
        gx = j; gy = i;
        dang[i][j] = '.';
      }else if(islower(dang[i][j])){
        if(mapping[dang[i][j]] == -1)
          mapping[dang[i][j]] = cnt++;
      }
    }
    queue<pair<int,pair<int,int> > > q;
    q.push(mp(0,mp(sx,sy)));
    memo[0][sy][sx] = 1;
    while(!q.empty()){
      int f = q.front().f;
      int x = q.front().s.f;
      int y = q.front().s.s;
      int m = memo[f][y][x];

      //printf("f=%d, x=%d, y=%d, m=%d\n",f,x,y,m);

      if(x == gx && y == gy){
        print(m-1);
        break;
      }

      q.pop();

      if(islower(dang[y][x]))
        f ^= (1 << mapping[dang[y][x]]);

      REP(i,4){
        int xx = x + _dx[i];
        int yy = y + _dy[i];
        char dd = dang[yy][xx];
        if(isupper(dd)){
          char ddd = tolower(dd);
          if(mapping[ddd] == -1)
            continue;
          if((f & (1 << mapping[ddd])) == 0)
            continue;
        }
        if((dd == '.' || isalpha(dd)) && memo[f][yy][xx] == 0){
          memo[f][yy][xx] = m + 1;
          q.push(mp(f,mp(xx,yy)));
        }
      }
    }

    if(q.empty())
      puts("-1");
  }
  return 0;
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a,b;
  cin >> a >> b;
  REP(i,a*2-1){
    cout << b - a + i + 1 << " ";
  }
  cout << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    int test=0;
    for(int i=0;i<n/2;i++)
        if(s[i]!=s[n-i-1])
            test++;
    cout<<test<<endl;
    

    return 0;   
}


 
 


Measured memory_bytes: 256