akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

#heapq
import heapq
class Reverse:
    def __init__(self, val):
        self.val = val
        
    def __lt__(self, other):
        return self.val > other.val
        
    def __repr__(self):
        return repr(self.val)
    
class Heapq:
    def __init__(self, arr, desc = False):
        if desc:
            for i in range(len(arr)):
                arr[i] = Reverse(arr[i])
        self.desc = desc
        self.hq = arr
        heapq.heapify(self.hq)
 
    def pop(self):
        if self.desc: return heapq.heappop(self.hq).val
        else: return heapq.heappop(self.hq)
 
    def push(self, a):
        if self.desc: heapq.heappush(self.hq, Reverse(a))
        else: heapq.heappush(self.hq, a)
 
    def top(self):
        if self.desc: return self.hq[0].val
        else: return self.hq[0]


from operator import itemgetter
def index_sort(A):
    A_sort = sorted(enumerate(A),key=itemgetter(1))
    index = [a[0] for a in A_sort]
    sorted_A = [a[1] for a in A_sort]
    return index, sorted_A


N,C = II()
s,t,c = Line(N,3)

# 同じチャンネルで，空き時間なしで番組が続くときはまとめて録画する
new_s = []
new_t = []
tl = [[] for _ in range(C)]
for i in range(N):
    tl[c[i]-1].append((s[i],t[i]))
for j in range(C):
    if not tl[j]:
        continue
    tl[j].sort(key=itemgetter(0))
    sj = []
    tj = []
    start,last = tl[j][0][0],tl[j][0][1]
    for i in range(1,len(tl[j])):
        if tl[j][i][0] != last:
            sj.append(start)
            tj.append(last)
            start = tl[j][i][0]
            last = tl[j][i][1]
        else:
            last = tl[j][i][1]
    sj.append(start)
    tj.append(last)
    new_s.extend(sj)
    new_t.extend(tj)

index, _ = index_sort(new_s)
s = [new_s[i] for i in index]
t = [new_t[i] for i in index]

h = Heapq([10**6])
ans = 0
for i in range(len(s)):
    if h.top() < s[i]:
        h.pop()
        h.push(t[i])
    else:
        h.push(t[i])
        ans += 1

print(ans)

Measured memory_bytes: 94940
n = gets.to_s

array = n.split("")
chka = [0,0,0]

i = 0

while i <= 2 do
    j = 1
    while j <= 2 do
        if array[i] != array[j] then
            chka[i] = 1 
            chka[j] = 1
        end
        j = j + 1
    end
    i = i + 1
end
i = 0
chkt = true
#p chka
while i <= 2 do
    if chka[i] == 0 then
        #p chka[i]  
        chkt = false
    end
    i = i + 1
end
if chkt  == false then
    puts 'No'
