akhauriyash/Code-Regression huggingface dataset:
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a+b,a,b])
l.sort(reverse=True)
t=0
a=0
for i in range(n):
    if i%2==0:
        t+=l[i][1]
    else:
        a+=l[i][2]
print(t-a)



Measured memory_bytes: 59640
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int x,h;
	while(cin>>x>>h,x)
	{
		printf("%.9lf\n",x*x+x*0.5*sqrt(x*x*0.5*0.5+h*h)*4);
	}
  return 0;
}

Measured memory_bytes: 1192
from operator import itemgetter
N = int(input())
restrant = []
for i in range(N):
    mise = [j for j in input().split()]
    L = []
    for k in range(2):
        if k == 0:
            L.append(mise[k])
        else:
            L.append(int(mise[k]))
    restrant.append(L+[i+1])
restrant.sort(key = lambda x:(x[0],-x[1]))
for i in restrant:
    print(i[2])

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

int main() {
	int n, m;
	int survey[31];
	memset(survey, 0, sizeof(survey));
	cin>>n>>m;
	for (int i=0; i<n; i++) {
		int k; cin>>k;
		while(k--) {
			int food;
			cin>>food;
			survey[food]++;
		}
	}
	int ans=0;
	for (int i=1; i<=m; i++)
		if (survey[i] == n)
			ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

# 操作はl, r番目の人以外の幸福状態を変えない。適切に選んで操作をすると1回1人(l=r)か2人増える)
groups = []

nowDirection = S[0]
sameCount = 1
for i in range(1, N):
    if S[i] == nowDirection:
        sameCount += 1
    else:
        groups.append(sameCount)
        nowDirection = S[i]
        sameCount = 1
groups.append(sameCount)

groupCount = len(groups)
ans = sum(groups) - groupCount

for _ in range(K):
    if groupCount >= 3:
        ans += 2
        groupCount -= 2
    elif groupCount == 2:
        ans += 1
        groupCount -= 1
    else:
        break

print(ans)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

const int MAXN = 200;
char S[MAXN][MAXN + 1];
int D[MAXN][MAXN];
int N;

int main() {
    cin >> N; 
    rep(i, N) cin >> S[i];
    rep(i, N) rep(j, N) {
        if(i == j) D[i][j] = 0;
        else if(S[i][j] == '1') D[i][j] = 1;
        else D[i][j] = INT_MAX;
    }
    // Floyd-Warshall
    rep(k, N) rep(i, N) {
        if(D[i][k] == INT_MAX) continue;
        rep(j, N) {
            if(D[j][k] == INT_MAX) continue;
            D[i][j] = min(D[i][j], D[i][k] + D[j][k]);
        }
    }
    int max_set = 0, start = -1;
    rep(i, N) rep(j, N) {
        if(max_set < D[i][j]) {
            start = i;
            max_set = D[i][j];
        }
    }
    // cout << max_set + 1 << " " << start << "\n";
    vector<vector<int>> group(max_set + 1);
    rep(i, N) group[D[start][i]].push_back(i);
    repp(i, 1, max_set) {
        for(auto &u : group[i]) for(auto &v : group[i]) {
            if(u == v) continue;
            if(S[u][v] == '1') {
                cout << "-1\n";
                return 0;
            }
        }
    }
    cout << max_set + 1 << "\n";
}

Measured memory_bytes: 512
char_list = [ chr(ord('a')+num) for num in range( 26 ) ]
N = int(input())

def Base_10_to_n(X, n):
    if X % n != 0 and (int(X//n)):
        return Base_10_to_n(int(X//n), n)+str(char_list[((X%n)-1)%n])
    elif X % n == 0 and (int(X//n)):
        if X//n == 1:
            return str(char_list[((X%n)-1)%n])
        else:
            return Base_10_to_n(int((X-1)//n), n)+str(char_list[((X%n)-1)%n])
    return str(char_list[((X%n)-1)%n])

print(Base_10_to_n(N,26))

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

using namespace std;

int main(){
    char s[20];
    for(int i=0;i<19;i++){
        cin >> s[i];
    }
    for(int i=0;i<19;i++){
        if(s[i] == ','){
            cout << " " ;
        }
        else{
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

//foreach ($data as &$line) {
//    $line = array_map(function($val) { return (int)$val; }, $line);
//}


$N = $data[0][0];
$L = $data[0][1];
$arr = [];
for ($i = 1; $i <= $N; $i++) {
$arr[] = $data[$i][0];
}

sort($arr);

$ans = join('',$arr);

printf('%s', $ans);


Measured memory_bytes: 4728
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,d;
    scanf("%d%d", &n,&d);

    int ans = n/(d*2+1);
    if(n%(d*2+1)) ans++;
    printf("%d\n", ans);

    
    return 0;
}



Measured memory_bytes: 128
import * as fs from 'fs';

namespace AtCoder.abc102 {
    class ProgramB {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        main(): void {
            const a: number[] = this.args[1].split(' ').map(Number);
            const sorted: number[] = a.sort((a: number, b: number) => a - b);

            console.log(Math.abs(sorted[sorted.length - 1] - sorted[0]));

        }
    }

    new ProgramB(fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')).main();
}

Measured memory_bytes: 7500
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

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

    string a, b, c;
    cin >> a >> b >> c;

    cout << ((a.back() == b.front() && b.back() == c.front()) ? "YES" : "NO") << "\n";

    return 0;
}


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

int main(){
  int H,W;
  char S[6];
  scanf("%d %d\n",&H,&W);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      scanf("%s",S);
      if(strcmp(S,"snuke")==0) printf("%c%d",j+'A',i+1);
    }
  }
  return 0;
}

Measured memory_bytes: 1732
import math
n, d = map(int, input().split())
x = []
for _ in range(n):
    x.append(list(map(int, input().split())))
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        dist = 0.0
        for k in range(d):
            dist += (x[i][k] - x[j][k])**2
            # print(x[i][k], x[j][k])
        if (math.sqrt(dist)).is_integer():
            # print(i, j, dist)
            ans += 1
# print(x)
print(ans)


Measured memory_bytes: 3064
S = input()
ans = []
for n in range(len(S)):
    counter = 0
    for i in range(n,len(S)):
        if (S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] =='T'):
            counter+=1
        else:
            break
    ans.append(counter)
print(max(ans))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rep0(i, n) for(int i = (0); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plli pair<pll,int>
#define mp make_pair
#define endl '\n'
#define pb push_back
#define x first
#define y second
#define pt pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpll vector<pll>
#define vpt vector<pt>
#define pdd pair<double, double>
#define vpdd vector<pair<double, double> >
#define pq priority_queue
//#define _USE_MATH_DEFINES
using namespace std;
#define left(i) (i << 1)
#define right(i) ((i << 1) + 1)


int main()
{
	//freopen("E.in", "r", stdin);
	//freopen("E2.txt", "w", stdout);
	ll a, b, n, c, d;
	cin >> n >> a >> b >> c >> d;
	if (a > b) {
		swap(a, b);
	}

	vector<ll> mins(n), maxs(n);
	mins[0] = a;
	maxs[0] = a;
	mins[n - 1] = a;
	maxs[n - 1] = a;
	for (int i = 1; i <= n - 1; ++i) {
		mins[i] = mins[i - 1] + c;
		maxs[i] = maxs[i - 1] + d;
		ll dif = maxs[i] - mins[i];
	
		ll minsDest = mins[i] - d * (n - 1 - i);
		ll maxDest = maxs[i] - c * (n - 1 - i);
		if (b >= minsDest && b <= maxDest) {
			cout << "YES" << endl;
			return 0;
		}
		

	}
	
		cout << "NO" << endl;
		return 0;


}


Measured memory_bytes: 8064
import sys
N,K = list(map(int,input().split()))
D = input().split()
while True:
    breaked = False
    for i in range(len(str(N))):
        if str(N)[i] in D:
            breaked = True
            break
    if not(breaked):
        print(N)
        sys.exit()
    N += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int K;
    string s;
    cin >> K >> s;

    int N = sz(s);

    if (N <= K) {
        cout << s << endl;
    } else {
        rep(i, K)
        {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3652
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int[] height=new int[300];
        int[] weight=new int[300];
        int i=0;
        while(true){
            height[i]=scan.nextInt();
            weight[i]=scan.nextInt();
            if(height[i]==0&&weight[i]==0) break;
            for(int j=0;j<height[i];j++){
                for(int k=0;k<weight[i];k++){
                    if((j+k)%2==0) System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.println();
            }
            System.out.println();
        }


    }
}


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

void split(int out[], char str[]);
void max(int list[], size_t size, int* max, int* max_i);

int main(void) {
  char *buf;
  int *list, *fixed;
  int num;
  int i;
  int n, r, n_i;
  int now_max;
  int max_i = 0;
  scanf("%d\n", &num);
  buf = (char *)malloc(sizeof(char) * 11 * num);
  list = (int *)malloc(sizeof(int) * num);
  fixed = (int *)malloc(sizeof(int) * num);
  gets(buf);
  split(list, buf);
  max(list, num, &n, &n_i);
  list[n_i] = 0;
  memcpy(fixed, list, sizeof(int) * num);
  now_max = 0;
  for (i = 0; i < num; ++i) {
    if (fixed[i] * 2 > n) {
      fixed[i] = n - fixed[i];
    }
    if (now_max < fixed[i]) {
      max_i = i;
      now_max = fixed[i];
    }
  }
  r = list[max_i];
  printf("%d %d\n", n, r);
  return 0;
}

void split(int out[], char str[]) {
  int i;
  int out_i = 0, tmp_i = 0;
  char tmp[11] = {};
  for (i = 0; ; ++i) {
    if (str[i] == ' ') {
      out[out_i++] = atoi(tmp);
      memset(tmp, '\0', sizeof(tmp));
      tmp_i = 0;
    } else if (str[i] == '\0') {
      out[out_i] = atoi(tmp);
      break;
    } else {
      tmp[tmp_i++] = str[i];
    }
  }
}

void max(int list[], size_t size, int* max, int* max_i) {
  int i;
  *max = 0;
  *max_i = 0;
  for (i = 0; i < size; ++i) {
    if (list[i] > *max) {
      *max = list[i];
      *max_i = i;
    }
  }
}


Measured memory_bytes: 1920
nn = int(input())
s = str(input())
a = s.count('a')
b = s.count('b')
c = s.count('c')
d = s.count('d')
e = s.count('e')
f = s.count('f')
g = s.count('g')
h = s.count('h')
i = s.count('i')
j = s.count('j')
k = s.count('k')
l = s.count('l')
m = s.count('m')
n = s.count('n')
o = s.count('o')
p = s.count('p')
q = s.count('q')
r = s.count('r')
ss = s.count('s')
t = s.count('t')
u = s.count('u')
v = s.count('v')
w = s.count('w')
x = s.count('x')
y = s.count('y')
z = s.count('z')
print(((q+1)*(w+1)*(e+1)*(r+1)*(t+1)*(y+1)*(1+u)*(1+i)*(o+1)*(p+1)*(a+1)*(1+ss)*(1+d)*(1+f)*(1+g)*(1+h)*(1+j)*(1+k)*(1+l)*(1+z)*(x+1)*(c+1)*(1+v)*(b+1)*(n+1)*(m+1)-1)%(10**9+7))


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


Measured memory_bytes: 128
#include <stdio.h>

int main() {
  int i;
  char str[20];
  for(i = 0; i < 19; i++) {
    scanf("%s", str);
    if(str[i] == ',') {
      printf(" ");
    } else {
      printf("%c", str[i]);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
n, x = map(int, input().split())

def dfs(i, sum, t):
    if t == 0:
        if sum == x:
            return 1
        else:
            return 0
    else:
        if sum >= x:
            return 0
        elif i == 0:
            return 0
        else:
            return dfs(i - 1, sum + i - 1, t - 1) + dfs(i - 1, sum, t)

while n != 0 or x != 0:
    c = dfs(n + 1, 0, 3)
    print(c)
    n, x = map(int, input().split())



Measured memory_bytes: 5608
from sys import stdin
def main():
    n = int(stdin.readline().rstrip())
    a = list(map(int,stdin.readline().rstrip().split()))
    mod = 10**9+7
    point = 0
    for i in range(61):
        now = sum(1 for j in a if(j >> i)&1)
        point += now*(n-now)*(2**i)%mod
        point %= mod
    print(point)
if __name__ == "__main__":
    main()

Measured memory_bytes: 42212
#include<iostream>
using namespace std;
int main(){
    long long x,a[5],k=0;
    int i,j;
    cin >> x;
    for(i=0;i<5;i++){
        cin >> a[i];
        if(a[i]<a[k])
            k=i;
    }
    cout << (x+a[k]-1)/a[k]+4 << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin >> num.at(i);
  }
  
  sort(num.begin(),num.end());
  
  int max = abs( num.back() - num.front() );
  
  cout << max << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;

    vi v(n);
    for(int &x:v) cin>>x;
        int count = 0;

    for(int i=0;i<n-2;i++){
        for(int j=i + 1; j<n-1; j++){
            for(int k=j + 1; k<n; k++){
                if(v[i] == v[j] || v[j] == v[k] || v[i] == v[k]) continue;
                vi temp;
                temp.pb(v[i]);
                temp.pb(v[j]);
                temp.pb(v[k]);
                sort(all(temp));

                if(temp[0] + temp[1] > temp[2]){
                    // cout<<temp[0]<<' '<<temp[1]<<' '<<temp[2]<<endl;
                    count++;
                }
            }
        }
    }

    cout<<count;
} 

Measured memory_bytes: 3648
def read_input():
    w, a, b = map(int, input().split())

    return (a, a + w), (b, b + w)

def submit():
    a, b = read_input()

    if a[0] < b[0]:
        print(max(b[0] - a[1], 0))
    else:
        print(max(a[0] - b[1], 0))


if __name__ == '__main__':
    submit()


Measured memory_bytes: 38384
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int tetra[16] = {0};
	int digit;
	
	while (scanf("%d", &n)){
		if (n == -1){
			break;
		}
		digit = 0;
		if (n == 0){
			printf("%d", n);
		}
		while (n > 0){
			tetra[digit] = n % 4;
			n /= 4;
			digit++;
		}
		for (i = digit - 1; i >= 0 ; i--){
			printf("%d", tetra[i]);
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int n, k;
    double sum = 0;
    double ans = 0;
    cin >> n >> k;
    vector<double> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    vector <double> s(n + 1);
    for (int i = 1; i <= n; i++) {
        sum += (1 + p.at(i - 1)) / 2;
        s.at(i) = sum;
    }
    for (int i = 0; i < n - k + 1; i++) {
        ans = max(ans, s.at(i + k) - s.at(i));
    }
    cout << fixed << setprecision(12) << ans << endl;

}

Measured memory_bytes: 6488
def solve(N, K, Xs):
    plus = sorted([x for x in Xs if x >= 0])
    minus = sorted([abs(x) for x in Xs if x < 0])
    ans = 10 ** 9
    for i in range(0, K + 1):
        j = K - i
        if i <= len(plus) and i == K:
            p = plus[i-1]
            ans = min(ans, p)
        elif j <= len(minus) and j == K:
            m = minus[j-1]
            ans = min(ans, m)
        elif i <= len(plus) and j <= len(minus):
            p = plus[i - 1]
            m = minus[j - 1]
            ans = min(ans, p * 2 + m, m * 2 + p)

    return ans
  
if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    Xs = list(map(int, input().split(" ")))
    print(solve(N, K, Xs))


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int a , b; 
	cin >> a >> b; 
	cout << a * b<< endl ;
	
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        // 入力(s)
        String s = sc.next();

        System.out.println("aiueo".indexOf(s) >= 0 ? "vowel" : "consonant");
        sc.close();
    }
}

Measured memory_bytes: 21588
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

long long int combination(long long int n, long long int r)
{
	//printf("n:%lld, r:%lld\n", n, r);
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)



int main(){
	char str[1010];
	scanf("%s", str);
	int len = strlen(str);
	//printf("%d\n", len);
	if(str[len-1] == 's') printf("%ses\n", str);
	else printf("%ss\n", str);

	//printf("%lld\n", ans);
	
	return 0;
}



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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int A, B;
    cin >> A >> B;

    int answer = A + B;
    chmax(answer, A - B);
    chmax(answer, A * B);

    cout << answer << endl;
    
    return 0;
}


Measured memory_bytes: 256
"""
A,B = map(int,input().split())
answer = 'Yes'

if A%2 == 0:
	answer = 'No'
if B%2 == 0:
	answer = 'No'
	
print(answer)
"""

N = int(input())
W = list(map(str,[input() for i in range(N)]))

answer = 'Yes'

#重複がないか判定する
ww = set(W)
if len(W) != len(ww):
	answer = 'No'

#前の単語の最後の文字を、listから取り出す→最後の文字を指定で無理矢理取り出す。
#これと、次の単語の文字を比較。
for i in range(1,N):
	wnext = W[i]
	wforword = W[i-1]
	
	if wnext[0] != wforword[len(wforword)-1]:
		answer = 'No'

print(answer)

Measured memory_bytes: 3064
N, M = map(int, input().split())
L = 100000
dp = [[1000000001 for _ in range(L+1)] for _ in range(N+1)]
W, V = [], []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
dp[0][0] = 0
for i in range(N):
    for j in range(L+1):
        if j - V[i] >= 0:
            dp[i+1][j] = min(dp[i][j], dp[i][j-V[i]] + W[i])
        else:
            dp[i+1][j] = dp[i][j]
for i, d in enumerate(dp[N]):
    if d <= M:
        maxv = i
print(maxv)

Measured memory_bytes: 171656
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    P = input_nums()
    Q = sorted(P)
    diff = [1 for p, q in zip(P, Q) if p != q]
    if sum(diff) <= 2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define DEBUG false
int INF = 1<<30;
int Min(int a,int b){
  if(a<b){
    return a;
  }
  return b;
}
int gcd(int a,int b){
  if(a < b){
    int temp=a;
    a=b;
    b=temp;
  }
  if(b==0)return a;
  return gcd(b,a%b);
}
int main(void){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  vector<pair<pair<int,int> ,int> >data(n);
  for(int i=0;i<n;i++){
    cin>>data[i].first.first>>data[i].first.second>>data[i].second;
  }
  if(DEBUG)cout<<"Check"<<endl;
  int***dp=new int**[n+1];
  for(int i=0;i<n;i++){
    dp[i]=new int*[401];
    for(int j=0;j<=400;j++){
      dp[i][j]=new int[401];
      for(int k=0;k<=400;k++){
        dp[i][j][k]=INF;
      }
    }
  }
  if(DEBUG)cout<<"Finish"<<endl;
  dp[0][0][0]=0;
  dp[0][data[0].first.first][data[0].first.second]=data[0].second;
  int pre_x=data[0].first.first;
  int pre_y=data[0].first.second;
  if(DEBUG)cout<<"Start"<<endl;
  for(int i=1;i<n;i++){
    int a=data[i].first.first;
    int b=data[i].first.second;
    int c=data[i].second;
    if(DEBUG)cout<<a<<' '<<b<<' '<<c<<endl;
    for(int j=0;j<=pre_x;j++){
      for(int k=0;k<=pre_y;k++){
        dp[i][j][k]=Min(dp[i-1][j][k],dp[i][j][k]);
        dp[i][j+a][k+b]=Min(dp[i-1][j+a][k+b],dp[i-1][j][k]+c);
      }
    }
    pre_x+=a;
    pre_y+=b;
  }
  if(DEBUG)cout<<"Next"<<endl;
  int minimum=INF;
  for(int i=1;i<=pre_x;i++){
    for(int j=1;j<=pre_y;j++){
      int k=gcd(i,j);
      if(DEBUG)cout<<k<<endl;
      if(i/k ==ma && j/k ==mb){
        minimum=Min(dp[n-1][i][j],minimum);
      }
    }
  }
  if(minimum!=INF){
    cout<<minimum<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 25728
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n; cin >> n;
    int sum = 0, lng = 0;
    while (n--) {
        int l; cin >> l;
        lng = max(lng, l);
        sum += l;
    }
    sum -= lng;
    cout << (lng < sum ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3636
#include <stdio.h>

int binarysearch(int a[], int n, int key) {
  int r = 0;
  int l = n;
  int i;
  while (l - r >= 1) {
    i = (r + l) / 2;
    if (a[i] == key)
      return 1;
    else if (a[i] < key) 
      r = i + 1;
    else
      l = i;
  }
  return 0;
}

int main()
{
  int n, q;
  int s[100000];
  int t[50000];
  int sum = 0;

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &s[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &t[i]);
    if (binarysearch(s, n, t[i]))
      sum++;
  }
  printf("%d\n", sum);

  return 0;
}



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

int main() {
  char S[101];
  scanf("%s", S);

  int ans = 0;
  int N = strlen(S);
  for(int i = 0; i < N; ++i) {
    if (S[i] != S[N - 1 - i]) ans++;
  }

  printf("%d\n", ans / 2);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.append(-1)
up = []
pre = False
sw = False
for i in range(1,N+1):
    if A[i] > A[i-1]:
        sw = True
    elif A[i] < A[i-1]:
        sw = False
    if sw != pre:
        up.append(i-1)
    pre = sw
if up == []:
    print(1000)
    exit()
money = 1000
p = False
for j in up:
    if p == False:
        stock = money//A[j]
        money -= stock*A[j]
    else:
        money += stock*A[j]
        stock = 0
    p = not p
print(money)

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

using namespace std;

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

	int current = H[0] - 1;
	for (int i = 0; i < N; i++) {
		if (H[i] < current) {
			cout << "No" << endl;
			return 0;
		}
		current = H[i] == current ? current : H[i] - 1;
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int calc(int num)
{
 int cnt=0;
 for(int i=1;i<=num;i++)
  if(num%i==0)cnt++;
 return cnt;
}
int main()
{
 int n,ans=0;
 scanf("%d",&n);
 for(int i=1;i<=n;i+=2)
  if(calc(i)==8)ans++;
 printf("%d",ans);
 return 0;
}

Measured memory_bytes: 128
import sys
import numpy as np

def excute_min_m(a):
    m = len(a)
    for i,a_i in enumerate(a[:-1]):
        for j,a_j in enumerate(a[i+1:]):
            if a_i == a_j:
                m = min(j+i+2, m)
    print(m)

def solve(s: int):
    a = []
    a.append(s)
    tmp = s
    flag = False
    b = [4, 2, 1, 4]
    while not flag:
        if tmp%2==0:
            tmp = tmp//2
        else:
            tmp = 3*tmp + 1
        a.append(tmp)
        if len(a) >= 4 and a[-4:] == b:
            flag = True
    excute_min_m(a)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = int(next(tokens))  # type: int
    solve(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12484
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (K, X) = get!(i64, i64);

    // 座標X - K + 1 から X + K - 1 まで石が置かれる
    let ans = ((X - K + 1)..(X + K)).into_iter()
        .map(|i| i.to_string())
        .collect::<Vec<_>>()
        .join(" ");

    println!("{}", ans);
}


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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a (n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i - 1]) {
      a[i]--;
    }
  }
  if (is_sorted(a.begin(), a.end())) {
    puts ("Yes");
  } else{
    puts ("No");
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuffer str = new StringBuffer(sc.next());
		String S = str.reverse().toString();
		sc.close();
		System.out.println(solve(S));
	}
	
	public static String solve(String S) {
		int index = 0;
		while(index+5<S.length()) {
			if(S.substring(index,index+5).equals("esare")) {
				index += 5;
			}else if(S.substring(index,index+5).equals("maerd")) {
				index += 5;
			}else if(S.substring(index,index+6).equals("resare")) {
				index += 6;
			}else if(S.substring(index,index+7).equals("remaerd")) {
				index += 7;
			}else {
				return "NO";
			}
		}
		return "YES";
	}
}

Measured memory_bytes: 29736
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>=0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r){
  if(l<r){
    return gcd(r, l);
  }
  if(r == 0){
    return l;
  }
  return gcd(r, l % r);
}

template<class T>
vector<T> accum_sum(vector<T> a){
  vector<T> b(a.size() + 1);
  b[0] = a[0];
  rep(i, a.size()){
    b[i + 1] = b[i] + a[i];
  }
  return b;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(A);readl(B);
  if(B % A){
    cout << B - A << endl;
  }else{
    cout << A + B;
  }
}
#endif


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

int main(void) {
    int n;
    cin >> n;
    vector< int > a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }    
    sort(a.begin(), a.end());
    long long int sum = 0;
    if (n % 2 == 0) {
        for (int i = 0; i < n/2; i++) {
            sum += a[n-1-i];
        }
        for (int i = 1; i < n/2; i++) {
            sum += a[n-1-i];
        }
    } else {
        for (int i = 0; i < n/2; i++) {
            sum += a[n-1-i];
        }
        for (int i = 1; i < n/2+1; i++) {
            sum += a[n-1-i];
        }
    }


    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4000
# ABC 152 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
snm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
c=[[0]*10 for _ in range(10)]

for i in range(1,n+1):
    sl=str(i)
    sl_s=int(sl[0])
    sl_e=int(sl[-1])
    c[sl_s][sl_e]+=1

ans=0
for i in range(1,10):
    for j in range(1,10):
        ans+=c[i][j]*c[j][i]
print(ans)

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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	int Q;
	cin >> Q;
	for(int q=0; q < Q; q++){
		long long a, b;
		cin >> a >> b;
		if(a > b)swap(a, b);
		if(a + 1 >= b){
			cout << 2*a -2 << "\n";
		}else{
			long long ok = 1, ng = 1e9+5;
			while(abs(ok-ng)>1){
				long long mid = (ok+ng)/2;
				bool flag = false;
				if(mid * mid < a*b)flag=true;
				if(flag)ok=mid;
				else ng=mid;
			}
			long long c = ok;
			if(c*(c+1) >= a*b)cout << 2*c -2 << "\n";
			else cout << 2 * c - 1 << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
for i in range(q): a[i], b[i], c[i], d[i] = map(int, input().split())
A = [1] * 10
 
def check(A, ans):
  t = 0
  for i in range(q):
    if A[b[i]-1] - A[a[i]-1] == c[i]:
      t += d[i]
  if ans < t: return t
  else: return ans
 
ans = 0
for i1 in range(1, m+1):
  A[1] = i1
  for i2 in range(i1, m+1):
    A[2] = i2
    for i3 in range(i2, m+1):
      A[3] = i3
      for i4 in range(i3, m+1):
        A[4] = i4
        for i5 in range(i4, m+1):
          A[5] = i5
          for i6 in range(i5, m+1):
            A[6] = i6
            for i7 in range(i6, m+1):
              A[7] = i7
              for i8 in range(i7, m+1):
                A[8] = i8
                for i9 in range(i8, m+1):
                  A[9] = i9
                  ans = check(A, ans)
print(ans)

Measured memory_bytes: 9308
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int Num[] = new int[N + 1];
		Num[0] = 0;
		int x = 0;
		for (int i = 1; i < N + 1; i++) {
			x = scanner.nextInt();
			Num[x] = i;
		}
		for (int j = 1; j < N + 1; j++) {
			System.out.println(Num[j]);
		}
	}
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int x;
	cin>>x;
	
	if(x == 0)
	cout<<1<<"\n";
	else
	cout<<0<<"\n";
	

}


Measured memory_bytes: 3616
N = int(input())
A = list(map(int, input().split()))
ans = 0
alen = len(A)

r = 0
l = 0
p1, p2 = 0, 1
for i in range(N):
    if p1 + p2 > alen:
        break
    if r >= l:
        l += A[p1]
        p1 += 1
    else:
        r += A[-p2]
        p2 += 1 
print(abs(l- r))

Measured memory_bytes: 26220
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  [n, m] <- readInts
  edges <- replicateM m $ do
    [a, b] <- readInts
    return (a-1, b-1)
  let graph = createGraph n edges
  print $ solve n graph

type Graph = [[Int]]

createGraph :: Int -> [(Int, Int)] -> Graph
createGraph n edges = foldr addEdges (replicate n []) edges
  where updateGraph i v graph = concat [take i graph, [v : (graph !! i)], drop (i+1) graph]
        addEdges (a, b) = updateGraph a b . updateGraph b a

solve :: Int -> Graph -> Int
solve n graph = dfs 0 1 [0]
  where dfs i depth visited
          | depth == n = 1
        dfs i depth visited
          | nexts == [] = 0
          | otherwise = sum $ flip map nexts $ \w -> dfs w (depth+1) (w:visited)
            where nexts = filter (not . (`elem` visited)) $ graph !! i

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,M;
    cin >> N >> M;
    vector<vector<int>>s(M);
    vector<int>p(M);
    for(int i = 0; i < M; i++) {
        int k;cin >> k;
        for(int j = 0; j < k; j++) {
            int X;cin >> X;X--;
            s[i].push_back(X);
        }
    }
    for(int i = 0; i < M; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << N); bit++) {
        bool ok = true;
        for(int i = 0; i < M; i++) {
            int cnt = 0;
            for(int j = 0; j < s[i].size(); j++) {
                if(1 & (bit >> s[i][j])) {
                    cnt++;
                }
            }
            if(cnt%2 != p[i]) {
                ok = false;
            }
        }
        if(ok) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    cin>>ch;
    if(ch=='A')
        cout<<"T"<<endl;
    else if(ch=='T')
        cout<<"A"<<endl;
    else if(ch=='C')
        cout<<"G"<<endl;
    else
        cout<<"C"<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B;
    cin >> A >> B;
    if(A >= 10 || B >= 10){
        cout << -1 << endl;
    }else{
        cout << A * B << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

//debug処理
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int k, n;
int a[224514];
signed main() {
	cin >> k >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n - 1)chmax(ans, a[i + 1] - a[i]);
	ans = max(ans, k - a[n - 1] + a[0]);
	cout << k - ans << endl;
	ggr
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        new Program().Solve();
    }
    
    public void Solve()
    {
        var n=int.Parse(Console.ReadLine());
        int ans=0;
        for(int i=0;i<n;i++)
        {
               var l=Console.ReadLine().Split(' ');
               var left=int.Parse(l[0]);
               var right=int.Parse(l[1]);
               ans+=right-left+1;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
h1,m1,h2,m2,k=map(int,input().split(" "))
if h1>h2:
  h2=h2+24
if m2>=m1:
  mk=m2-m1
  T=mk+(h2-h1)*60
else:
  mk=m2+60-m1
  T=mk+(h2-h1-1)*60
print(T-k)

Measured memory_bytes: 9180
def pow(a,b,c):
    ans = 1
    while b > 0:
        if b & 1:
            ans = ans*a % c
        a = a*a % c
        b = b >> 1
    return ans
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,c-2,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = ans + mod
print(ans)


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

int n, a, x, y, ans;
vector<P> G[20];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n){
        cin >> a;
        rep(j,a){
            cin >> x >> y;
            G[i].push_back({x-1,y});
        }
    }
    rep(bt,1<<n){
        bool ok = true;
        rep(i,n) if(bt>>i&1){
            for(P it: G[i]) if((bt>>it.first&1) ^ it.second) ok = false;
        }
        if(ok) ans = max(ans, (int)__builtin_popcount(bt));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main() {
  string S;

  cin >> S;

  if (S.size() == 3) reverse(S.begin(), S.end());

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 3592