akhauriyash/Code-Regression huggingface dataset:
package main

// Solution for https://atcoder.jp/contests/abc073/tasks/abc073_a

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s int
	con.Scan(&s)
	ok := false
	for s > 0 {
		d := s % 10
		if d == 9 {
			ok = true
		}
		s /= 10
	}
	if ok {
		con.Println("Yes")
	} else {
		con.Println("No")
	}
	return nil
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        int x = n;
        int sum = 0;
        while (x > 0)
        {
            sum += x % 10;
            x /= 10;
        }

        Console.WriteLine(n % sum == 0 ? "Yes" : "No");
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans = 0;
    for(int i=2;i<=n-1;i++)
    {
        vector<int> tmp;
        tmp.pb(a[i-1]);
        tmp.pb(a[i]);
        tmp.pb(a[i+1]);
        sort(all(tmp));
        if(tmp[1] == a[i])
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,a,x,y,s[16],t[16],i,j,m=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    s[i]=0;
    t[i]=0;
    for(j=0;j<a;j++){
      scanf("%d",&x);
      scanf("%d",&y);
      x--;
      s[i]|=1<<x;
      t[i]|=(y&1)<<x;
    }
  }
  for(i=(1<<n)-1;i>0;i--){
    x=0;
    for(j=0;j<n;j++){
      if((i>>j)&1){
        x++;
        if(i&s[j]^t[j]) break;
      }
    }
    if((j==n)&(m<x)) m=x;
  }
  printf("%d",m);
  return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int 
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LL n,m,i;cin>>n>>m;
      std::vector<std::vector<LL>> v(m+1);
      fo(i,0,n){
        LL a,b;cin>>a>>b;
        if(a>m) continue;
        v[a].pb(b);
      }
      LL ans=0;
      priority_queue<LL> q;
      fo(i,1,m+1){
        for(auto x:v[i]){
          q.push(x);
        }
        if(q.size()){
          ans+=q.top();q.pop();
        }
      }
      cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 8288
#include <stdio.h>

#define cmp(x,y) (x==y)?0:1
#define ans(x) (x==0)?"Yes":"No"

int main(void)
{
  int i;
  int N;
  char S[100];
  int judge=0;

  scanf("%d",&N);
  scanf("%s",S);

  if(N%2==0){
    for(i=0;i<N/2;i++){
      judge += cmp(S[i],S[N/2+i]);
    }
  }else{
    judge = 1;
  }

  printf("%s\n",ans(judge));

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){

    string s;
    cin>>s;
    for(int i = 0;i<s.size();i++){
      if(s[i] == '9')s[i] = '1';
      else if(s[i] == '1')s[i] = '9';
    }
    cout<<s<<endl;
    
    return 0;
}


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