else
    puts 'Yes'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<vector<int>> g(n);
    while (m--) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (g[i].empty()) {
            ans++;
        }
        else {
            bool ok = 1;
            for (int v : g[i]) {
                if (h[v] >= h[i]) {
                    ok = 0;
                }
            }
            if (ok) ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 9784
#include "bits/stdc++.h"

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	int ans = 0;
	for (int i = a; i <= b; i++)
	{
		// 桁の取り出し
		int s = i % 10, t = i / 10000 % 10;
		int u = i / 10 % 10, v = i / 1000 % 10;
		if (s == t && u == v) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  int count = 0;
  rep(i,N){
    int h;cin >> h;
    if(h>=K) ++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
n,x1,y1 = map(int,input().split())
x = min(x1,y1)
y = max(x1,y1)

def ans(k):
    c = 0
    for i in range(1,x):
        if (y-x+1)/2.==k-i and k-i>0:
            c+=1
        elif (y-x+1)//2 >= k-i and k-i>0:
            c+=2

    # print(c)

    for i in range(1,n-y+1):
        if (y-x+1)/2.==k-i and k-i>0:
            c+=1
        elif (y-x+1)//2 >= k-i and k-i>0:
            c+=2

    # print(c)

    c+= max((n-y+x+1-k),0)

    # print(c)

    if (y-x +1)/2. == k:
        c += k
    elif (y-x+1)//2 >=k:
        c += y-x+1
    # print(c)
    if x-1 >= k-1 and c>0:
        c-=1
    if n-y >= k-1 and c>0:
        c-=1
    # print(c)
    if c<0: 
        return 0

    return c+1 if k==1 else c
    # return c


for k in range(n-1):
    print(ans(k+1))







Measured memory_bytes: 3444
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Main main = new Main();
		List<Point> list = new ArrayList<Point>();
		for (int i=0;i<N;i++) {
			Point p = main.new Point();
			p.a= sc.nextInt();
			p.b= sc.nextInt();
			list.add(p);
		}
		long sum =0;
		Collections.sort(list);
		TreeSet<Integer> set = new TreeSet<Integer>();
		for (int i=0;i<M;i++) {
			set.add(i);
		}
		for (Point p: list) {
			int t = M-p.a;
			if (set.floor(t)!=null) {
				int g = set.floor(t);
				sum +=p.b;
				set.remove(g);
			}
		}
		System.out.println(sum);
	}

	public class Point implements Comparable {
		int a ;
		int b;
		@Override
		public int compareTo(Object o) {
			Point p = (Point)o;
			if (p.b!=this.b) {
				return p.b-this.b;
			}
			return this.a-p.a;
		}
	}
}

Measured memory_bytes: 64484
#include <iostream>

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdlib>

template <typename T>
T str2(std::string str){
	T res;
	std::istringstream iss(str);
	iss >> res;
	return res;
}

std::vector<std::string> split(std::string str, std::string delimiters){
	std::vector<std::string> result;
	while(str.length()){
		bool found_delim = false;
		for(auto& d : delimiters){
			auto pos = str.find_first_of(d);
			if(pos != std::string::npos){
				result.push_back(str.substr(0, pos));
				str = str.substr(pos + 1, str.length() - pos - 1);
				found_delim = true;
			}
		}
		if(!found_delim){
			result.push_back(str);
			return result;
		}
	}
}

int main(int argc,char *argv[]){
	uint64_t N;
	double sum_of_BTC = 0.;
	uint64_t sum_of_JPY = 0u;
	std::cin >> N;
	for(uint64_t i=0u ; i<N ; ++i){
		std::string s,t;
		std::cin >> s >> t;
		if(t.compare("JPY") == 0){
			sum_of_JPY += str2<uint64_t>(s);
		} else {
			sum_of_BTC += str2<double>(s);
		}
	}
	std::cout << sum_of_JPY + 3.8e5 * sum_of_BTC;
	return 0;
}



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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
static const int INF = 1e9;
static const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main(){
    ios::sync_with_stdio(true);
    int a,b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    s = input()
    ls = len(s)
    ans = 0
    for bit in range(1 << (ls - 1)):
        f = ""
        for j in range(ls - 1):
            f += s[j]
            if 1 << j & bit:
                f += "+"
        f += s[-1]
        ans += eval(f)
    print(ans)


if __name__ == "__main__":
    resolve()


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


int main(void){
    int n;
    scanf("%d",&n);
    int i,a[n],c = 0,cc = 1;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int now = a[0];
    for(i=1;i<n;i++){
        if(a[i] == now){
            cc++;
        }else{
            now = a[i];
            c += cc/2;
            cc = 1;
        }
    }
    c+=cc/2;
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}

int main() {
string S;
  string T;
  cin >>S>>T;
  
  ll c=S.size();
  ll ps=0;
  rep(i,c) {
    if(S.at(i)!=T.at(i)) {
ps=1;
      break;
    }
  }

  if(!ps) {
cout<<"Yes"<<endl;
  }
else {
cout<<"No"<<endl;
}

}



Measured memory_bytes: 3548
#include <iostream>

using namespace std;

const int64_t INF = 1000000000LL;

int main() {
    int N, C, i, j;
    int **D, M[3][30] = { 0 };

    cin >> N >> C;
    D = new int*[C];

    for (i=0;i<C;i++) {
        D[i] = new int[C];
        for (j=0; j<C; j++)
            cin >> D[i][j];
    }
    
    for (i=0;i<N;i++) {
        for (j=0; j<N; j++) {
            int t;
            cin >> t;
            M[(i+j)%3][t-1]++;
        }
    }


    int k, l, m;
   
    int64_t ans = INF; 
    int64_t w = 0LL;
    for (k=0;k<C;k++) {
        for (l=0;l<C;l++) {
            if (l == k) continue;
            for (m=0;m<C;m++) {
                if (m == l || m == k) continue;
                w = 0LL;

                for (i=0;i<C;i++) w += D[i][k] * M[0][i];
                for (i=0;i<C;i++) w += D[i][l] * M[1][i];
                for (i=0;i<C;i++) w += D[i][m] * M[2][i];

                ans = min(ans, w);
            }
        }
    }


    cout << ans << endl;

    return 0;
}

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

main()
{
    int n; cin>>n;
    vector<vector<int>> t(n);
    for(int i=1; i<n; ++i)
    {
        int a,b; cin>>a>>b; --a,--b;
        t[a].emplace_back(b);
        t[b].emplace_back(a);
    }
    queue<pair<int,int>> q;
    q.emplace(0,-1);
    long long ans=0;
    while(!q.empty())
    {
        auto [no,pa]=q.front();
        q.pop();
        if(pa<no) ans+=(long long)(no-pa)*(n-no);
        else ans+=(long long)(no+1)*(pa-no);
        for(int to:t[no])
        {
            if(pa!=to) q.emplace(to,no);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 16624
N=int(input())
A=[[0 for n in range(9)] for n in range(9)]

for n in range(N+1):
    head=int(str(n)[0])
    tail=n%10
    if head!=0 and tail!=0:
        A[head-1][tail-1]+=1

count=0

for i in range(9):
    for j in range(9):
        count+=A[i][j]*A[j][i]

print(count)

Measured memory_bytes: 3064
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse::<i32>().unwrap());
    let (area, primeter) = {
        let (a, b) = (iter.next().unwrap(), iter.next().unwrap());
        (a * b, a + a + b + b)
    };
    println!("{} {}", area, primeter);
}



Measured memory_bytes: 5036
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]

for i in range(n):
    dt = txy[i][0]
    dst = txy[i][1] + txy[i][2]
    if dt < dst:
        print('No')
        exit()

    if txy[i][0] % 2 == 0:
        if (txy[i][1]+txy[i][2]) % 2 != 0:
            print('No')
            exit()

    elif txy[i][0] % 2 != 0:
        if (txy[i][1]+txy[i][2]) % 2 == 0:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 27380
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b!=c||b==c&&c!=a||c==a&&a!=b)
    cout<<"Yes\n";
    else
    cout<<"No";
        // your code goes here
	return 0;
}


