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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N,M; cin >> N >> M;
    cout << ((N+M)*(N+M-1))/2 - (N*M) << endl;

    return 0;
}


Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<random>
#include<deque>
#include<cstdio>
#include<fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2000100;
const int mod = (int)pow(10, 9) + 7;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define ppp pair<pp,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
#define print(s) cout<<s<<endl
#define inp(s) cin>>s
string yn(bool b) { return (b ? "Yes" : "No"); }
string YN(bool b) { return (b ? "YES" : "NO"); }
ll n, k;
int main() {
	cin >> n >> k;
	cout << (n%k == 0 ? 0 : 1) << endl;
	return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll h;
  cin >> h;
  
  ll ans = 0, enemy = 1;
  while(h > 0){
    if(h == 1){
      ans += enemy;
      h = 0;
    }
    else{
      ans += enemy;
      enemy *= 2;
      h /= 2;
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int i, n, m, b[9];
	for (i = 0; i < 9; i++) {
		b[i] = 5;
		if (i > 0) {
			b[i] *= b[i - 1];
		}
	}
	while (1) {
		scanf(" %d ", &n);
		if (!n) {
			break;
		}
		for (m = i = 0; i < 9; i++) {
			m += n / b[i];
		}
		printf("%d\n", m);
	}
	return 0;
}

Measured memory_bytes: 604
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, E, C;
	List<E> all;
	List<E>[] es;
	void Solve()
	{
		var I = G();
		V = I[0];
		E = I[1];
		all = new List<E>();
		es = new List<E>[V];
		for (var i = 0; i < V; i++) es[i] = new List<E>();
		for (var i = 0; i < E; i++)
		{
			I = G();
			AddEdge(I[0] - 1, I[1] - 1, I[2]);
		}
		var d = new int[V, V];
		for (var i = 0; i < V; i++)
		{
			var e = DijkstraFrom(i);
			for (var j = 0; j < V; j++) d[i, j] = e[j];
		}
		var c = E;
		foreach (var e in all)
		{
			var flag = false;
			for (var i = 0; i < V; i++)
				if (d[i, e.From] + e.Cost == d[i, e.To])
				{
					flag = true;
					break;
				}
			if (flag) c--;
		}
		WriteLine(c);
	}
	void AddEdge(int f, int t, int c)
	{
		var e = new E(f, t, c);
		es[f].Add(e);
		es[t].Add(new E(t, f, c));
		all.Add(e);
		C = Max(C, c);
	}
	int[] DijkstraFrom(int from)
	{
		var d = Enumerable.Repeat(MOD, V).ToArray();
		var queue = new DialQueue(C);
		d[from] = 0;
		queue.Add(from, 0);
		while (queue.Any)
		{
			var p = queue.Pop();
			var v = p.To;
			if (d[v] < p.Cost) continue;
			foreach (var e in es[v])
			{
				var tmp = d[v] + e.Cost;
				if (d[e.To] > tmp)
				{
					if (d[e.To] != MOD) queue.Move(e.To, d[e.To], tmp);
					else queue.Add(e.To, tmp);
					d[e.To] = tmp;
				}
			}
		}
		return d;
	}
}
struct E
{
	public int From, To, Cost;
	public E(int f, int t, int c)
	{
		From = f;
		To = t;
		Cost = c;
	}
	public override string ToString()
	{
		return string.Format("From = {0}, To = {1}, Cost = {2}", From, To, Cost);
	}
}
class DialQueue
{
	public int Count { get; private set; }
	int C, offset;
	HashSet<int>[] buckets;
	HashSet<int> this[int n] { get { return buckets[(n - offset + offset % C) % C]; } }
	public DialQueue(int c)
	{
		C = c + 1;
		buckets = new HashSet<int>[C];
		for (var i = 0; i < C; i++) buckets[i] = new HashSet<int>();
	}
	public void Add(int v, int d)
	{
		Count++;
		this[d].Add(v);
	}
	public void Move(int v, int prev, int now)
	{
		this[prev].Remove(v);
		this[now].Add(v);
	}
	public bool Any { get { return Count > 0; } }
	public E Pop()
	{
		Count--;
		var t = offset;
		while (true)
		{
			var s = this[t];
			if (s.Count > 0)
			{
				var v = s.First();
				s.Remove(v);
				offset = t;
				return new E(-1, v, t);
			}
			t++;
		}
	}
	public override string ToString()
	{
		return string.Format("C = {0}, Offset = {1}, count = {2}", C, offset, Count);
	}
}


Measured memory_bytes: 24812
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    double r;
    cin >> r;
    cout << 2.0 * r * 3.1415926535 << endl;
}

