akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <locale>
#include<set>



using namespace std;

#define MAX 300000
int main() {
    long long  h,w,i,j,halfkosu,ans,ans2;
    double a,b,c,x,y,halfvalue;
    bool flg;

    cin>>a>>b>>c>>x>>y;
    halfvalue=min((a+b)/2,c);
    halfkosu=min(x,y);

    ans=halfkosu*halfvalue*2+a*(x-halfkosu)+b*(y-halfkosu);
    ans2=halfvalue*2*max(x,y);

    ans=min(ans,ans2);
    std::cout << ans << std::endl;
    return 0;
}


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

ll inf=9223372036854775806,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int r,g;
	cin>>r>>g;
	cout<<2*g-r;
 	return 0;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

template<typename T> struct SegmentTree{
    int SZ;
    T id;
    vector<T> t;
    SegmentTree(T x, int sz): id(x), SZ(sz) {
        t.assign((SZ << 2) + 5, id);
    }
    SegmentTree(vector<T> &a, T x, int sz){
        id = x; SZ = sz;
        t.assign((SZ << 2) + 5, id);
        build(1, 0, SZ - 1, a);
    }
    T cmb(T x, T y){ return x + y;}
    void build(int v, int tl, int tr, vector<T> &a){
        if(tl == tr) t[v] = a[tl];
        else{
            int tm = tl + (tr - tl)/2;
            build(v << 1, tl, tm, a);
            build((v << 1) | 1, tm + 1, tr, a);
            t[v] = cmb(t[v << 1], t[(v << 1) | 1]);
        }
    }
    T qry(int l, int r){ return qry(1, 0, SZ - 1, l, r);}
    T qry(int v, int tl, int tr, int l, int r){
        if(l > r) return id;
        if(tl == l && tr == r) return t[v];
        int tm = tl + (tr - tl)/2;
        return cmb(qry(v << 1, tl, tm, l, min(r, tm)), qry((v << 1) | 1, tm + 1, tr, max(l, tm + 1), r));
    }
    void upd(int u){ upd(1, 0, SZ - 1, u);}
    void upd(int v, int tl, int tr, int u){
        if(tl == tr) t[v]++;
        else{
            int tm = tl + (tr - tl)/2;
            if(u > tm) upd((v << 1) | 1, tm + 1, tr, u);
            else upd(v << 1, tl, tm, u);
            t[v] = cmb(t[v << 1], t[(v << 1) | 1]);
        }
    }
    void chng(int u){ chng(1, 0, SZ - 1, u);}
    void chng(int v, int tl, int tr, int u){
        if(tl == tr) t[v]--;
        else{
            int tm = tl + (tr - tl)/2;
            if(u > tm) chng((v << 1) | 1, tm + 1, tr, u);
            else chng(v << 1, tl, tm, u);
            t[v] = cmb(t[v << 1], t[(v << 1) | 1]);
        }
    }
};

int n, q;
vector<int> c, res;
vector<pair<pair<int, int>, int>> qr;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> q;
    c.assign(n, 0);
    res.assign(q, 0);
    for(int i = 0; i < n; ++i){
        cin >> c[i]; c[i]--;
    }
    for(int i = 0; i < q; ++i){
        int l, r; cin >> l >> r; l--, r--;
        qr.pb(mp(mp(l, r), i));
    }
    sort(qr.begin(), qr.end(), [&](auto a, auto b)->bool{
        return a.f.f >= b.f.f;
    });
    //highest left first
    map<int, int> pos;
    SegmentTree<int> st(0, n);
    for(int i = qr[0].f.f; i < n; ++i){
        if(pos.find(c[i]) == pos.end()){
            pos[c[i]] = i;
            st.upd(i);
        }
    }
    int curL = qr[0].f.f;
    for(int i = 0; i < q; ++i){
        while(qr[i].f.f < curL){
            curL--;
            if(pos.find(c[curL]) != pos.end()){
                st.chng(pos[c[curL]]); 
            }
            pos[c[curL]] = curL;
            st.upd(curL);
        }
        res[qr[i].s] = st.qry(0, qr[i].f.s);
    }
    for(auto i : res) cout << i << "\n";
    return 0;
}

Measured memory_bytes: 44812
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N=2e5+5;
 
int n;
int a[N];
 
bool inc(int k, vector<pair<int, int> > &v)
{
	vector<pair<int, int> > temp;
	int cur=0;
	while(v.size() && v.back().first==k)
	{
		temp.push_back(v.back());
		v.pop_back();
	}
	if(!v.size())
		return 0;
	if(v.back().second>=2)
	{
		v[v.size()-1].second-=1;
		int cur=v.back().first;
		v.push_back({cur+1, 1});
	}
	else
		v[v.size()-1].first+=1;
	while(temp.size())
	{
		v.push_back({1, temp.back().second});
		temp.pop_back();
	}
	return 1;
}
 