int main(){
  int N,t;
  long long sum=0;
  cin >> N;
  map<int, int> A;
  for(int i=0; i<N; i++){
    cin >> t;
    if(A.count(t)) A[t]++;
    else A[t] = 1;
    sum += t;
  }
  int Q;
  cin >> Q;
  vector<int> B(Q),C(Q);
  for(int i=0; i<Q; i++){
  	cin >> B[i] >> C[i];
  }
  for(int i=0; i<Q; i++){
    int bnum=0;
    if(A.count(B[i])){
      bnum = A[B[i]];
      if(A.count(C[i])){
        A[C[i]] += A[B[i]];
      }
      else{
        A[C[i]] = A[B[i]];
      }
      A.erase(B[i]);
    }
    sum -= (long long)bnum*(long long)(B[i] - C[i]); 
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 6880
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int num1 = s.nextInt();
        int num2 = s.nextInt();
        int num3 = s.nextInt();

        if (num1 + num2 + num3 >= 22){
            System.out.println("bust");
        }
        else {
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 21588
S = input()
T = input()

ls = len(S)
lt = len(T)
ans = 1<<60
for i in range(ls-lt+1):
    cnt = 0
    X = S[i:i+lt]
    for x, t in zip(X, T):
        if x != t:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 73404
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    int n=st.size();
    if(st[0]=='0'||st[n-1]=='1'){
        cout<<-1<<endl;
        return 0;
    }
    int x=-1;
    FOR(i,1,n-1){
        if(st[i]=='0'&&st[n-i-2]=='1'){
            cout<<-1<<endl;
            return 0;
        }
    }
    int par=2;
    cout<<1<<" "<<2<<endl;
    FOR(i,1,n-1){
        cout<<par<<" "<<i+2<<endl;
        if(st[i]=='1'){
            par=i+2;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main(){
int k,s,z;
cin>>k>>s;
int n=0;
for(int i=0;i<=k;i++){
for(int j=0;j<=k;j++){
	z=s-i-j; 
	if(s==(i+j+z))
if(z>=0&&z<=k)
n+=1;
}}
cout<<n;
return 0;
}

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

int a[200009], mn[200009], r[200009];
bool vs[200009], avs[200009];
vector<int> v, ans;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; long long k; cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = n; i >= 1; i--) {
		if (mn[a[i]] == 0) r[i] = a[i];
		else r[i] = r[mn[a[i]] + 1];
		mn[a[i]] = i;
	}
	int p = 1;
	while (true) {
		v.push_back(p);
		if (r[p] == 0) break;
		vs[p] = true;
		p = mn[r[p]] + 1;
		if (vs[p]) break;
	}
	k = (k - 1LL) % (long long)v.size();
	p = v[k];
	for (int i = p; i <= n; i++) {
		if (avs[a[i]]) {
			while (ans.back() != a[i]) {
				avs[ans.back()] = false;
				ans.pop_back();
			}
			avs[a[i]] = false;
			ans.pop_back();
		}
		else {
			ans.push_back(a[i]);
			avs[a[i]] = true;
		}
	}
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i] << " ";
	cout << '\n';
	return 0;
}

Measured memory_bytes: 6004
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int M = sc.nextInt();
	        
	        int[][] s=new int[M][N];
	        for(int i=0;i<M;i++) {
	        	int k = sc.nextInt();
	        	for(int j=0;j<k;j++) {
	        		s[i][sc.nextInt()-1]++;
	        	}
	        }
	        int[] p = new int[M];
	        for(int i=0;i<M;i++) {
	        	p[i]=sc.nextInt();
	        }
	        long ans=0;
	        for(int i=0;i<(1<<N);i++) {
		        int[] m= new int[M];
		        for(int j=0;j<N;j++) {
		        	if(((i>>j)&1)==1) {
			        	for(int k=0;k<M;k++) {
			        		if(s[k][j]==1) {
			        			m[k]++;
			        		}
		        		}		        	
			        }
	        	}
	        	boolean isOK=true;
	        	for(int j=0;j<M;j++) {
	        		if(m[j]%2!=p[j]) {
	        			isOK=false;
	        			break;
	        		}
	        	}
	        	if(isOK==true) {
	        		ans++;
	        	}
	        }
	        
	        System.out.println(ans);
  	        	        
	 }

}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int i;
	string s,t;
	cin>>s>>t;
	int ans=0;
	REP(i,0,sz(s)-1){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextInt();
    long b = sc.nextInt();
    System.out.print(a/b + " ");
    System.out.print(a%b + " ");
    double f = (double)a/b;
    String f2 = String.format("%.5f", f);
    System.out.println(f2);
  }
}

Measured memory_bytes: 26552
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <pair<int,int>> A(n);
    rep(i,n) {int t,a; cin>>t>>a; A[i] = {t,a};}
    int now1=A[0].F, now2=A[0].S;
    rep(i,n){
        int x = (now1 + A[i].F -1)/ A[i].F;
        int y = (now2 + A[i].S -1)/ A[i].S;
        int z = max(x,y);
        now1 = A[i].F * z, now2 = A[i].S* z;
    }
    cout<<now2+now1<<endl;
}


Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

