akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define pb push_back
#define sz size()
using namespace std;
typedef vector<int> vi;

const int INF = 1e9;

struct edge{
  int from,to,cost,cap,rev;
  edge(int a,int b,int c,int d,int e)
    :from(a),to(b),cost(c),cap(d),rev(e){}
};

struct FordFulkerson{
  int n;
  vector< vector<edge> > graph;
  vi use;

  FordFulkerson(int a=0):n(a){
    graph.resize(a); use.resize(a);
  }

  void AddEdge(int s,int g,int c,int p){
    graph[s].pb( edge(s,g,c,p,graph[g].sz) );
    graph[g].pb( edge(g,s,-c,0,graph[s].sz-1) );
  }

  void DeleteEdge(int s, int g){
    int id = -1, rev = -1;
    rep(e,graph[s].sz){
      if(graph[s][e].to == g && graph[s][e].cost>0){
	id = e; rev = graph[s][e].rev;
      }
    }
    if(id<0)return;
    //cout << id << " " << rev << endl;

    swap(graph[s][id],graph[s].back());
    swap(graph[g][rev],graph[g].back());

    edge e = graph[s][id];
    //cout << s << " " << e.to << " " << e.rev << endl;
    if(id+1!=(int)graph[s].size())graph[e.to][e.rev].rev = id;
    e = graph[g][rev];
    //cout << g << " " << e.to << " " << e.rev << endl;
    if(rev+1!=(int)graph[g].size())graph[e.to][e.rev].rev = rev;
    graph[s].pop_back(); graph[g].pop_back();
  }
  