int check(int k)
{
	vector<pair<int, int> > v;
	v.push_back({1, a[1]});
	int len=a[1];
	for(int i=2;i<=n;i++)
	{
		int sz=v.size();
		if(a[i]>a[i-1])
			v.push_back({1, a[i]-a[i-1]});
		else if(a[i]==a[i-1])
		{
			if(!inc(k, v))
				return 0;
		}
		else
		{
			while(v.size())
			{
				if(len-v.back().second>=a[i])
				{
					len-=v.back().second;
					v.pop_back();
				}
				else
					break;
			}
			v[v.size()-1].second-=(len-a[i]);
			if(!inc(k, v))
				return 0;
		}
		len=a[i];
	}
	return 1;
}
 
int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi)/2;
		if(check(mid))
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}
 
int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int ans=binsearch(1, n);
	cout<<ans;	
	return 0;
}

Measured memory_bytes: 9288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int					max = 0;
		int					len = 0;
		int[]				num = null;
		int[][]				cnt = new int[331][10];
		ArrayList<int[]>	in  = new ArrayList<int[]>();

		while((num = parseNum()) != null) {
			max = Math.max(max, num[0]);
			in.add(num);
		}

		calc(0, 1, max, 0, cnt);

		len = in.size();
		for (int n = 0; n < len; n++) {
			num = in.get(n);
			if (num[1] <= cnt.length) {
				System.out.println(cnt[num[1]][num[0]-1]);
			} else {
				System.out.println(0);
			}
		}
	}

	private static void calc(int nBit, int trmc, int trmm, int sum, int[][] cnt) {
		for (int n = 0; n <= 9; n++) {
			if ((nBit & 1 << n) != 0) {
				continue;
			}

			cnt[sum + n * trmc][trmc-1]++;
			if (trmc < trmm) {
				// 最終項より前までの総和が指定した総和より小さい
				nBit |= 1 << n;
				calc(nBit, trmc + 1, trmm, sum + n * trmc, cnt);
				nBit &= ~(1 << n);
			}
		}
	}

	private static int[] parseNum() {
		int[]	num   = null;
		String	strIn = null;

		if ((strIn = parseStdin()) != null) {
			String[]	split = strIn.split(" ");
			num    = new int[2];
			num[0] = Integer.parseInt(split[0]); 
			num[1] = Integer.parseInt(split[1]); 
		}
		
		return num;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 18988
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
a, b = gi()
ans = 0
sock = 1
while sock < b:
	sock += a - 1
	ans += 1
print(ans)

Measured memory_bytes: 3060
import math
# from itertools import product
from functools import reduce

def main():
#     def gcd(*numbers): return reduce(math.gcd, numbers)
    K = int(input())
    ans = 0
#     valiation = list(itertools.product(range(1, K+1), repeat=3))
#     for v in valiation:
#         ans += gcd(v)
    for i in range(1, K+1):
        for j in range(i, K+1):
            for k in range(j, K+1):
                x = math.gcd(math.gcd(i, j), k)
                if i == j == k:
                    ans += x
                elif i != j and j != k and k != i:
                    ans += 6 * x
                else:
                    ans += 3 * x
    print(ans)
        
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define br cout<<"\n";
#define ull unsigned long long int
#define ld long double
#define loop1(i,a,b) for(int i=a;i<b;i++)
#define loop2(i,a,b) for(int i=a;i<=b;i++)
#define loop3(i,a,b) for(int i=a;i>b;i--)
#define loop4(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define test(t) ll t; cin >> t; while(t--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define fi first
#define se second
#define line cout<<"\n********************************************\n";
///////////////////////////////////////////////////////////////////////////////////////////////////////
 ll MI( ll a , ll mod) // mod inverse (x/y) % mod --> y == a.. multiply result with x..
 {
     return ((a %= mod) < 2) ? a : ((1 - (MI(mod % a , a) * mod))/a+mod);
 }
 bool isprime(ll n);
 ll power(ll x, ll y, ll mod);
 ll fact( ll n );
 ll nCrMod(ll n, ll r, ll p);
///////////////////////////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------
// H B L O R D 7 8 7
// Solution for Problem Code : 
// Contest : 
//--------------------------------------------

signed main() 
{
    FASTIO
     int x;
     cin >> x;
     if( x >= 30) cout << "Yes\n";
     else cout << "No\n";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
//--------------------------------------------
bool isprime(ll n)
 {
     for(ll i = 2 ; i*i<=n ; i++)
        if( n % i == 0)
            return false;
     return true;
 }
 //--------------------------------------------
 ll fact( ll n )
{
 if( n == 1 ) return n;
 else return n*fact(n-1);
}
 //--------------------------------------------
ll power(ll x, ll y, ll mod)  // (x ^ y) % mod...
{  
    ll result = 1; 
    x = x % mod; 
    if (x == 0) return 0;
    while (y > 0)  
    {  
        if (y & 1) result = (result * x) % mod;  
        y = y >> 1; // y = y / 2
        x = (x * x) % mod;  
    }  
    return result;  
}  
 //--------------------------------------------
ll nCrMod(ll n, ll r, ll p) 
{ 
    if (r == 0) 
        return 1; 
    ull fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
    return (((fac[n] * MI(fac[r], p)) % p) * (MI(fac[n - r], p) % p)) % p; 
}
 //--------------------------------------------
 /*
 fact[i] = (fact[i-1]*i)%MOD;
 invfact[i] = power(fact[i],MOD-2);
 int nCr(int n,int r){
    if(r > n) return 0;
    int ret = (fact[n]*invfact[r])%MOD;
    return (ret*invfact[n-r])%MOD;
}*/
 //--------------------------------------------
 //////////////////////////////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,m,ans = 0;
    cin >> n;
    m = n-1;
    vector<ll> a,b;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            a.push_back(i);
            if(n/i != i)a.push_back(n/i);
        }
    }
    a.push_back(n);

    for(ll i=2;i*i<=m;i++){
        if(m%i==0){
            b.push_back(i);
            if(m/i != i)b.push_back(m/i);
        }
    }
    if(m!=1)b.push_back(m);

    for(auto k:a){
        ll now = n;
        while(now % k == 0 )now/=k;
        now %= k;
        if(now == 1)ans++;
    }
    cout << ans + b.size() << endl;
}