Measured memory_bytes: 3804
$n=<>;$_=<>;chomp;@s=split //,$_;
@W=(0);@E=(0);$i=0;
for(@s){
    $f=("W"eq$_)?1:0;
    push(@W,$W[$i]+$f);
    push(@E,$E[$i]+1-$f);
    $i++;
}
$m=$n;$r=$E[$#E];
for(1..$n){
    $c=$W[$_-1]+$r-$E[$_];
    $m=$c<$m?$c:$m;
}
print$m

Measured memory_bytes: 52808
#include <stdio.h>
#include <algorithm>
using namespace std;

int n;
long long l;
long long t;
long long a[100002];
long long w[100002];
long long p[100002];
int np;
long long q[100002];
int nq;
long long tmpnum;
long long zero;

int i;
int num;
long long pos;
long long first_ant;
long long tmpnum2;

int main(){
	scanf("%d%lld%lld",&n,&l,&t);
	for(i=0;i<n;i++){
		scanf("%lld%d",&a[i],&w[i]);
		if(w[i]==1){
			p[np++] = a[i];
			if(np==1){
				tmpnum = i;
				tmpnum2 = nq;
				
			}
		}
		else{
			q[nq++] = a[i];
		}
		
	}
	if(np>0){
		num=tmpnum+((2*t)/l)*nq;
		num%=n;
		pos=(p[0]+2*t)%l;
		zero=t%l;
	
		//find num
		bool tick = 0;
		if(nq>0){
			for(i=0;i<nq;i++){
				if(pos<=q[i]){
					if(i>=tmpnum2){
						num+=i-tmpnum2+n;
						num%=n;
					}
					else{
						num+=nq+i-tmpnum2+n;
						num%=n;
					}
					tick = 1;
					break;
				}
			}
			if(!tick){
				num+=nq-tmpnum2+n;
				num%=n;
			}
		}
		
		pos = (p[0]+t)%l;
		for(i=0;i<n;i++){
			if(w[i]==1) a[i] = (a[i]+2*t)%l;
			a[i] = (a[i]-zero+l)%l;
		}
		sort(a,a+n);
		for(i=0;i<n;i++){
			if(pos==a[i]){
				first_ant = (i-num+n)%n;
				break;
			}
		}
		for(i=first_ant;i<n;i++){
			printf("%lld\n",a[i]);
		}
		for(i=0;i<first_ant;i++) printf("%lld\n",a[i]);
	}
	else{
		for(i=0;i<n;i++){
			printf("%lld\n",(((a[i]-t)%l)+l)%l);
		}
	}

	
	return 0;
}

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





int main() {
  int64_t x;
  cin>>x;
  
  int64_t a,b;
  
  a=x/11;
  b=x%11;
  
  int64_t answer;
  
  if (b==0){
    answer=2*a;
  }
  
  else if (1<=b and b<=6){
    answer=2*a+1;
  }
  
  else {
    answer=2*a+2;
  }
  
  cout<<answer<<endl;
  
  
  
}












Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n, m;
i64 a[50], b[50], c[50], d[50];

i32 main()
{
    cin >> n >> m;
    times(n, i) {
        cin >> a[i] >> b[i];
    }
    times(m, i) {
        cin >> c[i] >> d[i];
    }
    times(n, i) {
        i32 len = INT_MAX, ans = INT_MAX;
        times(m, j) {
            i32 dd = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if (dd < len) {
                ans = j+1;
                len = dd;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();

	vector<int> V;
	int M = sqrt(A[0]);
	for (int i = M; i >= 1; i--) {
		if (A[0] % i == 0) {
			V.pb(i);
			V.pb(A[0] / i);
		}
	}
	M = sqrt(A[1]);
	for (int i = M; i >= 1; i--) {
		if (A[1] % i == 0) {
			V.pb(i);
			V.pb(A[1] / i);
		}
	}
	sort(V.begin(), V.end());
	for (auto itr = V.rbegin(); itr != V.rend(); itr++) {
		int k = 0;
		rep(i, N) {
			if (A[i] % (*itr)) k++;
			if (k > 1) break;
		}
		if (k <= 1) {
			printf("%d", *itr);
			break;
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 768
N = input()
K = int(input())

dp = [[[0] * 5 for _ in range(2)] for _ in range(len(N) + 1)]
dp[0][0][0] = 1

for i in range(len(N)):
    D = int(N[i])
    for j in range(2):
        for k in range(5):
            dMax = 9 if j else D
            for d in range(dMax + 1):
                dp[i + 1][j | (d < D)][min(4, k + (d != 0))] += dp[i][j][k]

ans1 = dp[len(N)][0][K]
ans2 = dp[len(N)][1][K]

print(ans1 + ans2)


Measured memory_bytes: 41840
#include<stdio.h>
#include<stdlib.h>
#define max(a,b) ((a)>(b)?(a):(b))

int compare_int(const void *a,const void *b){
	long long A=*(long long*)a-*(long long*)b;
	if(A>0)return 1;
	if(A<0)return -1;
	return 0;
}

long long gcd(long long a,long long b){
	if(a%b==0)return b;
	return gcd(b,a%b);
}

int main(){
	int n,i;
	long long a[100000];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lld",&a[i]);
	if(n==2){
		printf("%lld\n",(a[0]>a[1]?a[0]:a[1]));
		return 0;
	}
	if(n==3){
		long long ab=gcd(a[0],a[1]);
		long long ac=gcd(a[2],a[1]);
		long long ad=gcd(a[2],a[0]);
		printf("%lld\n",max(ab,max(ac,ad)));
		return 0;
	}
	qsort(a,n,sizeof(long long),compare_int);
	long long aa=a[0],at,f=0,ans=1,ff,g;
//	while(f==0){
		aa=a[0];g=a[0];
		for(i=1;i<n;i++){
			g=gcd(g,a[i]);
			if(gcd(aa,a[i])==1){
				at=a[i];
				f=1;
				ff=i;
				break;
			}
		}
		if(f==0){
		ans*=g;
		for(i=0;i<n;i++)a[i]/=g;
		aa=a[0];g=a[0];
		for(i=1;i<n;i++){
			g=gcd(g,a[i]);
			if(gcd(aa,a[i])==1){
				at=a[i];
				f=1;
				ff=i;
				break;
			}
		}
		}
//	}
	for(i=0;i<n;i++){
		if(ff!=i)aa=gcd(aa,a[i]);
	}
	for(i=1;i<n;i++)at=gcd(a[i],at);
	printf("%lld\n",max(aa,at)*ans);
	return 0;
}

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

using namespace std;

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

    while(1){
      int a[5];
      int b[3]={};
      int i;
      cin >> a[0];
      if(a[0]==0)
	break;

      for(i=1;i<5;i++){
	cin >> a[i];
      }

      for(i=0;i<5;i++)
	b[a[i]-1]++;


      if((b[0]*b[1]*b[2]!=0) || (b[0]==0 && b[1]==0) || (b[1]==0 && b[2]==0) || (b[2]==0 && b[0]==0)){
	for(i=0;i<5;i++)
	  cout << 3 << endl;
      }
      
      else{
	//??°??????0
	if(b[0]==0){
	  for(i=0;i<5;i++){
	    if(a[i]==2)
	      cout << 1 << endl;
	    if(a[i]==3)
	      cout << 2 << endl;
	  }
	}

	//?????§??????0
	if(b[1]==0){
	  for(i=0;i<5;i++){
	    if(a[i]==3)
	      cout << 1 << endl;
	    if(a[i]==1)
	      cout << 2 << endl;
	  }
	}

	//?????????0
	if(b[2]==0){
	  for(i=0;i<5;i++){
	    if(a[i]==1)
	      cout << 1 << endl;
	    if(a[i]==2)
	      cout << 2 << endl;
	  }
	}
      }
    }
    return 0;
}

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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int MAXN = 305;

int n, m, d;
int a[MAXN][MAXN];
pair<int, int> pos[MAXN * MAXN + 123];
long long sum[MAXN * MAXN + 123];

int main() {

    scanf("%d %d %d", &n, &m, &d);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
            pos[a[i][j]] = {i, j};
        }
    }

    for (int i = 1; i <= n * m; i++) {
        if (i - d >= 1) {
            sum[i] = sum[i - d];
            sum[i] += abs(pos[i].first - pos[i - d].first) + abs(pos[i].second - pos[i - d].second);
        }
    }

    int q;
    scanf("%d", &q);

    while (q--) {
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%lld\n", sum[r] - sum[l]);
    }

    return 0;
}


Measured memory_bytes: 2944
# https://atcoder.jp/contests/arc080/tasks/arc080_b

h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))

hw=[]
for i in range(n):
    hw+=([str(i+1)]*a[i])

flag = False
for i in range(h):
    bgn=i*w
    end=bgn+w
    res = hw[bgn:end]
    if flag:
        res=res[::-1]
        flag = False
    else:
        flag = True
    print(*res)

Measured memory_bytes: 4084
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val S = ns()
    val K = "keyence"
    val ok = S.contains(K) || {
      1 to 6 exists { l =>
        val r = K.length - l
        S.take(l) == K.take(l) && S.takeRight(r) == K.takeRight(r)
      }
    }

    if (ok) out.println("YES")
    else out.println("NO")
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 27324
<?php
list($n) = ints();
for ($i = 1; $i <= 5; ++$i)
    if ($n === 10 ** $i) exit('10');
echo digitSum($n);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function digitSum($n)
{
    return array_sum(array_map('intval', str_split((string) $n)));
}


Measured memory_bytes: 15772
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

lli gcd(lli x, lli y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    lli A, B, C, D;
    cin >> A >> B >> C >> D;

    lli CD_gcd = gcd(C, D);
    lli CD_lcd = C * D / CD_gcd;

    lli B_waru_C = B / C;
    lli B_waru_D = B / D;
    lli B_waru_LCD = B / CD_lcd;
    lli B_kosu = B - B_waru_C - B_waru_D + B_waru_LCD;

    A = A - 1;
    lli A_waru_C = A / C;
    lli A_waru_D = A / D;
    lli A_waru_LCD = A / CD_lcd;
    lli A_kosu = A - A_waru_C - A_waru_D + A_waru_LCD;

    cout << B_kosu - A_kosu << endl;
    return 0;
}

Measured memory_bytes: 256
const main = input => {
  const inputs = input.trim().split('\n')
  const N = parseInt(inputs[0])
  const takoyakis = inputs[1].split(' ').map(x => parseInt(x))

  let sum = 0
  for (let i = 0; i < N - 1; i++) {
    for (let j = i + 1; j < N; j++) {
      sum += takoyakis[i] * takoyakis[j]
    }
  }

  console.log(sum)
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30428
use input::Input;

fn main() {
    let mut input = Input::default();

    let k: usize = input.parse();
    let s: String = input.parse();

    if s.len() <= k {
        println!("{}", s);
    } else {
        println!("{}...", &s[..k]);
    }
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


Measured memory_bytes: 2140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		int l = a.length();
		int cnt = 0;
		for(int i = 0; i < l; i++){
			char c = a.charAt(i);
			if(c=='g'){
				cnt++;
			}else{
				cnt--;
			}
		}
		cnt = cnt/2;
		sb.append(cnt);
		System.out.print(sb);
	}
}

Measured memory_bytes: 10836
# abc171_c.py
import math
N = int(input())
ans=[]
while N > 0:
    ans.append(N%26)
    N = math.floor((N-1)/26)
alphabet = 'abcdefghijklmnopqrstuvwxyz'
ans = reversed(ans)
for i in ans:
    print(alphabet[i-1],end="")


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef DEBUG
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
  int a,b,v,w,t;cin>>a>>v>>b>>w>>t;
  if(v<w){
    cout<<"NO\n";return 0;
  }
  if(abs(a-b)<=1ll*t*abs(v-w)){
    cout<<"YES\n";
  }else{
    cout<<"NO\n";
  }
  
  return 0;
}
//2020.06.13 20:02:56


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=105;

int L,n,m,bin[N],a[N];
struct data{int x,y,w;}ans[N];

void add(int x,int y,int w)
{
	m++;
	ans[m].x=x;ans[m].y=y;ans[m].w=w;
}

int main()
{
	scanf("%d",&L);
	n=20;
	bin[0]=1;
	for (int i=1;i<=20;i++) bin[i]=bin[i-1]*2;
	for (int i=n-1;i>=2;i--) add(i,i+1,bin[n-i-1]),add(i,i+1,0);
	int top=0,sum=0;
	while (L>=262144) add(1,2,sum),sum+=262144,L-=262144;
	while (L) a[++top]=L%2,L/=2;
	for (int i=top;i>=1;i--)
	{
		if (!a[i]) continue;
		add(1,n-i+1,sum);
		sum+=bin[i-1];
	}
	printf("%d %d\n",n,m);
	for (int i=1;i<=m;i++) printf("%d %d %d\n",ans[i].x,ans[i].y,ans[i].w);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int len = s.length;

			for (char c = 'a'; c <= 'z'; c++) {
				for (int i = 0; i < len; i++) {
					if (i + 1 < len && s[i] == c && s[i + 1] == c) {
						out.println((i + 1) + " " + (i + 2));
						return;
					} else if (i + 2 < len && s[i] == c && s[i + 2] == c) {
						out.println((i + 1) + " " + (i + 3));
						return;
					}
				}
			}

			out.println("-1 -1");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23252
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

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

    if (s == "abc") {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int T = sc.nextInt();
        int[] a = new int[T];
        for(int i = 0; i < T; i++)
            a[i] = sc.nextInt();
        sc.close();

        Arrays.sort(a);
        int max = a[T-1];
        if(max <= K-max+1){
            System.out.println(0);
        } else {
            System.out.println(2*max - K - 1);
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    ll k = (c - a - b);
    bool ans = k * k > 4LL * a * b;
    if (k < 0)
    {
        ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,a[100],i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=n-1;i>0;i--)
    printf("%d ",a[i]);
  printf("%d\n",a[0]);
  return 0;
}


Measured memory_bytes: 2052
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n,x,m; cin>>n>>x>>m;
    vector<vector<ll>>amari(m,vector<ll>(2,-1));
    amari[x][0]=x;
    amari[x][1]=0;
    ll ans=x;
    ll cnt=0;
    bool B=false;
    for(ll i=1;i<n;i++){
         x=x*x%m;
        if(amari[x][0]!=-1){
            ans+=x;
            ll len=i-amari[x][1];
            ll sum=ans-amari[x][0];
            ll remain=n-(i+1);
            //cout<<i<<endl;
            ll howmanytime=remain/len;
           
            i+=howmanytime*len;
            cnt=i;
            //cout<<ans<<endl;
            //cout<<len<<endl;
            //cout<<sum<<endl;
            //cout<<remain<<endl;
            
            //return 0;

            ans+=howmanytime*sum;
            B=true;
            break;
        }
        else{
            ans+=x;
            amari[x][0]=ans;
            amari[x][1]=i;
        }
    }
   if(B){ for(ll i=cnt+1;i<n;i++){
               x=x*x%m;
                    ans+=x;
    }
   }
    cout<<ans<<endl;
}











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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll K;
ll A[101010];
ll num[42];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>A[i];
		FOR(j,41) if(A[i]&(1LL<<j)) num[j]++;
	}
	
	ll ma=-1;
	ll ret=0;
	FOR(i,41) ret+=num[i]*(1LL<<i);
	ma=ret;
	
	ret=0;
	FOR(j,41) {
		int a=(K>>j)&1;
		if(a) ret+=(N-num[j])*(1LL<<j);
		else ret+=num[j]*(1LL<<j);
	}
	ma=max(ma,ret);
	
	FOR(i,41) if(K&(1LL<<i)) {
		ll ret=0;
		FOR(j,41) {
			if(j>i) {
				int a=(K>>j)&1;
				if(a) ret+=(N-num[j])*(1LL<<j);
				else ret+=num[j]*(1LL<<j);
			}
			if(j==i) {
				ret+=num[j]*(1LL<<j);
			}
			if(j<i) {
				ret+=max(N-num[j],num[j])*1LL<<j;
			}
		}
		ma=max(ma,ret);
	}
	
	
	cout<<ma<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
P = list(map(int, input().split()))

left = 0
right = k - 1
maxi = sum(P[left: right + 1])
now = maxi
for i in range(n - k):
    if now - P[i] + P[i + k] > maxi:
        left = i + 1
        right = i + k
        maxi = now - P[i] + P[i + k]
    now = now - P[i] + P[i + k]

kitai = []
for i in range(1001):
    if i == 0:
        kitai.append(0)
    else:
        kitai.append((1 + i)/ 2)

ans = 0
for p in P[left: right + 1]:
    ans += kitai[p]
print(ans)

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

int main()
{
	long n;
    cin>>n;
    if(n%1000 == 0)
        cout<<0<<endl;
    else
    {
        long x=(n/1000);
        ++x;
        cout<<(x*1000)-n<<endl;
    }
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	//static int[] d=new int[4];

	static int line(int x, int el) {
		int[] d=new int[el+1];
		int max=0, min=0;
		for(int i=0; i<el; i++) {
			d[i]=x%10; //ｘのi桁目がd[i]に格納
			x=x/10;
		}
		for(int i=0; i<el; i++) {
			for(int j=i+1; j<el; j++) {
				if(d[i]>d[j]) {
					int tmp=d[i];
					d[i]=d[j];
					d[j]=tmp;
				}
			}
		}//昇順にソート
		for(int i=0; i<el; i++) {
			max+=d[el-1-i];
			max*=10;
			min+=d[i];
			min*=10;
		}
		return max/10-min/10;
		
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int[] a=new int[22];
				a[0]=sc.nextInt();
				int L=sc.nextInt();
				if(a[0]==0 && L==0) {
					break;
				}
				int[] d=new int[10];
				int check=0, ai=0, aj=0;
				for(int i=1; i<=20; i++) {
					a[i]=line(a[i-1], L);
					for(int j=0; j<i; j++) {
						if(a[j]==a[i]) {
							ai=i;
							aj=j;
							check=1;
							break;
						}
					}
					if(check==1) {
						break;
					}
				}
				//System.out.printf("%d %d %d\n",a[0], d[0], a[3]);
				System.out.printf("%d %d %d\n", aj, a[ai], ai-aj);
			}
		}
	}
}


