akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int a, b, c; cin >> a >> b >> c;) {
		bool C[11] = {};
		C[a] = C[b] = C[c] = true;
		int my = a + b;
		int d = 0;
		FOR(i, 1, 11)if (my + i <= 20 && !C[i])d++;
		if (d >= 4)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = ReadInts();
            var k = ReadInt();

            var max = abc.Max();
            var ans = abc.Sum() - max;

            for (int i = 0; i < k; i++)
            {
                max = max * 2;
            }
            ans += max;
            WriteLine(ans);
        }

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

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

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

    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int N;
    cin >> N;
    map<long, int, greater<long>> sticks;
    for(int i = 0; i < N; i++){
        long num;
        cin >> num;
        sticks[num]++;
    }
    long one_side = 0;
    for(auto i: sticks){
        if(i.second >= 2 && one_side){
            cout << one_side * i.first << endl;
            return 0;
        }else if(i.second >= 4){
            cout << i.first * i.first << endl;
            return 0;
        }else if(i.second >= 2){
            one_side = i.first;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,i,min=10000;
  	cin>>n>>x;
  	vector<int> m(n);
  	for(i=0;i<n;i++){
      	cin>>m[i];
      	x-=m[i];
      if(m[i]<min){
        min=m[i];
      }
    }

  	cout<<n+x/min<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
 
using namespace std;
 
int main(){
  int A, B, C, i, x, r;
  bool can = false;
  cin >> A >> B >> C;
  for (i = 1; i <= B; i++){
    x = A * i;
    r = x % B;
    if (r == C){
      can = true;
      break;
    }
  }
  if (can)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Locale;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    int maxVal = Math.max(A, B);
    int result = 0;
    if (C > maxVal) {
      result = C * 10 + A + B;
    } else {
      result = maxVal * 10 + C + Math.min(A, B);
    }

    System.out.println(result);
  }
}


Measured memory_bytes: 21844
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<vector<long long int>>num(N, vector<long long int>(10));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> num[i][j];
		}
	}
	M = LLONG_MIN;
	vector<vector<long long int>>p(N, vector<long long int>(11));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}
	for (int i = 1; i < 1024; i++) {
		int box = i;
		vector<bool>flag(10, false);
		int bag = 0;
		while (box) {
			if (box % 2) {
				flag[bag] = true;
			}
			box /= 2;
			bag++;
		}
		K = 0;
		for (int j = 0; j < N; j++) {
			int fig = 0;
			for (int k = 0; k < 10; k++) {
				if (flag[k]&&num[j][k]) {
					fig++;
				}
			}
			K += p[j][fig];
		}
		M = max(M, K);
	}
	cout << M << endl;
	return 0;
}

Measured memory_bytes: 256
K, A, B = map(int, input().split())

if B-A <= 2:
    print(K+1)
    exit(0)

if 1+(K-2) < A:
    print(K+1)
    exit(0)

exchange_times, last = divmod(K-(A-1), 2)
profit = B - A
ans = A + exchange_times * profit + last
print(ans)


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

void solve(int M, int n1, int n2) {
  vector<int> P(M);
  rep(i, 0, M) { cin >> P[i]; }
  sort(all(P), greater<int>());
  pii ans(0, 0);
  rep(i, n1 - 1, n2) { chmax(ans, pii(P[i] - P[i + 1], i)); }
  cout << ans.second+1 << endl;
}
signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int M, n1, n2;
  while (cin >> M >> n1 >> n2, M or n1 or n2) {
    solve(M, n1, n2);
  }

  return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n;
vector<int> dp;

int rec(int n) {

	int res = n;
	if (n == 0) return 0;
	if (dp[n] != -1) return dp[n];
	
	for (int p = 1; p <= n; p *= 6) res = min(res, rec(n - p) + 1);
	for (int p = 1; p <= n; p *= 9) res = min(res, rec(n - p) + 1);

	return dp[n] = res;
}

int main() {

	int n; cin >> n;

	dp.resize(n+1,-1);

	int res = rec(n);

	cout << res << endl;

}

Measured memory_bytes: 8136
# dp[i][j]=(i人目までにj個配る場合の数)
mod=10**9+7
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    dp=[[0]*(k+1) for _ in range(n)]
    for i in range(a[0]+1):
        dp[0][i]=1
    for i in range(1,n):
        dp[i][0]=dp[i-1][0]
        for j in range(1,k+1):
            dp[i][j]=dp[i-1][j]+dp[i][j-1]
            if j-a[i]>0:
                dp[i][j]-=dp[i-1][j-a[i]-1]
            dp[i][j]%=mod
    print(dp[-1][-1])
    # for i in dp:
    #     print(i) 