Measured memory_bytes: 3572
import fractions

a,b,c,d = map(int,input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

gcd_cd = lcm(c,d)

a_c_numbers = a//c
if a % c == 0:
    a_c_numbers -= 1
a_d_numbers = a//d
if a % d == 0:
    a_d_numbers -= 1

a_numbers = a_c_numbers + a_d_numbers

b_c_numbers = b//c
b_d_numbers = b//d
b_numbers = b_c_numbers + b_d_numbers

if a % gcd_cd == 0:
    gcd_cd_numbers = b//gcd_cd - a//gcd_cd + 1
else:
    gcd_cd_numbers = b//gcd_cd - a//gcd_cd

# print(a_c_numbers,a_d_numbers)
# print(b_c_numbers,b_d_numbers)
# print(gcd_cd_numbers)
# print(b_numbers - a_numbers - gcd_cd_numbers)
ans = b - a + 1 - (b_numbers - a_numbers - gcd_cd_numbers)

if ans > 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 5600
A,B,M = map(int, input().split())



a=list(map(int,input().split()))
b=list(map(int,input().split()))
m=[]
for i in range(M):
    m.append(input().split())

counta=0
countb=0
nummin=int(a[0])+int(b[0])
for i in m:
    
    x=int(i[0])-1
    y=int(i[1])-1
    c=int(i[2])
    num=a[x]+b[y]-c

    if num<nummin:
        nummin=num
if min(a)+min(b)<nummin:
    nummin=min(a)+min(b)

print(nummin)


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

int main() {
  int n;
  unordered_set<int> u;
  cin >> n;
  rep(i, n){
    int a;
    cin >> a;
    u.insert(a);
  }
  if(u.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 8520
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
ll x[1000000];
int main()
{
  ll a,b=0,c=0,d,e=-1,i,j;
  char s[1000];
  cin>>s;
  for(i=0;i<3;i++)
  {
      if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
      {
          out<<3<<nl;
          break;
      }
      else if(s[0]=='R'&&s[1]=='S'&&s[2]=='R')
      {
          out<<1<<nl;break;
      }
      else if(s[0]=='S'&&s[1]=='R'&&s[2]=='R')
      {
          out<<2<<nl;break;
      }
      else if(s[0]=='R'&&s[1]=='R'&&s[2]=='S')
      {
          out<<2<<nl;break;
      }
        else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S')
      {
          out<<0<<nl;break;
      }
      else {out<<1<<nl;break;}
  }
  //out<<e<<nl;


}


Measured memory_bytes: 3632
import sys
n, a, b, c, d = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()

def can_reach(start, end):
    for i in range(start, end):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True

if can_reach(a-1, c-1) and can_reach(b-1, d-1):
    if c < d:
        print('Yes')
    else:
        flag = False
        for i in range(b-1, d):
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                flag = True
        print('Yes' if flag else 'No')
else:
    print('No')


Measured memory_bytes: 39920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int idx = 0;
			int max_value = 0;
			for(int i=0;i<5;i++){
				int tmp = stdIn.nextInt() + stdIn.nextInt();
				if(i==0&&tmp==0){
					return;
				}
				if(max_value<tmp){
					max_value = tmp;
					idx = i;
				}
			}
			System.out.print(idx==0?"A":idx==1?"B":idx==2?"C":idx==3?"D":"E");
			System.out.println(" "+max_value);
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[][] plan = new int [n][3];
		int[] planlog = new int [3];

		for(int i=0;i<n;i++) {
			plan[i][0] = Integer.parseInt(sc.next());
			plan[i][1]=Integer.parseInt(sc.next());
			plan[i][2]=Integer.parseInt(sc.next());
		}
		sc.close();

		for(int i=0;i<n;i++) {
			//time,X,Y差分
			int absT = plan[i][0] - planlog[0];
			int absX = Math.abs(plan[i][1] - planlog[1]);
			int absY = Math.abs(plan[i][2] - planlog[2]);
			//時間内に移動できるか && とどまることができるか
			if(absT>=absX+absY&&absT%2==(absX+absY)%2) {
				//System.out.println(absT+" "+absX+" "+absY);
				planlog[0]=absT;
				planlog[1]=absX;
				planlog[2]=absY;
			}else{
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

}


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

int main()
{
  string result;
  int H,N,sum=0;
  cin >> H >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }

  if(sum>=H){
    result = "Yes";
  }else{
    result = "No";
  }

  cout << result << endl;
}

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

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a==1){
    cout << "YES" << endl;
    return 0;
  }
  for (int i=a;i<=a*100;i+=a){
    if(b*(i/b)+c==i){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

    int N;
    cin >> N;

    int a, b;
    vector<vector <int> > c(10, vector<int>(10));

    int i, j;

    int af, al;
    for(a=1; a<=N; a++){
        
        if(a < 10){
            af = a;
        }
        else{
            int atmp = a;
            while(atmp / 10){
                atmp /= 10;
            }
            af = atmp;
        }

        al = a % 10;

        c.at(af).at(al)++;
    }

    int ans = 0;
    for(i=0; i<10; i++){
        for(j=0; j<10; j++){

            ans += c.at(i).at(j) * c.at(j).at(i);
        }
    }


    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

int k;
int n;
int main() {
	cin>>n>>k;
	int a[100001];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	int ans=INF;
	rep(i,0,n-k+1){
		ans=min(ans,a[i+k-1]-a[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())
    k = int(input())
    x = list(map(int, input().split()))

    dist = 0
    for i in range(n):
        dist += min(x[i], k - x[i]) * 2
    print(dist)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		char[] s = stdIn.next().toCharArray();
		int cnt = 0;
		
		for(int i = 0; i < s.length; i++) {
			if(s[i] == 'o') {
				cnt++;
			}
		}
		boolean flag = true;
		
		if(15 - s.length +cnt < 8) {
			flag = false;
		}
		
		if(flag) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		
	}

}


Measured memory_bytes: 35696
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int count = 3;

	if (a ==b){
		count--;
	}
	if (a ==c){
		count--;
	}
	if (b ==c){
		count--;
	}
	if ((a ==b) && (a ==c)){
		count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
xyz = []
for i in range(n):
    xyz.append(list(map(int, input().split())))

ans = 0
for a in [-1, 1]:
    for b in [-1, 1]:
        for c in [-1, 1]:
            temp = []
            for x, y, z in xyz:
                temp.append(a * x + b * y + c * z)
            temp.sort(reverse=True)
            ans = max(ans, sum(temp[:m]))
print(ans)


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

ll A, B, K;

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

    if (A >= K) {
        A -= K;
        K = 0;
    } 
    else {
        K -= A;
        A = 0;
        if (B >= K) {
            B -= K;
            K = 0; 
        }
        else {
            K -= B;
            B = 0;
        }
    }

    cout << A << " " << B << endl;

    return 0;
}

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

int main() {
  string SA, SB, SC;
  cin >> SA >> SB >> SC;

  string player = "a";
  int amount = SA.length() + SB.length() + SC.length();

  for (int i = 0; i < amount; i++) {
    if(player == "a"){
      if(SA.length() == 0){
        cout << "A" << endl;
        exit(0);
      }
      player = SA[0];
      SA.erase(0,1);
    }else if(player == "b"){
      if(SB.length() == 0){
        cout << "B" << endl;
        exit(0);
      }
      player = SB[0];
      SB.erase(0,1); 
    }else if(player == "c"){
      if(SC.length() == 0){
        cout << "C" << endl;
        exit(0);
      }
      player = SC[0];
      SC.erase(0,1);
    }
  }
}

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

#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //ifstream cin("input.txt");
    //freopen("input.txt", "r", stdin);
    //ofstream cout("output.txt");

	string s;
	cin >> s;

	vector<int> cnt(26);
	ll ans = 1;

	for (int i = sz(s) - 1; i >= 0; --i) {
		for (int c = 0; c < 26; ++c) {
			if (s[i] - 'a' != c) {
				ans += cnt[c];
			}
		}
		++cnt[s[i] - 'a'];
	}
	cout << ans << "\n";

}


Measured memory_bytes: 720
//
// Created by Akifumi Ohata on 2017/10/01.
//


#include<iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll =  long long int;

int main() {
    ios::sync_with_stdio(false);

    int N;

    ll MOD=1000000007;


    cin >> N ;




    vector<int> Array(N,0);

    ll value_A=0;
    for(int iter=0;iter<=N-1;iter++){
        cin >>Array[iter];
        value_A+=Array[iter];
    }

    ////
    ll value_S=0;
   // ll value_A=std::accumulate(Array.begin(), Array.end(), 0);

    ll Diff= 9223372036854775807LL;//;=1000000000000000000LL

    for(int k=0;k<=N-2;k++){


        value_S+=Array[k];
        value_A-=Array[k];



        Diff=min(Diff,abs(value_S-value_A));

    }











    cout  << Diff << endl ;

    return 0;
}

Measured memory_bytes: 1024
def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

def run():
    s = input()

    if s.endswith("s"):
        print(s + "es")
        return

    print(s + "s")

run()



Measured memory_bytes: 9100
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE
#define inf 0x3f3f3f3f
#define mod
#define maxm
#define maxn
char a[110], b[110];
int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	// ios::sync_with_stdio(false);
	int n;
	
	scanf("%d%s%s", &n, a, b);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!strncmp(a + i, b, n - i)) {
			ans = n - i;
			break;
		}
	}
	printf("%d\n", 2 * n - ans);
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/
#include <bits/stdc++.h>

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) { cin >> x[i]; }

    ll sum = LLONG_MAX;

    for (int p = 1; p <= 100; p++) {
        ll s = 0;
        rep(i, n) { s += (x[i] - p) * (x[i] - p); }
        sum = min(sum, s);
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, X) = nextLongList()
    val ans = L(N.toInt(), X)
    println(ans)
}

