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

typedef long long ll;
typedef pair<int,int> pii;
int main(){
  string S;
  cin >> S;
  map<char,bool> m;
  for(int i = 0; i < S.size(); i++){
    m[S[i]] = true;
  }
  string all = "abcdefghijklmnopqrstuvwxyz";
  
  bool flg = true;
  for(int i = 0; i < all.size(); i++){
    if(m.count(all[i]) == 0){
      cout << all[i] << endl;
      flg = false;
      break;
    }
  }
  if(flg){
    cout << "None" << endl;
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	if(a>12){
		cout<<b<<endl;
	}
	else if(a>5){
		cout<<b/2<<endl;
	}
	else{
		cout<<0<<endl;
	}
}				

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

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

int main() {
	int n; cin >> n;
	vector<int>s(n);
	int sum =  0;
	rep(i , n){
		cin >> s[i];
		sum += s[i];
	}	
	sort(s.begin(),s.end());

	if(sum % 10 != 0){
		cout << sum << endl;
	}else{
		for(auto x : s){
			if(x % 10 != 0){
				cout << sum - x << endl;
				return 0;
			}
		}
		cout << "0" << endl;
	}
}

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


int main(){


    long long n, m, a, b, i, t;

    long long ans = 0;


    cin >> n >> m;


    vector< pair<long long, long long> > pv;


    for( i = 1 ; i <= n ; i = i + 1 ){

         cin >> a >> b ;

         pv.push_back( make_pair( a, b ) );

         }


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


    for( i = 0 ; 0 < m ; i = i + 1 ){    

         t = min( m, pv[i].second );

         ans += (long long) ( pv[i].first * t );

         m -= t;

         }
 

    cout << ans << endl;


    return 0;

    }


Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b == c + d) {
        cout << "Balanced" << endl;
    } else if (a + b < c + d) {
        cout << "Right" << endl;
    } else {
        cout << "Left" << endl;
    }
}




Measured memory_bytes: 3632
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main = panaC
panaC = do
    [a,b,c] <- getIntList
    putStrLn $ solveC a b c

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

solveC :: Integer -> Integer -> Integer -> String
solveC a b c
    | c - a - b > 0 = if result > 0 then "Yes" else "No"
    | otherwise = "No"
    where result = (c - a - b)^2 - 4 * a * b

Measured memory_bytes: 380
import java.util.*
import java.math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private const val MOD = 1_000_000_007L


fun solveC(N:Int, M:Int, X:Int, C:Array<Int>, A:Array<Array<Int>>): Int {
    var res = Int.MAX_VALUE
    for(p in 0..(0b01 shl N)) {
        var ptn = p
        var sk = Array<Int>(M){0}
        var cost = 0
        for (i in 0 until N) {
            if ((ptn and 0b01) == 1) {
                for(j in 0 until M) {
                    sk[j] += A[i][j]
                }
                cost += C[i]
            }
            ptn = ptn shr 1
        }
        var ok = true
        for(j in 0 until M) {
            if (sk[j] < X) {
                ok = false
                break
            }
        }

        if (ok) {
            res = Math.min(res, cost)
        }
    }

    return if (res == Int.MAX_VALUE) -1 else res
}


fun main(args: Array<String>) {
    val (N,M,X) = readListInt()
    val C = Array<Int>(N){0}
    val A = Array(N){Array<Int>(M){0} }
    for(i in 0 until N) {
        val ca = readListInt()
        C[i] = ca[0]
        for(j in 1 ..  M) {
            A[i][j-1] = ca[j]
        }
    }

    val ans = solveC(N, M, X, C, A)

    println(ans)
}


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

int N, M;
const int MAX_NM = 100 + 10;
int T[MAX_NM], P[MAX_NM], X[MAX_NM];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> T[i];
    cin >> M;
    for (int i = 0; i < M; i++) cin >> P[i] >> X[i];
    
    int sum_T = 0;
    for (int i = 0; i < N; i++) {
        sum_T += T[i];
    }

    for (int i = 0; i < M; i++) {
        int ans_i = sum_T - T[P[i] - 1] + X[i];
        cout << ans_i << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
int n;cin>>n;
string s;cin>>s;
for(char &x:s){
	if(x+n<91) x+=n;
    else x=64+(x+n)%90;
}
cout<<s;

}

