akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    s = input()

    g = [[]]
    t = []
    for i in s:
        t.append(i)
        if t != g[-1]:
            g.append(t)
            t = []

    print(len(g) - 1)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 59420
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n;
    string s;
    cin>>n>>s;
    ll ans=n;
    ll west=0;
    ll east=0;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='E')
            east++;
    }
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='E')
        {
            east--;
        }
        if(i)
        {
            if(s[i-1]=='W')
                west++;
        }
        ans=min(ans,east+west);
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 3868
using System.Linq;
using System.Collections.Generic;
using System;
using System.Text;

    public class P
    {
        public int area { get; set; }
        public int id { get; set; }
    }

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    public static void print(Stack<P> st)
    {
        var n = st.Count();
        if (n == 0) { Console.WriteLine(0); Console.WriteLine(0); return; }
        var asum = st.Pop().area;
        var sb = new StringBuilder(10000);
        sb.Append(asum);
        for (int i = 1; i < n; i++)
        {
            var w = st.Pop();
            sb.Insert(0, " ");
            sb.Insert(0, w.area);
            asum += w.area;
        }
        sb.Insert(0, " "); sb.Insert(0, n);
        Console.WriteLine(asum);
        Console.WriteLine(sb.ToString());
    }
    public static void getAns(string s)
    {
        var st1 = new Stack<int>();
        var st2 = new Stack<P>();
        for (int i = 0; i < s.Length; i++)
            if (s[i] == '\\') st1.Push(i);
            else if (s[i] == '/' && st1.Count() > 0)
            {
                var id = st1.Pop();
                var area = i - id;
                while (st2.Count() > 0 && id <= st2.Peek().id)
                {
                    area += st2.Peek().area;
                    st2.Pop();
                }
                st2.Push(new P { id = id, area = area });
            }
        print(st2);
    }
}



Measured memory_bytes: 10856
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

def isOdd(num):
    if num % 2 == 0:
        return False
    else:
        return True

def solve(num):
    if isOdd(num):
        if (num // 2) % 2 == 0:
            return 1
        else:
            return 0
    else:
        return solve(num+1) ^ (num+1) 


print(solve(B) ^ solve(A-1))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


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

  int cnt[100001] = {0};
  Rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    cnt[a]++; cnt[b]++;
  }

  bool flag = true;
  Rep(i, N) {
    if( cnt[i] % 2 ) flag = false;
  }

  if( flag ) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
map<int,int> mp;
for(int i=0;i<n;i++){int t;cin>>t;mp[t]++;}
int ans=0;
for(auto p:mp)ans+=p.second-(p.first>p.second?0:p.first);
cout<<ans<<endl;
}

Measured memory_bytes: 4736
N = int(input())
num = ['3', '5', '7']
array = ['']
len_array = [0, 0, len(array)]
for i in range(len(str(N))):
    array.extend(array[len_array[1]:] * 3)
    len_array = [len_array[1], len_array[2], len(array)]
    for j in range(len_array[1], len_array[2]):
        diff_len = len_array[2] - len_array[1]
        for k in range(3):
            if k * diff_len // 3 + len_array[1] <= j < (k + 1) * diff_len // 3 + len_array[1]:
                array[j] += num[k]
array = [int(array[i]) for i in range(len(array)) if set(num) <= set(array[i])]
array = list(filter(lambda i: i <= N, array))
print(len(array))

Measured memory_bytes: 6040
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;
int r,c,k ;
int a[3003][3003] ;
int dp[3003][3003][5] ;

int dfs(int i,int j,int cnt){
	if(i>r || j>c || cnt > 3) return 0 ;
	int& ans = dp[i][j][cnt] ;
	if(ans != -1) return ans ;
	ans = max(dfs(i+1,j,0),dfs(i,j+1,cnt)) ;
	if(cnt<3){
		ans = max(ans,dfs(i+1,j,0)+a[i][j]) ;
		ans = max(ans,dfs(i,j+1,cnt+1)+a[i][j]) ;
	}
	return ans ;
}

void solve(){
	cin >> r >> c >> k ;
	forn(i,k){
		int x,y,c ;
		cin >> x >> y >> c ;
		a[x][y] = c ;
	}
	ms(dp,-1) ;
	cout << dfs(1,1,0) << endl ;
}