class CombMod:
	def __init__(self, N):
		facts = [1]
		rfacts = [1]
		for i in range(1, N+1):
			facts.append(facts[i-1]*i % mod)
			rfacts.append(pow(facts[i], mod-2, mod))
		self.facts = facts
		self.rfacts = rfacts

	def comb(self, n, k):
		return self.facts[n]*self.rfacts[k]*self.rfacts[n-k] % mod

	def perm(self, n, k):
		return self.facts[n]*self.rfacts[n-k] % mod

	def fact(self, n):
		return self.facts[n] % mod

	def rfact(self, n):
		return self.rfacts[n] % mod


N, K = rl()
cm = CombMod(N)
for i in range(1, K+1):
	remain = N-(K+i-1)
	if i-1 > N-K:
		print(0)
		continue
	cnt = cm.comb(K-1, i-1) * cm.comb(remain+i, remain)
	print(cnt % mod)



Measured memory_bytes: 74788
#include <bits/stdc++.h>
using namespace std;
int n,a[3][105],dp[3][105];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=2;++i)
        for (int j=1;j<=n;++j) {
            int x;scanf("%d",&x);
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])+x;
        }
    printf("%d\n",dp[2][n]);
    return 0;
}


Measured memory_bytes: 3724
from collections import Counter
from itertools import combinations
N = int(input())
S = [input()[0] for _ in range(N)]
S = Counter([s for s in S if s in ("M", "A", "R", "C", "H")])
trio = combinations(S.keys(), 3)
num = 0
for a, b, c in trio:
    num += S[a] * S[b] * S[c]
print(num)


Measured memory_bytes: 4988
#include<bits/stdc++.h>
using namespace std;
const int N=605,mo=1e9+7;
int n,K,a,b,i,j,k,f[N][N],g[N],h[N][N],ans,le[N][N],ri[N][N],s[N][N];
int main(){
	scanf("%d%d",&n,&K);
	for(i=1;i<=n*2;++i)for(j=i;j<=n*2;++j)le[i][j]=N;
	for(i=0;i<K;++i){
		scanf("%d%d",&a,&b);if(a>b)swap(a,b);
		le[b][b]=a;ri[a][a]=b;s[a][b]=1;
	}
	for(i=1;i<=n*2;++i)for(j=i;j<n*2;++j)le[i][j+1]=min(le[i][j+1],le[i][j]),
		ri[i][j+1]=max(ri[i][j+1],ri[i][j]),s[i][j+1]+=s[i][j];
	for(i=n*2;i>1;--i)for(j=i;j<=n*2;++j)le[i-1][j]=min(le[i-1][j],le[i][j]),
		ri[i-1][j]=max(ri[i-1][j],ri[i][j]),s[i-1][j]+=s[i][j];
	for(i=*g=1;i<N;++i)g[i]=(2ll*i-1)*g[i-1]%mo;
	for(i=1;i<n*2;i+=2)for(j=1;j+i<=n*2;++j){
		int l=j,r=j+i;
		if(le[l][r]>=l && ri[l][r]<=r){
			f[l][r]=g[(i+1)/2-s[l][r]];
			for(k=1;k<i;k+=2)f[l][r]=(f[l][r]+mo-1ll*f[l][l+k]*h[l+k+1][r]%mo)%mo,
				h[l][r]=(h[l][r]+1ll*f[l][l+k]*h[l+k+1][r])%mo;
			h[l][r]=(h[l][r]+f[l][r])%mo;
			ans=(ans+1ll*f[l][r]*g[n-(i+1)/2-(K-s[l][r])])%mo;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 7424
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a>9 || b>9) System.out.println(-1);
        else System.out.println(a*b);
    }
}