main()     

Measured memory_bytes: 117232
#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

int main()
{
  int n, d;
  cin >> n >> d;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++)
  {
    cin >> x[i] >> y[i];
  }
  scc_graph g(2 * n);
  vector<int> w(2 * n);
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (i == j) continue;
      if (abs(x[i] - x[j]) < d)
      {
        g.add_edge(2 * i, 2 * j + 1);
      }
      if (abs(x[i] - y[j]) < d)
      {
        g.add_edge(2 * i, 2 * j);
      }
      if (abs(y[i] - x[j]) < d)
      {
        g.add_edge(2 * i + 1, 2 * j + 1);
      }
      if (abs(y[i] - y[j]) < d)
      {
        g.add_edge(2 * i + 1, 2 * j);
      }
    }
  }
  vector<vector<int> > S = g.scc();
  for (int i = 0; i < S.size(); i++)
  {
    for (int j = 0; j < S[i].size(); j++)
    {
      w[S[i][j]] = i;
    }
  }
  for (int i = 0; i < n; i++)
  {
    if (w[2 * i] == w[2 * i + 1])
    {
      cout << "No\n";
      return 0;
    }
    w[i] = w[2 * i] < w[2 * i + 1];
  }
  cout << "Yes\n";
  for (int i = 0; i < n; i++)
  {
    if (w[i]) cout << y[i] << "\n";
    else cout << x[i] << "\n";
  }
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
 
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll temp1 = 0;
 
    temp1 = a*x + b * y;
 
    if (x < y) {
        swap(x, y);
        swap(a, b);
    }
 
    ll temp2 = 0;
    temp2 = x*2*c;
 
    ll temp3 = 0;
    ll temp4 = 0;
    ll temp5 = 0;
    temp3 = y*2*c + (x -y)*a;
    temp4 = y*2*c + (x-y)*2*c;
    temp5 = y*2*c + (x-y)*2*c;
 
    temp3 = min(temp3, temp4);
 
    cout << min(temp3,min(temp1, temp2));
    //cout << temp1 << endl;
    //cout << temp2 << endl;
    //cout << temp3 << endl;
 
 
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){

    int A,B;

    std::cin >> A  >> B ;

    int X_min, X_max;
    int Y_min, Y_max;
    int ans = -1; // 初期値でfalseを与える
    // 8%消費税でA円のお釣りを与える代金X
    // A / 0.08 =< X < (A+1)/0.08

    // A * 100 / 8 が余り0の時 A mod 2 = 0
    X_min = (A % 2 == 0) ? A * 100 / 8 : A * 100 / 8 + 1;
    X_max = ((A+1) % 2 == 0 ) ? (A+1) * 100 / 8 -1  : (A+1) * 100 / 8;

    Y_min = B * 10;
    Y_max = (B+1) * 10  - 1;
    bool flag_findone = false;


    int tmp = 0;
    for(int i = 0; i < X_max - X_min; ++i){
        tmp = i + X_min;

        for(int j = 0; j < Y_max - Y_min; ++j){

            if(tmp == j + Y_min && flag_findone == false){
                ans = tmp;
                flag_findone = true;
            }
        }
    }
    

    std::cout << ans << std::endl;
}

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

using namespace std;
int main()
{
    long long n,counter=1,i=1;
    cin>>n;
    long long x=n;
    while (n!=1){
        i*=2;
        counter+=(i);
        n=n/2;
    }
    //counter+=x;
    cout<<counter;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
    int n,num=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int pos=1;
    for(int i=1;i<=n;i++){
        if(a[i]==pos){
            num++;pos++;
        }
    }
    if(num==0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<n-num<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int A, B; cin >> A >> B;
    int ans = 0;
    REP(i, 2){
        if(A >= B){
            ans += A;
            A--;
        }else{
            ans += B;
            B--;
        }
    }
    cout << ans << endl;

    return 0;
}


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

const int N = 500009;
const int mod = 1000000007;

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

int a, b, k;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin >> a >> b >> k;

	if (k >= a)
	{
		cout << 0 << " " << max(b - k + a, (int)0) << endl;
	}
	else
	{
		cout << (a - k) << " " << b << endl;
	}
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b;
  cin >> a >> b;
  cout << ((a-1)*(b-1)) << endl;
}


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

char map[101][101];
int t[101][101];