Measured memory_bytes: 256
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int N = 1e4;
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}


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

   vector<int> a(3);

   for(int i=0;i<3;i++)
      cin>>a[i];

   vector<string> s(n);

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

   bool flag = 0;
   vector<int> ans;

   int sum = 0;

   for(auto x:a)
      sum+=x;     

   if(sum==2){

      for(int i=0;i<s.size();i++){

         string &x = s[i];

         int ind1 = x[0]-'A',ind2 = x[1]-'A';

         if(a[ind2]<a[ind1])
           swap(ind1,ind2);
         
         map<int,int> mm;

         for(auto y:x)
            mm[y-'A']++;

         int temp = ind1;   

         if(i<(int)s.size()-1 && a[ind1]==1 && a[ind2]==1){
           for(auto y:s[i+1])
              mm[y-'A']++;  
         } 

         for(auto y:mm)
            if(y.ss>=2)
              temp = y.ff;

         if(ind1==temp)
           a[ind1]++,a[ind2]--,ans.pb(ind1);
         else 
           a[ind2]++,a[ind1]--,ans.pb(ind2); 

       //  cout<<ans.back()<<' '<<ind1<<endl;

         if(a[ind1]<0 || a[ind2]<0){
           flag = 1;
           break;
         }   

      }

   }   
   else{
   for(auto x:s){
      int ind1 = x[0]-'A',ind2 = x[1]-'A';
      
      if(a[ind1]<a[ind2]){

        a[ind1]++,a[ind2]--;

        if(a[ind2]<0){
          flag = 1;
          break;
        }

        ans.pb(ind1);

      }
      else{
        a[ind2]++,a[ind1]--;
        
        if(a[ind1]<0){
          flag = 1;
          break;
        }

        ans.pb(ind2);

      }

   }
   }

   if(flag){
     cout<<"No\n";
   } 
   else{
     cout<<"Yes\n";
     for(auto x:ans)
        cout<<char(x+'A')<<endl;
   }

    
   return 0;
}

Measured memory_bytes: 7416
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		System.out.println((s.charAt(0) != s.charAt(1) && s.charAt(1) != s.charAt(2) && s.charAt(2) != s.charAt(0)) ? "Yes" : "No");
		
	}
	
}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.HashMap;
public class Main {
    public static void main(String[] args) {
	try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
	    int n = Integer.parseInt(br.readLine());
	    int[] v = Arrays.stream(br.readLine().split("[\\s]+"))
		.mapToInt(Integer::parseInt).toArray();
	    Map<Integer,Integer> map1 = new HashMap<>();
	    for (int i=0;i<n;i+=2) {
		int count = map1.containsKey(v[i]) ? map1.get(v[i])+1 : 1;
		map1.put(v[i],count);
	    }
	    Map<Integer,Integer> map2 = new HashMap<>();
	    for (int i=1;i<n;i+=2) {
		int count = map2.containsKey(v[i]) ? map2.get(v[i])+1 : 1;
		map2.put(v[i],count);
	    }
	    Entry<Integer,Integer> conv1 = map1.entrySet().stream().sorted(Comparator.comparingInt(e -> -e.getValue())).findFirst().orElse(null);
	    int conv2 = map1.entrySet().stream().sorted(Comparator.comparingInt(e -> -e.getValue())).skip(1).mapToInt(Entry::getValue).findFirst().orElse(0);
	    Entry<Integer,Integer> conc1 = map2.entrySet().stream().sorted(Comparator.comparingInt(e -> -e.getValue())).findFirst().orElse(null);
	    int conc2 = map2.entrySet().stream().sorted(Comparator.comparingInt(e -> -e.getValue())).skip(1).mapToInt(Entry::getValue).findFirst().orElse(0);
	    int ans = n - (conv1.getValue()+conc1.getValue());
	    if (conv1.getKey().equals(conc1.getKey())) ans = n - max(conv1.getValue()+conc2,conv2+conc1.getValue());
	    System.out.println(ans);
	} catch(IOException e) {
	    e.printStackTrace();
	}
    }
    
    private static int max(int a,int b) {
	return a > b ? a : b;
    }
}

Measured memory_bytes: 44788
import java.util.*;

class Main {
	public static void main(String[] args){
		List<String> list = new ArrayList<String>();

		String[] mark = {"S", "H", "C", "D"};

		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 13; j++){
				list.add(mark[i] + " " + (j + 1));
			}
		}

		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.nextLine());
		
		for(int i = 0; i < n; i++){
			list.remove(sc.nextLine());
		}

		for(String str : list){
			System.out.println(str);
		}
		
	}
}

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

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()