int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
}


Measured memory_bytes: 426676
from collections import deque
N,M=map(int,input().split())
to=[[] for _ in range(N)]
for _ in range(M):
  a,b=map(int,input().split())
  to[a-1].append(b-1)
  to[b-1].append(a-1)

q=deque([0])
r=[None]*N
r[0]=0
while q:
  x=q.popleft()
  for i in to[x]:
    if r[i] is None:
      q.append(i)
      r[i]=x+1
      
print('Yes')
for i in range(N):
  if r[i]!=0:
    print(r[i])

Measured memory_bytes: 95064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int a,b;
  int coin[]={1000,500,100};
  int ans[4];
  while(cin>>a>>b){
    if(a==0&&b==0)break;
    int ret=abs(a-b);
    ans[0]=ans[1]=ans[2]=0;
    for(int i=0;i<3;i++){
      for(;;){
	if(coin[i]<=ret){
	  ret-=coin[i];
	  ans[i]++;
	}else{
	  break;
	}
      }
    }
    cout<<ans[2]<<" "<<ans[1]<<" "<<ans[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int i, data;
    int count = 0;
    for(i = 0; i < n; i ++)
    {
    	cin >> data;
    	if(data != i + 1)
    		count ++;
    }

    if(count <= 2)
    	cout << "YES" << endl;
    else
    	cout << "NO" << endl;
}

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;
fn main() {
    input! {
        c: char
    }
    if 'A' <= c && c <= 'Z' {
        println!("A");
    }
    if 'a' <= c && c <= 'z' {
        println!("a");
    }
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    string s;
    cin>>s;
    int n=s.size();
    
    ll r=0,l=0,ans=0;
    rep(i,n-1){
        if(s[i]=='>' && s[i+1]=='<'){
            l++;
            ll a=max(r,l);
            ll b=min(r,l)-1;
            ans+=a*(a+1)/2;
            ans+=b*(b+1)/2;
            r=0,l=0;
        }
        else if(s[i]=='>') l++;
        else r++;
    }
    if(s[n-1]=='<') r++;
    else l++;

    ll a=max(r,l);
    ll b=min(r,l)-1;
    ans+=a*(a+1)/2;
    ans+=b*(b+1)/2;



    cout<<ans<<endl;
    
}




Measured memory_bytes: 4252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=2010;
int ans=1<<30;
int L[N],R[N];
char a[N],b[N];
struct Dat {
    int x,y;
    inline bool operator < (const Dat &A) const {
	return x==A.x?y<A.y:x<A.x;
    }
} v[N],g[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void solve(int tp,int t) {
    int k=0;
    sort(v+1,v+1+tp);
    for(int i=1;i<=tp;i++) {
	while(k&&v[i].y>=g[k].y) --k;
	g[++k]=v[i];
    }
    if(!k) ans=min(ans,t);
    else {
	ans=min(ans,t+min(g[1].y,g[k].x)*2);
	for(int i=1;i<k;i++)
	    ans=min(ans,t+g[i].x*2+g[i+1].y*2);
    }
}
int main() {
    scanf("%s%s",a,b);
    int n=strlen(a),p=0;
    for(int i=0;i<n;i++) a[i]-='0',b[i]-='0';
    while(p<n&&!b[p]) ++p;
    for(int i=0;i<n;i++) {
	int j=(p+i)%n;
	if(!b[j]) L[j]=L[(j-1+n)%n]+1;
	j=(p-i+n)%n;
	if(!b[j]) R[j]=R[(j+1)%n]+1;
    }
    for(int t=0;t<n;t++) {
	if(p==n) {
	    for(int i=0;i<n;i++) {
		if(a[(t+i)%n]!=b[i]) break;
		if(i==n-1) ans=min(ans,min(t,n-t));
	    }
	}
	else {
	    int tp=0,c=0;
	    for(int i=0;i<n;i++) {
		int j=(t+i)%n;
		if(a[j]!=b[i]&&(++c,L[j]>t))
		    v[++tp]=(Dat){L[j]-t,R[j]};
	    }
	    solve(tp,t+c),tp=0;
	    for(int i=0;i<n;i++) {
		int j=(t+i)%n;
		if(a[j]!=b[i]&&R[j]>n-t)
		    v[++tp]=(Dat){L[j],R[j]-n+t};
	    }
	    solve(tp,n-t+c);
	}
    }
    cout<<(ans==1<<30?-1:ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int M, K;
	cin >> M >> K;
  	M = 1 << M;
	if (K < M && M != 2) {
		for (int i = 0;i < M;++ i) {
			if (i == K) continue;
			cout << i << ' ';
		}
		cout << K << ' ';
		for (int i = M - 1;i >= 0;-- i) {
			if (i == K) continue;
			cout << i << ' ';
		}
		cout << K << endl;
	} else if (M == 2 && K == 0) cout << "0 0 1 1" << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1792
# 問題文の意味がわからんコンテスト
# 0の場合も自分自身を照らす、っての気づくところからやっと読解
# Kを5000兆回やったあとはすべての要素がNになっとる この収束はわりと早いらしい
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(min(k, 100)):
    b = [0] * (n + 1)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]
    a = b[:n]
print(" ".join(list(map(str, a))))

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

using namespace std;

double Value;
string HexInput, BinaryInput;

const string ConvertTable[16] = {
	"0000","0001","0010","0011",
	"0100","0101","0110","0111",
	"1000","1001","1010","1011",
	"1100","1101","1110","1111",
};


void changeToBinary() {
	int index;

	BinaryInput = "";
	for (int i = 0; i < 8; ++i) {
		switch (HexInput[i]) {
			case 'a':index = 10; break;
			case 'b':index = 11; break;
			case 'c':index = 12; break;
			case 'd':index = 13; break;
			case 'e':index = 14; break;
			case 'f':index = 15; break;
			default :index = HexInput[i] - '0'; break;
		}
		BinaryInput += ConvertTable[index];
	}
	reverse(BinaryInput.begin(), BinaryInput.end());
	//cout << "outBinary:" << BinaryInput << endl;
}

void solve() {
	int countOfFraction;
	
	Value = 0;
	countOfFraction = 1;
	for (int i = 0; i < 7; ++i) {
		if (BinaryInput[6-i] != '0') {
			Value += pow(0.5, i + 1);
			countOfFraction = i + 1;
		}
	}
	//cout << Value << " : cnt=" << countOfFraction << endl;

	for (int i = 7; i < 31; ++i) {
		if (BinaryInput[i] != '0') {
			Value += pow(2, i-7);
		}
	}
	if (BinaryInput[31] == '1') {
		cout << "-";
	}
	cout << fixed << setprecision(countOfFraction) << Value << endl;
}

int main() {
	int n;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> HexInput;
		changeToBinary();
		solve();
	}
	
	return 0;
}



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

int p_string(string str) {
    int len = str.length();
    int res = 0;

    for (int i = 0; i < len / 2; i++) {
        if (str[i] == str[len - i - 1]){
            res++;
        }
    }
    if (res == len / 2) {
        return 1;
    }
    return 0;
}

int main() {

    string str;
    cin >> str;

    int len = str.length();

    string str_p1 = str.substr(0, len / 2);
    string str_p2 = str.substr((len + 3) / 2 - 1, len / 2);

    if (p_string(str) && (p_string(str_p1) && p_string(str_p2))) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import itertools
n = int(input())
lis = list(map(int,input().split()))
li = list(map(int,input().split()))
su = ""
for i in range(n):
    su += str(1+i)
cnt = 1
for x in itertools.permutations([i for i in range(1,n+1)]):
    if list(x) == lis:
        a1 = cnt
    if list(x) == li:
        a2 = cnt
    cnt += 1
print(abs(a2-a1))

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

/*
nCk mod. p
https://drken1215.hatenablog.com/entry/2018/06/08/210000
*/
const ll MAX = 510000;
const ll MOD = 1e9+7;

ll 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;
    }
}

// 二項係数計算
long long COM(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;
}

// 検索タグ
int main() {
	// 入力
	ll n,k;cin>>n>>k;

	// 解法
	ll ans = 0;
	
    // 前処理
    COMinit();

	// k = 空室にできる部屋の数
	REP(i,k+1){ // i = 空室にする部屋の数
		if (i>n-1)break; // 空室にできるのはn-1部屋まで
		ll tmp = COM(n-1, n-1-i) * COM(n, i);
		// printf("i: %lld, tmp: %lld\n", i, tmp);
		ans += COM(n-1, n-1-i) * COM(n, i);
		ans %= MOD;
	}
 
	//出力
	printf("%lld\n", ans);
}


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

int main()
{
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<k){
		cout<<n*x<<endl;
	}
	else{
	int ans=((n-k)*y)+(k*x);
	cout<<ans<<endl;}

	
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


ll gcd(ll a, ll b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

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

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

	ll sum = 0;

	reple(i, 1, K)
	{
		reple(j, 1, K)
		{
			ll tmp = gcd(i, j);

			reple(k, 1, K)
			{
				sum += gcd(tmp, k);
			}
		}
	}

	cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N, H;
	scanf("%d%d", &N, &H);

	int32_t a_max = 0, b[100000];
	for (int32_t i = 0; i < N; i++) {
		int32_t a;
		scanf("%d%d", &a, &b[i]);
		a_max = max(a_max, a);
	}
	sort(b, b + N, greater<int32_t>());

	int64_t sum[100001];
	sum[0] = 0;
	for (int32_t i = 1; i <= N; i++)
		sum[i] = sum[i - 1] + (int64_t)b[i - 1];

	int64_t res = numeric_limits<int64_t>::max();
	for (int32_t k = 0; k <= N; k++) {
		int64_t hit_point = (int64_t)H - sum[k];
		int64_t attacks = k;
		if (hit_point > 0) {
			attacks += hit_point / a_max;
			if (hit_point % a_max > 0)
				attacks++;
		}
		res = min(res, attacks);
	}

	printf("%" PRId64 "\n", res);

	return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>k >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	auto d = a;
	d.push_back(a[0]+k);
	ll mx = 0;
	rep(i, n){
		mx = max(mx, d[i+1] - d[i]);
	}
	//for(auto x :d) cerr<<x<<" "; dbg();
	cout << k - mx <<"\n";
	return 0;
}


Measured memory_bytes: 7424
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main() {
	
    set<int> s;

    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        s.insert(d);
    }

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

    return 0;
}