void func(int x, int y, int h){
    if(h == 0){
        map[x][y] = '#';
        for(int i=0; i<=100; i++){
            for(int j=0; j<=100; j++){
                if(map[i][j] == 'o'){
                    t[i][j] = abs(i-x) + abs(j-y);
                    map[i][j] = 'v';
                }else if(map[i][j] == '.'){
                    if(t[i][j] > abs(i-x) + abs(j-y)){
                        map[i][j] = '#';
                    }
                }else if(map[i][j] == 'v'){
                    if(t[i][j] > abs(i-x) + abs(j-y)){
                        t[i][j] = abs(i-x) + abs(j-y);
                    }
                }
            }
        }
    }else{
        for(int i=0; i<=100; i++){
            for(int j=0; j<=100; j++){
                if(map[i][j] == 'o'){
                    map[i][j] = '.';
                    t[i][j] = abs(i-x) + abs(j-y) + h;
                }else if(map[i][j] == '.'){
                    if(t[i][j] != abs(i-x) + abs(j-y) + h){
                        map[i][j] = '#';
                    }
                }else if(map[i][j] == 'v'){
                    if(t[i][j] < abs(i-x) + abs(j-y) + h){
                        map[i][j] = '#';
                    }else{
                        map[i][j] = '.';
                        t[i][j] = abs(i-x) + abs(j-y) + h;
                    }
                }
            }
        }
    }
}

int main(){
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            map[i][j] = 'o';
            t[i][j] = -1;
        }
    }
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        int x, y, h;
        scanf("%d %d %d", &x, &y, &h);
        func(x, y, h);
    }
    int ans_x, ans_y, ans_h = 0;
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            if(map[i][j] != '#'){
                if(t[i][j] > ans_h){
                    ans_h = t[i][j];
                    ans_x = i;
                    ans_y = j;
                }
            }
        }
    }
    printf("%d %d %d", ans_x, ans_y, ans_h);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int ll
