akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
 
    using namespace std;
    using namespace __gnu_pbds;
 
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define int long long 
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
 
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
 
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
 
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
 
/*.....................................................................................................................*/
 
    const ll mod=(ll)1e9+ 7;
 
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
 
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
 
    //A.erase(unique(A.begin(),A.end()),A.end());
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll  man  =   (int)200005   ,  inf   =   1e18;
 
 
/*......................................................................................................................*/

const int vmax=1e5+1;

signed main()
{
    fast;
    int n,w;
    cin>>n>>w;
    vector<int>dp(vmax,inf);
    dp[0]=0;
    vector<pair<int,int>>a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i].first>>a[i].second;
    }
    for(pair<int,int>x:a)
    {
        for(int i=vmax-1;i>=0;i--)
        {
            if(i-x.second>=0)
            {
                dp[i]=min(dp[i],dp[i-x.second]+x.first);
            }
        }
    }
    int ans=0;
    for(int i=0;i<vmax;i++)
    {
        if(dp[i]<=w)ans=i;
    }
    cout<<ans<<endl;
}   

Measured memory_bytes: 3984
n=int(input())
a=[list(input()) for i in range(n)]
if max([a[i].count("#") for i in range(n)]) ==0:
  print(-1)
  exit()
minus=0
b=list(zip(*a))
for i in range(n):
  if b[i].count("#")>=1:
    minus=max(minus,a[i].count("#"))
  else:
    minus=max(minus,a[i].count("#")-1)
for j in range(n):
  if b[j].count(".")==0:
    minus+=1
print(2*n-minus)

Measured memory_bytes: 7412
L = input()
N = len(L)
MOD = 10**9+7

dp = [[0,0] for i in range(N+1)]
dp[0][0] = 1
for i,a in enumerate(L):
    a = int(a)
    for less in range(2):
        for d in range(2):
            if less==0 and d > a: continue
            nl = int(less or d < a)
            dp[i+1][nl] += dp[i][less] * (d+1)
    dp[i+1][0] %= MOD
    dp[i+1][1] %= MOD

print(sum(dp[-1]) % MOD)

Measured memory_bytes: 24124
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

// ����̕�����𐔂���֐�
size_t count(const string& str, const string& sub, const size_t ini = 0, const size_t fin = string::npos) {
	size_t pos = str.find(sub, ini);
	size_t cnt = 0;
	while (pos < fin) {
		cnt += 1;
		pos = str.find(sub, pos + sub.length());
	}
	return cnt;
}

int main() {

	string S;
	cin >> S;

	vector<long long> v(3, 0);
	v[0] = count(S, "a");
	v[1] = count(S, "b");
	v[2] = S.length() - v[0] - v[1];

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

	v[1] -= v[0];
	v[2] -= v[0];

	if (v[1] <= 1 && v[2] <= 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 3724
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, h, a[100005], b[100005], i, amax = 0, ans = 0, bb = 0;

	cin >> n >> h;
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (amax < a[i]) {
			amax = a[i];
		}
	}

	sort(b, b + i, greater<int>());

	for (bb = 0; bb < n && b[bb] > amax; bb++) {
		ans++;
		h -= b[bb];
		if (h <= 0) {
			cout << ans << endl;
			return 0;
		}
	}
	ans += (h % amax == 0)? h / amax : h / amax + 1;

	cout << ans << endl;
}

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

using namespace std;

int field[6][6];
int dp[6][6][1<<12];
int n;
const int INF=1000000000;
int seiseki[4];