Measured memory_bytes: 3756
import java.util.HashMap;
import java.util.Scanner;

public class Main {

  static int d;
  static int[] array_c;
  static int[][] array_s;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    d = sc.nextInt();
    array_c = new int[27];
    array_s = new int[d + 1][27];
    int[] schedule = new int[d + 1];
    for (int i = 1; i <= 26; i++) {
      array_c[i] = sc.nextInt();
    }
    for (int i = 1; i <= d; i++) {
      for (int j = 1; j <= 26; j++) {
        array_s[i][j] = sc.nextInt();
      }
    }

    for (int i = 1; i <= d; i++) {
      int maxc = 1;
      for (int j = 2; j <= 26; j++) {
        if (array_s[i][maxc] < array_s[i][j]) {
          maxc = j;
        }
      }
      schedule[i] = maxc;
    }

    // 最終OUTPUT
    for (int i = 1; i <= d; i++) {
      System.out.println(schedule[i]);
    }
  }

  static int calcScore(int[] schedule) {
    int m = 0;
    HashMap<Integer, Integer> last = new HashMap<>();
    for (int i = 1; i <= d; i++) {
      last.put(schedule[i], i);
      m += array_s[i][schedule[i]];
      for (int j = 1; j <= 26; j++) {
        int lastday = last.get(j) == null ? 0 : last.get(j);
        m -= (i - lastday) * array_c[j];
      }
    }
    return m;
  }
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<double> a(n);
    double sum = 0.0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int count = 0;
    for (double v : a) {
        if (v >= sum/(4.0*m)) {
            count++;
            if (count >= m) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


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

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = 1 << 12;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    int n;
    cin >> n;
    if(n<1200)cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		sc.close();
		for (i = (int) sqrt(n); i >= 1; i--) {
			if(n%i==0)break;
		}
		out.println((i-1)+(n/i-1));
	}
}


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

int n, cnt;
long long ans;

struct data
{
    int x, y, id;
} town[100005];

bool cmp1(data f, data s) {return f.x < s.x;}
bool cmp2(data f, data s) {return f.y < s.y;}

class Disjoint_Set
{
    struct data {
        int parent;
        int rankk;
    } Node[300005];

public:
    void MakeSet(int x)
    {
        Node[x].parent = x;
        Node[x].rankk = 0;
    }

    int FindSet(int x)
    {
        if(Node[x].parent == x)
            return x;
        else
            Node[x].parent = FindSet(Node[x].parent);

        return Node[x].parent;
    }

    void UnionSet(int x, int y)
    {
        int i = FindSet(x);
        int j = FindSet(y);

        if(i == j)
            return ;

        if(Node[i].rankk == Node[j].rankk) { //If they have the same depth
            Node[i].rankk++;
            Node[j].parent = i;
        } else if (Node[i].rankk > Node[j].rankk) {
            Node[j].parent = i;
        } else {
            Node[i].parent = j;
        }
    }
};

Disjoint_Set DS;

struct data2
{
    int node1;
    int node2;
    int weight;
} Edges[300005];

bool Sorter(data2 x, data2 y)
{
    return x.weight < y.weight;
}