  int dfs(int v, int t, int f){
    if(v==t)return f;
    use[v] = 1;
    rep(i,graph[v].sz){
      edge &e = graph[v][i];
      if(!use[e.to] && e.cap > 0){
	int d = dfs(e.to,t,min(f,e.cap));
	if(d > 0){
	  e.cap -= d;
	  graph[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }
  
  int max_flow(int s, int t){
    int res = 0;
    for(;;){
      rep(i,n)use[i] = 0;
      int f = dfs(s,t,INF);
      if(!f)return res;
      res += f;
    }
  }
};

int main(){
  int n,E,q;
  cin >> n >> E >> q;
  FordFulkerson mf(n);
  rep(i,E){
    int f,t;
    cin >> f >> t; f--; t--;
    mf.AddEdge(f,t,1,1);
    mf.AddEdge(t,f,1,1);
  }

  int F = mf.max_flow(0,n-1);
  rep(i,q){
    int m,a,b;
    cin >> m >> a >> b; a--; b--;
    if(m==1){
      mf.AddEdge(a,b,1,1);
      mf.AddEdge(b,a,1,1);
      F += mf.max_flow(0,n-1);
    }else{
      int use = 0;
      for(edge e : mf.graph[a]){
	if(e.to == b && e.cost>0 && e.cap == 0)use |= 1;
      }
      for(edge e : mf.graph[b]){
	if(e.to == a && e.cost>0 && e.cap == 0)use |= 2;
      }
      //cout << "use: " << use << endl;
      mf.DeleteEdge(a,b);
      mf.DeleteEdge(b,a);

      if(use==1 || use==2){
	rep(i,n)mf.use[i] = 0;
	int another = 0;
	if(use==1)another = mf.dfs(a,b,1);
	if(use==2)another = mf.dfs(b,a,1);

	if(!another){
	  rep(i,n)mf.use[i] = 0;
	  mf.dfs(use==1?a:b,0,1);
	  rep(i,n)mf.use[i] = 0;
	  mf.dfs(n-1,use==1?b:a,1);
	  F--;
	}
      }
    }
    //rep(i,n)for(edge e: mf.graph[i])cout << i << " " << e.to << " " << e.cost << " " << e.cap << " " << e.rev <<  endl;

    cout << F << endl;
  }
}

Measured memory_bytes: 3388
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int count = 0, a = 0;
  for(int i = 0; i < N; i++) {
    cin >> a;
    while(a % 2 == 0) {
      a /= 2;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
// finish date: 2019/1/26

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    vvl XH(N, vl(2));
    rep(i, N) {
        cin >> XH[i][0] >> XH[i][1];
    }
    sort(XH.begin(), XH.end());
    vl X(N), H(N);
    rep(i, N) {
        X[i] = XH[i][0];
        H[i] = XH[i][1];
    }
    ll cnt = 0;
    vl acc(N + 1, 0);
    rep(i, N) {
        if (i > 0) acc[i] = acc[i] + acc[i - 1];
        if(acc[i] >= H[i]) continue;
        int pos = distance(X.begin(), upper_bound(X.begin(), X.end(), X[i] + 2 * D));
        int use_bomb = max((H[i] - acc[i] - 1) / A + 1, (ll) 0);
        acc[i] += use_bomb * A;
        acc[pos] -= use_bomb * A;
        cnt += use_bomb;
    }
    cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int out(int in1, int in2)
{
    double result = 0, i = 0;
    for(i = 0; i < in2; i ++)
    {
        result += (double)in1 * pow(10, i);
        //printf("%lf\n", result);
    }
    return (int)result;
}

int main(int argc, char const *argv[])
{
    /* code */
    int a, b;
    scanf("%d %d", &a, &b);
    if(a <= b)
    {
        printf("%d", out(a, b));
    }
    else
    {
        printf("%d", out(b, a));
    }
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fr first
#define sc second
#define memset(X,Y) memset(X,Y,sizeof X)
#define all(X) X.begin(),X.end()
#define sz size()
#define pb push_back
#define ve vector<int>
#define pii pair < int,int >
#define pll pair < ll,ll >
#define ll long long
#define Graph vector<vector < int > >
#define Fp cout << fixed <<  setprecision(9)
#define Fast  ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
const ll M = 1e3+30 , N= 1e5+30 , MOD = 1e9+7 , OO = 1e7;
ll m ,n ,k , x, y , dp[N] , bla ,c=1,cnt ,ans,sum , a[N] , ok=1 ;
int main(){

cin >> n  ;
for(int i=1;i<=n;i++){
  cin >> a[i];
}
for(int i=0;i<=n;i++) dp[i] = OO;
dp[1] = 0;
for(int i=2;i<=n;i++){
        dp[i] = min(dp[i-1] + abs(a[i-1]  -a[i]) , dp[i-2] + abs(a[i-2]  -a[i]));
     }

cout << dp[n];
return 0;
}
/*
6 15= max
6 5
5 6
6 4
6 6
3 5
7 2
*/


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int m,d;
	cin>>m>>d;

	int ans=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			int d1=j%10,d10=j/10;
			if(i == d1*d10 && d1 > 1 && d10 > 1){
				ans++;
				//cout << i << "=" << d10 << "*" << d1<<endl; 
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
def Candies():
    A = []
    N = int(input())
    for _ in range(2):
        A.append(list(map(int, input().split())))

    ans = 0
    for n in range(N - 1):
        total = sum(A[0][:n + 1]) + sum(A[1][n:])
        ans = max(ans, total)
    if N == 1:
        ans = A[0][0] + A[1][0]

    print(ans)

Candies()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D) cout << "Left" << endl;
  else if(A+B < C+D) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

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

using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int P[N];
    for (int i = 0; i < N; i++){
        cin >> P[i];
    }
    sort(P, P+N-1);
    int one = 0;
    int two = 0;
    int three = 0;
    for(int i = 0; i < N; i++){
        if(P[i] <= A){
            one++;
        }else if(P[i] <= B){
            two++;
        }else{
            three++;
        }
    }
    cout << min(min(one, two), min(two, three)) << endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int count = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) != t.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 41304
def primes(max_number):
    pr = list(range(3, max_number+1, 2))
    lpr = len(pr)
    for i,n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, lpr, n):
                pr[j] = 0
    yield 2
    yield from[i for i in pr if i]

p = list(primes(55555))
n = int(input())
cnt = 0
i = 0
ans = []
while cnt < n:
    if p[i] % 5 == 1:
        ans.append(p[i])
        cnt += 1
    i += 1
print(*ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) cin >> c[i];
    SORT(a);
    SORT(b);
    SORT(c);

    vector<ll> sum(n + 1);
    REP(i, n) {
        auto p = upper_bound(ALL(c), b[i]);
        if (p != c.end()) sum[i] = distance(p, c.end());
    }
    FORR(i, n, 1) {
        sum[i - 1] += sum[i];
    }

    ll ans = 0;
    REP(i, n) {
        auto p = upper_bound(ALL(b), a[i]);
        if (p == b.end()) break;
        ans += sum[distance(b.begin(), p)];
    }
    cout << ans << endl;
    
}



Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main()
{
	char b;
	cin >> b;
	            
	if (b == 'A')
		cout << 'T' << endl;
	else if (b == 'T')
		cout << 'A' << endl;
	else if (b == 'C')
		cout << 'G' << endl;
	else 
		cout << 'C' << endl;
}

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

int main() {
	ios :: sync_with_stdio(false);
	int t; cin >> t;
	while(t --) {
		int a[10];
		for(int i = 0; i < 10; i ++)
			cin >> a[i];
		bool f = false;
		auto check = [](auto v) {
			for(int i = 0; i + 1 < v.size(); i ++)
				if(v[i] > v[i + 1])
					return false;
			return true;
		};
		for(int k = 0; k < (1 << 10); k ++) {
			vector <int> u, v;
			for(int i = 0; i < 10; i ++)
				if((k >> i) & 1)
					u.push_back(a[i]);
				else
					v.push_back(a[i]);
			f |= check(u) && check(v);
		}
		cout << (f ? "YES\n" : "NO\n");
	}
	return 0;
}

Measured memory_bytes: 2968
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
  int d,t,s;
  cin>>d>>t>>s;
  if(d<=t*s)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;


}
int  main() 
{
  auto start=clock();
  fast_io;
    int t=1;
    //cin>>t;
    while(t--){
      solve();
    }
    auto stop =clock();
    cerr<<"time taken:"<<double(stop-start)/double(CLOCKS_PER_SEC)<<" s"<<endl;
  return 0; 
}


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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int ct = 0;
    rep(i,s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            ct++;
            ans = max(ct,ans);
        }
        else ct = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CCitySavers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n + 1];
            int b[] = new int[n];
            long sum = 0;
            for (int i = 0; i <= n; i++) a[i] = in.nextInt();
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
                sum += b[i];
            }
            for (int i = 0; i < n; i++) {
                if (a[i] >= b[i]) {

                    a[i] -= b[i];
                    b[i] = 0;
                    continue;
                } else {
                    b[i] = b[i] - a[i];
                    a[i] = 0;
                }
                if (a[i + 1] >= b[i]) {
                    a[i + 1] -= b[i];
                    b[i] = 0;
                } else {
                    b[i] -= a[i + 1];
                    a[i + 1] = 0;
                }

            }
//        Array.print(a);
//        Array.print(b);
            if (a[n] >= b[n - 1]) {
                b[n - 1] = 0;
                a[n] -= b[n - 1];
            } else {
                a[n] = 0;
                b[n - 1] -= a[n];
            }

//        Array.print(b);
            long count = 0;
            for (int i = 0; i < n; i++) count += b[i];
            out.println(sum - count);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

typedef long long ll;

int main()
{
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
x,k,d=list(map(int,input().split()))

if abs(x)//d>=k:
  print(abs(x)-k*d)
else:
  if (k-abs(x)//d)%2==0:
    print(abs(x)-d*(abs(x)//d))
  else:
    print(abs(abs(x)-d*(abs(x)//d)-d))
    

Measured memory_bytes: 9176
#include<iostream>
#include<string>
using namespace std;
int main(){	
	int i,n,x,s=0,p=1;
	cin>>n>>x;
	int a[n+1];
	for(i=1;i<=n;i++)cin>>a[i];
	
	for(i=1;i<=n;i++){
		s=s+a[i];
		if(s<=x)p++;
		if(s>x)break;
	}
	cout<<p;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N;
  cin >> N;
  map<string,int> mp;
  rep(i,N){
    string str;
    cin >> str;
    mp[str]++;
  }
  int M;
  cin >> M;
  rep(i,M){
    string str;
    cin >> str;
    mp[str]--;
  }
  int ans=0;
  for(pair<string,int> c:mp){
    if(ans<c.second) ans=c.second;
  }
  cout << ans << endl;
  
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long n, ans = 0;
    cin >> n;
    vector<int> as(n);
    vector<int> bs(n);
    REP(i, n) { cin >> as[i]; }
    REP(i, n) { cin >> bs[i]; }
    int max = 0;
    REP(i, n) {
        int sum = 0;
        for (int j = 0; j <= i; j++) {
            sum += as[j];
        }
        for (int j = i; j < n; j++) {
            sum += bs[j];
        }
        if (sum > max) {
            max = sum;
        }
        // cout << max << endl;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
def main():
    input()
    lcm = 1
    num_list = [int(i) for i in input().split()]
    for i in range(len(num_list)):
        lcm = num_list[i] * lcm
    lcm -= 1

    counter = 0
    for i in num_list:
        counter += (lcm % i)
    
    print(counter)

main()

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

int main() {

    int x[3000], y[3000];
    int count = 0;
    for (int i = 0;; i++) {
        cin >> x[i] >> y[i];
        if (x[i] == 0 && y[i] == 0) {
            break;
        }
        else {
            if (x[i] > y[i]) {
                int temp = y[i];
                y[i] = x[i];
                x[i] = temp;
            }
        }
        count++;
    }

    for (int i = 0; i < count; i++) {
        cout << x[i] << " " << y[i] << endl;
    }
}



Measured memory_bytes: 3112
n = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

if n%2 == 1:
    m = (n+1)//2
    l =[0]*m
    for i in range(n):
        if (n-A[i]-1)%2 != 0:
            print(0)
            exit()
        else:
            id = (n-A[i]-1)//2
            l[id] += 1
    #print(l)
    ans = 1
    for i in range(m):
        #print(i, ans)
        if i != m -1:
            if l[i] != 2:
                print(0)
                exit()
            else:
                ans *= l[i]
                ans %= mod
        else:
            if l[i] != 1:
                print(0)
                exit()
            else:
                ans *= l[i]
                ans %= mod
    print(ans)

else:
    m = n//2
    l =[0]*m
    for i in range(n):
        if (n-A[i]-1)%2 != 0:
            print(0)
            exit()
        else:
            id = (n-A[i]-1)//2
            l[id] += 1
    #print(l)
    ans = 1
    for i in range(m):
        #print(i, ans)
        if l[i] != 2:
            print(0)
            exit()
        else:
            ans *= l[i]
            ans %= mod
    print(ans)

Measured memory_bytes: 52716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc045/tasks/arc061_a

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

    int len = S.size();

    ll ans = 0;
    for (int mas = 0; mas < 1 << (len - 1); mas++) {
        ll num = S[0] - '0';

        for (int i = 0; i < len - 1; i++) {
            if (mas & 1 << i) {
                ans += num;
                num = 0;
            }
            num = num * 10 + (S[i + 1] - '0');
        }

        ans += num;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
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, 0};
int dx[] = {1, -1, 0, 0, 0};

ll n, m, a, b, c, d, sum = 0;
ll graph[1005][1005] = {}, s, g, v, p;
int x,y,z;

int main()
{
    cin >> x >> y >> z;
    x -= z;
    x /= (y+z);
    cout<<x<<endl;
}

Measured memory_bytes: 256
def resolve():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    B = [max(A)-min(A)]
    for i in range(N-1):
        B.append(A[i+1]-A[i])
    for j in B:
        if j > K/2:
            B.remove(j)
            B.append(K-j)
    print(K-max(B))
resolve()

Measured memory_bytes: 26420
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(2e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
int a[N];

void solve(){
	string s;
	cin >> s;
	int n = s.size();
	bool ok = false;
	for(int i = 0;i<n-1;i++){
	if(s[i] == s[i+1]){
		cout << i+1 << " " << i+2 << endl;return;
	}
	}
	for(int i = 0;i<n-2;i++){
		map<char,int> m;
		m[s[i]]++;
		m[s[i+1]]++;
		m[s[i+2]]++;
		int cnt= 0;
		for(int j =i;j<=i+2;j++) cnt = max(cnt,m[s[j]]); 
		if(cnt >= 2){
			cout << i+1 << " " << i+3 << endl;
			return;
		}
	}
	cout << "-1 -1\n";

}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3652
use proconio::input;

fn main() {
    input! { n: usize, q: usize }

    let mut t = FenwickTree::new(n);
    for i in 0..n {
        input! { a: u64 }
        t.add(i, a);
    }

    for _ in 0..q {
        input! { f: usize };
        if f == 1 {
            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
            input! { p: usize, x: u64 }
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    n: usize,
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};
impl<T: Copy + Integer + AddAssign> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            n,
            v: vec![zero(); n],
        }
    }

    fn add(&mut self, i: usize, v: T) {
        let mut i = i + 1;
        while i <= self.n {
            self.v[i - 1] += v;
            i += i & i.wrapping_neg();
        }
    }

    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= i & i.wrapping_neg();
        }
        v
    }
}


Measured memory_bytes: 21444
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 1e6 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];

void solve()
{
	int n;
	cin >> n;
	int tot = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		tot += arr[i];
		tot %= mod;
	}
	int ret = 0;
	for(int i = 0; i < n; i++)
	{
		tot -= arr[i];
		tot += mod;
		tot %= mod;
		ret += arr[i] * tot;
		ret %= mod;
	}
	cout << ret << endl;
}

 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

Measured memory_bytes: 5176
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val N: Int = sc.nextInt
    val M: Int = sc.nextInt
    val D: Int = sc.nextInt
    val A: Array[String] = Array.fill[String](N)(sc.next)

    var ans = 0
    for (i <- 0 until N) {
      for (j <- 0 to M - D) {
        var flag = true
        for (k <- 0 until D) {
          if (A(i)(j + k) != '.') {
            flag = false
          }
        }
        if (flag) {
          ans += 1
        }
      }
    }
    for (i <- 0 to N - D) {
      for (j <- 0 until M) {
        var flag = true
        for (k <- 0 until D) {
          if (A(i + k)(j) != '.') {
            flag = false
          }
        }
        if (flag) {
          ans += 1
        }
      }
    }
    println(ans)
  }
}

Measured memory_bytes: 51416
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};

ll i,j,k;
ll n,m;

int main(){
	cin>>n;
	if(n==3){
		cout<<2<<" "<<5<<" "<<63<<" ";
	}else{
		ll num=0,sum=0;
		for(i=1;i>=0;i++){
			if(i%2==0 || i%3==0){
				num++;
				sum+=i;
				if(num==n-1 && (sum%6==1 || sum%6==5)){
					num--;
					sum-=i;
					continue;
				}else{
					cout<<i<<" ";
				}
				sum=sum%6;
				if(num==n-1)break;
			}
		}
		for(j=i+1;j>=1;j++){
			if((sum+j)%6==0 && (j%2==0 || j%3==0)){
				cout<<j;
				break;
			}
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 4992
// C - Skip

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int x[100001];

int main() {
	int N, X;
	cin >> N >> X;

	x[0] = X;
	int min_x = X;
	for (int i=1; i<=N; i++) {
		cin >> x[i];
		min_x = min(min_x, x[i]);
	}

	for (int i=0; i<=N; i++) {
		x[i] -= min_x;
	}

	int ans = x[0];
	for (int i=0; i<=N; i++) {
		ans = __gcd(ans, x[i]);
	}

	cout << ans << endl;

	return 0;
}

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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
vector<ll> A;
int main(){
  cin >> N;
  queue<ll> que;
  for (int i = 0; i < (1 << N); i++){
    ll val;
    cin >> val;
    que.emplace(val);
  }
  while (que.size() > 1){
    ll p1 = que.front();
    que.pop();
    ll p2 = que.front();
    que.pop();
    if (p1 > p2)swap(p1, p2);//p1 < p2
    if (p1 < p2){
      p2 -= p1;
    }
    que.push(p2);
  }
  cout << que.front() << endl;
  return 0;
}


Measured memory_bytes: 2560
import math

N = int(input())
A = []
A = input().split()

hantei = True

for i in range(N):
  if int(A[i]) %2 == 0:
    if int(A[i]) % 3 != 0 and int(A[i]) % 5 != 0:
      hantei = False

if hantei == True:
  print('APPROVED')
else:
  print('DENIED')

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

int main() {

    int N;
    string S;
    int cnt = 0;

    cin >> N >> S;

    for (int i = 0; i < N - 2; i++) {

        // substr(開始位置, 取り出す長さ);
        string ss = S.substr(i, 3);
        if (ss == "ABC"){
            cnt++;
        }
    }
    cout << cnt << endl;
    
    return 0;

}

Measured memory_bytes: 3616
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let k: usize = input();
    let s = input_char_vec();
    if s.len() > k {
        for i in 0..k {
            print!("{}", s[i]);
        }
        println!("...");
    } else {
        for c in s {
            print!("{}", c);
        }
        println!("");
    }
}


Measured memory_bytes: 2108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp=0,mm=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n){
    scanf("%d",&a[i]);
    result += (ll)abs(a[i]);
    if(a[i]<0) tmp^=1;
    if(i==0) mm=(ll)abs(a[i]);
    else mm=min(mm,(ll)abs(a[i]));
  }
  printf("%lld", result-((tmp==0) ? (0) : (mm*2)));
  
  return 0;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a, b;
	cin>>a>>b;
	int right = a + b - 1;
	int left = b - a + 1;
	//cout<<left << " "<< right<<endl;
	
	for(int i = left; i<=right; i++)
		cout<<i<<" ";
			
	return 0;
	
}

Measured memory_bytes: 256
INF = 10**9 + 1
def merge(A: list, left: int, mid: int, right: int) -> int:
    '''
    2つの配列をmergeする関数

    Aはこのプログラムで処理する配列。
    left, mid, rightはAのindex。
    '''
    cnt = 0  # mergeするときに何回反転するか
    n1 = mid-left  # 右の方の配列のlen (反転数を計算するときにこいつを使う)
    # n2 = right-mid  # 左の方の配列のlen ぶっちゃけいらない

    L = A[left:mid]  # python sliceはshallow copyらしい
    L.append(INF)  # 番兵
    R = A[mid:right]
    R.append(INF)  # 番兵

    i_l, i_r = 0, 0  # LとRのコントロール用idx
    for k in range(left, right):
        # L,Rの先頭を比較していって小さい方をAに打ち込む
        if L[i_l] <= R[i_r]:
            A[k] = L[i_l]
            i_l += 1
        else:
            A[k] = R[i_r]
            i_r += 1
            cnt += n1-i_l  # ここが重要 反転したときだけ反点数を足し込んでいく
    return cnt


def merge_sort(A: list, left: int, right: int):
    '''
    マージソートをしつつ、反転数を再帰的に計算する。

    ここではマージを再帰的に適応し反転数をどんどん上に伝播させていく仕組み
    '''
    if left + 1 >= right:  # 終了条件
        return 0

    mid = (left+right)//2
    v1 = merge_sort(A, left, mid)  # 右左にも再帰的にmerge_sortを適応
    v2 = merge_sort(A, mid, right)
    v3 = merge(A, left, mid, right)  # 右左整ったらmerge

    return v1+v2+v3


n = int(input())
A = list(map(int, input().split()))
print(merge_sort(A, 0, n))


Measured memory_bytes: 27480
r, c = map(int,input().split())
ans = [0 for i in range(c+1)]
for i in range(r):
    l = list(map(int, input().split()))
    l.append(sum(l))
    ans = [x + y for (x, y) in zip(ans, l)]
    print(" ".join(map(str,l)))
print(" ".join(map(str,ans)))

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


signed main() { /*[J][O][L][S][K][E][Y]*/
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        string str; cin >> str;
        cout << (str == "ABC" ? "ARC" : "ABC");
        return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;

signed main(){
    int n;
    cin >> n;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
    }
    if(n%2==0){
        n /= 2;
        for(int i = n; i > 0;i--){
            cout << a[i*2-1] << " ";
        }
        REP(i,n){
            cout << a[i*2] << " ";
        }
    }
    else{
        n -= 1;
        n /=2;
        for(int i=n;i>=0;i--){
            cout << a[i*2] << " ";
        }
        REP(i,n){
            cout << a[i*2+1] << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <set>
#include <queue>

#define MAX_N_PLUS_M (100000)

using namespace std;

void maximum_path(const vector<vector<int>> &adj_lists, vector<int> ds, int cur) {

}

int main(int argc, char *argv[]) {
  // read inputs
  int n, m, as[MAX_N_PLUS_M - 1], bs[MAX_N_PLUS_M - 1];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m + n - 1; i++) {
    scanf("%d %d", &as[i], &bs[i]);
    as[i]--;  // NOTE : modified input
    bs[i]--;  // NOTE : modified input
  }

  // create graph and determine root
  int root = -1;
  vector<int> cnts(n, 0);
  vector<vector<int>> adj_lists(n, vector<int>());
  for (int i = 0; i < m + n - 1; i++) {
    adj_lists[as[i]].push_back(bs[i]);
    cnts[bs[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (cnts[i] == 0) {
      root = i;
      break;
    }
  }
  // printf("root = %d\n", root);

  // erase links
  vector<int>ds(n, 0);
  queue<int> que[2];
  int d = 0;
  que[d % 2].push(root);
  while (!que[d % 2].empty()) {
    while (!que[d % 2].empty()) {
      const int v = que[d % 2].front();
      que[d % 2].pop();
      // erase all links starting from v
      for (int u : adj_lists[v]) {
        cnts[u]--;
        // if there are no more links to u, u's depth is d + 1
        if (cnts[u] == 0) {
          que[(d + 1) % 2].push(u);
          ds[u] = d + 1;
        }
      }
    }
    d++;
  }
  // for (int i = 0; i < n; i++) {
  //   printf("i = %d, d = %d\n", i, ds[i]);
  // }

  // links between nodes with depth differing by 1 are real
  vector<int> ps(n, 0);
  ps[root] = -1;
  for (int i = 0; i < m + n - 1; i++) {
    if (ds[as[i]] + 1 == ds[bs[i]]) {
      ps[bs[i]] = as[i];
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", ps[i] + 1);
  }

  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.141592653589793238
typedef long long ll;
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int s=0;
    for(int i=0;i<m;i++)
    {
        int a;
        cin>>a;
        s+=a;
    }
    if(s>n)
    cout<<"-1"<<"\n";
    else
    cout<<n-s<<"\n";
    return 0;
}

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

int main(int argc, char const *argv[]) {
  int a, b;
  char op;

  cin >> a >> op >> b;

  while (op != '?') {
    switch (op) {
      case '+':
        cout << a + b << endl;
        break;

      case '-':
        cout << a - b << endl;
        break;

      case '*':
        cout << a * b << endl;
        break;

      case '/':
        if (b != 0) cout << a / b << endl;
        break;

      default:
        break;
    }

    cin >> a >> op >> b;
  }

  return 0;
}



Measured memory_bytes: 3096
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int j, j_;
    j = h1*60+m1;
    j_ = h2*60+m2;
    cout << j_-j-k << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int parent[200004];
int length[200004];
int num[200004];

void init(){
  for (int i=0; i<200004; i++) {
    parent[i] = i;
    length[i] = 1;
    num[i] = 1;
  }
  return;
}

int getroot(int n) {
  int orig = n;
  while(n!=parent[n]){
    n = parent[n];
  }
  parent[orig] = n;
  return n;
}

bool samegroup(int n, int m){
  n = getroot(n);
  m = getroot(m);
  return n==m;
}

void unite(int n, int m) {
  n=getroot(n);
  m=getroot(m);
  if (samegroup(n, m)) return;
  if (length[n]>length[m]) {
    parent[m] = n;
    num[n]+=num[m];
  } else if (length[m]>length[n]) {
    parent[n] = m;
    num[m]+=num[n];
  } else {
    parent[n] = m;
    length[n]++;
    num[m]+=num[n];
  }
}

int main() {
  int N, M;
  std::cin >> N >> M;
  init();
  int A, B;
  for (int i=0; i<M; i++) {
    std::cin >> A >> B;
    A--;
    B--;
    unite(A, B);
  }
  int max = 0;
  for (int i=0; i<N; i++) {
    max = std::max(max, num[i]);
    //printf("root of %d = %d, num=%d\n", i, getroot(i), num[getroot(i)]);
  }
  std::cout << max << std::endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;

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

    int highest = height[0];
    int view = 1;
    for (int i = 1; i < N; i++) {
        if (height[i] >= highest) {
            view += 1;
            highest = height[i];
        }
    }
    cout << view << endl;
    return 0;
}

Measured memory_bytes: 384
// ORZ YJZ
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int n;
ll a, b, c, d;
bool can(ll target, int num) {
	if (target<0) return 0;
	if (target>num*d||target<num*c) return 0;
	return 1;
}
int main() {
	n=readint();a=readll();b=readll();c=readll();d=readll();
	ll diff=abs(a-b), sum=0;
	rep(i,1,n-1) {
		sum+=c;
		if (can(sum-diff,n-1-i)) {
			printstr("YES\n");return 0;
		}
	}
	sum=0;
	rep(i,1,n-1) {
		sum+=d;
		if (can(sum-diff,n-1-i)) {
			printstr("YES\n");return 0;
		}
	}
	printstr("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
  int n, k, i, a, p = 0;
  int max = 0;
  scanf("%d%d", &k, &n);
  int *S, *s;
  S = (int *)malloc(sizeof(int) * (n + 1));
  s = (int *)malloc(sizeof(int) * (n + 1));
  scanf("%d", &a);
  S[0] = a;
  for (i = 1; i < n; i++)
  {
    scanf("%d", &a);
    S[i] = a;
    s[i - 1] = a - S[i - 1];
    if (s[i - 1] > max)
    {
      max = s[i - 1];
      p = i - 1;
    }
  }
  s[i] = k - S[n - 1] + S[0];
  if (s[i] > max)
  {
    printf("%d\n", S[n - 1] - S[0]);
    return 0;
  }
  printf("%d\n", S[p] + k - S[p + 1]);

  return 0;
}

Measured memory_bytes: 1792