akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int MX = 307;

char a[MX][MX];
char b[MX][MX];

bool check(int n, int x, int y) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            b[(i + x) % n][(j + y) % n] = a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (b[i][j] != b[j][i]) {
                return false;
            }
        }
    }
    return true;
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < n; j++) {
            a[i][j] = s[j];
        }
    }
    int ans = 0;
    map<int, int> mem;
    for (int x = 0; x < n; x++) {
        for (int y = 0; y < n; y++) {
            int d = x - y;
            if (!mem.count(d)) {
                mem[d] = check(n, x, y);
            }
            ans += mem[d];
        }
    }
    cout << ans << "\n";
}


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

#define ll long long


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

    string t;
    cin >> t;

    int changes = 0;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            changes++;
        }
    }

    cout << changes;
}

Measured memory_bytes: 3900
<?php
fscanf(STDIN, '%n', $n);
$Aarray = explode(' ', trim(fgets(STDIN)));
$count = -1;
$tf = array_map('checkint', $Aarray);
while(! in_array(false, $tf)){
    $Aarray = array_map('divtwo', $Aarray);
    $tf = array_map('checkint', $Aarray);
    $count++;
}
print $count;

function divtwo($num){
    return $num/2;
}

function checkint($num){
    return filter_var($num, FILTER_VALIDATE_INT);
}

Measured memory_bytes: 4604
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int w = sc.nextInt();
      int[] weight = {1,2,4,8,16,32,64,128,256,512};
      boolean[] useW = new boolean[10];
      for (int i = 9; i >= 0; i--) {
        if (w >= weight[i]) {
          w -= weight[i];
          useW[i] = true;
        }
      }
      String str = "";
      for (int i = 0; i < 10; i++) {
        if (useW[i]) {
          str += weight[i] + " ";
        }
      }
      System.out.println(str.trim());
    }
  }
}

Measured memory_bytes: 12000
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String bun;
		do {
		bun = stdIn.next();
		}while(bun.length()<1||bun.length()>100);
		int length = bun.length();
		int count = 0;
		int n;
		if(length %2==0) {
			n = length/2;
		}else {
			n = (length-1)/2;
		}
		for(int i=1 ; i<=n ; i++ ) {
			if(!(bun.substring(i-1,i).equals(bun.substring(length-i,length-i+1)))) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    vector<int> A(3);
    for ( int i = 0; i < 3; i++ ) {
        cin >> A[i];
    }
    sort( A.begin(), A.end() );
    int ans = 0;
    while ( A[2]-A[0] > 1 ) {
        A[0] += 2;
        ans++;
    }
    while ( A[2]-A[1] > 1 ) {
        A[1] += 2;
        ans++;
    }
    if ( A[0] == A[1] && A[1] == A[2] ) { cout << ans << endl; }
    else if ( A[0]+1 == A[2] && A[1]+1 == A[2] ) { cout << ans+1 << endl; }
    else { cout << ans+2 << endl; }

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val input=io.Source.stdin.getLines.toIndexedSeq.head.split(' ').map(_.toInt)
  val K=input(0)
  val S=input(1)
  
  var count=0
  (0 to Math.min(S, K)).foreach{ x =>
    (0 to Math.min(S-x, K)).foreach{ y=>
      if(S-x-y <= K) count += 1
    }
  }
  println(count)
}


Measured memory_bytes: 27440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
ll a[10000];
ll b[10000];
ll c[10000];

ll suma=0,sumb=0;
int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a[i];
    suma+=a[i];
  }
  for(int i=0;i<N;i++){
    cin>>b[i];

    c[i]=a[i]-b[i];
    sumb+=b[i];
  }
  
  ll first=sumb-suma;
  ll X=0;
  ll Y=0;
  for(int i=0;i<N;i++){
    if(c[i]<0){
      ll tmp=-c[i];
      X+= tmp/2;
      X+= tmp%2;
      Y+= tmp%2;
    }
    if(c[i]>0){
      Y+=c[i];
    }
  }

  if(X>first || Y>first || first<0){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return 0;
}


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

int main() {
  int x, y;
  cin >> x >> y;
  if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
    x = 1;
  } else if(x == 2) {
    x = 3;
  } else {
    x = 2;
  }
  if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
    y = 1;
  } else if(y == 2) {
    y = 3;
  } else {
    y = 2;
  }
  if(x == y) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (replicateM, forM_)
