akhauriyash/Code-Regression huggingface dataset:
//
//AtCoder Beginner Contest 126
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    
    s[k-1] = s[k-1] + 32;

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

ll num_of_ways(vector<vector<char>>grid, ll r, ll c)
{
	if (r == 1 and c == 1)
	{
		return 1;
	}
	vector<vector<ll>>dp(r, vector<ll>(c));
	bool block = false;

	//Initialisation
	for (ll i = 0; i < r; i++)
	{
		if (block == true)
		{
			dp[i][0] = 0;
			continue;
		}
		if (grid[i][0] == '#')
		{
			dp[i][0] = 0;
			block = true;
		}
		else
		{
			dp[i][0] = 1;
		}
	}
	block = false;
	for (ll j = 0; j < c; j++)
	{
		if (block == true)
		{
			dp[0][j] = 0;
			continue;
		}
		if (grid[0][j] == '#')
		{
			dp[0][j] = 0;
			block = true;
		}
		else
		{
			dp[0][j] = 1;
		}
	}
	//Initialisation finish

	for (ll i = 1; i < r; i++)
	{
		for (ll j = 1; j < c; j++)
		{
			if (grid[i][j] == '#')
			{
				dp[i][j] = 0;
			}
			else
			{
				dp[i][j] = ((dp[i - 1][j] % MOD) + (dp[i][j - 1] % MOD)) % MOD;
			}

		}
	}
	return dp[r - 1][c - 1];


}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll h, w;
	cin >> h >> w;
	vector<vector<char>>grid(h, vector<char>(w));
	for (ll i = 0; i < h; i++)
	{
		for (ll j = 0; j < w; j++)
		{
			char ch;
			cin >> ch;
			grid[i][j] = ch;
		}
	}
	cout << num_of_ways(grid, h, w) << endl;
	return 0;

}

Measured memory_bytes: 12944
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[100001];
		int sum = 0;
		for(int i=0;i<n;i++){
			int m=sc.nextInt();
			if(m>100000){
				sum++;
			}else
				x[m]++;
		}
		for(int i=0;i<=100000;i++){
			if(x[i]<i){
				sum+=x[i];
			}
			else if(x[i]>i){
				sum+=x[i] - i;
			}
		}
		System.out.print(sum);
	}
}


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

public class ALDS1_11_C
{
    public struct Node
    {
        public int Id;
        public List<int> Adj;
        public int Depth;
        public Node(int id)
        {
            Id = id + 1;
            Adj = new List<int>();
            Depth = -1;
        }
    }

    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int n = int.Parse(Console.ReadLine());

        var g = new Node[n];
        for (int i = 0; i < n; i++)
        {
            g[i] = new Node(i);
        }
        for (int i = 0; i < n; i++)
        {
            int[] val = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            for (int j = 2; j < val[1] + 2; j++)
            {
                g[val[0] - 1].Adj.Add(val[j] - 1);
            }
        }

        var q = new Queue<int>();
        g[0].Depth = 0;
        q.Enqueue(0);
        Bfs(g, q);

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++)
        {
            sb.Append(g[i].Id);
            sb.Append(" ");
            sb.Append(g[i].Depth);
            sb.AppendLine();
        }
        Console.Write(sb.ToString());
    }

    public static void Bfs(Node[] g, Queue<int> queue)
    {
        while (queue.Count > 0)
        {
            var i = queue.Dequeue();
            for (int j = 0; j < g[i].Adj.Count; j++)
            {
                if (g[g[i].Adj[j]].Depth == -1)
                {
                    g[g[i].Adj[j]].Depth = g[i].Depth + 1;
                    queue.Enqueue(g[i].Adj[j]);
                }
            }
        }
    }
}



Measured memory_bytes: 18764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		int[] H = Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();

		int current = 0;
		for(int i = 0; i < N; i++)
		{
			if(H[i] < current)
			{
				Console.WriteLine("No");
				return;
			}
			else if(H[i] > current)
			{
				current = H[i] - 1;
			}
		}
		Console.WriteLine("Yes");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define eb emplace_back
#define pb push_back
#define lli long long int
#define modn 1000000007
#define NL '\n'

using namespace std;

typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< bool > vb;
typedef vector< string > vs;
typedef vector< lli > vli;
typedef vector< vector< char > > vvc;
typedef vector< vector< int > > vvi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef pair< lli, int> pli;
typedef pair< lli, lli> pll;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	#ifdef LOCAL_TEST
		clock_t z = clock();
    	ifstream h("in");
	    ofstream g("out");
	#else
	    #define h cin
	    #define g cout
	#endif // LOCAL_TEST
	
	string s, t;
	h >> s >> t;
	int a, b;
	h >> a >> b;
	string u;
	h >> u;
	if (u == s)
		a--;
	else
		b--;
	g << a << ' ' << b;
	
	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif // LOCAL_TEST
}



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