fun L(N: Int, X: Long): Long {
    if (N == 0) return if (X != 0L) 1L else 0L
    val H = 4L * 2.0.pow(N).toLong() - 3L
    val t = (H + 1L) / 2L
    return when {
        X <= 1 -> 0L
        X < t -> L(N - 1, X - 1)
        X == t -> C(N - 1) + 1
        X <= H -> C(N - 1) + 1 + L(N - 1, X - t)
        else -> C(N)
    }
}

fun C(N: Int) = 2.0.pow(N + 1).toLong() - 1

Measured memory_bytes: 36568
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

signed main() {
	int a;
	string b;
	scanf("%d", &a); cin >> b;
	reverse(b.begin(), b.end());// IOI???IOJ?????????
	int s = 0, g = a / 3+1;//(s,g]
	while (g - s > 1) {
		int k = (s + g) / 2;
		vector<int>c;
		for (int d = 0; d < a&&c.size()<k; d++) {
			if (b[d] == 'I')c.push_back(d);
		}
		if (c.size() < k) { g = k; continue; }
		vector<int>d;
		int e = 0;
		for (int f = 0; f < k; f++) {
			if (c[f] > e)e = c[f] + 1;
			for (; e < a; e++) {
				if (b[e] == 'O') {
					d.push_back(e);
					e++;
					break;
				}
			}
		}
		if (d.size() < k) { g = k; continue; }
		vector<int>f;
		int h = 0;
		for (int i = 0; i < k; i++) {
			if (d[i] > h)h = d[i] + 1;
			for (; h < a; h++) {
				if (b[h] == 'J' || (b[h] == 'I'&&h > c[k - 1])) {
					f.push_back(h);
					h++;
					break;
				}
			}
		}
		if (f.size() == k) {
			s = k;
		}
		else {
			g = k;
		}
	}
	printf("%d\n", s);
}

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