#define pii pair <int,int>
#define pipii pair <int,pair <int,int>>
#define mp make_pair
#define sz(var) (int)var.size()
const int maxinput=2000005;
const int mod=1e9+7;
signed main() 
{
    FAST
    int n;cin>>n;
    string s;cin>>s;

    int dp[n+5][n+5];
    memset(dp,0,sizeof(dp));

    for(int j=1;j<=n;j++)
        dp[1][j]=1;   //prefix sum
    dp[1][0]=0;
    
    dp[1][1]=1;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            if(s[i-2]=='<')
            {
                /*
                    for(int k=1;k<=j-1;k++)
                        dp[i][j]+=dp[i-1][k];
                */
                dp[i][j]=dp[i-1][j-1]-dp[i-1][0];
                dp[i][j]%=mod;
            }
            else
            {
                /*
                    for(int k=j;k<=i-1;k++)
                        dp[i][j]+=dp[i-1][k];
                */
                dp[i][j]=dp[i-1][i-1]-dp[i-1][j-1];
                dp[i][j]%=mod;
                
            }
        }
        for(int j=1;j<=n;j++)
        {
            dp[i][j]+=dp[i][j-1]; //prefix sum
            dp[i][j]%=mod;
        }
    }

    /*for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/

    int ans=0;
    ans=dp[n][n]; //prefix sum already there
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
}


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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rrep(i,n) for(ll i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)
#define rrep1(i,n) for(ll i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  vector<ll> a(n), aa, ca;
  rep(i, n)cin>>a[i];
  ca.push_back(0);
  rep(i, n) ca.push_back( ca.back() + a[i] );

  rep(i, n)for(int j=i+1; j<=n; j++) aa.push_back(ca[j]-ca[i]);

  sort(aa.begin(), aa.end());

  // search biggest bit satisfying numbers
  vector<ll>na;
  rrep(bit, 40){
    rrep(i, aa.size()) if( aa[i]>>bit & 1 )na.push_back(aa[i]);

    if(na.size()>=k)swap(aa, na);
    na.clear();
  }

  ll result=aa[0];
  rep(i, k)result = result&aa[i];
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 6524
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
char c;
bool flag;

//----------------------------------------------------------------------


int main(void) {
  ll a, b;

  cin >> a >> b;

  ans = a * b;

  if (ans % 2 == 0) {
	cout << "Even" << endl;
  }
  else {
	cout << "Odd" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int i,cnt=0;
  for(i=a;i<=b;i++){
    if(i%c==0) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    // 0: R, 1: S, 2: P
    int t[N];
    int v[3] = {R, S, P};
    for (int i = 0; i < N; i++) {
        if (T[i] == 'r') t[i] = 2;
        if (T[i] == 's') t[i] = 0;
        if (T[i] == 'p') t[i] = 1;
    }
    
    int d[N][3]{};
    int g = (N ) / K;
    for (int i = 0; i < K; i++) {
        d[i][t[i]] = v[t[i]];
        for (int j = i + K; j < N; j += K) {
            for (int k = 0; k < 3; k++) {
                if (t[j] == k) {
                    d[j][k] = max(d[j - K][(k + 1) % 3], d[j - K][(k + 2) % 3]) + v[k];
                } else {
                    d[j][k] = max(d[j - K][(k + 1) % 3], d[j - K][(k + 2) % 3]);
                }
            }
        }
    }
    // for (int i = 0; i < N; i++) {
    //     for (int j = 0; j < 3; j++) {
    //         cout << d[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    int ans = 0;
    for (int i = 1; i <= K; i++) {
        ans += max(d[N - i][0], max(d[N - i][1], d[N - i][2]));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2048
// 2016-12-12
#include <iostream>
#include <algorithm>
#include <cmath>
#include <array>
#include <map>
#include <vector>
using namespace std;

int main() {
	int n, p;
	bool a[100275];
	fill(a, a + 100275, true);
	a[0] = a[1] = false;
	vector<int> v;
	for (int i = 2; i < 100275; i++) {
		if (a[i]) {
			v.push_back(i);
			for (int j = i + i; j < 100275; j += i) {
				a[j] = false;
			}
		}
	}
	vector<pair<int, int>> w;
	for (int i = 0; i < v.size(); i++) {
		for (int j = i, l = min((int)v.size(), i + 50); j < l; j++) {
			if (v[i] + v[j] > 200274) {
				break;
			} else {
				w.push_back(make_pair(v[i] + v[j], min(v[i], v[j])));
			}
		}
	}
	sort(begin(w), end(w));
	while (cin >> n >> p, n >= 0) {
		int i, m;
		for (i = 0, m = 0; i < w.size(); i++) {
			if (w[i].second > n) {
				m++;
				if (m >= p) {
					break;
				}
			}
		}
		cout << w[i].first << endl;
	}
	return 0;
}

Measured memory_bytes: 6956
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);//freopen("out", "w", stdout);
	int n;
	cin >> n;
	vector < int > v(n);
	for(int & i : v)
		cin >> i;
	sort(v.begin(), v.end());
	int ans = 0;
	for(int i = 0; i < n; i++){	
		for(int j = i+1; j < n; j++){
			for(int k = j+1; k < n; k++){
				ans += v[k] < (v[i] + v[j]) && (v[i] != v[j]) && v[j] != v[k];
			}
		}
	}
	cout << ans << endl;	
	return 0;
}


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

map<int,int>cnt;
int main()
{
    int n, a[100005];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        if(cnt[a[i]]!=a[i])
        {
            if(cnt[a[i]]>a[i])
            {
                ans += abs(cnt[a[i]] - a[i]);
                cnt[a[i]] = a[i];
            }

            else
            {

                ans += cnt[a[i]];
                cnt[a[i]] = a[i];
            }

        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
/*******source code below********/
int main(void) {
	int a, b, t; cin >> a >> b >> t;
	int ans = 0;
	for (int i = 1; i <= t; i++) {
		if (i %a == 0) {
			ans += b;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
      	var dic = new Dictionary<int,int>();
		for(var i=0;i<N;i++){
			string s = Console.ReadLine();
			int c10 = 0;
			if(s.IndexOf(".")!=-1){
              	int cai = s.Length - s.IndexOf(".") - 1;
              	s = s.Replace(".","");
              	c10 = -cai;
            }
			int c5 = 0;
			int c2 = 0;
			long d = long.Parse(s);
			while(d%5==0){
				d /= 5;
				c5++;
			}
			while(d%2==0){
				d /= 2;
				c2++;
			}
			while(c10<0 && c5>0 && c2>0){
              	c10++;
              	c5--;
              	c2--;
            }
			int dai = -c10*1000000+c5*1000+c2;
			if(dic.ContainsKey(dai)){
              	dic[dai]++;
            } else {
              	dic[dai] = 1;
            }
		}
      	long ansct = 0;
      	var listA = new List<int>();
      	var list1 = new List<int>();
      	var list2 = new List<int>();
      	var list3 = new List<int>();
      	foreach(var dab in dic.Keys){
          	int a1 = dab/1000000;
          	int a2 = (dab/1000)%1000;
          	int a3 = dab%1000;
          	listA.Add(dic[dab]);
            list1.Add(-a1);
            list2.Add(a2);
            list3.Add(a3);
        }
      	for(var i=0;i<listA.Count;i++){
          	for(var j=i;j<listA.Count;j++){
              	if(list2[i]+list2[j]>=-list1[i]-list1[j] && list3[i]+list3[j]>=-list1[i]-list1[j]){
					if(i==j){
                      	ansct += (long)(listA[i]-1)*listA[j]/2;
                    } else {
                      	ansct += (long)listA[i]*listA[j];
                    }
                }
            }
        }
		Console.WriteLine(ansct);
	}
}


Measured memory_bytes: 22708
#include <stdio.h>
int main(){
    int a,b,c,k;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d", &k);
    while(1){
        if(a<b&&b<c){
            printf("Yes\n");
            return 0;
        }
        if(k==0){
            printf("No\n");
            return 0;
        }
        if(b>=c){
            c*=2;
            k--;
            continue;
        }else if(a>=b){
            b*=2;
            k--;
            continue;
        }
    }
}

Measured memory_bytes: 1660
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
#define ll long long
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int main(){
    int m,d;
    cin >> m >> d;
    int ans = 0;
    lpi(i,1,m+1){
        lpi(j,1,d+1){
            if(j < 10) continue;
            int dig1 = (j%10);
            int dig2 = (j/10);
            if(dig1 < 2 || dig2 < 2)continue;
            if( dig1 * dig2 == i )ans++;
            //cout << i << " " << j << endl;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    VL a(n), b(n);
    REP(i,n){
        a[i] = in();
        b[i] = in();
    }

    vector<PL> p(n);
    REP(i,n){
        p[i] = PL(a[i] + b[i], i);
    }
    sort(ALL(p));
    reverse(ALL(p));

    ll ans = 0;
    REP(i,n){
        int x = p[i].second;
        if (i % 2 == 0) ans += a[x];
        else ans -= b[x];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

public class Main {

	static TreeMap<Integer,String> data = new TreeMap<Integer,String>();
	static Map<Integer,Integer> dataOrder = new TreeMap<Integer,Integer>();
	static Map<String,Integer> numMap = new HashMap<String,Integer>();
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int cityNum = Integer.valueOf(line.split(" ")[1]);
		for(int i=0;i<cityNum;i++) {
			String tempLine = br.readLine();
			String xiaquTemp = tempLine.split(" ")[0];
			int cityTemp = Integer.valueOf(tempLine.split(" ")[1]);
			data.put(cityTemp, xiaquTemp);
			dataOrder.put(i, cityTemp);
		}
		Iterator<Integer> it=data.keySet().iterator();
		String baseStr = "000000";
		while(it.hasNext()) {
			int key = it.next();
        	String pre = data.get(key);
        	int intback = 0;
        	if(numMap.containsKey(pre)) {
        		intback = numMap.get(pre)+1;
        	}else {
        		intback = 1;
        	}
        	String back = String.valueOf(intback);
        	String str1 = baseStr.substring(0, baseStr.length()-pre.length())+pre;
        	String str2 = baseStr.substring(0, baseStr.length()-back.length())+back;
        	numMap.put(pre, intback);
        	data.put(key, str1+str2);
		}
		Iterator<Integer> it1=dataOrder.keySet().iterator();
		while(it1.hasNext()) {
			int a = it1.next();
			int b = dataOrder.get(a);
			System.out.println(data.get(b));
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> diam(N);
  for (int i = 0; i < N; i++) {
   cin >> diam.at(i);
  }
  
  sort(diam.begin(), diam.end());
  int steps = N;
  for (int i = 0; i < N-1; i++) {
   if (diam.at(i) == diam.at(i+1)) {
     steps--;
   }
  }
  cout << steps << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
int main(void){
    string S;
    cin >> S;

    if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
        cout <<"Yes"<<endl;
    }
    else cout <<"No"<<endl;

    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

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

long long extGcd(long long a, long long b, long long &p, long long &q) {
    if (b == 0) { p = 1; q = 0; return a; }
    long long d = extGcd(b, a%b, q, p);
    q -= a/b * p;
    return d;
}

pair<long long, long long> ChineseRem(const vector<long long> &b, const vector<long long> &m) {
    long long r = 0, M = 1;
    for (int i = 0; i < (int)b.size(); ++i) {
        long long p, q;
        long long d = extGcd(M, m[i], p, q); // p is inv of M/d (mod. m[i]/d)
        if ((b[i] - r) % d != 0) return make_pair(0, -1);
        long long tmp = (b[i] - r) / d * p % (m[i]/d);
        r += M * tmp;
        M *= m[i]/d;
    }
    return make_pair(mod(r, M), M);
}


int main(){
  ll n, m;cin >> n >> m;
  vector<ll> a(n), b(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    b[i]= a[i]/2;
  }
  auto p = ChineseRem(b,a);
  ll ans = 0;
  if(p.first!=0 && p.first<=m){
    ans = (m-p.first)/p.second + 1;
  }
  cout << ans << endl;
}


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

int main() {
	
	int a[3];
	
	cin>>a[0]>>a[1]>>a[2];

	sort(a, a+3);
	
	if(a[0]==5 && a[1]==5 && a[2]==7) cout<<"YES"<<endl;
	
	else cout<<"NO"<<endl;
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 3632
a=int(input())
b=set()
b.add(a)
while(len(b)):
    count=len(b)
    if a%2==1:
        a=a*3+1
    else:
        a=a//2
    b.add(a)
    if count==len(b):
        break
print(len(b)+1)


Measured memory_bytes: 3316
#include<stdio.h>
#define MAX 100000

int partition(int,int);

int A[MAX],n;

int main()
{
  int i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }

  q = partition(0,n-1);

  for(i=0;i<n;i++)
    {
      if(i==q)
	{
	  printf("[");
	  printf("%d",A[i]);
	  printf("]");
	}
      else
	{
	  printf("%d",A[i]);
	}
      if(i<n-1)
	{
	  printf(" ");
	}
    }
  printf("\n");
  
  return 0;
}

int partition(int p,int r)
{
  int x;
  int i,j;
  int temp;
  x = A[r];
  i = p-1;

  for(j=p;j<=r-1;j++)
    {
      if(A[j] <= x)
	{
	  i = i+1;
	  temp = A[i];
	  A[i] = A[j];
	  A[j] = temp;
	}
    }
  
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;

  return i+1;
}



Measured memory_bytes: 2144
#include <cstdio>

using namespace std;

double X[25] , Y[25] , Z[25] , Ans;
int A[25] , n , m;

double CalcDis(int p , int q)
{
	return  (X[p] - X[q]) * (X[p] - X[q]) +
			(Y[p] - Y[q]) * (Y[p] - Y[q]) +
			(Z[p] - Z[q]) * (Z[p] - Z[q]);
}

void Dfs(int x , int sum)
{
	if (sum == m)
	{
		double Now = 0;
		for (int i = 0 ; i < m ; i++)
			for (int j = i + 1 ; j < m ; j++)
				Now += CalcDis(A[i] , A[j]);
		if (Now > Ans) Ans = Now;
	}
	else
	{
		if (m - sum == n - x)
		{
			A[sum] = x;
			Dfs(x + 1 , sum + 1);
		}
		else
		{
			Dfs(x + 1 , sum);
			A[sum] = x;
			Dfs(x + 1 , sum + 1);
		} 
	}
}

int main()
{
	scanf("%d%d" ,&n , &m);
	for (int i = 0 ; i < n ; i++)
		scanf("%lf%lf%lf" , &X[i] , &Y[i] , &Z[i]);
	
	Ans = 0;
	Dfs(0 , 0);
	
	printf("%.16f\n" , Ans);
	return 0;
}

Measured memory_bytes: 1096
N = int(input())
rates = list(map(int, input().split()))
over = 0
colors = []
GREY = 0
BROWN = 1
GREEN = 2
SKY = 3
BLUE = 4
YELLOW = 5
ORANGE = 6
RED = 7

for rate in rates:
  if rate <= 399:
    if not GREY in colors:
      colors.append(GREY)
  elif rate <= 799:
    if not BROWN in colors:
      colors.append(BROWN)
  elif rate <= 1199:
    if not GREEN in colors:
      colors.append(GREEN)
  elif rate <= 1599:
    if not SKY in colors:
      colors.append(SKY)
  elif rate <= 1999:
    if not BLUE in colors:
      colors.append(BLUE)
  elif rate <= 2399:
    if not YELLOW in colors:
      colors.append(YELLOW)
  elif rate <= 2799:
    if not ORANGE in colors:
      colors.append(ORANGE)
  elif rate <= 3199:
    if not RED in colors:
      colors.append(RED)
  else:
    over += 1
min_c = max(1, len(colors))
max_c = len(colors)+over
print(min_c, max_c)


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

int main() {
  int num_query; cin >> num_query;
  set<int> integers;
  
  for (int i = 0; i < num_query; i++) {
    int command, x; scanf("%d %d", &command, &x);
    
    switch (command) {
      case 0:
        integers.insert(x);
        printf("%d\n", integers.size());
        break;
        
      case 1:
        printf("%d\n", integers.count(x));
        break;
        
      case 2:
        integers.erase(x);
        break;
        
      case 3:
        int y; scanf("%d", &y);
        set<int>::iterator it = integers.lower_bound(x);
        set<int>::iterator last = integers.upper_bound(y);
        while (it != last) {
          printf("%d\n", *it);
          it++;
        }
        break;
    }
  }
}


Measured memory_bytes: 12512
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long x,y;
int main(){
	int i,j;
	scanf("%lld%lld",&x,&y);
	long long ans=0;
	while(x<=y){
		ans++;
		x*=2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;

typedef long long ll;

long long Mygcd(long long a, long long b)
{
	if (a % b == 0)return b;
	return Mygcd(b, a % b);
}

int Mygcd(int a, int b)
{
	if (a % b == 0)return b;
	return Mygcd(b, a % b);
}

long long Mylcm(long long a, long long b)
{
	return a * b / Mygcd(a, b);
}

int Mylcm(int a, int b)
{
	return a * b / Mygcd(a, b);
}

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

	int N;
	vector<string> S;
	string temp;

	cin >> N;

	REP(i, N)
	{
		cin >> temp;
		S.pb(temp);
	}

	sort(S.begin(),S.end());
	decltype(S)::iterator r = unique(S.begin(), S.end());

	S.erase(r, S.end());

	cout << S.size() << endl;

	return 0;
}

Measured memory_bytes: 11624
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
    //freopen("../input.txt","r",stdin);
    int N, input, min = 0, counter = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> input;
        if (i == 0) {
            min = input;
            counter++;
        }
        if (input < min) {
            min = input;
            counter++;
        }
    }
    cout << counter;
}

Measured memory_bytes: 3608
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H1, M1, H2, M2, K = getlist()
	X = H2 * 60 + M2 - (H1 * 60 + M1)
	print(X - K)

if __name__ == '__main__':
	main()

Measured memory_bytes: 64708
#include<iostream>
using namespace std;
int main(){
  int n,i,flag=0;
  cin >> n;
  char s;
  for(i=0;i<n;i++){
    cin >> s;
    if(s=='Y')flag=1;
  }
  if(flag==0)cout << "Three" << endl;
  else cout <<"Four" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
o = []
#とりあえず後ろから1つ飛ばしで並べる。
for i in range(n)[::-2]:
    o.append(a[i])
#前からも1つ飛ばしで並べる。
#被らないように、要素数が奇数の時は、0番目ではなく1番目から並べる
for i in range(n)[n%2::2]:
    o.append(a[i])
print(*o)


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

int main(){
  int x;
  cin>>x;
  int i=0;
  while(i*(i+1)/2<x){
    i++;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 256
# dpでいけそう
n = int(input())
a = list(map(int, input().split()))
INF = 10**16

ans = -INF

a = [0, 0, 0, 0] + a
dp = [[-INF for _ in range(n+4)] for _ in range(3)]
dp[0][2] = 0
for i in range(4, len(a)):
    dp[2][i] = max(dp[2][i], dp[1][i-3] + a[i], dp[0][i-4] + a[i], dp[2][i-2] + a[i])
    dp[1][i] = max(dp[1][i], dp[0][i-3] + a[i], dp[1][i-2] + a[i])
    dp[0][i] = max(dp[0][i], dp[0][i-2] + a[i])
if n % 2 == 1:
    ans = max(ans, dp[0][n])
    ans = max(ans, dp[1][n+2])
    ans = max(ans, dp[2][n+3])
else:
    ans = max(ans, dp[0][n+2])
    ans = max(ans, dp[1][n+3])
# print(dp)
print(ans)

Measured memory_bytes: 130864
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
	int  N;
	ll a,b;
	int ans=0;
	scanf("%d%lld%lld",&N,&a,&b);
	for(int i=0;i<N;i++)
	{
		ll x,y;
		scanf("%lld%lld",&x,&y);
		if(x-a>=0&&y-b>=0)
			ans++;
	}
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
string s;
ll dfs(ll x,ll y,ll z){
	if(x==s.size())return y*(z==0);
  	return (dfs(x+1,y,z*10+s[x]-'0')+dfs(x+1,y+z*10+s[x]-'0',0));
}
int main(){
	cin>>s;
	cout<<dfs(0,0,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll mod = 1e9+7;

#define MAXN 1005

char mat[MAXN][MAXN];

ll dist[MAXN][MAXN];
/* //naive sol
void dfs(int i,int j){
    
    if(mat[i+1][j] == '.'){

        dist[i+1][j]++;
        dfs(i+1,j);

    }

    if(mat[i][j+1] == '.'){

        dist[i][j+1]++;
        dfs(i,j+1);

    }
    return;

}
*/

void dfs(int h, int w){

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(mat[i][j] == '.'){
                if(mat[i-1][j]=='.')
                    dist[i][j] = (dist[i][j]+dist[i-1][j]) % mod;
                if(mat[i][j-1]=='.')
                    dist[i][j] = (dist[i][j] + dist[i][j-1]) % mod;
            }
        }
    }



}
int main(){

    //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);

    int h,w;//cin>>h>>w;
    scanf("%d %d",&h,&w);
    for(int i=1;i<=h;i++){
        scanf("%s",mat[i]+1);
    }
    dist[1][1]=1;
    dfs(h,w);

    //cout<<dist[h][w]<<endl;
    printf("%lld\n",dist[h][w]);
#ifdef NOTINAIR
    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            cerr<<dist[i][j]<<' ';

        }
        cerr<<endl;
    }
#endif



}


Measured memory_bytes: 9088
nums1=[]
nums2=[]
while True:
    num=[]
    num=input().split()
    for i in range(0,len(num)):
        num[i]=int(num[i])
    if num[0]==0 and num[1]==0:
        break
    nums1.append(num[0])
    nums2.append(num[1])

for i in range(0,len(nums1)):
    if nums1[i]<nums2[i]:
        print(nums1[i],nums2[i])
    else:
        print(nums2[i],nums1[i])

Measured memory_bytes: 8040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << (val) << "\n";
#define RANGE(c) c.begin(), c.end()
using namespace std;

int main(void){
    int a[4] = {0}, x;
    FOR(i, 6){
        cin >> x;
        a[x-1] ++;
        if(a[x-1] == 3){ COUT("NO"); return 0; }
    }
    COUT("YES");
}

Measured memory_bytes: 256
import sys

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


def main():
    S = readline().strip()
    K = int(readline())

    subs = set()

    for i in range(len(S)):
        for j in range(i + 1, min(len(S) + 1, i + K + 1)):
            subs.add(S[i:j])

    subs = sorted(subs)
    print(subs[K - 1])

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 68448
import sys

sys.setrecursionlimit(10 ** 6)


def main():
    n, k = map(int, input().split())
    MOD = 10 ** 9 + 7
    t = [{} for _ in range(n)]
    for _ in range(n-1):
        a, b = map(int, input().split())
        t[a-1][b-1] = 1
        t[b-1][a-1] = 1
    values = [1] * n

    def dfs(x):
        colors = k - 2
        for y in t[x]:
            del t[y][x]
            values[y] = colors
            colors -= 1
            dfs(y)

    values[0] = k
    colors = k - 1
    for x in t[0]:
        del t[x][0]
        values[x] = colors
        colors -= 1
        dfs(x)

    ans = 1
    for v in values:
        ans *= v
        ans %= MOD
    print(ans)


main()


Measured memory_bytes: 122740
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int ans = 0;
		boolean[] used = new boolean[n];

		List<Integer> aiList = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int ai = scan.nextInt();
			aiList.add(ai - 1);
		}

		for (int i = 0; i < n; i++) {
			if (!used[i]) {
				int ai = aiList.get(i);
				if (i == aiList.get(ai)) {
					ans++;
					used[ai] = true;
				}
			}
		}

		System.out.println(ans);

		scan.close();

	}

}


Measured memory_bytes: 50360
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
void solve();
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;

	for (int i = 1; i <= t; i++)
	{	//cout<<"Case #"<<i<<": ";
		solve();
		cout << "\n";
	}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
void solve()
{	string s;
	cin >> s;
	string s1 = "RSR";
	if (s1 == s) {
		cout << "1";
		return;
	}
	int r = 0;
	for (int i = 0; i <= 2; i++)
	{
		if (s[i] == 'R')
			r++;
	}

	cout << r;
}


Measured memory_bytes: 3784