Measured memory_bytes: 888
s=input()
alpha=list('abcdefghijklmnopqrstuvwxyz')
ans=[0]*26
for i in range(len(s)):
  for j in range(26):
    if s[i]==alpha[j]:
      ans[j]+=1
for i in range(26):
  if ans[i]%2==1:
    print('No')
    break
  if i==25:
    print('Yes')

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static long C(long n, long k)
        {
            long bunbo = 1;
            long bunsi = 1;
            for (long i = n - k; i <= n; i++)
                bunsi *= i;
            for (long i = 1; i <= n - k; i++)
                bunbo *= i;
            return bunsi / bunbo;
        }
        bool f = false;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var n = Read();
            var p = Reads();
            long min =p[0];
            long ans = 1;
            for (int i = 1; i < n; i++)
            {
                if (p[i] <= min)
                {
                    ans++;
                    min = p[i];
                }
            }

            Console.WriteLine(ans);
   
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 36048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s ;
  int n=sz(s);
  if(n==2) cout << s << endl;
  else {
    for(int i=2; i>=0; i--) cout << s[i];
    cout  << endl;
  }
  return 0;
}


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

int main(){
	int seg[] = {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
	int n;
	while(cin >> n,n != -1){
		int prev = 0;
		for(int i = 0;i < n;i++){
			int t,next;
			cin >> t;
			next = seg[t] ^ prev;
			for(int j = 6;j >= 0;j--){
				cout << (next >> j & 1);
			}
			cout << endl;
			prev = seg[t];
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
typedef long long ll;
#define MOD 1000000007

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;}

const ll INF = 1LL << 60;

int main(){
  ll n;
  cin >> n;
  ll a[100000],ans=0;
  FOR(i,n){
    cin >> a[i];
  }
ll v;
  for(int i=1;i<31;i++){
    v=pow(2,i);
    FOR(j,n){
      
      if(a[j]%v==0)ans++;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 384
i = 0
ans = 1
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    while ans<10**18 and i<len(a):
        ans*=a[i]
        i+=1
    if (ans<=10**18):
        print(ans)
    else:
        print(-1)

Measured memory_bytes: 21492
n = int(input())
h = list(map(int,input().split()))
cnt = 0
ans = [0]
for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt += 1
  else:
    if ans[0] > cnt:
      cnt = 0
    else:
      ans.pop()
      ans.append(cnt)
      cnt = 0
ans.append(cnt)
print(max(ans))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> like(m + 1);
    for(int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++) {
            int a;
            cin >> a;
            like[a]++;
        }
    }
    cout << count(like.begin(), like.end(), n) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    System.out.println((a * n) <= b ? (a * n) : b);
  }
}

Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int A, B;
	cin >> A >> B;
	if (A == B) {
		cout << A + B << endl;
	}
	else {
		cout << 2 * max(A, B) - 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    int ans = a + b;
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    out(ans);
}


Measured memory_bytes: 256
a = int(input())
b = input()
c = {}
for i in range(a):
    if b[i] not in c:
        c[b[i]] = 1
    else:
        c[b[i]] += 1
d = 1
for k in c.keys():
    d = (d * (c[k] + 1)) % (10 ** 9 + 7)
d -= 1
print(d)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int M;
int A[200000];
int B[200000];
void doit(int a, int b){
  A[M] = a;
  B[M++] = b;
}
int main(){
  int i, j, k;
  rd(N);
  k = 0;
  for(i=0;i<20;i++){
    if(N&1<<i){
      k = (1<<i);
    }
  }
  if(N==k){
    wt_L("No");
    wt_L('\n');
    return 0;
  }
  doit(1, 2);
  doit(2, 3);
  doit(3, 1+N);
  doit(1+N, 2+N);
  doit(2+N, 3+N);
  for(i=4;i<N;i+=2){
    doit(i, i+1);
    doit(N+i, N+i+1);
    doit(1, i);
    doit(1, N+i+1);
  }
  if(N%2==0){
    doit(k+1+N, N);
    doit(N-k, N+N);
  }
  wt_L("Yes");
  wt_L('\n');
  for(i=0;i<M;i++){
    wt_L(A[i]);
    wt_L(' ');
    wt_L(B[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190714-1

// --- original code ---
// int N;
// 
// int M, A[2d5], B[2d5];
// 
// void doit(int a, int b){
//   A[M] = a;
//   B[M++] = b;
// }
// 
// {
//   int i, j, k;
//   
//   rd(N);
// 
//   k = 0;
//   rep(i,20) if(N&1<<i) k = (1<<i);
// 
//   if(N==k){
//     wt("No");
//     return 0;
//   }
// 
//   doit(1, 2);
//   doit(2, 3);
//   doit(3, 1+N);
//   doit(1+N, 2+N);
//   doit(2+N, 3+N);
// 
//   for(i=4;i<N;i+=2){
//     doit(i, i+1);
//     doit(N+i, N+i+1);
//     doit(1, i);
//     doit(1, N+i+1);
//   }
//   if(N%2==0){
//     doit(k+1+N, N);
//     doit(N-k, N+N);
//   }
// 
//   wt("Yes");
//   rep(i,M) wt(A[i], B[i]);
// }


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy, y3 = y2 + dx;
    int x4 = x3 - dx, y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}

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

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

    static class ASecurity {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            boolean ok = false;
            if (S.charAt(0) == S.charAt(1) && S.charAt(1) == S.charAt(2) && S.charAt(2) == S.charAt(3)) {
                ok = true;

            } else if (S.charAt(0) == S.charAt(1) && S.charAt(1) == S.charAt(2) || S.charAt(1) == S.charAt(2) && S.charAt(2) == S.charAt(3)) {
                ok = true;

            } else if (S.charAt(0) == S.charAt(1) || S.charAt(1) == S.charAt(2) || S.charAt(2) == S.charAt(3)) {
                ok = true;

            }
            out.println(ok ? "Bad" : "Good");

        }

    }
}



Measured memory_bytes: 35736
#include<bits/stdc++.h>
using namespace std;
int gcd(int p, int q){
 while(q != 0){
 int r = p % q;
 p = q;
 q = r;
 }
 return p;
 }
int main ()
{
    int i,j,k,n,c=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                c=c+gcd(gcd(i,j),k);
            }
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

int a[51];
int n;

//??\?????????tmp(m) ???????????????????´????????????????????????°??¢??°
bool slove(int i, int m){
	if(m == 0) return true;//m=0?????????m????????£????????¨??????????????????
	if(i >= n) return false;//i???n????????§???????????£???????????£???????????§????????????
	/*
	 slove(i + 1 , m)???i?????????m????????°?????????
	 slove(i + 1, m - A[i])???i?????????m????????¶???
	*/
	return (slove(i + 1, m) || slove(i + 1, m - a[i]));//??????
}

int main(void){
	int q;
	cin >> n;
	rep(i, n) scanf("%d", &a[i]);
	cin >> q;
	rep(i, q){
		int tmp;
		cin >> tmp;
		if (slove(0, tmp)) printf("yes\n");
		else printf("no\n");
	}

	return 0;
}

Measured memory_bytes: 3156
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto a = readLongs();
    auto ai = a[0];
    auto ao = a[1];
    auto aj = a[3];
    auto al = a[4];
    long nOdd;
    long ans;
    foreach(ax; [ai, aj, al]) {
        if(ax % 2 == 1) {
            nOdd += 1;
        }
    }
    if(nOdd >= 2 && ai > 0 && aj > 0 && al > 0) {
        ans += 3;
        --ai;
        --aj;
        --al;
    }
    ans += (ai/2)*2 + (aj/2)*2 + (al/2)*2 + ao;
    writeln(ans);
}



Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))

d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

d_sorted = sorted(d.items(), key = lambda x: x[1], reverse = True)

tmp = 0

for i in range(min(k, len(d_sorted))):
    tmp += d_sorted[i][1]

print(n - tmp)


Measured memory_bytes: 38964
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

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

    int root_n = 1;
    for (; root_n*root_n<n; ++root_n);

    // initialize container
    vector<ll> array(n, (1LL<<31)-1);
    vector<multiset<ll>> blocks(root_n);
    rep(i, 0, root_n)
        rep(j, 0, root_n)
            blocks[i].insert((1LL<<31)-1);
    
    rep(_, 0, q)
    {
        ll com, x, y;
        cin >> com >> x >> y;
        if (com == 0)
        {
            ll prev = array[x];
            array[x] = y;
            auto itr = blocks[x/root_n].find(prev);
            blocks[x/root_n].erase(itr);
            blocks[x/root_n].insert(y);
        }
        else
        {
            assert (x<=y);

            int block_from = (x+root_n)/root_n;
            int block_to = (y-root_n)/root_n;
            // cout << block_from << ' ' << block_to << ' ' << endl;

            ll res = (1LL<<31) - 1;
            rep(i, block_from, block_to+1)
                res = min(res, *blocks[i].begin());
            for (int i=x; i<block_from*root_n and i<=y; ++i)
                res = min(res, array[i]);
            for (int i=max((int)x, (block_to+1)*root_n); i<=y; ++i)
                res = min(res, array[i]);
            
            cout << res << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8388
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int A, B;
  cin >> A >> B;
  int sum = A + B;
  cout << (sum < 24 ? sum : sum - 24) << endl;
  return 0;
}


Measured memory_bytes: 256
s = str(input())
t = str(input())
ans = []
for i in range(len(s) - len(t) + 1):
    if s[i] == t[0] or s[i] == '?':
        for j in range(len(t)):
            if not(s[i+j] == t[j] or s[i+j] == '?'):
                break
        else:
            news = s[:i] + t + s[i+len(t):]
            news = news.replace('?', 'a')
            ans.append(news)
ans.sort()
if ans:
    print(ans[0])
else:
    print('UNRESTORABLE')


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

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    int n;
    cin >> n;
    bool c = false;
    while(n){
        int tmp = n % 10;
        if (tmp == 7)
            c = true;
        n /= 10;
    }
    if(c)
        cout << "Yes";
    else
        cout << "No";
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];
    SORT(a,n);
    cout << a[n-1]-a[0] << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
N=[]
T=[]
while True:
    n = raw_input().split()
    for e in n:
        N += [int(e)]
    if len(n) == 1 and N[-1] == 0:
        break

T += [N.pop(0)]
while T[-1] != 0:
    T += [N.pop(sum(T)*2)]

for t in T:
    if t == 0:
        break
    A = 0
    B = 0
    f = N[:t*2]
    del N[:t*2]
    for n in range(t):
        g = 2*n
        if f[g] > f[g+1]:
            A += f[g]+f[g+1]
        elif f[g] < f[g+1]:
            B += f[g]+f[g+1]
        else:
            A += f[g]
            B += f[g+1]
    print A,B


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

using namespace std;

const int N = 2e5+ 10;
const int M = 4e5 + 10;//undirect edge

struct Edge{
	int to, next;
}e[M];

char col[N];
int aflag[N], bflag[N], q[N], del[N], ecnt, head[N];

inline void adde(int x, int y) {
	e[++ecnt].to = y;
	e[ecnt].next = head[x];
	head[x] = ecnt;
}

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	scanf("%s", col + 1);
	for(int i = 1, la, lb; i <= m; ++i) {
		scanf("%d %d", &la, &lb);
		adde(la, lb);
		adde(lb, la);
		if(col[lb] == 'A') aflag[la] += 1;
		else bflag[la] += 1;
		if(col[la] == 'A') aflag[lb] += 1;
		else bflag[lb] += 1;
	}	
	int qhd = 1, qtl = 1;
	for(int i = 1; i <= n; ++i){
		if(!aflag[i] || !bflag[i])
			q[qtl++] = i;
	}
	while(qhd != qtl){
		int u = q[qhd++], qwq;
		if(del[u]) continue;
		del[u] = 1;
		if(col[u] == 'A') qwq = 1;
		else qwq = 2;
		for(int i = head[u]; i; i = e[i].next){
			if(!del[e[i].to]){
				if(qwq == 1) {
					aflag[e[i].to]--;
					if(!aflag[e[i].to])
						q[qtl++] = e[i].to;
				}else {
					bflag[e[i].to]--;
					if(!bflag[e[i].to])
						q[qtl++] = e[i].to;
				}				
			}

		}
		
	}
	for(int i = 1; i <= n; ++i)
		if(!del[i]){
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;	
}


Measured memory_bytes: 7168
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int m;
    cin >> m;
    i64 ans = -1, s = 0;
    while (m--)
    {
        i64 d, c;
        cin >> d >> c;
        d *= c;
        ans += c;
        s += d;
    }
    cout << ans + (s - 1) / 9 << endl;
}