import Data.List (foldl')
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import Data.Sequence ((<|), (|>), (><), ViewL(..), ViewR(..), Seq)
import qualified Data.Sequence as Sq
import Control.Monad.State

main :: IO ()
main = do
  n <- readLn
  solve n <$> replicateM n (map read <$> words <$> getLine) >>= printDist n
  -- solve n <$> replicateM n (map read <$> words <$> getLine) >>= printDist

solve :: Int -> [[Int]] -> Vector Int
solve n xss = evalState (bfs (Sq.singleton 0)) (Stat dd dc)
  where gd = foldl' (\v (i:_:ls) -> v // [(i-1, map (subtract 1) ls)]) (V.replicate n []) xss
        dd = V.replicate n (-1) // [(0, 0)]
        dc = V.replicate n W // [(0, B)]
        bfs :: Seq Int -> State Stat (Vector Int)
        bfs que = do
          case Sq.viewl que of
           EmptyL -> do
             Stat d _ <- get
             return d
           (u :< que') -> do
             Stat d col <- get
             let nbl = (filter ((==W) . (col !)) (gd ! u))
             let (d', col', que'') = foldl' (\(td, tc, tq) v -> (td // [(v, (td ! u) + 1)],
                                                          tc // [(v, B)],
                                                          tq |> v)) (d, col, que') nbl
             put (Stat d' col')
             bfs que''
             
data Color = W | B deriving (Show, Eq, Ord)

data Stat = Stat (Vector Int) (Vector Color) deriving (Show)

-- printDist :: Vector Int -> IO ()
-- printDist v = V.imapM_ (\i x -> putStrLn . unwords . map show $ [i+1, x]) v

printDist :: Int -> Vector Int -> IO ()
printDist n v = do
  forM_ [0..n-1] $ \i -> do
    putStrLn . unwords . map show $ [i+1, v ! i]



Measured memory_bytes: 4900
fun main(args: Array<String>) {
    val (H, A) = listOfInt()
    val ans = (H + A - 1) / A
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 37808
using System;
class ITP1_6_B
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        bool[] have = new bool[52];
        for (int i = 0; i < n; i++)
        {
            int ptr;
            string[] input = Console.ReadLine().Split(' ');
            switch (input[0])
            {
                case "S":
                    ptr = -1;
                    break;
                case "H":
                    ptr = 12;
                    break;
                case "C":
                    ptr = 25;
                    break;
                case "D":
                    ptr = 38;
                    break;
                default:
                    ptr = 53;
                    Console.WriteLine("Input Error at {0},{1}", i, input[0]);
                    break;
            }
            ptr += int.Parse(input[1]);
            have[ptr] = true;
        }
        for (int i = 0; i < 52; i++)
        {
            if (!have[i])
            {
                int sel = i / 13;
                char Pf;
                switch (sel)
                {
                    case 0:
                        Pf = 'S';
                        break;
                    case 1:
                        Pf = 'H';
                        break;
                    case 2:
                        Pf = 'C';
                        break;
                    case 3:
                        Pf = 'D';
                        break;
                    default:
                        Pf = '?';
                        Console.WriteLine("Decode Error {0}", i);
                        break;
                }
                Console.WriteLine("{0} {1}", Pf, i % 13 + 1);
            }
        }
        return;
    }
}