int a, b, k;

int main()
{
    cin >> a >> b >> k;
    for (int i = min(a,b); i; i--)
    {
        if (a % i == 0 && b % i == 0)
        {
            k--;
            if (k == 0) cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut p: Vec<usize> = Vec::new();
    let mut y: Vec<usize> = Vec::new();
    for _ in 0..m {
        p.push(read::<usize>() - 1);
        y.push(read());
    }
    let mut v = vec![Vec::new(); n];
    for i in 0..m {
        v[p[i]].push(y[i]);
    }
    for i in 0..n {
        v[i].sort();
        v[i].dedup();
    }

    for i in 0..m {
        let x = p[i];
        print!("{:06}", x+1);

        let id = lower_bound(&v[x], y[i]);
        print!("{:06}", id + 1);
        println!("");
    }
}

fn lower_bound(v: &Vec<usize>, x: usize) -> usize {
    let mut l = 0;
    let mut r = v.len() - 1;
    while l < r {
        let mid = (l + r) / 2;
        if x <= v[mid] {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    l
}


Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>k>>x;

    for(int i=x-k+1;i<=x+k-1;i++)
        cout<<i<<" ";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.
 
 
 
int main(){
   string S;
   cin>>S;
 
 if(S=="ABC"){cout<<"ARC";}
 else{cout<<"ABC";}}

Measured memory_bytes: 3636
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: kundaikwangwari
 *
 * Created on August 6, 2019, 1:12 AM
 */

#include<stdio.h>
#include<stdlib.h>
#define UpperBound 11000000
#define trackarraymax 6500000
#define ArrayLim 100025

int Done = 0;

typedef struct
{
  int  weight,previous, next;
} edges; edges track[trackarraymax];



void Dijkstra(int n, int count){
  
  int Hold[ArrayLim];
  Hold[0] = 0;
  for(int a = 1; a < n; a++)Hold[a]=UpperBound;
 
  while(Done != 1){
    Done = 1;

    for(int b=0; b<count; b++)
    
    {
      if(Hold[track[b].next] >Hold[track[b].previous] + track[b].weight )
      
      {
        Hold[track[b].next]= Hold[track[b].previous]+track[b].weight;
        Done = 0;
      }
      
    }
  }

  for(int c = 0; c <n ; c++)printf("%d %d\n", c, Hold[c]);
  return;
}


int main(void){
  int val2, v, val1, track1;
  int num;
  scanf("%d", &num);
  for(int a = 0; a < num; a++)
  {
        scanf("%d %d", &val1, &val2);
  for(int b=0; b<val2; b++)
  {
      track[track1].previous=val1;
      scanf("%d%d",&track[track1].next,  &track[track1].weight);
      track1++;
      
  }
  }

  Dijkstra(num,track1);
  return 0;
}



Measured memory_bytes: 7568
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a[3][3];
    bool bingo[3][3] = {false};
    rep(i,0,2)cin >> a[i][0] >> a[i][1] >> a[i][2];
    int n;
    cin >> n;
    rep(k,0,n-1){
        int b;
        cin >> b;
        rep(i,0,2)rep(j,0,2)if(b == a[i][j])bingo[i][j] = true;
    }
    string ans = "No";
    if(bingo[0][0] && bingo[1][0] && bingo[2][0])ans = "Yes";
    if(bingo[0][1] && bingo[1][1] && bingo[2][1])ans = "Yes";
    if(bingo[0][2] && bingo[1][2] && bingo[2][2])ans = "Yes";
    if(bingo[0][0] && bingo[0][1] && bingo[0][2])ans = "Yes";
    if(bingo[1][0] && bingo[1][1] && bingo[1][2])ans = "Yes";
    if(bingo[2][0] && bingo[2][1] && bingo[2][2])ans = "Yes";
    if(bingo[0][0] && bingo[1][1] && bingo[2][2])ans = "Yes";
    if(bingo[0][2] && bingo[1][1] && bingo[2][0])ans = "Yes";
    // cout << bingo[0][0] << bingo[0][1] << bingo[0][2] << endl;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(y).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    cout << 1-X << "\n";
}

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

using namespace std;

const int MaxN = 3005;
const long long oo = 1e18;

int n;
int a[MaxN];
long long dp[MaxN][MaxN];

long long Cal(int L, int R, int Type)
{
    if (L == R)
    {
        return Type * a[L];
    }
    if (dp[L][R] != -oo)
    {
        return dp[L][R];
    }
    if (Type == 1)
    {
        dp[L][R] = max(a[L] + Cal(L + 1, R, -1), a[R] + Cal(L, R - 1, -1));
    }
    else
    {
        dp[L][R] = min(Cal(L + 1, R, 1) - a[L], Cal(L, R - 1, 1) - a[R]);
    }
    return dp[L][R];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        for (int j = 1; j <= n; j++)
        {
            dp[i][j] = -oo;
        }
    }
    cout << Cal(1, n, 1);
    return 0;
}

Measured memory_bytes: 74252
# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


A, B, C, D = map(int, input().split())
l = lcm(C, D)
div_C = B // C - (A - 1) // C
div_D = B // D - (A - 1) // D
div_lcm = B // l - (A - 1) // l
div = div_C + div_D - div_lcm
ans = (B - A + 1) - div
print(ans)


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

int main() {
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<vector<int>> g(n);
	for (int i = 0; i < n; i++) {
		int k, t; cin >> k;
		while (k--) cin >> t, g[i].push_back(t);
	}
	int timer = 1;
	vector<int> stTime(n);
	vector<int> fiTime(n);
	function<void(int)> dfs = [&] (int u) {
		stTime[u] = timer++;
		for (int v : g[u]) dfs(v);
		fiTime[u] = timer;
	};
	dfs(0);
	vector<int> tr(n + 1);
	auto update = [&] (int x, int v) {
		for (; x <= n; x += x & -x) tr[x] += v;
	};
	auto query = [&] (int x) {
		int rt = 0;
		for (; x > 0; x -= x & -x) rt += tr[x];
		return rt;	
	};
	int q; cin >> q;
	while (q--) {
		int op; cin >> op;
		if (op == 0) {
			int x, v; cin >> x >> v;
			update(stTime[x], v);
			update(fiTime[x], -v);
		} else {
			int x; cin >> x;
			cout << query(stTime[x]) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 15752
#include<cstdio>
#include<cstring>
const int N=100007,P=1000000007;
char str[N];int a[N],f[N],las[3];
int main()
{
    scanf("%s",str+1);int n=strlen(str+1),flg=0;
    for(int i=1;i<=n;++i) if(a[i]=(a[i-1]+str[i]-'a'+1)%3,str[i]==str[i-1]) flg=1;
    if(!flg) return puts("1"),0;;
    for(int i=1;i<=n;++i) f[i]=(1ll*f[las[0]]+f[las[1]]+f[las[2]]+(a[i]>=1)-f[las[a[i]]]+P)%P,las[a[i]]=i;
    printf("%d",f[n]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1000000009
using namespace std;

int n,m,k,x,y;
char c[1000][1000];
bool vis[1000][1000];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<n;i++){
	    scanf("%s",&c[i]);
	    for(int j=0;j<m;j++) if(c[i][j]=='S') x=i,y=j;
    }
    int ans=min(min(x,y),min(n-x-1,m-y-1));
    vis[x][y]=true;
    if(ans%k==0) ans=ans/k;
    else ans=ans/k+1;
    int minv=ans+1;
    queue<pair<int,pair<int,int> > > q;
    q.push(make_pair(0,make_pair(x,y)));
    while(!q.empty())
    {
    	pair<int,pair<int,int> > t=q.front();q.pop();
    	if(t.first>=k) continue;
		for(int w=0;w<4;w++){
			int nx=t.second.first+dx[w],ny=t.second.second+dy[w];
			if(nx<0||ny<0||nx>=n||ny>=m) continue;
			if(c[nx][ny]=='#') continue;
			if(vis[nx][ny]) continue;
			vis[nx][ny]=true;
			int res=min(min(nx,ny),min(n-nx-1,m-ny-1));
			if(res%k==0) res=res/k;
			else res=res/k+1;
			minv=min(minv,res+1);
			q.push(make_pair(t.first+1,make_pair(nx,ny)));
		}
	}
	cout<<minv<<endl;
	return 0;
}
/*
7 7 1
######.
#####..
####..#
###S.##
##..###
#..####
..#####

HAHA!
*/

Measured memory_bytes: 1792
n = int(input())
l = []
l = input().split()
l = list(map(int,l))
print(*l)
for i in range(1,n):
    v = l[i]
    j = i - 1
    while j >= 0 and l[j] > v:
        l[j+1] = l[j]
        j = j - 1
    l[j+1] = v
    print(*l)


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

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

    map<int,int> mp;
    rep(i,3){
        int a;
        cin >> a;
        mp[a]++;
    }

    if(sz(mp) == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import math

def k(n,p1,p2):
    if n == 0:
        return 0

    sx = 2/3*p1[0]+1/3*p2[0]
    sy = 2/3*p1[1]+1/3*p2[1]
    s = (sx,sy)

    tx = 1/3*p1[0]+2/3*p2[0]
    ty = 1/3*p1[1]+2/3*p2[1]
    t = (tx,ty)

    ux = math.cos(math.radians(60))*(tx-sx)-math.sin(math.radians(60))*(ty-sy)+sx
    uy = math.sin(math.radians(60))*(tx-sx)+math.cos(math.radians(60))*(ty-sy)+sy
    u = (ux,uy)

    k(n-1,p1,s)
    print(*s)
    k(n-1,s,u)
    print(*u)
    k(n-1,u,t)
    print(*t)
    k(n-1,t,p2)

n=int(input())
p1=(0,0)
p2=(100,0)

print(*p1)
k(n,p1,p2)
print(*p2)


Measured memory_bytes: 5780
# Author: cr4zjh0bp
# Created: Sat Mar 28 10:36:41 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a = ns()
b = ns()

if len(a) > len(b):
    c = ''.join(['0' for _ in range(len(a) - len(b))])
    b = c + b
elif len(a) < len(b):
    c = ''.join(['0' for _ in range(len(b) - len(a))])
    a = c + a

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")

Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
using namespace std;
void dfs(char ch[105][105],int i,int j,bool visit[105][105],int m,int n)
{
    visit[i][j]= true;
    if(i-1>=0&&!visit[i-1][j]&&ch[i-1][j]=='#')
        dfs(ch,i-1,j,visit,m,n);
    if(i+1<m&&!visit[i+1][j]&&ch[i+1][j]=='#')
        dfs(ch,i+1,j,visit,m,n);
    if(j-1>=0&&!visit[i][j-1]&&ch[i][j-1]=='#')
        dfs(ch,i,j-1,visit,m,n);
    if(j+1<n&&!visit[i][j+1]&&ch[i][j+1]=='#')
        dfs(ch,i,j+1,visit,m,n);
}
void dfs1(char ch[105][105],int i,int j,bool visit[105][105],int m,int n)
{
    visit[i][j]= true;
    if(i-1>=0&&!visit[i-1][j]&&ch[i-1][j]=='@')
        dfs1(ch,i-1,j,visit,m,n);
    if(i+1<m&&!visit[i+1][j]&&ch[i+1][j]=='@')
        dfs1(ch,i+1,j,visit,m,n);
    if(j-1>=0&&!visit[i][j-1]&&ch[i][j-1]=='@')
        dfs1(ch,i,j-1,visit,m,n);
    if(j+1<n&&!visit[i][j+1]&&ch[i][j+1]=='@')
        dfs1(ch,i,j+1,visit,m,n);
}
void dfs2(char ch[105][105],int i,int j,bool visit[105][105],int m,int n)
{
    visit[i][j]= true;
    if(i-1>=0&&!visit[i-1][j]&&ch[i-1][j]=='*')
        dfs2(ch,i-1,j,visit,m,n);
    if(i+1<m&&!visit[i+1][j]&&ch[i+1][j]=='*')
        dfs2(ch,i+1,j,visit,m,n);
    if(j-1>=0&&!visit[i][j-1]&&ch[i][j-1]=='*')
        dfs2(ch,i,j-1,visit,m,n);
    if(j+1<n&&!visit[i][j+1]&&ch[i][j+1]=='*')
        dfs2(ch,i,j+1,visit,m,n);
}
int main() {
    int n,m;
    cin>>m>>n;
    while (n!=0 &&m!=0) {
        int result = 0;
        bool visit[105][105];
        memset(visit, false, sizeof(visit));
        char ch[105][105];
        int i, j;
        for (i = 0; i < m; i++)
            for (j = 0; j < n; j++)
                cin >> ch[i][j];
        for (i = 0; i < m; i++)
            for (j = 0; j < n; j++) {
                if(!visit[i][j])
                {
                    visit[i][j]=true;
                    if(ch[i][j]=='#')
                    {
                        dfs(ch,i,j,visit,m,n);
                        result++;
                    }
                    if(ch[i][j]=='@')
                    {
                        dfs1(ch,i,j,visit,m,n);
                        result++;
                    }
                    if(ch[i][j]=='*')
                    {
                        dfs2(ch,i,j,visit,m,n);
                        result++;
                    }
                }

            }
        cout << result << endl;
        cin >> m >> n;
    }
    return 0;
}


Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  //cout<<s.size();
  int n=s.size()/2;
  --n;
  for(int i=0;i<s.size()/2&&i<=n;i++)
    if(s[i]==s[n])n--;
    else {cout<<"No"<<endl;return 0;}
  n=s.size()-2;
  for(int i=(s.size()+3)/2;i<=n;i++)
    if(s[i]==s[n])n--;
  else {cout<<"No"<<endl;return 0;}
  n=s.size()-1;
  for(int i=0;i<s.size()/2;i++)
      if(s[i]==s[n])n--;
      else {cout<<"No"<<endl;return 0;}
     cout<<"Yes"<<endl;
}

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

long long int lcm(long long int a,long long int b)
{
     return (a*b)/__gcd(a, b);
}

int main()
{
    long long int a,b,c,d,i,j,k,n,m,cnt,e,f,g,h,p,q;
    cin>>a>>b>>c>>d;
    k=lcm(c,d);
    m=(b/c)+(b/d)-(b/k);
    k=((a-1)/c)+((a-1)/d)-((a-1)/k);
    k=abs(m-k);
    a=abs(a-b)+1;
    cout<<abs(a-k)<<"\n";
    return 0;
}


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

int main(){
  int n;
  int m;
  cin>>n>>m;
  vector<vector<int>> a(n,vector<int>(m,0));
  for(int i=0;i<n;i++)for(int j=0;j<m;j++){
      cin>>a[i][j];
      a[i][j]--;
    }
  vector<int> index(n,0);
  int res=301;
  vector<int> done(m,0);
  while(true){
    vector<int> peo(m,0);
    for(int i=0;i<n;i++){
      peo[a[i][index[i]]]++;
    }
    int val=*max_element(peo.begin(),peo.end());
    res=min(res,val);
    bool be=false;

    for(int i=0;i<m;i++){
      if(peo[i]==val){
	done[i]=true;
      }
    }
    for(int i=0;i<n;i++){
      if(peo[a[i][index[i]]]==val){
	while(index[i]==m || done[a[i][index[i]]]){
	  if(index[i]==m){
	    be=true;
	    break;
	  }
	  index[i]++;
	}
      }
    }
    if(be) break;
  }
  cout<<res<<endl;
  return 0;
}


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

int main(){
  int n,q,y[100];
  string name[100];

  cin >> n >> q;

  for(int i=0;i<n;i++)cin >> y[i] >> name[i];

  string ans = "kogakubu10gokan";
  for(int i=0;i<n;i++){
    if(y[i]<=q)ans = name[i];
    else break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1208
while True:
    try:
        count = 0
        n = int(input())
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    d = n - a - b - c
                    if (d >= 0 and d <= 9):
                        count += 1
        print(count)
    except EOFError:
        break


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
#define int long long

signed main() {
	int L , R; cin >> L >> R;
	vector<int> multiple;
	for(int i = 1 ; i*2019 <= R ; i ++) {
		if(i * 2019 >= L )
			multiple.push_back(i*2019);
	}
	if(multiple.size() > 0) {
		cout << 0 ;
		return 0;
	} 
	int ans = 2018;
	for(int i = L ; i <= R ; i ++ ) {
		for(int j = i + 1 ; j <= R ; j ++) {
		ans = min(ans , (i * j)% 2019);
		}
	}
	cout << ans;
}


Measured memory_bytes: 10348