ans = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)


Measured memory_bytes: 64904
from itertools import accumulate
s = list(input().replace("A","1").replace("B","2"))
t = list(input().replace("A","1").replace("B","2"))
s = list(map(int,s))
t = list(map(int,t))
accs = [0]+list(accumulate(s))
acct = [0]+list(accumulate(t))
q = int(input())
abcd = [list(map(int,input().split())) for i in range(q)]
for a,b,c,d in abcd:
  if (accs[b]-accs[a-1])%3 == (acct[d]-acct[c-1])%3:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 44040
using System;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; ; i++)
            {
                var n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).OrderBy(s => s).ToArray();
                if (n[0] == 0 & n[1] == 0) break;
                Console.WriteLine(n[0] + " " + n[1]);
            }
        }
    }
}


Measured memory_bytes: 10180
import java.util.*;
import java.util.stream.*;

public class Main {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int K = in.nextInt(), X = in.nextInt();
    int min = Math.max(-1000000, X - K + 1);
    for (int i = min; i < Math.min(1000001, X + K); i++) {
      if(i != min) {
        System.out.print(" ");
      }
      System.out.print(i);
    }
    System.out.println();
  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
char a[303][303];
int b[303][303];
int is[303];
signed main() {
    int h,w,k;
    cin >> h >> w>>k;
    rep(i,h) {
        bool f=false;
        string s;
        cin >> s;
        rep(j,w) {
            a[i][j]=s[j];
            if(s[j]=='#') is[i]++;
        }
    }
    bool first = false;
    int cnt = 0;
    rep(i,h) {
        if(is[i]>0) {
            first= true;
            int isc = is[i];
            cnt++;
            rep(j,w) {
                b[i][j]=cnt;
                if(a[i][j]=='#'){
                    if(isc>1) cnt++;
                    isc--;
                }
            }
        }else if(first) {
            rep(j,w) b[i][j]=b[i-1][j];
            is[i]=1;
        }
    }
    rrep(i,h) {
        if(is[i]==0) {
            rep(j,w) b[i][j]=b[i+1][j];
        }
    }
    rep(i,h) {
        rep(j,w) {
            cout << b[i][j] <<" "<< flush;
        }
        cout << "" << endl;
    }
  return 0;
}



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

int main() {
char c;
string s;
vector<int> v;
int x,ans;
int size;
ans = 999;
cin >> s;
size = s.size();
for(int i=0;i<size;i++){
c = s[i];
x = c - '0';
v.push_back(x);
}
for(int i=0;i<size-2;i++){
x = v[i]*100+v[i+1]*10+v[i+2];
if(x<753&&ans>753-x){
ans = 753 - x;
}else if(x>=753&&ans>x-753){
ans = x - 753;
}
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,a,b;cin >> h >> w >> a >> b;
  cout << h * w - a* w - b * (h-a) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>

int main(void){
    int N, max_p=0;
    std::map<std::string, int> mp;
    std::cin >> N;

    for (int i=0; i<N; ++i){
        std::string s;
        std::cin >> s;
        if (mp.find(s) == mp.end()){
            mp[s] = 0;
        } else {
            ++mp[s];
            max_p = std::max(max_p, mp[s]);
        }
    }

    for (auto& x: mp){
        if (x.second == max_p){
            std::cout << x.first << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 19240
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;


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

	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func divs(n int) []int {
	r := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			r = append(r, i)
			if i*i != n {
				r = append(r, n/i)
			}
		}
	}
	return r
}

func main() {
	var N, ans int
	fmt.Scan(&N)
	for i := 1; i <= N; i += 2 {
		d := 0
		for j := 1; j <= N; j += 2 {
			if i%j == 0 {
				d++
			}
		}
		if d == 8 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(1e5)+10;
int n,x; ll s[maxn],S;
struct node {
	int l,r,a; ll t;
	void init() {
		read(a); read(l); read(r);
		t=(ll)a*l+(ll)(x-a)*r;
		S-=(ll)l*a;
	}
} d[maxn];
bool cmp(node A,node B) {
	return A.t>B.t;
}
bool solve(ll mid) {
	ll q=mid/x,r=mid-q*x,tmp;
	if (q==n) return 1;
	for (int i=1;i<=n;i++) {
		tmp=S;
		if (i<=q) tmp+=s[q+1]-d[i].t;
		else tmp+=s[q];
		if (r>=d[i].a) tmp+=(ll)d[i].l*d[i].a+(r-d[i].a)*d[i].r;
		else tmp+=r*d[i].l;
		if (tmp>=0) return 1;
	} return 0;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(x);
	for (int i=1;i<=n;i++) d[i].init();
	sort(d+1,d+n+1,cmp);
	for (int i=1;i<=n;i++) s[i]=s[i-1]+d[i].t;
	ll l=0,r=(ll)x*n,mid,res;
	while (l<=r) {
		mid=(l+r)/2;
		if (solve(mid)) r=mid-1,res=mid;
		else l=mid+1;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 3328
import collections
n = int(input())
a = []
a_first = []
a_last = []
for i in range(n):
    b = str(input())
    a.append(b)
    a_first.append(b[0])
    a_last.append(b[-1])
c = collections.Counter(a)
if (len(c.keys()) == n):
    if (a_first[1:] == a_last[:-1]):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class UnionFind {
  public:
    vi Parent;
    UnionFind(int N) {
      Parent = vi(N,-1);
    }
  
    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }
  
    int size(int A) {
      return -Parent[root(A)];
    }
  
    bool connect(int A,int B) {
      A = root(A);
      B = root(B);
      if(A == B) return false;
      if(size(A) < size(B)) swap(A,B);
      Parent[A] += Parent[B];
      Parent[B] = A;
      return true;
    }
};
  
int main() {
  int N,K,L;
  cin >> N >> K >> L;
  UnionFind ufa(N),ufb(N);
  rep(i,K) {
    int p,q;
    cin >> p >> q;
    p--;q--;
    ufa.connect(p,q);
  }
  rep(i,L) {
    int p,q;
    cin >> p >> q;
    p--;q--;
    ufb.connect(p,q);
  }
  vp ids;
  map<P,int> cnt;
  rep(i,N) {
    ids.emplace_back(ufa.root(i),ufb.root(i));
    cnt[ids[i]]++;
  }
  rep(i,N) {
    cout << cnt[ids[i]] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 17528
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
#define PI 3.14
#define Rad2Deg  57.29578

using namespace std;
 
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    incin(n);
    incin(m);
    PairV p(n);
    Rap(n,i){
        cin >> p[i].first >> p[i].second;
    }
    sort(all(p));
    int count = 0;
    Rap(n,i){
        if(p[i].second>m){
            count+=p[i].first*m;
            break;
        }else{
            count+=p[i].first*p[i].second;
            m-=p[i].second;
        }
    }
    Pr(count);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    long long yen[102000];
    long long snuke[102000];
    priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > check;
    vector<pair<long long, int> > path1[102000];
    vector<pair<long long, int> > path2[102000];
    for(int i = 1; i <= m; i++){
        int u, v;
        long long a, b;
        cin >> u >> v >> a >> b;
        pair<long long, int> in;
        in.first = a;
        in.second = u;
        path1[v].push_back(in);
        in.second = v;
        path1[u].push_back(in);
        in.first = b;
        path2[u].push_back(in);
        in.second = u;
        path2[v].push_back(in);
    }
    for(int i = 0; i <= 100000; i++){
        yen[i] = -1;
        snuke[i] = -1;
    }
    yen[s] = 0;
    snuke[t] = 0;
    for(int i = 0; i < path1[s].size(); i++){
        check.push(path1[s][i]);
    }
    while(!check.empty()){
        pair<long long, int> out = check.top();
        check.pop();
        if(yen[out.second] != -1){
            continue;
        }
        yen[out.second] = out.first;
        for(int i = 0; i < path1[out.second].size(); i++){
            pair<long long, int> in = path1[out.second][i];
            in.first = in.first + yen[out.second];
            check.push(in);
        }
    }
    for(int i = 0; i < path2[t].size(); i++){
        check.push(path2[t][i]);
    }
    while(!check.empty()){
        pair<long long, int> out = check.top();
        check.pop();
        if(snuke[out.second] != -1){
            continue;
        }
        snuke[out.second] = out.first;
        for(int i = 0; i < path2[out.second].size(); i++){
            pair<long long, int> in = path2[out.second][i];
            in.first = in.first + snuke[out.second];
            check.push(in);
        }
    }
    long long ans[102000];
    for(int i = 1; i <= n; i++){
        //cout << yen[i] << endl;
    }
    for(int i = 1; i <= n; i++){
        //cout << snuke[i] << endl;
    }
    //cout << endl;
    ans[n] = 1000000000000000 - yen[n] - snuke[n];
    for(int i = n - 1; i >= 1; i--){
        ans[i] = max(ans[i + 1], 1000000000000000 - yen[i] - snuke[i]);
    }
    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 23160
# Contest: AtCoder Beginner Contest 142 (https://atcoder.jp/contests/abc142)
# Problem: C: Go to School (https://atcoder.jp/contests/abc142/tasks/abc142_c)

def rint():
    return int(input())


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


n = rint()
a = rints()
s = list(range(1, n + 1))
s.sort(key=lambda i: a[i - 1])
print(' '.join(map(str, s)))


Measured memory_bytes: 71212
import math
import collections

N = int(input())
A = list(int(x) for x in input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

C = collections.Counter(A)
csum = 0

for c in C.values():
    if c > 1:
        csum += combinations_count(c, 2)

for a in A:
    print(csum - (C[a]-1))

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

// dp[index][累積価値]: その累積価値を獲得するために必要な最低限のweight
ll dp[101][100001];

int main() {
    ll n, capacity;
    cin >> n >> capacity;
    vector<ll> w(n+1);
    vector<ll> v(n+1);
    for (ll i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    
    ll limit = accumulate(v.begin(), v.end(), 0);
    for(ll i = 0; i <= n; i++) {
        for(ll j = 0; j <= limit; j++) {
            dp[i][j] = capacity + 1;
        }
    }
    dp[0][0] = 0;
    for (ll i = 1; i <= n; i++) {
        for(ll j = 0; j <= limit; j++) {
            if (j == 0) dp[i][j] = 0;
            else if (j < v[i]) dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
        }
    }
    ll res;
    for(ll j = 0; j <= limit; j++) {
        if (dp[n][j] <= capacity) res = j;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<P> input;
    rep0(i,M){
        P p;
        cin >> p.first >> p.second;
        input.push_back(p);
    }
    string res ="";
    rep0(i,N){
        res+="a";
    }
    rep0(i,M){
        if(res[input[i].first-1]!='a'&&res[input[i].first-1]!=(char)(input[i].second+'1'-1)){
            cout << -1 << endl;
            return 0;
        }
        res[input[i].first-1]=(char)(input[i].second+'1'-1);
    }
    rep0(i,N){
        if(res[i]=='a'){
            if(i==0&&N!=1){
                res[i]='1';
            }else{
                res[i] = '0';
            }
        }
    }
    if(res[0]=='0'&&N!=1){
        cout << -1 << endl;        
        return 0;
    }
    cout <<res<<endl;

}


Measured memory_bytes: 3612
import java.util.*;
import java.lang.*; 
class Main{
	public static void main(String[] args){
		Scanner in=new Scanner (System.in);
		int s=0;
	int n=in.nextInt();
	
	for(int i=1;i<=n;i++)
	{
		s=s+i;
	}
	System.out.println(s);
	
	}
	
}

Measured memory_bytes: 21844
def warshall_floyd(d):
    global n
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

h,w = map(int,input().split())
n = 10
d = [[] for i in range(10)]
for i in range(10):
    for j in map(int,input().split()):
        d[i].append(j)
D = warshall_floyd(d)
ans = 0
for i in range(h):
    for j in map(int,input().split()):
        if j != -1:
            ans += D[j][1]
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
    // (*nil).next = nil
}

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key) cur = cur->next;
    return cur;
}


void deleteNode(Node *t){
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;

    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int cnt = 0;
    while(1){
        if(cur == nil) break;
        if(cnt > 0) cout << " ";
        cout << cur->key;
        cnt++;
        cur = cur->next;
    }
    cout << endl;
}

int main(){
    int n; scanf("%d", &n);
    char com[20];
    int d;

    init();
    for(int i=0; i<n; i++){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d", &d);
            insert(d);
        }
        else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F') deleteFirst();
                else if(com[6] == 'L') deleteLast();
            }
            else{
                scanf("%d", &d);
                deleteKey(d);
            }
        }
    }

    printList();
}


Measured memory_bytes: 34488
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int m = sc.intarr[0];

            wr.wri(48 - m);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(){
	
    int w,h,x,y,r;
    
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(x<=w-r && y<=h-r && x>=0+r && y>=0+r){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


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

#define ROOP(i,n) for(i=0;i<n;i++)

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdouble(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	int k, i;
	int even = 0, odd = 0;
	k = getint();
	if (k % 2 == 0) {
		even = k / 2;
		odd = k / 2;
	} else {
		even = k / 2;
		odd = (k / 2) + 1;
	}
	showint(even * odd);
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdouble(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    return 1 if N == 0 else 0


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78320
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
 
#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define loopi(n) for(int i=0;i<n;i++)
#define loopj(n) for(int j=0;j<n;j++)
#define loop(a,b,c) for(int i=a;i<=b;i=i+c)
 
#define     all(x)      (x).begin(),(x).end()
#define     reset(a)    memset(a,0,sizeof(a))
#define     sz(x)       ((int)(x.size()))
#define     pb          push_back
#define     pf          push_front
#define     pob	        pop_back
#define     pof         pop_front
#define     ins         insert
#define     F           first
#define     S           second
#define     mkp         make_pair
#define     mkt         make_tuple
#define     bitcount(x) __builtin_popcountll(x)
#define     gcd(a,b)    (__gcd(a,b))
#define     lcm(a,b)    ((a*b)/gcd(a,b))
 
const int mod=1e9+7;

void solve()
{
	string s;
	cin>>s;
	if(s[s.length()-1]=='s')
		s=s+"es";
	else
		s=s+"s";
	cout<<s;
}
 
int main() 
{
	sync;
 
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	} 
} 
	

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int s;
  cin >> s;
  int a = (s / 100);
  int s1 = s % 100;
  int b = (s1 / 10);
  int s2 = s1 % 10;
  cout << a + b + s2 << endl;
}

Measured memory_bytes: 3636
package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  ok := true
  if a > 8 {
    ok = false
  }
  if b > 8 {
    ok = false
  }
  if ok {
    fmt.Println("Yay!")
  } else {
    fmt.Println(":(")
  }
}

Measured memory_bytes: 512
#include <stdio.h>
#define N 36

typedef struct{
  char mark;
  int number;
} trump;

void bubbleSort(trump *,int );
void selectionSort(trump *, int );
int isStable(trump *, trump *,int);

int main(){

  int i,n;  
  trump tin[N],tout[N];
  
  scanf("%d",&n);
  
  for(i = 0; i < n ; i++){
    scanf(" %c%d",&tin[i].mark,&tin[i].number);
    tout[i] = tin[i];
  }
  bubbleSort(tin,n);
  printf("Stable\n");
 
 selectionSort(tout,n);
 if(isStable(tin,tout,n) == 1)printf("Stable\n");
 else printf("Not stable\n");
 
 return 0;
}

void bubbleSort(trump a[],int n){
  int i,j;
  trump tmp[1];

  for(i = 0; i < n ; i++){
    for(j = n-1 ; j >= i+1 ; j--){
      if(a[j].number < a[j-1].number){
	tmp[0] = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp[0];
      }
    }
  }
   for(i = 0 ; i < n-1 ; i++){
  printf("%c%d ",a[i].mark,a[i].number);
   }
   printf("%c%d\n",a[i].mark,a[i].number);
  }

void selectionSort(trump *a, int n){
  int i,j,minj;
  trump tmp[1];
  
  for(i = 0; i < n ; i++){
    minj = i;
    for(j = i ; j < n; j++){
      if(a[j].number < a[minj].number){
	 minj = j;
       }
     }
    tmp[0] = a[i];
    a[i] = a[minj];
    a[minj] = tmp[0];
   }
   for(i = 0 ; i < n-1 ; i++){
     printf("%c%d ",a[i].mark,a[i].number);
   }
   printf("%c%d\n",a[i].mark,a[i].number);
 }

 int isStable(trump *in,trump *out,int n){
   int i;

     for(i = 0; i < n; i++){
       if(in[i].mark != out[i].mark)return 0;
     }
   return 1;
 }
  




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

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    long long ans = 0;
    
    for ( int i = 0; i < N; i++ ) {
        long long a;
        cin >> a;
        ans += a-1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;

int main() {
ll x;
cin >> x;
ll ans = 1000*(x/500)+5*((x%500)/5);
cout << ans << endl;
return 0;
}


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

class dice {
private:
	int n[7];

public:
	dice(int, int, int, int, int, int);
	dice() {};
	int getcur() { return n[1]; }
	int getnum(int i) { return n[i]; }
	void rotate(char);
	void setdice(int, int, int, int, int, int);
};

dice::dice(int n1, int n2, int n3, int n4, int n5, int n6) {
	setdice(n1, n2, n3, n4, n5, n6);
}

void dice::rotate(char op) {
	dice copy(n[1], n[2], n[3], n[4], n[5], n[6]);
	switch (op) {
	case'W':
		n[1] = copy.n[3];
		n[3] = copy.n[6];
		n[6] = copy.n[4];
		n[4] = copy.n[1];
		break;
	case'E':
		n[1] = copy.n[4];
		n[3] = copy.n[1];
		n[6] = copy.n[3];
		n[4] = copy.n[6];
		break;
	case'S':
		n[1] = copy.n[5];
		n[2] = copy.n[1];
		n[6] = copy.n[2];
		n[5] = copy.n[6];
		break;
	case'N':
		n[1] = copy.n[2];
		n[2] = copy.n[6];
		n[6] = copy.n[5];
		n[5] = copy.n[1];
		break;
	case'C':
		n[2] = copy.n[3];
		n[3] = copy.n[5];
		n[5] = copy.n[4];
		n[4] = copy.n[2];
		break;
	}
}

void dice::setdice(int n1, int n2, int n3, int n4, int n5, int n6) {
	n[1] = n1;
	n[2] = n2;
	n[3] = n3;
	n[4] = n4;
	n[5] = n5;
	n[6] = n6;
}

bool check(dice,dice);
bool check_two_dices(dice, dice);

int main() {
	int n;
	dice D[110];
	bool isAllDifferent = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int in[6];
		for (int j = 0; j < 6; j++) {
			cin >> in[j];
		}
		D[i].setdice(in[0], in[1], in[2], in[3], in[4], in[5]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (check_two_dices(D[i], D[j])) isAllDifferent = false;
		}
	}

	if (isAllDifferent) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

bool check(dice a, dice b) {
	bool isequal = true;
	for (int i = 1; i <= 6; i++) {
		if (a.getnum(i) != b.getnum(i)) isequal = false;
	}
	return isequal;
}

bool check_two_dices(dice a, dice b) {
	bool ok = false;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if (check(a, b)) {
				ok = true;
				break;
			}
			b.rotate('C');
		}
		b.rotate('N');
	}

	if (!ok) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (check(a, b)) {
					ok = true;
					break;
				}
				b.rotate('C');
			}
			b.rotate('E');
		}
	}

	return ok;
}

Measured memory_bytes: 1160
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

//ユークリッドの互除法
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x;}


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

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

const int ALP_NUM = 26;

int main() {
    int d;
    cin >> d;
    vector<int> C(ALP_NUM);
    rep(i, ALP_NUM) cin >> C[i];
    vector<vector<int>> S(d, vector<int>(ALP_NUM));
    rep(i, d) rep(j, ALP_NUM) cin >> S[i][j];

    auto get_score = [&](vector<int> A, int n) {
        int res = 0;
        vector<int> D(ALP_NUM, -1);
        rep(i, n) {
            int t = A[i];
            res += S[i][t];
            D[t] = i;
            rep(j, ALP_NUM) {
                res -= (i-D[j]) * C[j];
            }
        }
        return res;
    };

    vector<int> ans(d);
    rep(i, d) cin >> ans[i];
    rep(i, d) --ans[i];
    rep(i, d) {
        cout << get_score(ans, i+1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
from sys import stdin
import itertools



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

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])
X = int(temp[1])

data = []
for i in range(N):
    data.append(int(stdin.readline()))
    
d = sorted(data)

mindif = 1000000000000000
for i in range(N-X+1):
    dif = d[i+X-1] - d[i]
    if dif < mindif:
        mindif = dif
        
print(mindif)

Measured memory_bytes: 8308
import java.util.Scanner;

public class Main {

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

		char i2 = S.charAt(2);
		char i3 = S.charAt(3);
		char i4 = S.charAt(4);
		char i5 = S.charAt(5);

		if (i2 == i3 && i4 == i5) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 35608
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if len(s) != 1{
		return
	}
	if strings.ToLower(s) == s{
		fmt.Println("a")
	}else{
		fmt.Println("A")
	}
}

Measured memory_bytes: 1844
A, B, C, D = map(int, input().split())


def ea(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x %= y
        x, y = y, x
    return y


gcd = ea(C, D)

ans = B - A + 1
ans -= B // C - (A - 1) // C
ans -= B // D - (A - 1) // D
ans += B // ((C * D) // gcd) - (A - 1) // ((C * D) // gcd)

print(ans)


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

int main() {
	u32 N;
	cin >> N;
	
	string S;
	cin >> S;
	
	u32 Q;
	cin >> Q;
	
	set<u32> cm[26];
	for(u32 i=0; i<N; i++) cm[S[i] - 'a'].insert(i);

	for(u32 q=0; q<Q; q++) {
		u32 t;
		cin >> t;
		
		if(t & 1) {
			u32 i;
			char c;
			cin >> i >> c;
	
			if(S[i-1] == c) continue;
			
			cm[c - 'a'].insert(i-1);
			cm[S[i-1] - 'a'].erase(i-1);
			
			S[i-1] = c;
			
		} else {
			u32 l, r;
			cin >> l >> r;
			
			u32 ans = 0;
			
			for(u32 i=0; i<26; i++) {
				auto itr = cm[i].lower_bound(l - 1);
				if(itr != cm[i].end() && *itr <= r - 1) ans++;
			}
			
			cout << ans << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 24324
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1000;
int N;
ll U[MAX_N],V[MAX_N];
bool uflg[35],vflg[35];
const int M=35;
int main(){
	cin>>N;
	REP(i,N){
		ll x,y;
		cin>>x>>y;
		U[i]=x+y;
		V[i]=y-x;
	}
	bool flg=true;
	int p=(U[0]&1);
	REP(i,N){
		if (p!=(U[i]&1) || p!=(V[i]&1)){
			flg=false;
		}
	}
	if (flg){
		cout<<(p==1 ? M+1 : M)<<endl;
		REP(i,M){
			ll x;
			if (i){
				cout<<" ";
			}
			if (i<=1){
				x=1;
			}else{
				x=(1ll<<(i-1));
			}
			cout<<x;
		}
		if (p==1){
			cout<<" 1";
		}
		cout<<endl;
		if (p==1){
			REP(i,N){
				U[i]--;
				V[i]++;
			}
		}
		REP(i,N){
			ll cur=0;
			for(int j=M-1;j>=0;j--){
				ll x;
				if (j<=1){
					x=1;
				}else{
					x=(1ll<<(j-1));
				}
				if (cur<=U[i]){
					uflg[j]=true;
					cur+=x;
				}else{
					uflg[j]=false;
					cur-=x;
				}
			}
			cur=0;
			for(int j=M-1;j>=0;j--){
				ll x;
				if (j<=1){
					x=1;
				}else{
					x=(1ll<<(j-1));
				}
				if (cur<=V[i]){
					vflg[j]=true;
					cur+=x;
				}else{
					vflg[j]=false;
					cur-=x;
				}
			}
			REP(i,M){
				char c;
				if (uflg[i]){
					if (vflg[i]){
						c='U';
					}else{
						c='R';
					}
				}else{
					if (vflg[i]){
						c='L';
					}else{
						c='D';
					}
				}
				cout<<c;
			}
			if (p==1){
				cout<<'R';
			}
			cout<<endl;
		}
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second
 
Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

bool dp[11][11][11];

int main() {
    Int n;
    cin >> n;
    string s;
    cin >> s;
    dp[10][10][10] = true;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j <= 10; j++) {
            for (Int k = 0; k <= 10; k++) {
                for (Int l = 0; l <= 10; l++) {
                    if (dp[j][k][l]) {
                        if (j == 10) {
                            dp[s[i] - '0'][k][l] = true;
                        }
                        else if (k == 10) {
                            dp[j][s[i] - '0'][l] = true;
                        }
                        else if (l == 10) {
                            dp[j][k][s[i] - '0'] = true;
                        }
                    }
                }
            }
        }
    }
    Int res = 0;
    for (Int i = 0; i < 10; i++) {
        for (Int j = 0; j < 10; j++) {
            for (Int k = 0; k < 10; k++) {
                if (dp[i][j][k]) {
                    res++;
                }
            }
        }
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<queue>
#include<deque>
#include<vector>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

int a[100000];
signed main() {
	int k; cin >> k;
	for (int i = 0; i < k; i++) {
		cin >> a[i];
	}
	int MIN = 2, MAX = 2;
	for (int i = k - 1; i >= 0; i--) {
		//MIN以上の最小の２の倍数
		int b = MIN / a[i] * a[i];
		if (b < MIN)b += a[i];
		if (b > MAX) {
			puts("-1");
			return 0;
		}
		MIN = b;
		//MAXより大きい最小の２の倍数
		b = MAX / a[i] * a[i];
		if (b <= MAX)b += a[i];
		if (b <= MAX)b += a[i];
		MAX = b - 1;
	}
	cout << MIN << " " << MAX << endl;
}

Measured memory_bytes: 1024