int main()
{
    solve();
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(Math.min(A*N, B));
    }
}

Measured memory_bytes: 22356
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int x = 0,y = 0;
    int OKflag = 0;
    
    scanf("%d %d",&x,&y);
    
    if( (x <= 12 || y <= 12) && (x != 0 && y != 0)){
        
        if(x > y){
            printf("error 1\n");
            return -1;
            
        }else{
            
            if(x == 2 || y == 2){
                printf("No\n");
                return 0;
            }
            
            
            int AG[7] = {1,3,5,7,8,10,12};
            int BG[4] = {4,6,9,11};
            
            
            for(int i=0;i<7;i++){
                
                if(AG[i] == x){
                    
                    for(int j=i;j<7;j++){
                        if(AG[j] == y){
                            printf("Yes\n");
                            OKflag = 1;
                        }
                    }
                }
            }
            
            for(int i=0;i<4;i++){
                
                if(BG[i] == x){
                    
                    for(int j=i;j<4;j++){
                        if(BG[j] == y){
                            printf("Yes\n");
                            OKflag = 1;
                        }
                    }
                }
            }
            
            if(OKflag == 0){
                printf("No\n");
            }
            
            
        }
    }
    
    return 0;
}

Measured memory_bytes: 128
from math import ceil
a = []
b = []
for i in range(5):
  w = int(input())
  a.append(w)
  b.append(ceil(w/10)*10)
  
ans = 130*5

for i in range(5):
  w = sum(b) - b[i] + a[i]
  ans = min(ans, w)
  
print(ans)

Measured memory_bytes: 3060
while True:
    t, h, s = map(int, input().split())
    if t == -1:
        break
    ans = 7200-(t*3600+h*60+s)
    ans2 = ans*3
    print("{:02d}:{:02d}:{:02d}".format(ans//3600, (ans//60)%60, ans%60))
    print("{:02d}:{:02d}:{:02d}".format(ans2//3600, (ans2//60)%60, ans2%60))


Measured memory_bytes: 5600