Measured memory_bytes: 5736
#include <bits/stdc++.h>
#define LL long long
#define P pair<int, int>
#define Fengexian cout<<"WZY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl
const LL N = 2e5 + 10;
const LL mod = 998244353;
const LL inf = 0x3f3f3f3f;
const double eps = 1e-9;
using namespace std;
template <typename tp>
inline void read(tp &x)
{
	x = 0; char c = getchar(); bool f = 0;
	for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar()) ;
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar()) ;
	if (f) x = -x;
}
LL n,m,q[N],ans[N],times[N],hou[N],sum;
deque<LL> de;
void solve(LL now)
{
	LL la=q[now];
	while(la>q[1])
	{
		LL pos=lower_bound(q+1,q+m+1,la)-q-1;
		LL flag=la/q[pos];
		la%=q[pos];
		times[pos]+=flag*times[now];
	}
	sum+=times[now];
	hou[la+1]+=times[now];
	return;
}
signed main()
{
	read(n),read(m);
	for(int i=1;i<=m;i++) read(q[i]);
	de.push_back(n);
	for(int i=1;i<=m;i++)
	{
		while(!de.empty()&&de.back()>=q[i])
			de.pop_back();
		de.push_back(q[i]);
	}
	m=0;
	while(!de.empty())
		q[++m]=de.front(),de.pop_front();
	times[m]=1;
	for(int i=m;i>=1;i--) solve(i);
	for(int i=1;i<=n;i++) sum-=hou[i],ans[i]+=sum;
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>S;
	if(S.size()>K) {
		S=S.substr(0,K)+"...";
	}
	cout<<S<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3596
# include <iostream>
using namespace std;
int main()
{
	int a,b,n,ans=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{	
		int j=i;
		int l=0;
		while(j>0)
		{
			l+=j%10;
			j/=10;
		}
		if(l>=a&&l<=b)
		ans+=i;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N=int(input())

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][b]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)


Measured memory_bytes: 3060
import sys
A = list(map(str,input().split()))
B=[]
for i in range(len(A)):
  c=0
  if A[i].isdecimal():
    B.append(int(A[i]))
  else:
    if A[i]=='+':
      c=B.pop(-2)+B.pop(-1)
      B.append(c)
    elif A[i]=='-':
      c=B.pop(-2)-B.pop(-1)
      B.append(c)
    elif A[i]=='*':
      c=B.pop(-2)*B.pop(-1)
      B.append(c)
print(B[-1])


Measured memory_bytes: 5608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MaxN = 1e5 + 5;
ll cnt1[MaxN + 5],cnt2[MaxN + 5],a[MaxN + 5],b[MaxN + 5],c[MaxN + 5],n;

ll cmp1(ll x, ll y){
	return x < y;
}
ll cmp(ll x, ll y){
	return x > y;
}

int main()
{
	scanf("%lld",&n);
	for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
	for(int i = 1; i <= n; i++) scanf("%lld",&b[i]);
	for(int i = 1; i <= n; i++) scanf("%lld",&c[i]);
	sort(a + 1, a + n + 1,cmp1);
	sort(b + 1, b + n + 1,cmp1);
	sort(c + 1, c + n + 1, cmp);
	ll p = 1, ok = 1;
	for(int i = 1; i <= n; i++){
		ok = 1;
		while(ok && p <= n){
			if(a[p] < b[i]) p++;
			else ok = 0; 
		}
		cnt1[i] = p - 1;
	}
	p = 1, ok = 1;
	for(int i = n; i >= 1; i--){
		ok = 1;
		while(ok && p <= n){
			if(c[p] > b[i]) p++;
			else ok = 0;
		}
		cnt2[i] = p - 1;
	}	
	long long sum = 0;
	for(int i = 1; i <= n; i++){
		sum += cnt1[i] * cnt2[i];
	}
	printf("%lld\n",sum);
}

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

int main() {
  long long n,an = 0,p = 0;
  cin >> n;
  vector<long long>a(n);
  for(int i = 0; i < n;i++) cin >> a[i];
  for(int i = 0; i < n;i++){
    if(p > a[i]) an += p - a[i];
    else p = a[i];
  }
  cout << an <<endl;
}

Measured memory_bytes: 4820
k = int(input())
lunlun = [i for i in range(1, 10)]
p = 0

def generate_lunlun(p):
    last = p % 10
    if last - 1 >= 0:
        yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 <= 9:
        yield p * 10 + last + 1

while len(lunlun) < k:
    for new_lunlun in generate_lunlun(lunlun[p]):
        lunlun.append(new_lunlun)
    p += 1

print(lunlun[k - 1])

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

int main(void){
  int n, k, temp;
  cin >> n >> k;
  map<int, int> m;
  for(int i = 0; i < n; i++){
    cin >> temp;
    m[temp]++;
  }
  if(m.size() <= k){
    cout << 0 << endl;
    return 0;
  }
  temp = 0;
  int a[m.size()];
  for(auto i = m.begin(); i != m.end(); i++){
    a[temp] = i->second;
    temp++;
  }
  sort(a, a + m.size());
  int ans = 0;
  for(int i = 0; i < m.size() - k; i++){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10368
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;


int main()
{
	migmig ;
	ll a , b , c ; 
	cin>>a>>b>>c ; 
	if(c >= a) 
	{
	 
		c -= a  ; 
			a = 0 ;
		b -= c ; 
		cout<<a<<" "<<max((ll)0 , b) ;  
	}
	else
	{
		a -= c ; 
		cout<<a<<" "<<b ; 
	}
}
//////
////////
///////////




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int a, x, b, y, k; cin >> a >> x >> b >> y >> k;
    int mins = (b - a - 1) * 60 + (60 - x) + y;
    int ans = mins - k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;

int main(){
    int n; cin>>n;
    mii v1,v2;
    for(int i = 0; i < n; i++){
        int t; cin>>t;
        if(i%2) v1[t]++;
        else v2[t]++;
    }
    vii m1,m2;
    for(auto i:v1) m1.pb({i.S,i.F});
    for(auto i:v2) m2.pb({i.S,i.F});
    sort(rall(m1));
    sort(rall(m2));
    m1.pb({0,-1});
    m2.pb({0,-1});
    if(m1[0].S!=m2[0].S) cout<<n-m1[0].F-m2[0].F;
    else{
        if(m1[0].F + m2[1].F > m1[1].F + m2[0].F) cout<<n-(m1[0].F + m2[1].F);
        else cout<<n-(m1[1].F + m2[0].F);
    }
}

Measured memory_bytes: 6136
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int point[1010];
pint yoko[100100];
int pos[1010];
int list[1010][1010];

int main() {
	int n,m,h,k;
	while(cin>>n>>m>>h>>k,n){
		memset(list,0,sizeof(list));
		int i;
		for(i=0;i<n;i++){
			cin>>point[i];
		}
		for(i=0;i<m;i++){
			cin>>yoko[i].second>>yoko[i].first;
			yoko[i].second--;
		}
		sort(yoko,yoko+m);
		for(i=0;i<n;i++){
			pos[i]=i;
		}
		for(i=0;i<m;i++){
//cout<<yoko[i].second<<" "<<pos[yoko[i].second]<<" "<<pos[yoko[i].second+1]<<endl;
			int c=pos[yoko[i].second];
			pos[yoko[i].second]=pos[yoko[i].second+1];
			pos[yoko[i].second+1]=c;
			if(pos[yoko[i].second]<k){
				list[pos[yoko[i].second]][pos[yoko[i].second+1]]=1;
			}
			if(pos[yoko[i].second+1]<k){
				list[pos[yoko[i].second+1]][pos[yoko[i].second]]=1;
			}
		}
		int m=0;
		int j;
		int res[1010];
		for(i=0;i<n;i++){
			res[pos[i]]=i;
		}
		for(i=0;i<k;i++){
			for(j=k;j<n;j++){
				if(list[i][j]==1){
					chmin(m,point[res[j]]-point[res[i]]);
				}
			}
		}
		for(i=0;i<k;i++){
			m+=point[res[i]];
		}
		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 5644
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll func(ll SS1, ll HH, ll WW){
  ll SS2, SS3, ans = INF;
  if(HH % 2 == 0 || WW % 2 == 0){
    SS2 = HH * WW / 2; SS3 = HH * WW / 2;
    ll maxs = max(SS1, max(SS2, SS3));
    ll mins = min(SS1, min(SS2, SS3));
    ans = maxs - mins;
  }
  else{
    ll a = HH/2, b = HH - HH/2;
    SS2 = a * WW; SS3 = b * WW;
    ll maxs = max(SS1, max(SS2, SS3));
    ll mins = min(SS1, min(SS2, SS3));
    chmin(ans, maxs - mins);

    a = WW/2; b = WW - WW/2;
    SS2 = a * HH; SS3 = b * HH;
    maxs = max(SS1, max(SS2, SS3));
    mins = min(SS1, min(SS2, SS3));
    chmin(ans, maxs - mins);
  }
  
  return ans;
}

int main(){
  ll H, W;
  cin >> H >> W;
  if(H % 3 == 0 || W % 3 == 0){
    cout << 0 << endl;
    return 0;
  }

  ll S1, S2, S3;
  ll ans = INF;
  //まず縦切りする場合
  S1 = (W/3) * H;
  chmin(ans, func(S1, H, W-W/3));
  S1 = (W/3+1) * H;
  chmin(ans, func(S1, H, W-(W/3+1)));

  S1 = (H/3) * W;
  chmin(ans, func(S1, H-H/3, W));
  S1 = (H/3+1) * W;
  chmin(ans, func(S1, H-(H/3+1), W));
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def dfs(G, v, p, color, prev_c):
    """G: graph, v: vertex, p: parent"""
    c = 1
    # Loop for each child
    for e in G[v]:
        if e[0] == p:
            continue
        if c == prev_c:
            c += 1
        color[e[1]] = c
        dfs(G, e[0], v, color, c)
        c += 1


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append((b, i))
        G[b].append((a, i))

    color = [-1] * (N - 1)
    dfs(G, 0, -1, color, -1)
    K = max(color)
    print(K)
    print(*color, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 75640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>

using namespace std;

const int INF = 1e8;

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

    std::vector<bool> is_visited(K, false);

    std::deque<pair<int, int>> deq;

    deq.push_back(std::make_pair(1, 0));
    while(!deq.empty()) {
        auto v = deq.front();
        deq.pop_front();
        
        if(is_visited[v.first]) {
            continue;
        }

        is_visited[v.first] = true;

        if(v.first == 0) {
            res = v.second+1;
            break;
        }

        deq.push_front(std::make_pair((v.first*10)%K, v.second));
        deq.push_back(std::make_pair((v.first+1)%K, v.second+1));
    }

    std::cout << res << std::endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 1;
    for(int i = 0; i < 10; i++) {
      if((2 * ans) <= n) {
        ans *= 2;
      } else {
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,L;
	cin>>N>>L;
	vector<string> S(N);
	FDS(i,N){
		cin>>S[i];
	}
	VSORT(S);
	FDS(i,N){
		cout<<S[i];
	}
	cout<<endl;
}

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

int main(void){
  int N,A;
  scanf("%d",&N);
  scanf("%d",&A);

  int n = N%500;
  if(n - A <= 0){
    printf("Yes\n");
    fflush(stdout);
  }else{
    printf("No\n");
    fflush(stdout);
  }
  return 0;
}

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

int main() {
  int N,max;
  int x = 0;
  cin >> N;
  vector<int> d(N);
  
  for(int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(),d.end(),greater<int>());
  
  for(int i = 0; i < N; i++) {
    if(max != d.at(i)){
      x++;
      max = d.at(i);
    }
  }
  
  cout << x << endl;
}

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

int N,K,L,c1[200010],c2[200010],C1,C2; map<int,int> mp[200010]; vector<int> g1[200010],g2[200010];
bool v[200010];

void dfs1(int nod){
    int i;
    if (v[nod]) return;
    v[nod]=1;

    c1[nod]=C1;
    for (i=0; i<g1[nod].size(); i++)
        dfs1(g1[nod][i]);
}

void dfs2(int nod){
    int i;
    if (v[nod]) return;
    v[nod]=1;

    c2[nod]=C2;
    for (i=0; i<g2[nod].size(); i++)
        dfs2(g2[nod][i]);
}

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

    int x,y,i;
    cin >> K >> L;
    for (i=1; i<=K; i++){
        cin >> x >> y;
        g1[x].push_back(y);
        g1[y].push_back(x);
    }

    for (i=1; i<=L; i++){
        cin >> x >> y;
        g2[x].push_back(y);
        g2[y].push_back(x);
    }

    memset(v,0,sizeof(v));
    for (i=1; i<=N; i++)
        if (!v[i]) C1++,dfs1(i);

    memset(v,0,sizeof(v));
    for (i=1; i<=N; i++)
        if (!v[i]) C2++,dfs2(i);

    for (i=1; i<=N; i++)
        mp[c1[i]][c2[i]]++;

    for (i=1; i<=N; i++)
        cout << mp[c1[i]][c2[i]] << " ";

    cout << "\n";

    return 0;
}


Measured memory_bytes: 34944
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {


	int a, b;

	cin >> a >> b;

	FOR(i, 1, 4) {
		if (i != a && i != b) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
N,M = [int(s) for s in input().split()]
lst=[]
for i in range(N):
  lst.append([int(s) for s in input().split()])
lst.sort()
count=0
cost=0
for e in lst:
  count+=e[1]
  cost+=e[0]*e[1]
  if(count>=M):
    cost-=e[0]*(count-M)
    break
print(cost)

Measured memory_bytes: 21616
module Main where

import Data.Char
import Data.Maybe
import Data.List

main :: IO ()
main = putStr
     . unlines
     . map ppr
     . countUps
     . map runlength
     . group
     . sort
     . map toLower
     . filter isAlpha
     =<< getContents

ppr :: (Char, Int) -> String
ppr (c,n) = c : (" : " ++ show n)

countUps :: [(Char, Int)] -> [(Char, Int)]
countUps rs = map (count rs) ['a' .. 'z']

count :: [(Char, Int)] -> Char -> (Char, Int)
count rs c = maybe (c,0) ((,) c) (lookup c rs)

runlength :: [Char] -> (Char, Int)
runlength cs = (head cs, length cs)

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < n; i++){
			String[] tmpArray = br.readLine().split(" ");
			
			int[] balls = new int[10];
			for(int j = 0; j < 10; j++){
				balls[j] = Integer.parseInt(tmpArray[j]);
			}
			
			//boolean[] isLeft = new boolean[10];
			int currentLeft = balls[0];
			//isLeft[0] = true;
			int currentRight = -1;
			boolean possible = true;
			for(int j = 1; j < 10 ; j++){
				if(balls[j] > currentLeft){
					currentLeft = balls[j];
				}
				else if(currentRight == -1 || currentRight < balls[j]){
					currentRight = balls[j];
				}
				else {
					possible = false;
				}
			}
			if(possible){
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 24208
#include <bits/stdc++.h>
using namespace std;
int K,R,L;
double P,E,T;
double dfs(int d,double l,double r){
  double mid=(l+r)/2;
  if(!d)return (T-E<mid&&mid<T+E)?1:0;
  if(r<T-E||T+E<l)return 0;
  if(T-E<l&&r<T+E)return 1;
  if(mid>=T)return (1.0-P)*dfs(d-1,l,mid)+P*dfs(d-1,mid,r);
  return (1.0-P)*dfs(d-1,mid,r)+P*dfs(d-1,l,mid);
}
main(){
  cin>>K>>L>>R>>P>>E>>T;
  printf("%.9f\n",dfs(K,L,R));
}

Measured memory_bytes: 3292
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MAX (ll(1e6)+7)
#define MOD (ll(1e9)+7)
#define INF (ll(1e18)+7)

#define elif else if
#define def inline auto

#define for_in(a,b,c) for(ll a=(b);a<(c);++a)
#define repeat(a,b) for(ll a=0;a<(b);++a)
#define repeat_down(a,b) for(ll a=(b);a>=0;--a)

#define array_size(a) ll(sizeof(a)/sizeof(a[0]))

#define def_input(...) ll __VA_ARGS__;input(__VA_ARGS__)
#define if_print(a,b,c) output(a?#b:#c)
#define print(a) output(#a)
#define fout(a) cout<<fixed<<setprecision(10)<<a
#define fillout(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define ios_boost cin.tie(0);ios::sync_with_stdio(false)

#define digit(a) to_string(a).length()
#define lcm(a,b) a*b/gcd(a,b)

char N='\n',S=' ';
const ll primes[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
ll temp_index;

inline void input(){}
template<class T,class...A>inline void input(T&&t,A&&...a){cin>>t;input(move(a)...);}
template<class T>inline void output(T&t){cout<<t<<N;}
template<class T,class...A>inline void output(T t,A...a){cout<<t<<S;output(move(a)...);}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>const&v)
{bool d=0;for(T x:v){if(d)o<<S<<x;else{o<<x,d=1;}}o<<N;return o;}

def get_ll(){ll x;input(x);return x;}
def gcd(ll a,ll b){ll c;while(a){c=a;a=b%a;b=c;}return b;}

inline bool is_prime(ll a){
    if(a<48){for_in(i,0,15)if(primes[i]==a)return 1;}
    elif(a<2809)return gcd(614889782588491410,a)==1;
    else {print(Error:Argument>2808);exit(1);}return 0;
}

template<class T>def sum_array(T&a,T&b){
    b[0]=a[0];
    for_in(i,1,array_size(a))b[i]=a[i]+b[i-1];
}

map<string,ll>LIST;
map<ll,string>VLIST;

def val(string a){
    auto IT=LIST.find(a);
    if(IT!=LIST.end()){
        return LIST[a];
    }
    else{
        ll v=LIST.size();
        LIST[a]=v;
        VLIST[v]=a;
        return v;
    }
}

ll a,b,c,d;
int main(){
    ios_boost;
    def_input(n,m);
    cout<<(n-1)*(m-1)<<"\n";
}

//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=2e5+20;
const ll mod=1e9+7;
ll f[N],n,m,A,B;
ll powmod(ll x,ll n)
{
    ll s=1;
    while(n){
        if(n&1)
            s=(s*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return s;
}
ll C(ll n,ll m)
{
    ll a=f[n];
    ll b=(f[m]*f[n-m])%mod;
    return (a*powmod(b,mod-2))%mod;
}
int main()
{
    f[0]=1;
    for(ll i=1;i<N;i++)
        f[i]=(f[i-1]*i)%mod;
    while(cin>>n>>m>>A>>B){
        ll res=0;
        for(ll i=B+1;i<=m;i++){
            ll tmp=(C(i-1+n-A-1,n-A-1)*C(m-i+A-1,m-i))%mod;
            res=(res+tmp)%mod;
        }
        cout<<res<<endl;
    }
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int r,g,b;
  cin >> r >> g >> b;;
  if((g*10+b)%4==0)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner

class ModInt {
	var v: Long
		private set
	constructor(v: Int){
		this.v = when {
			v>=0 -> v.toLong() % MOD
			v==Int.MIN_VALUE -> 852516373
			else -> MOD.toLong() - (-v%MOD)
		}
	}
	constructor(v: Long){
		this.v = when {
			v>=0 -> v % MOD
			v==Long.MIN_VALUE -> 708828003
			else -> MOD - (-v%MOD)
		}
	}

	override fun toString() = v.toString()
	fun toInt() = v.toInt()
	fun toLong() = v
	override fun equals(other: Any?): Boolean {
		return if (other is ModInt) v == other.v else false
	}
	override fun hashCode() = v.hashCode()

	operator fun unaryPlus() = this
	operator fun unaryMinus() = ModInt(MOD-this.v)

	private operator fun plus(o: Long) = ModInt(this.v + o)
	operator fun plus(o: ModInt) = this.plus(o.v)
	operator fun plus(o: Int) = this.plus(o.toLong())
	private operator fun minus(o: Long) = this.plus(-o)
	operator fun minus(o: ModInt) = this.minus(o.v)
	operator fun minus(o: Int) = this.minus(o.toLong())
	private operator fun times(o: Long) = ModInt(this.v*o)
	operator fun times(o: ModInt) = this.times(o.v)
	operator fun times(o: Int) = this.times(o.toLong())
	private operator fun div(o: Long) = this.times(pow(o, MOD-2))
	operator fun div(o: ModInt) = this.div(o.v)
	operator fun div(o: Int) = this.div(o.toLong())

	operator fun inc() = this.plus(1)
	operator fun dec() = this.minus(1)

	companion object{
		const val MOD = 1000000007

		private fun pow(b:Long, e: Int): ModInt{
			if (b==1L) return ModInt(1)
			var ans = 1L
			var b = b; var e = e
			while (e!=0){
				if (e%2==1) ans = (ans*b)%MOD
				b = (b*b)%MOD
				e /= 2
			}
			return ModInt(ans)
		}
		fun pow(b: Int, e: Int): ModInt = pow(b.toLong(), e)
		fun pow(b: ModInt, e: Int): ModInt = pow(b.v, e)
	}
}

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val lpf = mutableMapOf<Int, Int>()
	val arr = IntArray(n){scn.nextInt()}
	repeat(n){
		val a = arr[it]
		val pf = pFact(a)
		pf.forEach {
			lpf[it.key] = Math.max(lpf.getOrElse(it.key){0}, it.value)
		}
	}
	var l = ModInt(1)
	lpf.forEach { l *= ModInt.pow(it.key, it.value) }
	var ans = ModInt(0)
	arr.forEach { a ->
		ans += l/a
	}
	println(ans)
}

fun pFact(n: Int): Map<Int, Int>{
	var n = n
	val ans = mutableMapOf<Int, Int>()
	var i = 2
	while (i*i<=n){
		if (n%i==0){
			ans[i] = ans.getOrElse(i){0} + 1
			n /= i
		}else i++
	}
	if (n!=1) ans[n] = ans.getOrElse(n){0}+1
	return ans
}


Measured memory_bytes: 38212
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");

  var i = 0;
  while (true) {
    if (input[i] == "-") {
      break;
    }
    
    var text = input[i++];
    var m = parseInt(input[i++], 10);
    
    for (j = 0; j < m; j++) {
      var h = parseInt(input[i + j]);
      text = text.slice(h) + text.slice(0, h);
    }
    console.log(text);
    i += m;
  }
});

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

int main() {
    int n;

    cin >> n;

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

    for(int i = 1; i < n; i++) {
        int temp = card[i];
        int j = i - 1;
        for(; j >= 0 && card[j] < temp; j--) {
            card[j + 1] = card[j];
        }
        card[j + 1] = temp;
    }

    int aliceSum = 0;
    int bobSum = 0;
    
    for(int i = 0; i < n; i++) {
        if(i % 2) {
            bobSum += card[i];
        } else {
            aliceSum += card[i];
        }
    }

    cout << (aliceSum - bobSum);

    return 0;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = vec![0; n * n];
    for i in 0..n {
        for j in 0..n {
            a[i * n + j] = itr.next().unwrap().parse().unwrap();
        }
    }

    let mut s = vec![0i64; 1 << n];
    for bit in 0..1 << n {
        for i in 0..n {
            for j in i + 1..n {
                if (bit >> i & 1) == 1 && (bit >> j & 1) == 1 {
                    s[bit] += a[i * n + j];
                }
            }
        }
    }

    let mut dp = vec![0; 1 << n];
    for i in 1..1 << n {
        let mut j = i;
        while j > 0 {
            dp[i] = max(dp[i], dp[i ^ j] + s[j]);
            j = (j - 1) & i;
        }
    }
    println!("{}", dp[(1 << n) - 1]);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,ans="";
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='B'&&ans.size()!=0)ans.erase(--ans.end());
    else if(s[i]!='B')ans+=s[i];
  }
  cout<<ans<<endl;
  return(0);
}

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

int main(){
  int N; cin >> N;
  char A[N];
  int ans = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(A[i] == 'Y')
      ans++;
  }
  if(ans > 0){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {

	string s;
	cin >> s;
	string front;
	string back;

	int count = 0,q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;

		if (t == 1) {
			count++;
		}
		else {
			int f;
			char c;
			cin >> f >> c;
			if (f == 1) {
				if (count % 2 == 0) {
					front += c;
				}
				else {
					back += c;
				}
			}
			else {
				if (count % 2 == 1) {
					front += c;
				}
				else {
					back += c;
				}
			}
		}


	}

	reverse(front.begin(),front.end());

	s = front + s + back;

	if (count % 2 == 1) {
		reverse(s.begin(), s.end());
	}


	cout << s << endl;


	return 0;
}

Measured memory_bytes: 1348
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

bool isprime(int x)
{
    for(int i=2;i*i<=x;i++)
        if(x%i==0)
        return false;
    return true;
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=11;;i+=10)
    {
        if(n==0)break;
        if(isprime(i))
            {
                printf("%d ",i);
                n--;
            }
    }
    return 0;
}


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

using namespace std;



#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define beg begin()
#define end end()

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<string> vstr;

void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s;
    cin >> t;

    sort(s.beg, s.end);
    sort(t.beg, t.end, greater<int>());

    if(s<t)
        Yes();
    else
        No();



    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) {
		try {
			
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));// ??\????????????????????????
			String line;

			// ????????????????????´?????????
			// String line; // ??\???????????????????????\???
			// while ((line = br.readLine()) != null) {
			// processLine(line);
			// }

			calc: while ((line = br.readLine()) != null) {
				String[] fruit = line.split(" ");
				int nUm1 = Integer.valueOf(fruit[0]);
				String ope = fruit[1];
				int nUm2 = Integer.valueOf(fruit[2]);
				
				switch (ope) {
				case "+":
					System.out.println(nUm1 + nUm2);
					break;
				case "-":
					System.out.println(nUm1 - nUm2);
					break;
				case "*":
					System.out.println(nUm1 * nUm2);
					break;
				case "/":
					System.out.println(nUm1 / nUm2);
					break;
				case "?":
					break calc;
				}
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	// private static void processLine(String line) {
	// System.out.println(line);
	// }
}

Measured memory_bytes: 24176
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static String s;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        s = in.next();
        int n = s.length();

        // bit: 1 -> +, 0 -> -
        for(int i = 0; i < 1 << n-1; i++) {
            String ss = s;
            for(int j = n-1; j > 0; j--) {
                if((1 & (i >> j-1)) == 1) {
                    ss = ss.substring(0, j) + "+" + ss.substring(j);
                }else{
                    ss = ss.substring(0, j) + "-" + ss.substring(j);
                }
            }

            int ans = 0;
            boolean add = true;
            int current = 0;
            for(int j = 0; j < 7; j++) {
                if(j % 2 == 0) {
                    current = Integer.parseInt(ss.substring(j, j+1));
                    if(add) ans += current;
                    else ans -= current;
                }else{
                    add = (ss.charAt(j) == '+');
                }
            }
            if (ans == 7) {
                print(ss + "=7");
                return;
            }
        }
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }
}

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

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();


        long abs1 = Math.Abs(inpt[0]);
        long abs2 = Math.Abs(inpt[1]);

        long ans = Math.Abs(abs1 - abs2);
        if (inpt[0] == 0)
        {
            ans = Math.Abs(inpt[1]);
            if (inpt[1] < 0)
            {
                ans++;
            }

        }
        else if (inpt[1] == 0)
        {
            ans = Math.Abs(inpt[0]);
            if (inpt[0] >= 0)
            {
                ans++;
            }
        } else if (abs1 > abs2)
        {
            if (inpt[0] >= 0)
            {
                ans++;
            }
            if (inpt[1] > 0)
            {
                ans++;
            }
        }
        else if(abs1 < abs2)
        {
            if (inpt[0] < 0)
            {
                ans++;
            }
            if (inpt[1] < 0)
            {
                ans++;
            }
        }
        else
        {
            ans++;
        }

        Console.WriteLine(ans);

    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

-4 3



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 3032
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int N,K; cin >> N >> K;
    pr(N-K+1);
}


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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


long long qexp(long long A, long long B) { // calculate (A ^ B) % M
    if (B == 0) return 1; //base case A^0 = 1
    long long half = qexp(A, B/2);
    half *= half%mod;
    half %= mod;
    if (B % 2 == 1) half *= A;  //Compensate the 'round down' of B/2 when B is odd
    return half % mod;
}
ll coefficient(ll n, ll k) { // Calculate nCk
    ll res = 1;
    k = min(k, n - k); // as C(n, k) = C(n, n - k)
    for (ll i = 0; i < k; i++) {
        res = res * qexp(i + 1, mod - 2) % mod * (n - i) % mod;
    }
    return res;
}
int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n,a,b;
        cin>>n>>a>>b;
        cout<<((qexp(2,n)-coefficient(n,a)-coefficient(n,b)-1)%mod+mod)%mod;

    }
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python
"""AtCoder Beginner Contest 167: C - Skill Up
https://atcoder.jp/contests/abc167/tasks/abc167_c
"""

N, M, X = 0, 0, 0
BOOKS = []


def calc_price(book_combinations, current_answer):
    price = 0
    # calculate understandings
    understandings = [0] * M
    for i in range(len(book_combinations)):
        if book_combinations[i]:
            price += BOOKS[i][0]
            if current_answer < price:
                return -1  # overpriced
            for j in range(len(BOOKS[i][1:])):
                understandings[j] += BOOKS[i][j + 1]
    for u in understandings:
        if u < X:  # couldn't understand
            return -1
    return price


def main():
    global N, M, X, BOOKS
    N, M, X = list(map(int, input().split()))
    BOOKS = [list(map(int, input().split())) for i in range(N)]

    ans = float('inf')
    for i in range(1, 2 ** N):  # => 1: at least one book should be buy
        price = calc_price([(i >> j) & 1 for j in range(N)], ans)
        if 0 < price and price < ans:
            ans = price
    if ans == float('inf'):
        ans = -1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9112