Measured memory_bytes: 26824
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder sb=new StringBuilder();
			while (true) {
				String[] cut = br.readLine().split(" ");
				int H = Integer.parseInt(cut[0]);
				int W = Integer.parseInt(cut[1]);
				if (H == 0 && W == 0)
					break;
				for (int j = 0; j < H; j++) {
					for (int i = 0; i < W; i++) {
						sb.append("#");
					}
					sb.append("\n");
				}
				sb.append("\n");
			}
		System.out.print(sb);

	}

}

Measured memory_bytes: 25576
S = input()
a = 0
b = 0
c = 0
for s in S:
    if s=='a':
        a += 1
    elif s=='b':
        b += 1
    else:
        c += 1
if max(a,b,c)-min(a,b,c)<=1:
    print('YES')
else:
    print('NO')

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

int dy[] = {0, 0, 1, 1};
int dx[] = {0, 1, 0, 1};
int H, W;
char mas[1005][1005];
char data[4];
char ch[] = "JOI";
int calc(int y, int x)
{
    int cnt = 0;
    for(int i = 0; i < 4; i++) {
        int sy = y - 1 + dy[i], sx = x - 1 + dx[i];
        bool flag = true;
        if(sy < 0 || sx < 0 || sy >= H - 1 || sx >= W - 1) continue;
        for(int j = 0; j < 4; j++) {
            if(data[j] != mas[sy + dy[j]][sx + dx[j]]) flag = false;
        }
        if(flag) cnt++;
    }
    return (cnt);
}
int main()
{
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> mas[i][j];
        }
    }
    for(int i = 0; i < 4; i++) cin >> data[i];
    int old = 0;
    for(int i = 0; i < H - 1; i++) {
        for(int j = 0; j < W - 1; j++) {
            bool flag = true;
            for(int k = 0; k < 4; k++) {
                if(data[k] != mas[i + dy[k]][j + dx[k]]) flag = false;
            }
            if(flag) old++;
        }
    }
    int plus = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            for(int k = 0; k < 3; k++) {
                char temp = mas[i][j];
                int a, b;
                a = calc(i, j);
                mas[i][j] = ch[k];
                b = calc(i, j);
                mas[i][j] = temp; 
                plus = max(plus, b - a);
            }
        }
    }
    cout << old + plus << endl;
    return (0);
}