int main(){
    int n,x; bool f=1;
    scanf("%d",&n);

    for(int i=1;i<=n;i++){
        scanf("%d",&x);
//cout<<x<<endl;
        if(x%2==0){
          if(x%3!=0&&x%5!=0) f=0;
        }

    }
    if(f) puts("APPROVED");
    else puts("DENIED");
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1ll << 60;

struct MaximumFlow {
  typedef int Index;
  typedef ll Flow;
  static const Flow InfCapacity = INF;
  struct Edge {
    Index to;
    Flow capacity;
    Index rev;
  };
  vector<vector<Edge> > g;
  void init(Index n) { g.assign(n, vector<Edge>()); }
  void add(Index i, Index j, Flow capacity) {
    Edge e, f;
    e.to = j, f.to = i;
    e.capacity = capacity, f.capacity = 0;
    g[i].push_back(e);
    g[j].push_back(f);
    g[i].back().rev = (Index)g[j].size() - 1;
    g[j].back().rev = (Index)g[i].size() - 1;
  }
  void addB(Index i, Index j, Flow capacity) {
    Edge e, f;
    e.to = j, f.to = i;
    e.capacity = capacity, f.capacity = capacity;
    g[i].push_back(e);
    g[j].push_back(f);
    g[i].back().rev = (Index)g[j].size() - 1;
    g[j].back().rev = (Index)g[i].size() - 1;
  }
  // gを破壊する
  Flow maximumFlow(int s, int t) {
    int n = g.size();
    vector<Index> level(n);
    Flow total = 0;
    bool update;
    do {
      update = false;
      fill(level.begin(), level.end(), -1);
      level[s] = 0;
      queue<Index> q;
      q.push(s);
      for (Index d = n; !q.empty() && level[q.front()] < d;) {
        int u = q.front();
        q.pop();
        if (u == t) d = level[u];
        for (const auto &e : g[u])
          if (e.capacity > 0 && level[e.to] == -1)
            q.push(e.to), level[e.to] = level[u] + 1;
      }
      vector<Index> iter(n);
      for (Index i = 0; i < n; i++) iter[i] = (int)g[i].size() - 1;
      while (1) {
        Flow f = augment(level, iter, s, t, InfCapacity);
        if (f == 0) break;
        total += f;
        update = true;
      }
    } while (update);
    return total;
  }
  Flow augment(vector<Index> &level, vector<Index> &iter, Index u, Index t,
               Flow f) {
    if (u == t || f == 0) return f;
    Index lv = level[u];
    if (lv == -1) return 0;
    level[u] = -1;
    for (; iter[u] >= 0; --iter[u]) {
      Edge &e = g[u][iter[u]];
      if (level[e.to] <= lv) continue;
      Flow l = augment(level, iter, e.to, t, min(f, e.capacity));
      if (l == 0) continue;
      e.capacity -= l;
      g[e.to][e.rev].capacity += l;
      level[u] = lv;
      return l;
    }
    return 0;
  }
};

int main() {
  int N;
  while (cin >> N) {
    vector<ll> a(N);
    ll best = 0;
    for (int i = 0; i < N; i++) {
      cin >> a[i];
      if (a[i] >= 0) {
        best += a[i];
      }
    }
    MaximumFlow mf;
    mf.init(N + 2);
    int s = N, t = N + 1;
    for (int i = 1; i <= N; i++) {
      if (a[i - 1] >= 0) {
        mf.add(i - 1, t, a[i - 1]);
      } else {
        mf.add(s, i - 1, -a[i - 1]);
      }
      for (int j = i + i; j <= N; j += i) {
        mf.add(i - 1, j - 1, INF);
      }
    }
    ll ans = best - mf.maximumFlow(s, t);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 1000000

using namespace std;

bool prime[MAX];

void isPrime(void){

  fill(prime, prime + MAX, true);
  prime[0] = prime[1] = false;
  for(int i = 0 ; i*i < MAX ; i++){
    if(prime[i]){
      for(int j = i*i ; j < MAX ; j += i){
	prime[j] = false;
      }
    }
  }
}

int main(void){

  isPrime();

  int n;
  while(cin >> n, n){
    int cnt = 0;
    for(int i = 2 ; n - i >= i ; i++){
      if(prime[i] && prime[n - i]) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
using ld = long double;

ll dp[3001][3001];
constexpr ll MOD = 998244353;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    int n, s;
    cin >> n >> s;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
      cin >> a[i];

    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int v = 0; v <= 3000; v++) {
        dp[i][v] = (2 * dp[i - 1][v]) % MOD;
        if (v - a[i - 1] >= 0)
          dp[i][v] = (dp[i][v] + dp[i - 1][v - a[i - 1]]) % MOD;
      }
    }
    cout << dp[n][s] << '\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


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

int main(){
  string S; cin >> S;
  int size = S.size() - 2;
  cout << S.at(0) << size << S.at(size + 1) << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
vector<T> PrimeFactorization(T x){
    vector<T> res;
    T v = 2;
    while( v * v <= x){
        if(x%v != 0){
            v++;
        }else{
            res.push_back(v);
            x /= v;
        }
    }
    if(x!=1) res.push_back(x);
    sort(res.begin(), res.end());
    return res;
}

int main()
{
    ll N;
    cin >> N;
    auto ret = PrimeFactorization(N);
    map<ll, ll> primes;
    for(auto v : ret){
        if(primes.count(v)==0) primes[v] = 0;
        primes[v]++;
    }
    vector<ll> vsum;
    for(int i=0; i<41; i++){
        vsum.push_back(i);
    }
    for(int i=1; i<41; i++){
        vsum[i] += vsum[i-1];
    }

    ll res = 0;
    for(auto m : primes){
        auto itr = upper_bound(vsum.begin(), vsum.end(), m.second);
        auto i = distance(vsum.begin(), itr) - 1;
        res += i;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3636
def count(card)
  return 0 if card.inject(:+) % 3 != 0
  res = 0
  for i in 1..9 do
    if card[i] > 0 && card[i + 1] > 0 && card[i + 2] > 0
      new = card
      new[i] -= 1
      new[i + 1] -= 1
      new[i + 2] -= 1
      res = [res, 1 + count(new)].max
    end
    if card[i] >= 3
      new = card
      new[i] -= 3
      res = [res, 1 + count(new)].max
    end
  end
  res
end

T = gets.to_i
T.times do
  hand = Hash.new
  n = gets.split.map(&:to_i)
  c = gets.split
  for i in 0...9 do
    hand[c[i]] = Array.new(13, 0) unless hand.key?(c[i])
    hand[c[i]][n[i]] += 1
  end
  total = 0
  hand.each do |color, card|
    total += count(card)
  end
  puts total == 3 ? "1" : "0"
end

Measured memory_bytes: 6120
N = int(input())
s_list = []
s_dict = {}
count = 0

for i in range(N):
  x = "".join(sorted(input()))
  if x not in s_dict:
    s_dict[x] = 0
  else:
    s_dict[x] += 1
    count += s_dict[x]

print(count)
  

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

int main() {
  int N;
  cin>>N;
  vector<int64_t> p(N);
  vector<vector<int64_t>> q(N+1,vector<int64_t>(20));
  for(int i=0;i<N;i++){
    cin>>p[i];
    for(int j=0;j<20;j++){
      if(p[i]&(1<<j)){
        q[i+1][j]++;
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<20;j++){
      q[i+1][j]+=q[i][j];
    }
  }
  int64_t Z=0;
  for(int i=0;i<N;i++){
    int64_t l=-1,r=i;
    while(r-l>1){
      int k=0,D=(l+r)/2;
      for(int j=0;j<20;j++){
        if(q[i+1][j]-q[D][j]>1){
          k=1;
        }
      }
      if(k){
        l=D;
      }
      else{
        r=D;
      }
    }
    Z+=i;
    Z-=l;
  }
  cout<<Z<<endl;
}

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

int main(){
  int n;
  cin >> n;
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9){
    cout << "hon" << endl;
  }
  else if(n%10==0||n%10==1||n%10==6||n%10==8){
    cout << "pon" << endl;
  }
  else{
    cout << "bon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>

#define M 1000001/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M/* your task */; }
int h2(int key){ return 1+key%(M-10)/* your task */; }

int find(char str[]){
  int i,j;
  long key;
  i=0;
  while(1){
    key=getKey(str);
    j=(h2((int)key)+i*h1((int)key))%M;
    if(strcmp(H[j],str)==0) return j;
    else if(H[j][0]=='\0' || i>=M) return NULL;
    else i++;
  }
    /* your task */

}

int insert(char str[]){
  long key;
  int j,i;
  i=0;
  while(1){
    key=getKey(str);
    j=(h2((int)key)+i*h1((int)key))%M;
    if(H[j][0]=='\0'){
      strcpy(H[j],str);
       return j;
    }
    else i++;
  }
     
    /* your task */

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
INF = (10 ** 9) + 7
N, M = map(int, input().split())

aLst = set(int(input()) for _ in range(M))
ansLst = [0] * (N + 1)
ansLst[0] = 1

for i in range(1, N + 1):
    if i in aLst:
        continue
    tmp = ansLst[i - 1]
    if i > 1:
        tmp += ansLst[i - 2]
    ansLst[i] = tmp % INF


print(ansLst[N])


Measured memory_bytes: 11884
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
char s[100+10];
char ans[][10]={
	"No\n",
	"Yes\n"
};
struct DICE{
	int u,s,e,w,n,d;
	DICE (int u=0,int s=0,int e=0,int w=0,int n=0,int d=0):u(u),s(s),e(e),w(w),n(n),d(d){}
	DICE fW(){
		DICE tmp;
		tmp.s=this->s;
		tmp.n=this->n;
		tmp.e=this->d;
		tmp.w=this->u;
		tmp.u=this->e;
		tmp.d=this->w;
		return tmp;
	}
	DICE fS(){
		DICE tmp;
		tmp.s=this->u;
		tmp.n=this->d;
		tmp.e=this->e;
		tmp.w=this->w;
		tmp.d=this->s;
		tmp.u=this->n;
		return tmp;
	}
	DICE fE(){
		DICE tmp;
		tmp.s=this->s;
		tmp.n=this->n;
		tmp.e=this->u;
		tmp.w=this->d;
		tmp.d=this->e;
		tmp.u=this->w;
		return tmp;
	}
	DICE fN(){
		DICE tmp;
		tmp.s=this->d;
		tmp.n=this->u;
		tmp.e=this->e;
		tmp.w=this->w;
		tmp.d=this->n;
		tmp.u=this->s;
		return tmp;
	}
	int right(int t,int f){
		if(t==this->u)
		{
			if(f==this->s)return this->e;
			else if(f==this->e)return this->n;
			else if(f==this->n)return this->w;
			else if(f==this->w)return this->s;
			else return -1;
		}
		else if(t==this->s){
			DICE tmp=(*this).fN();
			return tmp.right(t,f);
		}
		else if(t==this->e){
			DICE tmp=(*this).fW();
			return tmp.right(t,f);
		}
		else if(t==this->n){
			DICE tmp=(*this).fS();
			return tmp.right(t,f);
		}
		else if(t==this->w){
			DICE tmp=(*this).fE();
			return tmp.right(t,f);
		}
		else if(t==this->d){
			DICE tmp=(*this).fE().fE();
			return tmp.right(t,f);
		}
		else return -1;
		}
};
bool check(DICE x,DICE y){
	int ax[]={
		x.s,x.e,x.n,x.w
	};
	int ay[]={
		y.s,y.e,y.n,y.w
	};
	if(x.u==y.u){
		if(x.d==y.d){
			int cnt=0;
			while(cnt<=4){
				while(ax[cnt]!=ay[0]&&cnt<=4)
					cnt++;
				int i=0;
				while(ax[(i+cnt)%4]==ay[i]&&i<=4)
					i++;
				if(i==4)return 1;
				cnt++;
			}
			
		}
	}
	return 0;
}
bool sovle(DICE x,DICE y){
	if(check(x,y))return 1;
	if(check(x.fE(),y))return 1;
	if(check(x.fW(),y))return 1;
	if(check(x.fN(),y))return 1;
	if(check(x.fS(),y))return 1;
	if(check(x.fS().fS(),y))return 1;
	return 0;
}
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	
	int a[6];
	for(int i=0;i<6;i++){
		scanf("%d", &a[i]);
	}
	DICE dice(a[0],a[1],a[2],a[3],a[4],a[5]);
	for(int i=0;i<6;i++){
		scanf("%d", &a[i]);
	}
	DICE dice2(a[0],a[1],a[2],a[3],a[4],a[5]);
	printf("%s", ans[sovle(dice,dice2)]);
//	printf("%s", ans[solve(dice,dice2)]);
//	DICE I
//	scanf("%s", s);
//	int len=strlen(s);
//	for(int i=0;i<len;i++){
//		switch(s[i]){
//			case'S':dice=dice.fS();break;
//			case'E':dice=dice.fE();break;
//			case'W':dice=dice.fW();break;
//			case'N':dice=dice.fN();break;
//		}
//	}
//	printf("%d\n", dice.u);
//
	return 0;
}
//aoj1_11_a.cc

//AC

Measured memory_bytes: 1188
import java.util.Scanner;

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

		if(1<=a && b <= 100){
			int area = a*b;
			int perimeter = (a+b)*2;
			System.out.println(area + " " + perimeter);
		}

		sc.close();
	}
}

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

using namespace std;

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

    bool is_possible = false;
    if (a % 3 == 0) is_possible = true;
    if (b % 3 == 0) is_possible = true;
    if ((a + b) % 3 == 0) is_possible = true;

    if (is_possible) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>



int main(){



  int a,s,m,h;



  scanf("%d",&a);



  s=a%60; //分にならない秒が出る



  m=a%3600; //時間にならない秒が出る



  m=m-s; //分になる秒が出る



  m=m/60; //分が出る



  h=(a-s-m*60)/3600; //あまりを全部引いて、時間を残す



  printf("%d:%d:%d\n",h,m,s);



  return 0;



}

Measured memory_bytes: 592
n = int(input())
a = list(map(int, input().split()))
x = max(range(n), key=lambda i: abs(a[i]))
print(2*n)
if a[x] >= 0:
    print(x+1, 1)
    print(x+1, 1)
    for i in range(2, n+1):
        print(i-1, i)
        print(i-1, i)
else:
    print(x+1, n)
    print(x+1, n)
    for i in range(n-1, 0, -1):
        print(i+1, i)
        print(i+1, i)

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int a, b, c, k;
  cin >> a >> b >> c >> k;

  int n = max(a, max(b, c));
  if (a == n) {
    cout << a * (1 << k) + b + c << endl;
  } else if (b == n) {
    cout << b * (1 << k) + a + c << endl;
  } else {
    cout << c * (1 << k) + b + a << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;

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

    int n;
    string s;
    cin >> n >> s;
    int ans;
    rep(i,0,n-2){
    	if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C') ans++;
    }
    cout << ans << "\n";

    
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;


class Solve
{
  public Solve() { }
  public static int Main()
  {
    new Solve().calc();
    return 0;
  }


  Scanner cin;

  void calc()
  {
    cin = new Scanner();
    int K = cin.nextInt();

    string input = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    string[] nums = input.Split(',');
    string result = nums[K - 1].Trim();

    Console.WriteLine(result);
  }
}
class Modulo
{
  private const int M = 1000000007;
  private readonly int[] m_facs;
  public int Mul(int a, int b)
  {
    return (int)(Math.BigMul(a, b) % M);
  }
  public Modulo(int n)
  {
    m_facs = new int[n + 1];
    m_facs[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
      m_facs[i] = Mul(m_facs[i - 1], i);
    }
  }
  public int Fac(int n)
  {
    return m_facs[n];
  }
  public int Pow(int a, int m)
  {
    switch (m)
    {
      case 0:
        return 1;
      case 1:
        return a;
      default:
        int p1 = Pow(a, m / 2);
        int p2 = Mul(p1, p1);
        return ((m % 2) == 0) ? p2 : Mul(p2, a);
    }
  }
  public int Div(int a, int b)
  {
    return Mul(a, Pow(b, M - 2));
  }
  public int Ncr(int n, int r)
  {
    if (n < r) { return 0; }
    if (n == r) { return 1; }
    int res = Fac(n);
    res = Div(res, Fac(r));
    res = Div(res, Fac(n - r));
    return res;
  }
}

class Scanner
{
  string[] s;
  int i;

  char[] cs = new char[] { ' ' };

  public Scanner()
  {
    s = new string[0];
    i = 0;
  }

  public string next()
  {
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }

  public int nextInt()
  {
    return int.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0)
  {
    int[] Array = new int[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextInt() + add;
    }
    return Array;
  }

  public long nextLong()
  {
    return long.Parse(next());
  }

  public long[] ArrayLong(int N, long add = 0)
  {
    long[] Array = new long[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextLong() + add;
    }
    return Array;
  }

  public double nextDouble()
  {
    return double.Parse(next());
  }


  public double[] ArrayDouble(int N, double add = 0)
  {
    double[] Array = new double[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}


Measured memory_bytes: 11092
#!/usr/bin/env python3
import sys, os
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): pass # if os.environ.get("USER")=="shun" else None
def exit(): sys.exit(0)


n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = a[-1]
m = 0
while True:
    if 2**m > max_a:
        break
    m += 1
used = [False] * n


def bisect(val, start, end):
    debug(used)
    if start >= end:
        return None
    elif start + 1 == end:
        if a[start] == val:
            if used[start]:
                return None
            used[start] = True
            return start
        else:
            return None
    mid = (start + end) // 2
    if a[mid] == val:
        if used[mid]:
            res = bisect(val, start, mid)
            return res
        else:
            res = bisect(val, mid+1, end)
            if res is not None:
                return res
            used[mid] = True
            return mid
        # if used[mid]:
        #     res = bisect(val, mid+1, end)
        #     if res is not None:
        #         return res
        #     res = bisect(val, start, mid)
        #     return res
        # else:
        #     used[mid] = True
        #     debug("fuga", used)
        #     return mid
    elif a[mid] > val:
        return bisect(val, start, mid)
    else:
        return bisect(val, mid, end)
    # for i in reversed(range(end)):
    #     if (not used[i]) and (a[i]  == val):
    #         used[i] = True
    #         return i
    return None


def _find(b, end, e):
    # debug(b, end, e)
    val = 2**e - b
    if val <= 0:
        return None
    return bisect(val, 0, end)
    # for i in reversed(range(end)):
    #     if (not used[i]) and (a[i] + b == 2**e):
    #         used[i] = True
    #         return i
    # return None


def find(b, end):
    for e in reversed(range(m+1)):
        res = _find(b, end, e)
        if res is not None:
            return True
    return False


ans = 0
for j in reversed(range(n)):
    if used[j]:
        continue
    b = a[j]
    used[j] = True
    res = find(b, j)
    if res:
        ans += 1


print(ans)


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

int main(){
int n=0;
  cin >>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++) cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  int cou=1;
  for(int i=0;i<(n-1);i++){
    if(vec.at(i)!=vec.at(i+1)){
      cou++;
    }
  }
  cout << cou<<endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j,k;
    ll n,ma,mb;
    cin >> n >> ma >> mb;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }
    
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(401,vector<ll>(401,5000)));

    dp[0][0][0] = 0;

    for(i = 0;i < n;++i){
        rep(j,401){
            rep(k,401){
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                if(j >= a.at(i) && k >= b.at(i)) dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j - a.at(i)][k - b.at(i)] + c.at(i));
            }
        }
    }
    ll ans = 1e14;
    for(i = 1;i <= 400;++i){
        if(i*ma > 400 || i*mb > 400) break;
        ans = min(ans, dp[n][i*ma][i*mb]);
    }
    if(ans == 5000) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 56556
class Task
	
	def initialize(name, qms)
		@name = name
		if !qms.is_a? Integer
			qms = qms.to_i
		end
		@qms = qms
	end

	def consume(time)
		@qms -= time
	end

	def to_s
		"#{@name}"
	end

end

n, consume_time = STDIN.gets.split.map(&:to_i)
queue = []
n.times do
	pname, ptime = STDIN.gets.split
	queue.push(Task.new(pname, ptime))
end

past_time = 0
until queue.empty?
	task = queue.shift
	remain = task.consume(consume_time)

	if remain > 0
		past_time += consume_time
		queue.push(task)
	else
		past_time += consume_time + remain # ここでremainはマイナスなので
		puts "#{task.to_s} #{past_time}"
	end
end

Measured memory_bytes: 13404
N,K=map(int, input().split())
R,S,P=map(int, input().split())
T=input()
score=0
hand = []
for i in range(len(T)):
  if T[i] == 'r':
    hand.append('p')
    if i >= K:
      if hand[i - K] == 'p':
        hand.pop()
        hand.append("z")
  elif T[i] == 's':
    hand.append('r')
    if i >= K:
      if hand[i - K] == 'r':
        hand.pop()
        hand.append("z")
  else:
    hand.append('s')
    if i >= K:
      if hand[i - K] == 's':
        hand.pop()
        hand.append("z")
for i in hand:
  if i == 'r':
    score+=R
  elif i == 's':
    score+=S
  elif i == 'p':
    score+=P
print(score)


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

int main()
{
    int h,n,sum=0,a;
    cin>>h>>n;
    for(int i=0;i<n;i++)
    {
     cin>>a;
     sum=sum+a;
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int main(){
    int a,b;
    cin >> a >> b;
    cout << a-b+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
#include<vector>

using namespace std ;
typedef long long ll;

// N K
// A_1, ..., A_N
int main(){
    int N ;
    cin >> N ;

    string S;
    cin >> S ;

    vector<int> W_count;

    int wt = 0 ;
    for(int i = 0; i != N; ++i)
    {
        if(S[i]=='W')
            ++wt ;
        W_count.push_back(wt) ;
    }

    vector<int> E_count;

    int et = 0 ;
    for(int i = 0; i != N; ++i)
    {
        if(S[N-i-1]=='E')
            ++et ;
        E_count.push_back(et) ;
    }

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

    vector<int> sum_count ;
    for(int i=0; i!=N; ++i)
    {
        sum_count.push_back(W_count[i]+E_count[i]) ;
    }

    auto m = min_element(sum_count.begin(), sum_count.end());

    std::cout << (*m - 1) << std::endl;
}

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

int main()
{
  int x, y;
  cin >> x >> y;
  
  if (x==2) {
    if (y==2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if (x==4 || x==6 || x==9 || x==11) {
    if (y==4 || y==6 || y==9 || y==11) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else {
	if (y!=2&&y!=4&&y!=6&&y!=9&&y!=11)
      cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n;
  scanf("%d",&n);
  if((int)n/100==9){
    n-=800;
  }else{
    n+=800;
  }
  if((int)n/10==19||(int)n/10==99){
    n-=80;
  }else{
    n+=80;
  }
  if(n%10==9){
    n-=8;
  }else{
    n+=8;
  }
  printf("%d",n);
  return 0;
}


Measured memory_bytes: 128
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")
MOD = 1000000007


def bellman_ford(edges, num_v, sv):
    #グラフの初期化
    dist = [INF] * num_v
    dist[sv] = 0
    
    #辺の緩和
    for i in range(num_v - 1):
        for edge in edges:
            s, t, d = edge[0], edge[1], edge[2]
            if dist[s] != INF and dist[t] > dist[s] + d:
                dist[t] = dist[s] + d
    
    return dist


def main():
    N, M = map(int, input().split())

    edges = []
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1; b -= 1; c *= -1
        edges.append([a, b, c])
    
    dist = bellman_ford(edges, N, 0)

    negative = [False]*N
    for _ in range(N):
        for edge in edges:
            s, t, d = edge[0], edge[1], edge[2]
            if dist[s] == INF:
                continue
            if dist[t] > dist[s] + d:
                dist[s] = dist[t] + d
                negative[t] = True
            if negative[s] == True:
                negative[t] = True

    if negative[N-1] == True:
        print("inf")
    else:
        print(-dist[N-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 67052
import sys
import math
from collections import Counter

k, n = [int(s) for s in sys.stdin.readline().strip().split()]
a = [int(s) for s in sys.stdin.readline().strip().split()]

longest = -1
prev = a[0]

for i in range(1, n):
    ai = a[i]
    dist = ai - prev
    longest = max(longest, dist)
    prev = ai

last_cand = k - a[-1] + a[0]
longest = max(longest, last_cand)

print(k - longest)


Measured memory_bytes: 72308
n, m = map(int, input().split())
l = []

for _ in range(m):
    l.append(list(map(int, input().split())))

l.sort(key=lambda x:x[1])

last = -1
ans = 0
for x in l:
    a, b = x
    if a < last:
        continue
    last = b
    ans += 1

print(ans)

Measured memory_bytes: 29072
#include<stdio.h>

int main(){
	int N,K,ans;
	scanf("%d %d",&N,&K);
	
	int a[N];
	for(int i=0;i<N;i++)scanf("%d",&a[i]);
	
	ans=(N+K-3)/(K-1);
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 512
def dfs(d:int, v:int, all:list):
    if d==11:
        return
    all.append(v)
    if list(str(v))[-1]=="0":
        dfs(d+1,10*v+int(list(str(v))[-1])+1,all)
        dfs(d+1,10*v+int(list(str(v))[-1]),all)
    elif list(str(v))[-1]=="9":
        dfs(d+1,10*v+int(list(str(v))[-1])-1,all)
        dfs(d+1,10*v+int(list(str(v))[-1]),all)
    else:
        dfs(d+1,10*v+int(list(str(v))[-1])+1,all)
        dfs(d+1,10*v+int(list(str(v))[-1]),all)
        dfs(d+1,10*v+int(list(str(v))[-1])-1,all)
k=int(input())
all=[]
for i in range(1,10):
    dfs(1,i,all)
all.sort()
print(all[k-1])
    

Measured memory_bytes: 18628
#include <vector>
#include <iostream>
#include<algorithm> 
#define MAX 1e5

using namespace std;
 
int main() {
    int N;
    cin >> N;
 
    int a;
    vector<int> cnt(MAX + 1);
    for (int i = 0; i < N; i++) {
        cin >> a;
        cnt[a]++;
    }
    
    int ans = 0;
    int total;
 
    for (int i = 1; i < MAX; i++) {
        ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
import sys

N = int(input())
a = list(map(int, input().split()))

from collections import Counter
ac = Counter(a)

if len(ac) == 3 and len(Counter(ac.values())) == 1 and ac.most_common()[0][0]^ac.most_common()[1][0] == ac.most_common()[2][0]:
    print('Yes')
    sys.exit()
if len(ac) == 2 and ac.most_common()[0][1] == ac.most_common()[1][1] * 2 and ac.most_common()[0][0]^ac.most_common()[0][0] == ac.most_common()[1][0]:
    print('Yes')
    sys.exit()
if len(ac) == 1 and ac.most_common()[0][0] == 0:
    print('Yes')
    sys.exit()
print('No')

Measured memory_bytes: 14708
#include <stdio.h>
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
void init(int n[6]){
	int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void throwdice(char c){
	int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}
int main()
{
    int q;
    int n[6];
    int i,j;
    for(i=0;i<6;i++){
       	scanf("%d",&n[i]);
    }
    init(n);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        int ok = 0;
        int up, front;
        scanf("%d %d",&up,&front);
        for(j=0;j<4;j++){
            throwdice('S');
            if(dice1.d[0]==up){
                ok = 1;
                break;
            }
        }
        if(!ok){
            while(1){
                throwdice('W');
                if(dice1.d[0] == up){
                    break;
                }
            }
        }
 
        for (j=0;j<4;j++){
            throwdice('R');
            if (dice1.d[1]==front){
                break;
            }
        }
        printf("%d\n",dice1.d[2]);
    }
 
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fbo find_by_order
#define ook order_of_key
#define INF (ll)1e18
#define PI (ld)3.14159265358979323846
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    ll cnt=0;
    for(int i=1;i<=n;i++){
        if(arr[i]!=i){
            swap(arr[i],arr[arr[i]]);cnt++;
        }
    }
    if(cnt<=1)cout<<"YES\n";
    else cout<<"NO\n";
}


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

int main() {
  int N;
  cin>>N;
  vector<tuple<string,int,int>>a;

  for (int i = 0; i < N; i++) {
    string A;
    int B;
    cin >> A>>B;
    B*=-1;
    int C=i+1;
    a.push_back(tuple<string,int,int>(A,B,C));
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    string aa;
    int b;
    int c;
    tie(aa, b, c) = a.at(i);
    cout<<c<<endl;
  }
}




Measured memory_bytes: 256
//ritik_patel05

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

// #define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
// #pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#include <bits/stdc++.h>
using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
//find_by_order()->returns an iterator to the k-th largest element(0-based indexing)
//order_of_key()->Number of items that are strictly smaller than our item

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
// const ld PI  = 3.141592;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&

void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(auto &x: a){
        cin >> x;
    }
    int ans = 0;
    sort(all(a));
    for(int i = 0; i < k; ++i)
        ans += a[i];
    cout << ans << '\n';

}


int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    // cin >> T;
    for(int i = 1; i <= T; ++i){
        // brute();
        solve();
    }
    return 0;
}

/*
Sample inp
*/

Measured memory_bytes: 3668
l=[]
n=int(input())
for i in range(n):
  l.append(input())
print("AC"+" "+ "x"+" "+ str(l.count('AC')))
print("WA"+" "+ "x"+" " +str(l.count('WA')))
print("TLE"+" "+ "x"+" " +str(l.count('TLE')))
print("RE"+" "+ "x"+" " +str(l.count('RE')))

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

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

	ll n, m;
	cin >> n >> m;

	if(n == 1 and m != 1){
		cout << m-2 << endl;
	} else if(n != 1 and m == 1){
		cout << n-2 << endl;
	} else if(n == 1 and m == 1){
		cout << 1 << endl;
	} else {
		cout << (n-2)*(m-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	int ans = 0;
	for (int i = 1; i < 3; i++) {
		ans += a[i] - a[i - 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <deque>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

vector<int> G[MAX+1];
int main(){
	int N,M;
	cin>>N>>M;
	rep1(j,M){
		int s,t;
		cin>>s>>t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	int n[MAX];
	rep1(i,N) n[i]=(int)G[i].size();
	
	bool v[MAX];
	rep1(i,N)v[i]=false;
	
	deque<int> deq;
	deq.push_front(1);
	v[1]=true;
	
	bool flag=true;
	while(flag){
		int u=deq.front();
		flag=false;
		rep(k,n[u]){
			if(!v[G[u][k]]){
				deq.push_front(G[u][k]);
				v[G[u][k]]=true;
				flag=true;
				k=n[u];
			}
		}
	}
	
	flag=true;
	while(flag){
		int u=deq.back();
		flag=false;
		rep(k,n[u]){
			if(!v[G[u][k]]){
				deq.push_back(G[u][k]);
				v[G[u][k]]=true;
				flag=true;
				k=n[u];
			}
		}
	}
	int sz=(int)deq.size();
	cout<<sz<<endl;
	
	while(!deq.empty()){
		cout<<deq.front()<<" ";
		deq.pop_front();
	}
}

Measured memory_bytes: 7168
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,n) for(int i=1;i<=n;i++)
int main()
{
    string x;

while(1){
    cin >> x;

    int ans=0;
    int num;
    int l = x.length();

    if(l==1 && x[0] == '0') break;

    rep(i,l){
        num = x[i]-'0';
        ans += num;
    }

    cout << ans << endl;

}
    return 0;


}


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

using namespace std;
using LL = long long;

int main(){
    int n,m;
    while(cin >> n >> m){
        if(n == 0 && m == 0)continue;
        vector<int> vec;
        for(int i = 0;i < n;i++){
            int b;cin >> b;
            vec.push_back(b);
        }
        int ans = -1;
        for(int i = 0;i < n-1;i++){
            for(int j = i + 1; j < n;j++){
                if(vec.at(i) + vec.at(j) <= m)ans = max(ans, vec.at(i) + vec.at(j));
            }
        }
        if(ans == -1){
            cout<<"NONE"<<endl;
            continue;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3028