void Kruskal()
{
    sort(Edges, Edges+cnt, Sorter);
    for(int i=0; i<cnt; i++) {
        int root1 = DS.FindSet(Edges[i].node1); //find representative of node1
        int root2 = DS.FindSet(Edges[i].node2); //find representative of node2

        if(root1 != root2) {
            DS.UnionSet(Edges[i].node1, Edges[i].node2);
            ans += Edges[i].weight; //total length of MST
        }
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> town[i].x >> town[i].y;
        town[i].id = i;
    }

    sort(town+1, town+n+1, cmp1);
    for(int i=1; i<=n-1; i++) {
        Edges[cnt].node1 = town[i].id;
        Edges[cnt].node2 = town[i+1].id;
        Edges[cnt].weight = abs(town[i+1].x-town[i].x);
        DS.MakeSet(town[i].id);
        DS.MakeSet(town[i+1].id);
        cnt++;
    }
    sort(town+1, town+n+1, cmp2);
    for(int i=1; i<=n-1; i++) {
        Edges[cnt].node1 = town[i].id;
        Edges[cnt].node2 = town[i+1].id;
        Edges[cnt].weight = abs(town[i+1].y-town[i].y);
        DS.MakeSet(town[i].id);
        DS.MakeSet(town[i+1].id);
        cnt++;
    }
    Kruskal();

    return 0;
}

Measured memory_bytes: 7296
using System;

namespace ITP1_3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int cnt = 0;
            int[] array = new int[10001];
            while (true) {
                int x = int.Parse(Console.ReadLine());
                if (x == 0) break;
                cnt++;
                array[cnt] = x;
            }
            for (int i=1;i<=cnt;i++)
            {
                Console.WriteLine("Case " + i + ": " + array[i]);
            }
        }
    }
}

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

using namespace std;

#define N 220000

struct Node {
    char a, b;
};

int n, m;
char s[N];
Node a[N];

int main() {
    scanf("%d%d", &n, &m); getchar();
    scanf("%s", s + 1); getchar();
    for (int i = 0; i < m; ++i) {
        scanf("%c %c", &a[i].a, &a[i].b); getchar();
    }
    int l = 1, r = n;
    for (int i = m - 1; i >= 0; --i) {
        if (a[i].b == 'L') {
            if (a[i].a == s[l]) ++l;
            if (r < n && a[i].a == s[r + 1]) ++r;
        } else if (a[i].b == 'R') {
            if (a[i].a == s[r]) --r;
            if (l > 1 && a[i].a == s[l - 1]) --l;
        }
    }
    printf("%d\n", max(r - l + 1, 0));
    return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String A = S;
        
        int count = 0;
        for(int i=0;i<N;i++){
            String tmp = S.substring(i, i+1);
            if("(".equals(tmp)){
                count++;
            }else if(")".equals(tmp)){
                count--;
                if (count<0){
                    A = "(" + A;
                    count++;
                }
            }
        }
        if (count > 0) {
            while(count != 0){
                A = A + ")";
                count--;
            }
        }
        System.out.println(A);
    }
    
}


Measured memory_bytes: 23124
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n, m;
	cin>>n>>m;
	int a[1001], b[1001];
	for(int i=0; i<n; i++) cin>>a[i];
	for(int j=0; j<m; j++) cin>>b[j];
	sort(a, a+n, greater<int>());
	sort(b, b+m, greater<int>());
	ll i1=0, i2=0;
	ll ans=1;
	for(int i=n*m; i>=1; i--){
		int c1=0, c2=0;
		while(i1<n && a[i1]>=i){
			i1++;
			c1++;
		}
		while(i2<m && b[i2]>=i){
			i2++;
			c2++;
		}
		if(c1>1 || c2>1){
			cout<<0<<endl;
			return 0;
		}
		if(c1==1 && c2==1){
			continue;
		}
		if(c1==1 && c2==0){
			ans*=i2;
			ans%=MOD;
			continue;
		}
		if(c2==1 && c1==0){
			ans*=i1;
			ans%=MOD;
			continue;
		}
		ans*=(i1*i2-n*m+i);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    cin>>n>>m>>k;
    if((n+m)==k)
        cout<<"Yes\n";
    else if((n+k)==m)
        cout<<"Yes\n";
    else if((m+k)==n)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

using namespace std;
#define LL long long

const int INF  = 0x3f3f3f3f;
const int MAXN = 512345;

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n, m;
	cin >> n >> m;

	int l, r;
	cin >> l >> r;

	--m;

	while (m--) {
		int L, R;
		cin >> L >> R;

		l = max (L, l);
		r = min (R, r);

	}

	cout << max (0, r - l + 1) << '\n';



	return 0;
}


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

const int64_t MOD = 998244353;

int main() {
  int n, s;
  cin >> n >> s;
  int64_t dp[s + 1];
  dp[0] = 1;
  for (int i = 1; i <= s; ++i) {
    dp[i] = 0;
  }
  for (int a; cin >> a; ) {
    for (int j = s; j >= 0; --j) {
      dp[j] = (2 * dp[j] + (j >= a ? dp[j - a] : 0)) % MOD;
    }
  }
  cout << dp[s];
  return 0;
}


Measured memory_bytes: 3156
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int h1 = Integer.parseInt(in.next());
            int m1 = Integer.parseInt(in.next());
            int h2 = Integer.parseInt(in.next());
            int m2 = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int ans = 0;

            int diffh = h2 - h1;
            int diffm = m2 - m1;

            ans = diffh * 60 + diffm - k;
            out.println(ans);

        }

    }
}