Measured memory_bytes: 4080
/**
 *    author:  math2do
 *    created: 05.04.2020 14:01:49
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;
  return 0;
}


Measured memory_bytes: 256
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const S = input[0]
  const T = input[1]
  const p = {}
  const r = {}

  for (let i = 0; i < S.length; i++) {
    const s = S[i]
    const t = T[i]
    if (!(s in p)) p[s] = t
    if (!(t in r)) r[t] = s
    if (p[s] !== t || r[t] !== s) {
      return console.log('No')
    }
  }
  console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
def printing(x, y):
    for w_ in range(w):
        if (w_ + 1) % 2 == 1:
            print(x, end = "")
        else:
            print(y, end = "")
    print()

while True:
    h, w = map(int, input().split())
    if h == 0:
        break
    for h_ in range(h):
        if (h_ + 1) % 2 == 1:
            printing('#', '.')
        else:
            printing('.','#')
    print()


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

int main(){
    int N;
    cin >> N;
    int a = 0, ba = 0, b = 0, ans = 0;
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        for(int j=0; j<s.size()-1; j++){
            if(s.substr(j, 2) == "AB") ans++;
        }
        bool A = s.back() == 'A';
        bool B = s[0] == 'B';
        if(A && B){
            ba++;
        }else if(A){
            a++;
        }else if(B){
            b++;
        }
    }

    if(ba > 0){
        ans += ba-1;
        if(a > 0){
            ans++;
            a--;
        }
        if(b > 0){
            ans++;
            b--;
        }
    }
    ans += min(a, b);
    cout << ans << endl;
    return 0;
}


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

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

    if (x >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a;
    int sum (0);
    for(int i = 1 ; i <= n ; i++){
        cin >> a;
        sum +=  a - 1;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;
int n,k;
long long s[20];
long long t[20];
long long sum;
void dfs(int x,int y,long long z)
{
	if(y==k)
	{
		if(sum>z)
		sum=z;
		return;
	}
	for(int i=x+1;i<n;i++)
	{
		int res=0;
		for(int j=0;j<=x;j++)
		{
			if(t[j]>res)
			res=t[j];
		}
		if(t[i]>res)
		dfs(i,y+1,z);
		else 
		{
			int c=t[i];
			t[i]=res+1;
		    dfs(i,y+1,z+res+1-c);
		    t[i]=s[i];
	    }
	}
}
int main(){
	while(scanf("%d%d",&n,&k)==2)
	{
		sum=20000000000;
		for(int i=0;i<n;i++)
		{
			scanf("%lld",&s[i]);
			t[i]=s[i];
		}
		for(int i=0;i<n;i++)
		dfs(i,1,0); 
		printf("%lld\n",sum);
	}
} 

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

int main() {
  int n;
  int a[9][9];
  bool b[9][9];
  int c[10];
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    for (int j=0; j<9; j++) {
      for (int k=0; k<9; k++) {
        scanf("%d", &a[j][k]);
      }
    }
    for (int j=0; j<9; j++) {
      for (int k=0; k<9; k++) {
        b[j][k] = false;
      }
    }
    for (int j=0; j<9; j++) {
      for (int k=1; k<=9; k++) c[k] = 0;
      for (int k=0; k<9; k++) {
        ++c[a[j][k]];
      }
      for (int k=0; k<9; k++) {
        if (c[a[j][k]]>1) b[j][k] = true;
      }
    }
    for (int j=0; j<9; j++) {
      for (int k=1; k<=9; k++) c[k] = 0;
      for (int k=0; k<9; k++) {
        ++c[a[k][j]];
      }
      for (int k=0; k<9; k++) {
        if (c[a[k][j]]>1) b[k][j] = true;
      }
    }
    for (int j=0; j<3; j++) {
      for (int jj=0; jj<3; jj++) {
        for (int k=1; k<=9; k++) c[k] = 0;
        for (int k=0; k<3; k++) {
          for (int kk=0; kk<3; kk++) {
            int p = 3*j+k;
            int q = 3*jj+kk;
            ++c[a[p][q]];
          }
        }
        for (int k=0; k<3; k++) {
          for (int kk=0; kk<3; kk++) {
            int p = 3*j+k;
            int q = 3*jj+kk;
            if (c[a[p][q]]>1) b[p][q] = true;
          }
        }
      }
    }

    if (i) {
      printf("\n");
    }
    for (int j=0; j<9; j++) {
      for (int k=0; k<9; k++) {
        if (b[j][k]) {
          putchar('*');
        } else {
          putchar(' ');
        }
        printf("%d", a[j][k]);
      }
      putchar('\n');
    }
  }

  return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
	int n,a[55];
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int ans=0,f=1;
	for(int i=1;i<=n;i++){
		if(a[i]!=i) ans++;
		if(ans>2) f=0;
	}
	if(f) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
mod = 10**9 + 7


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

cumsum = A[:]
for i in range(N - 1)[::-1]:
    cumsum[i] += cumsum[i + 1]
    cumsum[i] %= mod

ans = 0
for i in range(N - 1):
    ans += A[i] * cumsum[i + 1]
    ans %= mod

print(ans)


Measured memory_bytes: 31472
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 50 + 10;

ll a[N];

int main() {
	int n;
	cin >> n;
	int min_p = 1, max_p = 1;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (a[i] > a[max_p]) {
			max_p = i;
		}

		if (a[i] < a[min_p]) {
			min_p = i;
		}
	}

	vector <pii> moves;
	if (a[max_p] + a[min_p] >= 0) {
		for (int i = 1; i <= n; ++i) {
			if (a[i] < 0) {
				a[i] += a[max_p];
				moves.pb({max_p, i});
			}
		}

		for (int i = 2; i <= n; ++i) {
			if (a[i] < a[i - 1]) {
				a[i] += a[i - 1];
				moves.pb({i - 1, i});
			}
		}
	} else {
		for (int i = 1; i <= n; ++i) {
			if (a[i] >= 0) {
				a[i] += a[min_p];
				moves.pb({min_p, i});
			}
		}

		for (int i = n - 1; i >= 1; --i) {
			if (a[i] > a[i + 1]) {
				a[i] += a[i + 1];
				moves.pb({i + 1, i});
			}
		}
	}

	cout << moves.size() << endl;
	for (auto &i : moves) {
		cout << i.first << ' ' << i.second << endl;
	}
}

Measured memory_bytes: 256
import collections
import numpy

N,K = map(int,input().split())
A= list(map(int,input().split())) 	

A = collections.Counter(A)
C=A.most_common()

if len(C)> K:
	dels=len(C) - K
	delsList=numpy.array(C[-dels:])
	ans=sum(delsList)[1]
else :
	ans=0

print(ans)


Measured memory_bytes: 49516
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n, k; cin >> n >> k;
    k = k * n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    vector<vector<int>> g(2000005);
    for(int i = 0; i < n; i++){
        g[a[i]].push_back(i);
    }

    vector<pair<int, int>> info(2000005, {-1, -1});
    for(int i = 0; i < 2000003; i++){
        if(g[i].size() == 0) continue;
        if(g[i].size() == 1){
            int from = g[i][0];
            int to = (from + 1) % n;
            info[from] = {n + 1, to};
        }else{
            for(int j = 0; j < (int)g[i].size(); j++){
                int from = g[i][j];
                int to = (g[i][(j + 1) % g[i].size()] + 1) % n;
                int dist = (to - from + n) % n;
                if(dist == 0) dist = n;
                info[from] = {dist, to};
            }
        }
    }

    //for(int i = 0; i < n; i++) cerr << info[i].first << " " << info[i].second << endl;
    
    int sum = 0;
    int cur = 0;
    while(1){
        sum += info[cur].first;
        cur = info[cur].second;
        if(cur == 0) break;
    }
    k %= sum;
    cur = 0;
    while(1){
        if(k >= info[cur].first){
            k -= info[cur].first;
            cur = info[cur].second;
        }else break;
    }

    vector<int> ans;
    set<int> st;
    cerr << cur << " " << k << endl;

    for(int i = 0; i < k; i++){
        
        if(st.empty() or ans.size() == 0 or st.find(a[cur]) == st.end()){
            st.insert(a[cur]);
            ans.push_back(a[cur]);
            cur++;
            cur %= n;
        }else{
            st.erase(a[cur]);
            while(1){
                int val = ans.back();
                ans.pop_back();
                st.erase(val);
                if(val == a[cur]) break;
            }
            cur++;
            cur %= n;
        }
    }
    
    if(ans.size() >= 1){

        for(int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
        cout << endl;
    }

    return 0;
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

#define N_MAX 201010
ll f[N_MAX],rf[N_MAX];

ll pow(ll x,ll n){  // xのn乗 (mod m)
    ll res = 1;
    if(n > 0){
        res = pow(x,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }else{
            res = (((res * res) % mod) * x) % mod;
        }
    }
    return res;
}

void init(){
    f[0] = 1;
    for(int i = 1; i < N_MAX; i++){
        f[i] = (i * f[i-1]) % mod;
    }
    for(int i = 0; i < N_MAX; i++){
        rf[i] = pow(f[i],mod-2);
    }
}

ll com(ll n, ll k){
    //init();
    ll a = f[n];
    ll b = rf[k];
    ll c = rf[n-k];

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}
int main()
{
    int n,k; cin >> n >> k;
    init();
    ll ans = 0;
    rep(i,min(n,k)+1){
        ans += com(n,i) * com(n-1,i);
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s, ans="No";
    cin >> s;
    for(int i=0; i<s.size(); i++)
      if(s[i]=='9'){
        ans = "Yes";
        break;
      }
    cout << ans << endl;

}

Measured memory_bytes: 256