// óÔsÌidxÔÚÌlðæèo·
int getValue(int s,int idx){
    int b1=((s>>idx*2)&1);
    int b2=((s>>idx*2+1)&1);
    return b1+2*b2;
}
// óÔsÌidxÔÚÉlxðZbg
void setValue(int &s,int idx,int x){
    int b1=((x>>0)&1);
    int b2=((x>>1)&1);
    if(b1==0)
        s&=~(1<<idx*2);
    else
        s|=(1<<idx*2);
    if(b2==0)
        s&=~(1<<(idx*2+1));
    else
        s|=(1<<(idx*2+1));
}
// (»Ýn_ÌxÀW,»Ýn_ÌyÀW,êÔµ½5}XÌóÔ
int rec(int x,int y,int s){
    if(x==4){
        x=0;
        y++;
        if(y==4){
            int res=0;
            // ¡ÌsÌlð0-4Ìn_ÌàÌð·×Ä«µí¹A»êðÔ·
            for(int i = 0; i < 5; i++)
                if(field[y][i]!=-1)
                    res+=seiseki[getValue(s,i)];
            return res;
        }
    }
    if(dp[y][x][s]!=INF)
        return dp[y][x][s];
    int maxCost=0;
    // »Ýn_ð½ñ·©
    for(int i = 0; i <= 3; i++){
        if(x==0){
            int ns=0;
            setValue(ns,5,getValue(s,4));
            setValue(ns,4,getValue(s,3));
            setValue(ns,3,getValue(s,2));
            setValue(ns,2,(getValue(s,1)+i)%4);
            setValue(ns,1,(max(0,field[y+1][x+1])+i)%4);
            setValue(ns,0,(max(0,field[y+1][x])+i)%4);
            // ¶ãÌêÌXRAðmè³¹é
            int res=0;
            if(field[y][x]!=-1)
                res+=seiseki[(getValue(s,x)+i)%4];
            // rec
            maxCost=max(maxCost,res+rec(x+1,y,ns));
        }
        else{
            int ns=0;
            for(int j = 0; j < 6; j++){
                if(j==x||j==x+2)
                    setValue(ns,j,(getValue(s,j)+i)%4);
                else
                    setValue(ns,j,getValue(s,j));
            }
            setValue(ns,x+1,(max(0,field[y+1][x+1])+i)%4);
            // ¶ãÌêÌXRAðmè³¹é
            int res=0;
            if(field[y][x]!=-1)
                res+=seiseki[(getValue(s,x+1)+i)%4];
            // EãÌXRAàmè³¹é
            if(x==3)
                if(field[y][x+1]!=-1)
                    res+=seiseki[(getValue(s,x+2)+i)%4];
            maxCost=max(maxCost,res+rec(x+1,y,ns));
        }
    }
    return dp[y][x][s]=maxCost;
}
int main(){
    seiseki[0]=0;
    seiseki[1]=60;
    seiseki[2]=70;
    seiseki[3]=80;
    cin>>n;
    for(int q=0;q<n;q++){
        for(int i = 0; i < 6; i++)
            for(int j = 0; j < 6; j++)
                for(int k = 0; k < (1<<12); k++)
                    dp[i][j][k]=INF;
        for(int i = 0; i < 5; i++){
            for(int j = 0; j < 5; j++){
                cin>>field[i][j];
                field[i][j]--;
            }
        }
        int s=0;
        for(int i = 0; i < 5; i++)
            setValue(s,i,max(0,field[0][i]));
        int res=rec(0,0,s);
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 1444
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();


        if (a + b > c + d) {
            System.out.println("Left");
        } else if (a + b < c + d) {
            System.out.println("Right");
        } else {
            System.out.println("Balanced");
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <queue>
using namespace std;
int main(){
  long N,M;
  cin>>N>>M;
  
  std::priority_queue<int> q;
  for(int i=0;i<N;i++){
    long long a;
    cin>>a;
    q.push(a);
  }
  for(int i=0;i<M;i++){
    long long top=q.top();
    q.pop();
    q.push(top/2);
  }
  long long price=0;
  while(!q.empty()){
    price+=q.top();
    q.pop();
  }
  cout<<price<<endl;
  return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

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

		while(i <= n) {
			int x = i;
			if (x % 3 == 0 ) {
				System.out.print(" " + i);
				i++;
			}else if (x % 10 == 3 ) {
				System.out.print(" " + i);
				i++;
			}else { //ここの中考える
				x /= 10;
				if(x == 0)
					;
				else if(x >= 1) {
					while(x >= 1) {
						if(x % 10 == 3 ) {
							System.out.print(" " + i);
							x /= 10000;
						}else {
							x /= 10;
						}
					}
				}
				i++;
			}
		}
		System.out.println();
		sc.close();
	}
}


Measured memory_bytes: 28560
#include<iostream>
using namespace std;
int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  --k;
  if (s[k] >= 'A' && s[k] <= 'Z') s[k] = s[k] - 'A' + 'a';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scan_init()
	a := scanInt()
	b := scanInt()
	if 6 <= a &&  a <= 12 {
		fmt.Println(b/2)
	} else {
		if a <= 5 {
			fmt.Println(0)
		} else {
			fmt.Println(b)
		}
	}
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

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

using namespace std;

int main()
{
   int a[3],k;
   cin>>a[0]>>a[1]>>a[2]>>k;
   sort(a,a+3);
   int sum=a[0]+a[1];
   int s=a[2];
   for(int  i=0;i<k;i++)
   s=2*s;

   cout<<sum+s<<endl;

    return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
mina= 100
minb=100
a = set()
b = set()
C = A/0.08
D= B/0.1
E=(A+1)/0.08
F=(B+1)/0.1 
if C.is_integer() ==False:
  C= A//0.08 +1
if D.is_integer() ==False:
  D= B//0.1 +1

if E.is_integer() ==False:
  E= (A+1)//0.08 

if F.is_integer() ==False:
  F= (B+1)//0.1

C=int(C)
D=int(D)
E=int(E)
F=int(F)
for i in range(C,E):
  a.add(i)
for i in range(D,F):
  b.add(i)
c = a&b
d = list(c)
d.sort()
if len(d) ==0:
  print(-1)
else:
  print(d[0])




Measured memory_bytes: 3192
def sixnumber(aaa)
    
    aaa = aaa.to_s
    ll = aaa.length
    
    (6-ll).times{
        
        aaa = "0"+aaa
    }
    
    return aaa
    
end


n,m = gets.split.map(&:to_i)

arr = []

ansarray = Array.new(m,0)

i = 0
m.times{
    
    aa = gets.split.map(&:to_i)
    
    aa+=[i]
    i+=1
    arr<<aa}


arr = arr.sort



i = 0
count = 1
m.times{
    
    if i>0 && arr[i][0] == arr[i-1][0]
        
        count+=1
        
    else 
        count = 1
    end
    pre = arr[i][0]
    id = arr[i][2]
    
    ansarray[id] = sixnumber(pre)+sixnumber(count)
    
    
    i+=1
}


i = 0
m.times{
    
    puts ansarray[i]
    i+=1
}








Measured memory_bytes: 18156
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <cstdio>
int main()
{
 char c;
 scanf("%c",&c);
 if(c>='A'&&c<='Z')
  puts("A");
 else
  puts("a");
 return 0;
}

Measured memory_bytes: 1540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll M;
    cin >> M;
    ll d, c;
    ll S = 0;
    ll k = 0;
    for (int i = 0; i < M; i++) {
        cin >> d >> c;
        k += c;
        S += d*c;
    }
    printf("%lld\n", (S-1)/9 + k-1);

}

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

#define MOD 1000000007
int N;

int main() {
    cin >> N;
    long long ans = 1;
    for (int i = 1; i <= N; i++) {
        ans = ans * i % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main(void){
    int num;
    string numStr;
    cin >> num;
    numStr = to_string(num);
    int Sn = 0;

    for(int i=0; i<numStr.size(); i++){
    	Sn += numStr[i] - '0';
    }

    if(num % Sn == 0){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	ll n;cin>>n;
    vector<ll> a(n);
    rep(i,0,n) cin>>a[i];
    int q;cin>>q;
    map<ll,ll> lis;
    ll sum = 0;
    rep(i,0,n){
        lis[a[i]]++;
        sum+=a[i];
    }
    rep(i,0,q){
        ll b,c;cin>>b>>c;
        if (lis[b]){
            lis[c] += lis[b];
            sum = sum-b*lis[b]+c*lis[b];
            lis[b] = 0;
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 9588
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline split-ints-into-vector))
(defun split-ints-into-vector (string dest-vector &key (offset 0) (key #'identity))
  (declare (string string)
           (function key)
           ((array * (*)) dest-vector)
           ((integer 0 #.most-positive-fixnum) offset))
  (loop with position = 0
        for idx from offset below (length dest-vector)
        do (setf (values (aref dest-vector idx) position)
                 (parse-integer string :start position :junk-allowed t))
           (setf (aref dest-vector idx) (funcall key (aref dest-vector idx)))
        finally (return dest-vector)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (declare (inline sort))
  (let* ((n (read))
         (m (read))
         (xs (make-array m :element-type 'int32))
         (deltas (make-array (- m 1) :element-type 'uint32)))
    (split-ints-into-vector (read-line) xs)
    (setf xs (sort xs #'<))
    (dotimes (i (- m 1))
      (setf (aref deltas i) (- (aref xs (+ i 1)) (aref xs i))))
    (setf deltas (sort deltas #'<))
    (println
     (loop for i below (max (- m n) 0)
           sum (aref deltas i)))))

#-swank(main)


Measured memory_bytes: 41448
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long l = sc.nextInt();
		long t = sc.nextInt();

		int[] x = new int[n];
		int[] w = new int[n];

		for(int i=0;i<n;i++) {
			x[i] =  sc.nextInt();
			w[i] =  sc.nextInt();
		}

		int[] y = new int[n];



		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0;i<n;i++) {
			if(w[i]==1) {
				y[i] = location(l,x[i]+t);
			}else {
				y[i] = location(l,x[i]-t);
			}
			list.add(y[i]);
		}
		int firstIndex = y[0];
		Collections.sort(list);

		long counter =0;

		if(w[0]==1) {
			for(int i = 1;i<n;i++) {
				if(w[i]==2) {
					if(t*2-(x[i]-x[0])<0) {

					}else {
						counter+=(t*2-(long)(x[i]-x[0]))/l+1;
					}
				}
			}
			counter = (counter+1)%n;
			if(counter ==0)counter =n;

		}else {
			for(int i = n-1;i>0;i--) {
				if(w[i]==1) {
					if(t*2-(x[0]+l-x[i])<0) {

					}else {
						counter+=(t*2-(x[0]+l-x[i]))/l+1;
					}
				}
			}
			counter = (1-counter);

			counter = counter%n;
			if(counter<=0)counter+=n;
		}


		int offset = -1;
		if(w[0]==1) {
			offset =(int) (list.lastIndexOf(firstIndex)-counter);
		}else {
			offset = (int) (list.indexOf(firstIndex)-counter);
		}


		for(int i =1;i<n+1;i++) {
			int listindex = offset+i;
			if(listindex<0) {
				listindex+=n;
			}
			if(listindex>=n) {
				listindex-=n;
			}
			System.out.println(list.get(listindex));
		}



		/*
		TreeMap<Integer,Integer> treeMap = new TreeMap<>();//sorted no duplication
		treeMap.put(b[n], n);
		*/

	}

	static int location(long length,long value) {

		int loc = (int) (value%length);
		if(loc<0)loc+=length;

		return loc;
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 95580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
    T res = 1;
    for (; n; n >>= 1)
    {
        if (n & 1)
            res = res * a;
        a = a * a;
    }
    return res;
}

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

signed main()
{
    int n;
    cin >> n;
    vector<ll> v(n), pac(101, 0);
    rep(i, 0, n)
    {
        cin >> v[i];
        pac[v[i]]++;
    }
    sort(all(v));
    int mx = v.back();

    if (mx % 2 == 0)
    {
        if (pac[mx / 2] != 1)
        {
            cout << "Impossible" << endl;
            return 0;
        }

        rep(i, mx / 2 + 1, mx+1)
        {
            if (pac[i] < 2)
            {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    else
    {
        if (pac[(mx + 1) / 2] != 2)
        {
            cout << "Impossible" << endl;
            return 0;
        }

        rep(i, (mx+1) / 2 + 1, mx+1)
        {
            if (pac[i] < 2)
            {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    cout<<"Possible"<<endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong a,b,N;
	bool check[1001] = {false};

	cin >> a >> b >> N;
	int s,f;
	for(int i = 0; i < N; i++){
		cin >> s >> f;
		for(int j = s; j < f; j++)
			check[j] = true;
	}

	bool ok = false;
	for(int i = a; i < b; i++)
		if(check[i])
			ok = true;

	cout << ok << endl;

	return 0;
}


Measured memory_bytes: 3096
import scala.io.StdIn.readLine

object Main {

  def play(sb:StringBuilder):Unit = {
    val r = readLine.split(" ")
    if(r(0).toInt==0 && r(1).toInt==0) print(sb.result)
    else {
      var hit = 0
      var blow = 0
      for(i<-0 until r(0).length) {
        if(r(0)(i) == r(1)(i)) hit += 1
        else {
          for(j<-0 until r(1).length) {
            if(r(0)(i) == r(1)(j)) blow += 1
          }
        }
      }
      sb.append(hit + " " + blow + "\n")
      play(sb)
    }
  }

  def main(args:Array[String]) = play(new StringBuilder)
}

Measured memory_bytes: 56316
n, k = map(int, input().split())
r, s, p = map(int, input().split())
pointMap = {
  'r': p, 's': r, 'p': s
}

t = input()

pointSum = 0
preList = ['x'] * k # 一手前を覚えておくリスト

for i, c in enumerate(t):
  if preList[i % k] == c:
    preList[i % k] = 'x'
    continue
  pointSum += pointMap[c]
  preList[i % k] = c

print(pointSum)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    int N, M, s, t, p;
    cin >> N >> M;
    vector<pii> v[2];
    for (int i = 0; i < N; i++) {
        cin >> s >> t;
        int j = i+1;
        if (s < t) {
            v[0].push_back(pii(s, j));
            v[0].push_back(pii(t, j));
        } else {
            v[1].push_back(pii(s, -j));
            v[1].push_back(pii(t, -j));
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p;
        v[0].push_back(pii(p, 0));
        v[1].push_back(pii(p, 0));
    }

    sort(v[0].begin(), v[0].end());
    sort(v[1].rbegin(), v[1].rend());

    ll res = 0;
    for (int i = 0; i < 2; i++) {
        vector<int> use(N, -1);
        int cut = 0, even = 0, odd = 0;
        for (int j = 0; j < (int)v[i].size(); j++) {
            int k = (i == 0 ? +1 : -1);
            int x = v[i][j].second * k;
            if (j > 0) {
                ll cost = k * (ll)(v[i][j].first - v[i][j-1].first) * even;
                res += cost;
            }
                
            if (x != 0) {
                x--;
                if (use[x] == -1) {
                    use[x] = cut;
                    even++;
                } else {
                    if ((cut - use[x]) % 2 == 0) {
                        even--;
                    } else {
                        odd--;
                    }
                }
            } else {
                cut++;
                swap(even, odd);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6440
from math import sqrt


def solve():
    N, D = map(int, input().split())
    x_l = [0 for _ in range(N)]
    for i in range(N):
        x_l[i] = list(map(int, input().split()))
    ans = 0

    for i in range(N-1):
        for j in range(i+1, N):
            distance = 0
            for k in range(D):
                distance += (x_l[i][k] - x_l[j][k]) ** 2
            distance = sqrt(distance)
            if distance.is_integer():
                ans += 1

    print(ans)


if __name__ == '__main__':
    solve()

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

int main() {
    string s, t;
    cin >> s >> t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
double a[100],b[100];
double res[100];
int main(){
 int a,b;
 cin>>a>>b;
 for(int i=0;i<b/10000+1;i++){
  for(int j=0;j<b/5000+1;j++){
   if(a-(i+j)>=0 ){
    if(10000*i+5000*j+1000*(a-(i+j))==b){
      cout<<i<<" "<<j<<" "<<a-i-j<<endl;
      return 0;
    } 
   }
  }
 }
 cout<<"-1 -1 -1"<<endl;
 return 0;


}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int dp[3005][3005];

void solve() {
    int N, T; cin >> N >> T;
    vector<P> v(N);
    rep(i, N){
        int a, b; cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    sort(all(v));
    int res = 0;
    rep(i, N){
        rep(j, T){
            if(j-v[i].first < 0){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-v[i].first]+v[i].second);
            }
        }
        res = max(res, dp[i][T-1]+v[i].second);
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

const ll MAX_N=1001;



int main(){

  ll n;cin>>n;
  ll dp[100001];
  fill(dp,dp+100001,INF);
  dp[0]=0;
  rep(i,1,n+1){
    dp[i]=dp[i-1]+1;
    for(ll j=6;i-j>=0;j*=6)chmin(dp[i],dp[i-j]+1);
    for(ll j=9;i-j>=0;j*=9)chmin(dp[i],dp[i-j]+1);
  }

  out(dp[n]);

  return 0;
}


Measured memory_bytes: 1024
s = input()
k = int(input())

kn = len(s) * k
k_list = set(s)

for i in range(2, k+1):
    for j in range(len(s)):
        k_list.add(s[j:j+i])

k_list = list(k_list)
k_list.sort()
print(k_list[k-1])

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
struct unionfind{
  vector<int> p;
  unionfind(int N){
    p = vector<int>(N, -1);
  }
  int root(int x){
    if (p[x] == -1){
      return x;
    } else {
      p[x] = root(p[x]);
      return p[x];
    }
  }
  bool same(int x, int y){
    return root(x) == root(y);
  }
  void unite(int x, int y){
    x = root(x);
    y = root(y);
    if (x != y){
      p[x] = y;
    }
  }
};
int main(){
  int N, Q;
  cin >> N >> Q;
  unionfind UF(N);
  for (int i = 0; i < Q; i++){
    int t;
    cin >> t;
    if (t == 0){
      int u, v;
      cin >> u >> v;
      UF.unite(u, v);
    }
    if (t == 1){
      int u, v;
      cin >> u >> v;
      if (UF.same(u, v)){
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
}

Measured memory_bytes: 3864
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        try{
            int age = scanner.nextInt();
            int adultPrice = scanner.nextInt();
            int finalPrice = -1;
            if(age<6) finalPrice = 0;
            else if(age<13) finalPrice = adultPrice/2;
            else finalPrice = adultPrice;
            System.out.println(finalPrice);
        }catch(Exception e){
            System.out.println(e.getMessage());
        }finally{
            scanner.close();
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 310010
#define offset 30010
using namespace std;
typedef long long  ll;
typedef pair<short,short> ii;
typedef pair<ii,ii> iiii;
typedef vector<ll> vi;
const ll MOD=1e9+7;
vi V[tam];
map<iiii,ll> todo;
vector<iiii> vper;
vi auxmove(4,0);
iiii move(vi &nuevo,ll &delta)
{
    
    forr(i,0,4)
    {
        auxmove[i]=(nuevo[(i+delta)-4*((i+delta)>=4)]);
    }
    return mp(mp(auxmove[0],auxmove[1]),mp(auxmove[2],auxmove[3]));
}
void add(vi &nuevo,ll delta,map<iiii,ll> &mapa)
{
    //permutar(nuevo);
    forr(i,0,4)
    {
        mapa[move(nuevo,i)]+=delta;
    }
}
vector<iiii> vcaras(4);
iiii auxcara;
void gocaras(vi &v1,vi& v2)
{
    auxcara.fi.fi=v1[0],auxcara.se.se=v1[1],auxcara.fi.se=v2[0],auxcara.se.fi=v2[3];vcaras[0]=auxcara;
    auxcara.fi.fi=v1[1],auxcara.se.se=v1[2],auxcara.fi.se=v2[3],auxcara.se.fi=v2[2];vcaras[1]=auxcara;
    auxcara.fi.fi=v1[2],auxcara.se.se=v1[3],auxcara.fi.se=v2[2],auxcara.se.fi=v2[1];vcaras[2]=auxcara;
    auxcara.fi.fi=v1[0],auxcara.se.se=v2[0],auxcara.fi.se=v1[3],auxcara.se.fi=v2[1];vcaras[3]=auxcara;

}
void fiiv(vi &v1,iiii val)
{
    if (v1.size()<4)
        v1.assign(4,0);
    v1[0]=val.fi.fi;
    v1[1]=val.fi.se;
    v1[2]=val.se.fi;
    v1[3]=val.se.se;
}
int main()
{
   ios::sync_with_stdio(false);cin.tie(0);
   ll n;
   cin>>n;
   forr(i,0,n)
   {
        vi nuevo(4);
        forr(j,0,4)
            cin>>nuevo[j];
        add(nuevo,1,todo);
        V[i]=nuevo;
   }
   vi cara1,cara2;
   //permutar(V[2]);
   map<iiii,ll> extra;
   ll totp,answer=0,auxtotp;
   //return 0;
   vi vcarasvii;
   forr(i,0,n)
   {
        forr(j,i+1,n)
        {
            if (i==j)continue;
            //i=0,j=4;
            forr(ki,0,4)
            {
                //forr(kj,0,4)
                {
                    extra.clear();
                    fiiv(cara1,move(V[i],ki));
                    ll meh=0;
                    fiiv(cara2,move(V[j],meh));
                    /*<<"comenzamos\n";
                    prll(cara1);
                    prll(cara2);
                    <<"\n";*/
                    gocaras(cara1,cara2);
                    /*forr(l,0,vcaras.size()){
                        prll(vcaras[l]);
                    } */     
                    //<<endl;
                    add(cara1,1,extra);
                    add(cara2,1,extra);
                    //vcaras.pb(cara1);
                    //vcaras.pb(cara2);
                    totp=1;
                    forr(l,0,vcaras.size())
                    {
                        //<<totp<<' '<<l<<" "<<todo[vcaras[l]]<<endl;
                        auxtotp=todo[vcaras[l]]-extra[vcaras[l]];
                        totp*=(auxtotp);
                        fiiv(vcarasvii,vcaras[l]);
                        add(vcarasvii,1,extra);
                    }
         //           <<endl;
                    answer+=totp;

                }
            }
            //break;
        }
        //break;
   }
   //cout<<answer<<endl;
   cout<<answer/3<<endl;

}   


Measured memory_bytes: 87424
import java.util.Scanner;

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

    int aPos = sc.nextInt();
    int aSpeed = sc.nextInt();
    int bPos = sc.nextInt();
    int bSpeed = sc.nextInt();
    int time = sc.nextInt();

    int diffSpeed = aSpeed - bSpeed; //if +, a is faster; if -, b is faster
    int diffPos = Math.abs( aPos - bPos );

    if( diffSpeed <= 0 ){ //if same speed or b is faster
      System.out.println("NO");
    }else{ //if a is faster
      /*
      if( ((double)diffPos / time) <= diffSpeed ){ //compare speeds
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
      */

      if( ((long)diffSpeed * time) >= diffPos ){ //must use long as can reach high value
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }

  }
}


Measured memory_bytes: 27024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const double eps=1e-9;
vector<int>vec[10010];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",vec[i].size());
    }
    return 0;
}


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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(a+b >= x && a <= x){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d)
	cout<<"Yes";
	else if(abs(a-c)>d&&abs(a-b)<=d&&abs(b-c)<=d)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    string S;
    cin >> N >> S;

    map<string, int> Left, Right;

    for (int bit = 0; bit < (1 << N); ++bit)
    {
        string B, R;
        for (int i = 0; i < N; i++)
        {
            if (bit & (1 << i))
            {
                B.push_back(S[i]);
            }
            else
            {
                R.push_back(S[i]);
            }
        }
        reverse(ALL(R));
        B.push_back(' ');
        B.append(R);
        Left[B]++;
    }
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        string B, R;
        for (int i = 0; i < N; i++)
        {
            if (bit & (1 << i))
            {
                B.push_back(S[i + N]);
            }
            else
            {
                R.push_back(S[i + N]);
            }
        }
        reverse(ALL(R));
        R.push_back(' ');
        R.append(B);
        Right[R]++;
    }
    int ans = 0;
    for (auto itr = Left.begin(); itr != Left.end(); ++itr)
    {
        string key = itr->first;
        // cout << key << " " << Left[key] << " " << Right[key] << endl;
        ans += Left[key] * Right[key];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 88448
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d",a)
using namespace std;
int a,b;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
    return s*t;
}
int main()
{
	a=read(); b=read();
	if (a%2==0||b%2==0) puts("Even");
	else puts("Odd");
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 01.01.2020 20:09:07       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  vector<int> d(n - 1);
  for (int i = 0; i < n - 1; i++) {
    d[i] = x[i + 1] - x[i];
  }
  int m;
  long long k;
  cin >> m >> k;
  vector<int> p(n - 1);
  for (int i = 0; i < n - 1; i++) {
    p[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    swap(p[x - 2], p[x - 1]);
  }
  vector<int> q(n - 1);
  for (int i = 0; i < n - 1; i++) {
    q[i] = i;
  }
  while (k > 0) {
    if (k & 1) {
      vector<int> r(n - 1);
      for (int i = 0; i < n - 1; i++) {
        r[i] = p[q[i]];
      }
      swap(q, r);
    }
    vector<int> r(n - 1);
    for (int i = 0; i < n - 1; i++) {
      r[i] = p[p[i]];
    }
    swap(p, r);
    k >>= 1;
  }
  vector<int> new_d(n - 1);
  for (int i = 0; i < n - 1; i++) {
    new_d[i] = d[q[i]];
  }
  long long res = x[0];
  cout << res << '\n';
  for (int i = 0; i < n - 1; i++) {
    res += new_d[i];
    cout << res << '\n';
  }
  return 0;
}


Measured memory_bytes: 3176
def is_prime(x):
    if x <= 1:
        return False
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True

cnt = 0
for _ in range(int(input())):
    if is_prime(int(input())):
        cnt += 1
print(cnt)

Measured memory_bytes: 7752
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i > 0; i--)
#define reps(i, m, n) for(int i = m; i <= n; i++)
#define reprs(i, m, n) for(int i = n; i >= m; i--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}


int main(){

  int N;
  string S;
  int K;
  cin >> N >>K >>S;

  K--;

  S[K]-='A'-'a';

  cout << S <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 100
 
int main(){
  int i,j,k,n,key,A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  for(i=0;i<n-1;i++) printf("%d ",A[i]);
  printf("%d\n",A[i]);


  for(i=1;i<n;i++){
    key = A[i];
    j = i - 1;
    while(j>=0 && A[j]>key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    for(k=0;k<n-1;k++) printf("%d ",A[k]);
    printf("%d\n",A[k]);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    string str;
    int n,m,asize,bsize;
    vector<int> a,b;
    cin >> n;
    for(int i; i < n; i++){
        cin >> m;
        a.push_back(m);
        b.push_back(m);
    }

    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()), a.end());
    asize = a.size();
    bsize = b.size();
    if(asize == bsize){
        cout << "YES";
    } else if (asize != bsize){
        cout << "NO";
    }

    return 0;
}



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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long A, long long B, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> x, std::vector<long long> y, std::vector<long long> c) {

    int ans = *min_element(all(a)) + *min_element(all(b));
    rep(i, M) {
        chmin(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }
    cout << ans << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> a(A);
    for (int i = 0; i < A; i++) {
        scanf("%lld", &a[i]);
    }
    std::vector<long long> b(B);
    for (int i = 0; i < B; i++) {
        scanf("%lld", &b[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    std::vector<long long> c(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
        scanf("%lld", &c[i]);
    }
    solve(A, B, M, std::move(a), std::move(b), std::move(x), std::move(y), std::move(c));
    return 0;
}


Measured memory_bytes: 4224
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int x=Math.abs(sc.nextInt())-1;
    int s=0;
    int p=0;
    if(x==-1){
      System.out.println(0);
    }else{
      while(true){
        if(p<=x&&x<p+s){
          break;
        }
        p+=s;
        s++;
      }
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 21844
M=1000003
o=->a,n{n<1?1:(n%2>0?a:1)*o[a,n/2]**2%M}
f=f=1,*(1..M).map{|i|f=f*i%M}
gets
$<.map{|s|x,d,n=s.split.map &:to_i
p d<1?o[x,n]:(u=f[n+t=x*o[d,M-2]%M-1])?u*o[f[t],M-2]*o[d,n]%M: 0}

Measured memory_bytes: 19580
import sys
def kouyakusuu(a,b):
  A = max(a,b)
  B = min(a,b)
  d = A % B
  if d == 0:
    return B
  else:
    return kouyakusuu(B,d)
for line in sys.stdin.readlines():
  a,b = map(int,line.split())
  m = kouyakusuu(a,b)
  n = a*b//m
  print(m,n)

Measured memory_bytes: 7676
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
    cin >> s;
    FOR(i,0,SZ(s)-1) cout << 'x';
    return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
P = set(map(int, input().split()))

ans = 10**18

for i in range(-100, 200):
    if i in P:
        continue
    if abs(X - i) < abs(X - ans):
        ans = i
    if abs(X - i) == abs(X - ans):
        if i < ans:
            ans = i

print(ans)


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

int main() {
  int N,K;
  cin >> N >> K;
  
  if (K > (N-1)*(N-2)/2) {
    cout << "-1" << endl;
    return 0;
  }
  int limit = (N-1)*(N-2)/2;
  cout << N-1+(limit - K) << endl;;
  for (int i=2; i<=N; i++) {
    cout << 1 << ' ' << i << endl;
  }
  for (int i=2; i<N; i++) {
    for (int j=i+1; j<=N; j++) {
      if (K==limit) {
        return 0;
      }
      cout << i << ' ' << j << endl;
      limit--;
    }
  }
  
  
  return 0;
}

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

#define za ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod %1000000007
#define moz 1000000007
#define nl "\n"
#define S second
#define F first
#define PB push_back
#define MP make_pair
#define V vector
#define P pair
#define LEN length()
#define SZ size()
#define loop(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long ll;
typedef complex<ll> C;
#define X real()
#define Y imag()

int n,a,b,c;

int main()
{
    za;
    int arr[27]={0};
    string s;
    cin >> s;
    loop(i,0,s.LEN-1)
    {
        arr[s[i]-'a']++;
    }
    loop(i,0,25)
    {
        if(arr[i]==0)
        {
            char x='a'+i;
            cout << x << nl;
            return 0;
        }
    }
    cout << "None" << nl;
}


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

using namespace std;

int keta_sum(int n);

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

	int mn = 1010101010;
	int t;
	for (int i = 1; i < n; i++) {
		t = keta_sum(i) + keta_sum(n - i);
		mn = min(mn, t);
	}
	cout << mn << endl;

	return 0;
}

int keta_sum(int n)
{
	int ans = 0;
	while (n != 0) {
		ans += n % 10;
		n /= 10;
	}

	return ans;
}

Measured memory_bytes: 256