Measured memory_bytes: 22988
#include<stdio.h>
int array[1000000];
int main(){
    int n, i, j, count;
    while(scanf("%d",&n)!=EOF){
        count = 0;
        for(i=1;i<n+1;i++){
            array[i] = 1;
        }
        for(i=2;i<n+1;i++){
            if(array[i]){
                count += 1;
                for(j=2;j<n/i+1;j++){
                    array[i*j] = 0;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	map<int,int>m;
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(!m[a[i]])m[a[i]]++;
		else m[a[i]]--;
	}
	for(auto i:m)if(i.second>0)cnt++;
	cout<<cnt;

}
//solved  problems for today:0


Measured memory_bytes: 5376
#include<stdio.h>
#define N 1000000

typedef struct{
  char name[11];
  int time;
}Job;
void in(Job);
Job out();
int tail;
int head;  Job job[N],j;
int main(){
  int i,n,q,all=0; 
  //inqut
  scanf("%d%d",&n,&q);
  tail=n;
  for(i=0;i<n;i++)scanf("%s%d",job[i].name,&job[i].time);
  //-----
  while(head!=tail){
    j=out();
    if(j.time>q){
      j.time-=q;
      in(j);
      all+=q;
    }
    else{
      printf("%s %d\n",j.name,j.time+all);
      all+=j.time;
    }
  }
  return 0;
}
Job out(){
  int a;
  a=head;
  head++;
  head%=N;
  return job[a];
}
void in(Job j){
  tail++;
  tail%=N;
  job[tail-1]=j;
}



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

using namespace std;

const int N = 1e5 + 5;

int maxPoints[N][4];
int happiness[N][4];
int n;

main(){

    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
            for(int j = 0 ; j < 3 ; j ++){
                    scanf("%d" , &happiness[i][j]); // the happiness when doing activity j in day i
            }
    }

    maxPoints[0][0] = happiness[0][0];
    maxPoints[0][1] = happiness[0][1];
    maxPoints[0][2] = happiness[0][2];


    // day number
    for(int i = 1 ; i < n ; i ++){

            // activity in previous day
            for(int j = 0 ; j < 3 ; j ++){

                    // activity in current day
                    for(int k = 0 ; k < 3 ; k ++){

                            if(k == j)continue; // can't do same activity in consecutive days

                            maxPoints[i][k] = max(maxPoints[i][k] , maxPoints[i-1][j] + happiness[i][k]);

                    }
            }
    }


    int ans = 0;
    for(int i = 0 ; i < 3 ; i ++){
            ans = max(ans , maxPoints[n-1][i]);
    }

    printf("%d\n" , ans);

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
   
/* brownsands :Arpit */			

void solve()
{
    int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout<<A[k-1];
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, l, max = 0, sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &l);
		sum += l;
		if (max < l) {
			max = l;
		}
	}
	printf("%s", sum - max > max ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 128
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
#define exist_in(list, value) (list.end() != std::find(all(list),value))
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }
//template<class T> bool exist_in(const T& c, const typename T::value_type& v) {	return (c.end() != std::find(c.begin(), c.end(), v));}

/*****/

void Main()
{
	string s1, s2;
	cin >> s1 >> s2;
	if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
		cout << "YES";
	else
		cout << "NO";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
              
    int a, b ;
          
    scanf ("%d %d", &a, &b) ;
              
    while (a % b != 0 && b % a != 0) {
        if (a < b) b = b % a ;
        else a = a % b ;
    }
              
    if (a <= b) printf ("%d\n", a) ;
    if (b < a) printf ("%d\n", b) ;
              
return 0 ;
}

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

int main(void) {
    int x, y, z, cnt = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> y >> z;
    while (true) {
        int width = y * cnt + z * (cnt + 1);
        if (x < width) {
            cnt--;
            break;
        }

        cnt++;
    }

    cout << cnt << "\n";
    return 0;
}

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

int main(){
  int num,one = 0;
  cin>>num;
  for(int i=0;i<2;i++){
    if(num%10==1) one++;
    num/=10;
  }
  if(num==1) one++;
  cout<<one<<endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b = 0;
	for (int h = 0; h < 200; h++) {
		cin >> a;
		if (a == -1) {
			cin >> n; return 0;
		}
		b += 1150;
		if (a > 10) {
			b += min(10, a - 10) * 125;
		}
		if (a > 20) {
			b += min(10, a - 20) * 140;
		}
		if (a > 30) {
			b += (a - 30) * 160;
		}
		cout << 4280 - b << endl;
		b = 0;
	}
	cin >> n;
}


Measured memory_bytes: 3004
s=input()
t=input()

tmp_i=0
tmp_j=0
ans_lst=[]
if len(s)<len(t):
    ans='UNRESTORABLE'
else:
    for i in range(len(s)-len(t)+1):
        cnt=0
        for j in range(len(t)):
            if s[i+j]==t[j] or s[i+j]=='?':
                cnt+=1
            if cnt==len(t):
                ans_s=s[:i]+t+s[i+len(t):]
                ans_lst.append(ans_s.replace('?','a'))
    else:
        ans='UNRESTORABLE'
ans_lst=sorted(ans_lst)
if len(ans_lst)==0:
    print(ans)
else:
    print(ans_lst[0])


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

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

    // solve
    vector<int> v;
    for (int i = 0; i < s.length(); ++i) {
        switch (s[i]) {
        case '0':
            v.push_back(0);
            break;
        case '1':
            v.push_back(1);
            break;
        case 'B':
            if (v.empty()) {
                break;
            } else {
                v.pop_back();
                break;
            }
        }
    }

    // output
    for (int i = 0; i < v.size(); ++i) {
        cout << v[i];
    }

    return 0;
}


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

int main(){
  string C[100];
  int H, W;
  cin >> H >> W;
  for(int i=0; i<H; i++){
    cin >> C[i];
  }
  for(int i=0; i<H; i++){
    cout << C[i] << endl;
    cout << C[i] << endl;
  }
  return 0;
}

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

int main(){
    int x,y;
    cin >> x >> y;
    cout << x + y/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib> 
#include<cstring>
using namespace std;
int read()
{
	int x=0,f=1; char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
int x,t,a;
int main()
{
	x=read(); t=read();
	if (x>t) a=x-t; 
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#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++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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() {
    string s; cin >> s;

    vector<bool> used(26, false);
    vector<string> v;
    rep(i, s.size()) {
        used[s[i] - 'a'] = true;

        rep(j, 26) {
            if (s[i] - 'a' >= j) continue;
            if (used[j]) continue;
            v.push_back(s.substr(0, i) + (char)('a' + j));
            break;
        }
    }
    rep(j, 26) {
        if (!used[j]) {
            v.push_back(s + (char)('a' + j));
            break;
        }
    }
    if (v.size() == 0) {
        cout << -1 << endl;
        return 0;
    }
    sort(all(v));
    cout << v[0] << endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

if h % 3 == 0 or w % 3 == 0:
    print(0)
    import sys
    sys.exit()


def c(H, W):
    r = 1000000000000000000000000000000
    for y in range(1, H):
        l = [W * y, (W // 2) * (H - y), (W - W // 2) * (H - y)]
        r = min(r, max(l) - min(l))
    return r

ans=min(c(h, w), c(w, h))
if h > 3:
    ans = min(ans, w)
if w > 3:
    ans=min(ans,h)
print(ans)



Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
 
#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
 
#define cauto const auto&
#else
 
#endif
 
using namespace std;
 
 
namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
 
#define VV(T) vector<vector< T > >
 
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
 
template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}
 
 
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
 
 
#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
 
void mainmain(){
	int n;
	cin>>n;
	vector<pll> v(n);
	rep(i,n){
		cin>>v[i].F>>v[i].S;
	}
	vvll dp;
	initvv(dp,n+1,n+1,(ll)INT_MAX);
	rep(i,n){
		dp[i][i+1]=0;
	}
	reep(i,2,n+1){
		reep(j,0,n-i+1){
			reep(k,j+1,j+i){
				dp[j][i+j]=min(dp[j][i+j],dp[j][k]+dp[k][i+j]+v[j].F*v[k-1].S*v[k].F*v[i+j-1].S);
			}
		}
	}
	cout<<dp[0][n]<<endl;
}
 
 
 
}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1272
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 1; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t n, a = 100;
  cin >> n;

  REP(i,3761) {
    a += a / 100;
    if(a >= n) {cout << i << endl; return 0;}
  }

  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 3616
v = 0
i = 0
a = []
while v == 0:
    x = input()
    if 0 == int(x):
        v = 1
    else:
        a.append(int(x))
        i = int(i) + 1

for j in range(int(i)):
    print('Case %d: %d' % (int(j)+1,a[int(j)] ))


Measured memory_bytes: 5904
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> p(n + 1); FOR(i, 1, n + 1) cin >> p[i];
  int cnt = 0;
  FOR(i, 1, n + 1) {
    if (p[i] != i) ++cnt;
  }
  cout << (cnt <= 2 ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> graph(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  };
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  sort(c.rbegin(), c.rend());
  vector<int> ans(n);
  int s = 0;
  queue<int> q;

  int cur = 0;
  auto push = [&](int v) {
    if(ans[v] > 0) return;
    ans[v] = c[cur];
    cur++;
    q.push(v);
  };
  push(0);

  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int u : graph[v]) {
      push(u);
    }
  }

  for(int i = 1; i < n; ++i) s += c[i];
  cout << s << endl;
  rep(i, n) {
    cout << ans[i] << endl;
  }

}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(100000) 
def f(n):
    if n == 0:
        return 0
    else:
        return n + f(n-1)
a, b = list(map(int,input().split()))
i1 = 1
i2 = 2
while True:
    if b - a == f(i2) - f(i1):
        break
    i1 += 1
    i2 += 1
print(f(i1) -a)

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

using ll = long long;
using ld = long double;

int main()
{
    int a,b,c,x, ans=0;
    cin >> a >> b >> c >> x;
    
    
    for(int i = 0; i <= a; i++)
    {
        
        for(int j = 0; j <= b; j++)
        {
            
            for(int k = 0; k <= c; k++)
            {
                if(i*500+j*100+k*50 == x)
                {
                    ans++;
                }
            }
            
        }
        
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
<?php
    fscanf(STDIN, "%d", $n);
    $non_taxed_price = $n / 1.08;
        $r_up = ceil($non_taxed_price);
        $r_dn = floor($non_taxed_price);
        if(floor($r_up * 1.08) == $n){
            echo $r_up;
        }elseif(floor($r_dn * 1.08) == $n){
            echo $r_dn;
        }else{
            echo ':(';
        }
?>

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    B.at(A.at(i) - 1) = (i + 1);
  }
  for (int i = 0; i < N; i++) {
    cout << B.at(i) << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const LL inf = 1e9;
const int maxn = 55;
int N,K;
LL x[maxn],y[maxn];

bool inside(
    const int i, const LL x1, const LL x2, const LL y1, const LL y2)
{ return x1 <= x[i] && x[i] <= x2 && y1 <= y[i] && y[i] <= y2; }

int main()
{
    while (cin >> N >> K) {
        FOR(i,0,N)
            cin >> x[i] >> y[i];
        LL ans = 2*inf*2*inf;
        FOR(i,0,N) FOR(j,i+1,N) FOR(k,0,N) FOR(h,k+1,N) {
            LL X[] = { x[i], x[j] };
            LL Y[] = { y[k], y[h] };
            if (X[0] > X[1])
                swap(X[0],X[1]);
            if (Y[0] > Y[1])
                swap(Y[0],Y[1]);
            const LL A = (X[1]-X[0])*(Y[1]-Y[0]);
            if (0 < A) {
                int cnt = 0;
                FOR(ii,0,N) 
                    cnt += inside(ii,X[0],X[1],Y[0],Y[1]);
                if (cnt >= K)
                    ans = min(ans,A);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdbool.h>
bool prime(int x){
  if(x<=1){
    return false;
  }
  for(int loop=2;loop*loop<=x;loop++){
    if(x%loop==0){
      return false;
    }
  }
  return true;
}
signed main(void){
  int x;
  scanf("%d",&x);
  int p=x;
  while(!prime(p)){
    p++;
  }
  printf("%d\n",p);
  return 0;
}


Measured memory_bytes: 1688
N = int(input())
B = list(map(int,input().split()))
s = B[0]
for i in range(N-2):
    # print(i)
    if i == N - 2:
        s += B[i]
        # print(B[i])
        break
    else:
        if B[i] > B[i + 1]:
            s += B[i+1]
        else:
            s += B[i]
    # print(B[i])
s += B[N-2]
print(s)

Measured memory_bytes: 9032
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int[] num = new int[n];

    for (int i = 0; i < n; i++) {
      num[i] = cin.nextInt();
    }

    int[] right = new int[n + 1];

    for (int i = n - 1; i > 0; i--) {
      right[i] = calGCD(num[i], right[i + 1]);
    }

    int res = 0;
    int left = 0;
    for (int i = 0; i < n; i++) {
      res = Math.max(calGCD(left, right[i + 1]), res);
      left = calGCD(left, num[i]);
    }
    System.out.println(res);

  }

  private static int calGCD(int a, int b) {
    if (a == 0 || b == 0) {
      return a == 0 ? b : a;
    }
    if (a >= b) {
      return calGCD(b, a % b);
    } else {
      return calGCD(a, b % a);
    }
  }


}


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

int main() {
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
cin>>vec[i];
  }
sort(vec.begin(),vec.end());
  cout<<vec[N-1]-vec[0]<<endl;

  
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000

int size,X[MAX];

void maxHeapify(int i){
  int l,r,LL,a;
  l = 2*i;
  r = 2*i+1;
  if(l<=size && X[l]>X[i])LL = l;
  else LL = i;
  if(r<=size && X[r]>X[LL])LL = r;
  if(LL != i){
    a = X[i];
    X[i] = X[LL];
    X[LL] = a;
    maxHeapify(LL);
  }
}
int main(){
  int i;
  scanf("%d",&size);
  for(i=1;i<=size;i++)scanf("%d",&X[i]);
  for(i=size/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=size;i++){
    printf(" %d",X[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3688
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5,MAX_M=1e5;

int N,M;
ll A[MAX_N],B[MAX_N],C[MAX_N];
const ll INF=1e17;
vector<int> G[MAX_N];

int tpar[MAX_N];
vector<int> tre[MAX_N];
ll dp[MAX_N],bsm[MAX_N];

int upar[MAX_N];

void init(){
	REP(i,N){
		upar[i]=i;
	}
}

int fpar(int v){
	if (upar[v]==v){
		return v;
	}
	return upar[v]=fpar(upar[v]);
}

void unite(int s,int t){
	s=fpar(s);
	t=fpar(t);
	upar[t]=s;
}

void dfs(int v,int p){
	for(auto e:tre[v]){
		if (e!=p){
			dfs(e,v);
		}
	}
	bsm[v]+=B[v];
	for(auto e:tre[v]){
		if (e!=p){
			bsm[v]+=bsm[e];
		}
	}
	dp[v]=C[v]+bsm[v];
	for(auto e:tre[v]){
		if (e!=p){
			dp[v]=min(dp[v],max(dp[e],C[v])+bsm[v]-bsm[e]);
		}
	}
}

int main(){
	cin>>N>>M;
	REP(i,N){
		cin>>A[i]>>B[i];
		C[i]=max(A[i]-B[i],0ll);
	}
	REP(i,M){
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	init();
	REP(i,N){
		tpar[i]=i;
	}
	{
		vector<bool> flg;
		vector<int> vec;
		REP(i,N){
			vec.push_back(i);
			flg.push_back(false);
		}
		sort(vec.begin(),vec.end(),[](int a,int b){
			return C[a]<C[b];
		});
		for(auto v:vec){
			for(auto e:G[v]){
				if (C[v]>C[e] || (C[v]==C[e] && flg[e])){
					tpar[fpar(e)]=v;
					upar[fpar(e)]=v;
				}
			}
			flg[v]=true;
		}
	}
	int rot;
	REP(v,N){
		if (tpar[v]==v){
			rot=v;
		}else{
			tre[v].push_back(tpar[v]);
			tre[tpar[v]].push_back(v);
		}
	}
	dfs(rot,-1);
	cout<<dp[rot]<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  int cnt[n]={};
  for(int i=1; i<n; i++){
    if(s[i-1]=='A' && s[i]=='C') cnt[i] = cnt[i-1]+1;
    else cnt[i] = cnt[i-1];
  }
  for(int i=0; i<q; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(a==0) cout << cnt[b] << endl;
    else cout << cnt[b] - cnt[a] << endl;
  }
  return 0;
}


Measured memory_bytes: 4084