Measured memory_bytes: 35880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) {
        int r = read();
        System.out.println(r * r);
    }

    // 入出力用関数
    private static int read() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            return Integer.valueOf(reader.readLine().trim());
        } catch (IOException e) {
            e.printStackTrace();
            return -1;
        }
    }
}

Measured memory_bytes: 22356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			System.out.println(c(n, 2) + c(m, 2));
		}
	}

	private static int c(int n, int m) {
		if (m <= n) {
			int answer = 1;
			for (int i = 1; i <= m; i++) {
				answer *= n + 1 - i;
				answer /= i;
			}
			return answer;
		}
		return 0;
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int N = 400;

using namespace std;

int h,w;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
bool color[N][N],vis[N][N];
ll black=0,white=0;

bool inside (pair<int,int> cor, int d)
{
    int x=cor.ff+dx[d],y=cor.ss+dy[d];
    return (x>=0 && x<h && y>=0 && y<w);
}

bool check (pair<int,int> g, int cx, int cy)
{
    return (color[g.ff][g.ss]!=color[cx][cy]);
}

void bfs (pair<int,int> s)
{
    queue<pair<int,int>> q;
    q.push(s);
    vis[s.ff][s.ss]=true;
    int i;
    while (!q.empty())
    {
        pair<int,int> v=q.front();
        q.pop();
        int x=v.ff,y=v.ss;
        if (color[x][y])
            black++;
        else
            white++;
        for (i=0;i<4;i++)
        {
            if (inside(v,i))
            {
                int cx=x+dx[i],cy=y+dy[i];
                if (check(v,cx,cy))
                {
                    if (vis[cx][cy]==false)
                    {
                        q.push(mp(cx,cy));
                        vis[cx][cy]=true;
                    }
                }
            }
        }
    }
}

main()
{
    fast;
    int i,j;
    cin>>h>>w;
    string s;
    for (i=0;i<h;i++)
    {
        cin>>s;
        for (j=0;j<w;j++)
            color[i][j]=(s[j]=='#');
    }
    ll ans=0;
    for (i=0;i<h;i++)
    {
        for (j=0;j<w;j++)
        {
            if (vis[i][j])
                continue;
            black=0;
            white=0;
            bfs(mp(i,j));
            ans+=black*white;
        }
    }
    cout<<ans<<endl;
}


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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

int main()
{
    int n;
    multiset<int> ms;
    cin >> n;

    for(int i = 0; i < n; ++i){
        int temp;
        cin >> temp;
        if(i==0){
            ms.insert(temp);
            continue;
        }
        auto it = ms.lower_bound(temp);
        //cout << "it: " << *it << "\n";
        if(it == ms.begin()){
            ms.insert(temp);
        }else{
            it--;
            ms.erase(it);
            ms.insert(temp);
        }
    }

    cout << (int) ms.size() << "\n";

    return 0;
}


Measured memory_bytes: 4992
from collections import deque
 
h, w = map(int, input().split())
a = ''.join(input() + '#' for _ in range(h))
n = len(a)
b = ['#'] * w
r = 0
for i in range(n):
  if a[i] == '.':
    b[:-w] = a
    b[i] = 0
    q = deque([i])
    while(q):
      i = q.popleft()
      r = max(r, b[i])
      for j in (i - 1, i + 1, i - w - 1, i + w + 1):
        if b[j] == '.':
          b[j] = b[i] + 1
          q.append(j)
print(r)


Measured memory_bytes: 3316
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>
#define L(_i,_N) for(int _i=0;_i<_N;_i++)
#define C(_Dis) cout<<_Dis<<endl;

using namespace std;

typedef long long int lli;

int main() {
	string Str;
	cin >> Str;
	reverse(Str.begin(),Str.end());
	C(Str);
	return 0;
}

Measured memory_bytes: 3148
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        String s = scanner.next();

        int max = 0;
        String bef;
        String aft;

        for (int i = 0;i<=(a-1);i++) {
        	bef = s.substring(0, i+1);
        	aft = s.substring(i+1,s.length());
        	int cnt = 0;

        	String[] bef2 = bef.split("");
        	Set<String> hash_set = new HashSet<String>();
        	for (int j=0;j<=(bef2.length-1);j++) {

        		hash_set.add(bef2[j]);
        	}
        	for(String tmp : hash_set){
        		if(aft.contains(tmp)) {
        			cnt++;
        		}
        	}
        	if (cnt >= max) {
        		max = cnt;
        	}
        }
        System.out.println(max);

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 23508
V, E = map(int, input().split())
cost = [[float('inf') for _ in range(V)] for _ in range(V)]
for i in range(V):
    cost[i][i] = 0
for _ in range(E):
    s, t, d = map(int, input().split())
    cost[s][t] = d

# print(*cost, sep='\n')
for k in range(V):
    for i in range(V):
        for j in range(V):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
# print(*cost, sep='\n')
ans = [[] for _ in range(V)]
# ans = str(cost)
# print(*cost[0])
# print(*ans[0])
# print(ans)
ok = True
for i in range(V):
    if cost[i][i] != 0:
        ok = False
if ok:
    for i in range(V):
        for j in range(V):
            if cost[i][j] != float('inf'):
                ans[i].append(cost[i][j])
            else:
                ans[i].append('INF')
    for i in range(V):
        print(*ans[i])
else:
    print('NEGATIVE CYCLE')



Measured memory_bytes: 6624
import bisect
N,L=map(int,input().split())
S=[]
M=[]
a=0
for i in range(N):
    S.append(abs(L+i))
    M.append(L+i)
S.sort()
for i in range(N):
    if abs(M[i])==S[0]:
        a=M[i]
print(sum(M)-a)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < n; i++)
int main()
{
	int N;
	cin >> N;
	N = N%10;

	if(N==3)
		cout << "\nbon";
	else if(N==0 || N==1 || N==6 || N==8)
		cout << "\npon";
	else
		cout << "\nhon";

	cin >> N;
	
	return 0;	
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c)
{
    // 双方向に行ける頂点の集団の色をcとして，rを始点とする
    stack<int> S;
    S.push(r);
    color[r] = c;
    while(!S.empty()) {
        // rから行けるところなくなるまで深さ優先探索する
        int u = S.top();
        S.pop();
        for (int i = 0; i < G[u].size(); i++) {  // G[u].size()はuが行く可能性のある頂点の数だけ
            int v = G[u][i];  // vはuが行く可能性のある頂点
            if (color[v] == NIL) {
                // 配列colorで行く可能性のある頂点の色が埋まってなかったら
                // 行く可能性のある頂点の色をc(= id)とする
                // そしてvをSに格納する
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor()
{
    // 双方向に行ける集団の色を同じにする
    int id = 1;
    for (int i = 0; i < n; i++) {
        color[i] = NIL;  // 配列colorを初期化
    }
    for (int u = 0; u < n; u++) {
        // 初期化したcolorに対して，深さ優先探索をする
        if (color[u] == NIL) {
            dfs(u, id++);
        }
    }
}

int main()
{
    int s, t, m, q;

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        // 有向グラフの隣接リスト
        // s->tとt->s
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  int mul = a * b;
  if ((mul % 2) == 1) {
    cout << "Odd" << endl;
  } else {
    cout << "Even" << endl;
  }
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int kNumContests = 26;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int num_days;
  cin >> num_days;
  vector<int64> costs(kNumContests);
  for (int i = 0; i < kNumContests; i++) {
    cin >> costs[i];
  }

  auto score_table = Make2DVector(num_days, kNumContests, 0LL);

  vector<int> ls(kNumContests, -1);
  for (int d = 0; d < num_days; d++) {
    int64 max_score = INT64_MIN;
    int max_c = -1;
    for (int c = 0; c < kNumContests; c++) {
      int64 score = score_table[d][c] + (d - ls[c]) * costs[c] * 26;
      if (max_score < score) {
        max_score = score;
        max_c = c;
      }
    }

    ls[max_c] = d;

    cout << (max_c + 1) << endl;
  }
}

Measured memory_bytes: 3736
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>

typedef std::vector<int> BigInt;

std::string expr;
std::string::size_type idx;

/*
BigInt fromNum( int n )
{
	BigInt ret;
	while( n > 0 )
	{
		ret.push_back( n % 10 );
		n /= 10;
	}

	return ret;
}

void show( const BigInt& n )
{
	for( int i = n.size() - 1; i >= 0; --i )
		std::cout << n[i];
	std::cout << std::endl;

	return;
}*/

BigInt add( BigInt& a, BigInt& b )
{
	BigInt& mi = a.size() < b.size() ? a : b;
	mi.resize( std::max( a.size(), b.size() ) );

	BigInt ret( a.size() + 1 );
	for( int i = 0; i != a.size(); ++i )
	{
		ret[i] += a[i] + b[i];
		
		if( ret[i] > 9 )
			ret[i] -= 10, ++ret[i+1];
	}

	if( !ret[a.size()] )
		ret.resize( a.size() );

	return ret;
}

BigInt number( const std::string& s )
{
	BigInt ret;
	while( idx < s.size() && s[idx] >= '0' && s[idx] <= '9' )
		ret.push_back( s[idx++] - '0' );

	std::reverse( ret.begin(), ret.end() );

	return ret;
}

bool check( const std::string& s )
{
	BigInt p = number( s );
	
	++idx;
	
	BigInt q = number( s );
	
	++idx;

	BigInt r = number( s );
	
	return add( p, q ) == r;
}

std::string replaceX( int n )
{
	std::string ret = expr;
	std::string::size_type i;

	while( ( i = ret.find( "X" ) ) != std::string::npos )
	{
		char str[2] = { n + '0', '\0' };
		ret.replace( i, 1, str ); 
	}

	return ret;
}

int main()
{
	while( std::cin >> expr )
	{
		int ans = -1;

		for( int i = 0; i <= 9; ++i )
		{
			idx = 0;
			if( check( replaceX( i ) ) )
			{
				ans = i;
				break;
			}
		}

		if( ans < 0 )
			std::cout << "NA" << std::endl;
		else
			std::cout << ans << std::endl;
	}

	return 0;
}

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

int main(){
  char s[100010] = {};
  char t[100010] = {};
  scanf("%s", s);
  for(int i = 0; i <= strlen(s)/2; i++){
    t[i] = s[2*i];
  }
  printf("%s\n", t);
  return 0;
}

/*
s[]の奇数文字目は
  s[2*i] (i = 0, 2, 3, ...; 2*i <= strlen(s) - 1)
である．
*/


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15)puts("+");
	else if (a*b == 15)puts("*");
	else puts("x");
	ll
}

Measured memory_bytes: 256
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    vec = [A[-1]]
    for a in reversed(A[:-1]):
        if a >= vec[-1]:
            vec.append(a)
        else:
            vec[bisect_right(vec, a)] = a

    print(len(vec))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20116
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a,b;
    cin >> a;
    cin >> b;
    if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

using namespace std;

typedef long long ll;

int sumv[1505][1505],rpos[1505][1505];
int minn[2][1505][1505],maxn[2][1505][1505];

char str[1505][1505];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%s",str[i]+1);
  int cur=0;
  ll ans=0;
  for(int i=n;i>0;i--) {
  	cur^=1;
  	for(int j=n;j>0;j--)
  	  if (str[i][j]!='#') {
  	  	  sumv[i][j]=sumv[i][j+1]+sumv[i+1][j]+str[i][j]-'0';
  	  	  rpos[i][j]=max(max(rpos[i][j+1],rpos[i+1][j]),i);
  	  	  minn[cur][j][i]=j;
  	  	  for(int k=i+1;k<=rpos[i+1][j];k++) minn[cur][j][k]=minn[cur^1][j][k];
  	  	  for(int k=max(rpos[i+1][j],i)+1;k<=rpos[i][j+1];k++) minn[cur][j][k]=minn[cur][j+1][k];
  	  	  maxn[cur][j][i]=j;
  	  	  for(int k=i;k<=rpos[i][j+1];k++) maxn[cur][j][k]=maxn[cur][j+1][k];
  	  	  for(int k=max(rpos[i][j+1],i)+1;k<=rpos[i+1][j];k++) maxn[cur][j][k]=maxn[cur^1][j][k];
  	  	  int d=i+1,r=min(rpos[i][j+1],rpos[i+1][j]);
  	  	  while (d<=r) {
  	  	  	    if (maxn[cur^1][j][d]>=minn[cur][j+1][d]) {
  	  	  	    	    sumv[i][j]-=sumv[d][minn[cur][j+1][d]];
  	  	  	    	    d=rpos[d][minn[cur][j+1][d]];
					  }
  	  	  	    d++;
			  }
		  ans+=(ll)(str[i][j]-'0')*(sumv[i][j]-(str[i][j]-'0'));
		}
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main(){
    string x, ans; cin >> x;
    for (auto i = 0; i < (int)x.size(); i++) {
        if(x[i] == 'S' and x[i + 1] == 'T') {
            i++; continue;
        }
        if(ans.back() == 'S' and x[i] == 'T') {
            ans = ans.substr(0, ans.size() - 1);
            continue;
        }
        ans += x[i];
    }

    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 3912
N=int(input())
a=list(map(int,input().split()))
d=[[0]*21 for i in[0]*~-N]
d[0][a[0]]=1
for i in range(1,N-1):
 for j in range(21):
  if j+a[i]<21:d[i][j]=d[i-1][j+a[i]]
  if 0<=j-a[i]:d[i][j]+=d[i-1][j-a[i]]
print(d[N-2][a[N-1]])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  cin >> n;
  vector<int> v(n), c(n);
  rep(i, 0, n) cin >> v[i];
  rep(i, 0, n) cin >> c[i];

  int ans = 0;
  rep(i, 0, n) {
    int diff = v[i] - c[i];
    if (diff > 0) ans += diff;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int INF = (1<<20);
using namespace std;

struct edge{
    int to,cap,cost,rev;
    edge(int to,int cap,int cost,int rev)
        :to(to),cap(cap),cost(cost),rev(rev){}
};

int MAX_V=222;
int S=MAX_V-2,T=MAX_V-1; // S=スタート,T=ゴール
int N,M,B;
int ax[111],ay[111];
int bx[5],by[5];
int c[5],f[5];
vector<edge> G[222];
int dist[222];
int prevv[222],preve[222];

int min_cost_flow(int f){
  int ret = 0;
  while(f > 0){
    fill_n(dist,MAX_V,INF);
    dist[S] = 0;
    bool update = true;
    while(update){
      update = false;
      for(int v = 0; v < MAX_V;v++){
	if(dist[v] == INF) continue;
	for(int i=0;i<G[v].size();i++){
	  edge &e = G[v][i];
	  if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
	    dist[e.to] = dist[v] + e.cost;
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    update = true;
	  }
	}
      }
    }
    if(dist[T] == INF) return -1;
    int d = f;
    for(int v=T;v!=S;v=prevv[v]){
      d = min(d,G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    ret += d * dist[T];
    for(int v=T;v!=S;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return ret;
}

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(edge(to,cap,cost,G[to].size()));
  G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

void make_edge(int bit,int mid){
  fill_n(G,MAX_V,vector<edge>());
  for(int i=0;i<N;i++){
    add_edge(S,i,1,0);
    for(int j=0;j<M;j++){
      if((bit>>j&1)==0)continue;
      int d = abs(ax[i]-bx[j])+abs(ay[i]-by[j]);
      add_edge(i,N+j,1,max(0,d-mid));
    }
  }
  for(int i=0;i<M;i++){
    if((bit>i&1)==0)continue;
    add_edge(N+i,T,c[i],0);
  }
}

int search(int bit){
  int ret=0,cnt=0;
  for(int i=0;i<M;i++){
    if(bit&(1<<i)){
      ret += f[i];
      cnt++;
    }
  }
  int left=0,right=100000;
  while(right-left > 1){
    int mid = (left+right)/2;
    make_edge(bit,mid);
    int tmp1 = min_cost_flow(N)+mid*B*cnt;
    make_edge(bit,mid-1);
    int tmp2 = min_cost_flow(N)+(mid-1)*B*cnt;
    if(tmp1 == -1 || tmp2 == -1) return INF;
    if(tmp1 < tmp2) left = mid;
    else right = mid;
  }
  make_edge(bit,left);
  return ret+min_cost_flow(N)+left*B*cnt;
}

int main(){
  while(cin >> N >> M >> B, N) {
    for(int i=0;i<N;i++) cin >> ax[i] >> ay[i];
    for(int i=0;i<M;i++) cin >> bx[i] >> by[i] >> c[i] >> f[i];
    int ans = INF;
    for(int i=1;i<(1<<M);i++){
      ans = min(ans,search(i));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int d,n;
    cin >> d >> n;

    int startNum = 1;
    for (int i = 0; i < d; i++)
    {
        startNum *= 100;
    }
    
    int ans = 0;
    int count = 0;
    while (count < n)
    {
        ans += startNum;
        if (ans == (startNum *100))
        {
            continue;
        }

        count++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int S, h ,m  ,mm ,ss ;
int main() {
	int S;
	cin >> S;
	m = S / 60;
	ss = S % 60;	
	h = m / 60 ;
	mm = m % 60 ; 
	cout << h <<':'<< mm <<':' << ss << endl ;
}


Measured memory_bytes: 3096
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e5+10;
	
	map<ll,ll> A,B;
	void main()
	{
		int n=qread(),D=qread()*2,aa=qread();while(n--){ int pos=qread();A[pos]=qread(); }
		ll ans=0;ll left=0;
		while(sz(A))
		{
			ll i=A.begin()->FR,val=A.begin()->SE;A.erase(A.begin());
			while(sz(B) and B.begin()->FR<=i) left+=B.begin()->SE,B.erase(B.begin());val-=left;
			ll ned=ceil(1.0*max(val,0ll)/aa);ans+=ned,left+=ned*aa,B[i+D+1]-=ned*aa;
		}write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int ,int> P;
int main(void){
    int n, l, ans = 0;
    int a[100005];
    int length[100005];
    cin >> n >> l;
    vector<int> front;
    vector<int> back;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n-1; i++){
        length[i] = a[i] + a[i+1];
        if(length[i] >= l && ans == 0){
            ans = i+1;
        }else{
            if(ans == 0){
                front.push_back(i);
            }else{
                back.push_back(i);
            }
        }
    }
    reverse(back.begin(), back.end());

    for(int i=0; i<back.size(); i++){
        front.push_back(back[i]);
    }

    if(ans == 0){
        cout << "Impossible" << endl;
        return 0;
    }else{
        cout << "Possible" << endl;
    }

    for(int i=0; i<front.size(); i++){
        cout << front[i]+1 << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>

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

Measured memory_bytes: 592
#include <stdio.h>
int main(){
	int a,b,result;
	scanf("%d%d",&a,&b);
	if(b>0){
		int p=a+b;
		int q=a*b;
		printf("%d\n",p>q?p:q);
	}
	else if(a<0){
		int p=a-b;
		int q=a*b;
		printf("%d\n",p>q?p:q);
	}
	else
		printf("%d\n",a-b);
	return 0;
} 

Measured memory_bytes: 128