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

const int MAX = 1e6+6;

int n , ara[MAX];


bool ok () {

    
    for(int i =1 ; i<= n ;i++ ) {
        if( ara[i] != i) return false;
    }
    return true;
}
int main()
{
    cin>>n;
    for(int i = 1 ; i <= n ; i++ ) {
        cin>>ara[i];
    }
    
    if( ok() ) {
        
        cout<<"YES"<<endl;
        return 0;
    }
    
    for(int i =1 ; i <=n ; i++ ) {
        
        for(int j = i +1 ; j<=n ; j++ ) {
            
            if( ara[i] > ara[j] ) {
                
                swap(ara[i] , ara[j]);
                if( ok() ) {
                    cout<<"YES"<<endl;
                    return 0;
                }
                swap(ara[i] , ara[j]);
            }
        }
    }
    
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

	ll n,k;
	cin >> n >> k;
	vi seen(n+1,-1);
	vi a(n+1);
	vi zyun;
	rep1(i,n+1){
		cin >> a[i];
	}
	int tmp = 1;
	while(seen[tmp] == -1){
		seen[tmp]=zyun.size();
		zyun.pb(tmp);
		tmp = a[tmp];
	}
	int c = zyun.size()- seen[tmp];
	int start = seen[tmp];
	if(k < start) cout << zyun[k] << endl;
	else {
		k -= start;
		k %= c; 
		cout << zyun[start+k]<< endl;
	}
	return 0;
}


Measured memory_bytes: 5812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#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 rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    int N;
    cin >> N;
    VS S(N);
    set<string> A;
    rep(i,N){
        cin >> S[i];
        A.insert(S[i]);
    }
    cout << A.size() << endl;
}


Measured memory_bytes: 25120
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s,t;
  int i,mn=1e4,flag=0;
  cin>>s>>t;
  for(i=0;i<(int)(s.length());i++)
  {
      int count1=0;
      for(int j=0;j<(int)t.length();j++)
      {
        if(i+j>=(int)s.length()){
          flag=1;
          break;}
          if(s[i+j]!=t[j])
            count1++;
      }
    if(flag==1)
      break;
        mn=min(count1,mn);
  }
  cout<<mn<<endl;
  return(0);
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    char s[11];
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout <<     "Yes\n";
    }
    else
        cout <<"No";
    return 0;
}


Measured memory_bytes: 3580
N = int(input())
R_L = []
for n in range(N):
    S,P = input().split()
    R_L.append([S,int(P)])

R_L2 = R_L.copy()
R_L2.sort( key=lambda x:(x[0],-x[1]))
for r in R_L2:
    print(R_L.index(r)+1)

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

int main()
{
	long int a,b,k,i,s;
	cin>>a>>b>>k;
	if(b-a+1<=k*2-1)
	{
		for(i=a;i<=b;i++) printf("%d\n",i);
	}
	else
	{
		for(i=0;i<k;i++) printf("%d\n",i+a);
		for(i=k-1;i>=0;i--) printf("%d\n",b-i);
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define MAX 10010
using namespace std;
int N,M;
struct P
{
  int to,d,c;
  P(int to=-1,int d=-inf,int c=-inf):to(to),d(d),c(c){}
};

struct Pox
{
  int p,cost;
  Pox(int p=-1,int cost=-inf):p(p),cost(cost){}
  bool operator < (const Pox &a)const
  {
    return cost > a.cost;
  }
};

vector<vector<P> > G(MAX);
int mincost[MAX];
int mixico[MAX];

int dijkstra()
{
  rep(i,MAX)mincost[i] = mixico[i] = inf;
  mincost[0] = 0;
  priority_queue<Pox> Q;
  Q.push(Pox(0,0));
  while(!Q.empty())
    {
      Pox pox = Q.top(); Q.pop();

      rep(i,G[pox.p].size())
	{
	  P p = G[pox.p][i];

	  if(mincost[p.to] >= pox.cost + p.d)
	    {
	      if(mincost[p.to] == pox.cost + p.d)
		mixico[p.to] = min(mixico[p.to],p.c);
	      else 
		mixico[p.to] = p.c;
	      mincost[p.to] = pox.cost + p.d;
	      
	      Q.push(Pox(p.to,pox.cost+p.d));
	    }
	}
    }
  //rep(i,N)cout << mincost[i] << " : " << mixico[i] << endl;

  int sum = 0;
  REP(i,1,N)sum += mixico[i];
  return sum;
}

int main()
{
  while(cin >> N >> M,N|M)
    {
      rep(i,N)G[i].clear();

      rep(i,M)
	{
	  int u,v,d,c;
	  cin >> u >> v >> d >> c;	 
	  u = u - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1;
	  v = v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1;
	  G[u].push_back(P(v,d,c));
	  G[v].push_back(P(u,d,c));
	}  

      cout << dijkstra() << endl;
    }
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main() {
	int r, c;
	cin>>r>>c;
    int a[r+1][c+1];

	//taking input
    for(int i=0; i<r; i++)
 	{
		int rsum ;
		rsum = 0;
		for(int j=0; j<c; j++)
		{
			cin>>a[i][j];
            rsum +=a[i][j];
		}
		a[i][c] = rsum;
	}

 for(int i=0; i<=c; i++)
 	{
		int csum = 0;
		for(int j=0; j<r; j++)
		{
            csum +=a[j][i];
		}
		a[r][i] = csum;
	}

	for(int i=0; i<=r; i++) 
	{
		for(int j=0; j<=c; j++)
		{
			cout<<a[i][j] << (j!=c ? " " : "" );
		}
		cout<<endl;
	 }
}


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

int main() {
  int N;

  cin >> N;
  
  vector<int64_t> lucas(N+1); 
 
  
  for(int i=0;i<=N;i++){
    if(i==0)
      lucas.at(i) = 2;
    else if(i==1)
      lucas.at(i) = 1;
    else
      lucas.at(i)=lucas.at(i-1)+lucas.at(i-2);
  }
  
  
  
  cout << lucas.at(N) << endl;
}


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

int main(){
        int N,ans=1,k=1;
        for(int i=0; i<9; i++) {
                k*=10;
        }
        k+=7;
        cin >> N;
        int a[N],b[N];
        for(int i=0; i<N; i++) {
                cin >> a[i];
                b[i] =0;
        }
        sort(a,a+N);
        if(N%2==0) {
                for(int i=0; i<N/2; i++) {
                        if(a[2*i]!=a[2*i+1]) {
                                ans =0;
                        }else{
                                ans = 2 * (ans%k);
                        }
                }
        }else{
                for(int i=0; i<N/2; i++) {
                        if(a[2*i+1]!=a[2*i+2]) {
                                ans =0;
                        }else{
                                ans = 2 * (ans%k);
                        }
                }
        }
        cout << ans%k << endl;
        return 0;
}


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

using namespace std;

int main()
{
	int k;
	cin >> k;
	int tmp = 0;
	for (int i = 1; i <= k; i++)
		if (i % 2 == 0)
			tmp++;
	cout << tmp * (k - tmp) << endl;

	return 0;
}


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

int main() {
int n,m,c; cin>>n>>m>>c;
  int kiso[m];
  rep(i, m) cin>>kiso[i];
  int res=0;
  
  for(int i=0;i<n;i++){
    int res2=0;
    int wa[m];
    rep(j, m) cin>>wa[j];
    for(int k=0;k<m;k++){
      res2+=wa[k]*kiso[k];}
    if(res2+c>0) res++;
  }
  cout<<res<<endl;
      
  
}

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

int main(void){
    
    string s,t;
    cin>>s;
    cin>>t;
    ll count=0,max=0;
    ll n=s.length();
    ll m=t.length();
    for(ll i=0;i<n-m+1;i++)
    {
        count=0;
        for(ll j=0;j<m;j++)
        {
            if(t[j]==s[j+i])
                count++;
        }
        if(max<=count)
            max=count;
    }
    
    cout<<m-max<<endl;
    //cout<<max<<endl;
    // Your code here!
    
}


Measured memory_bytes: 3580
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
     
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
     
    int count = 0;
    int i;
    for(i=a;i<=b;i++){
        if(c%i == 0){
            count++;
        }
    }
     
    printf("%d\n",count);
     
    return 0;
}


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

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

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

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read)))
    (println (* 180 (- n 2)))))

#-swank(main)


;; For Test
#+swank
(defun io-equal (in-string out-string &optional (func #'main))
  (labels ((ensure-last-lf (s)
             (if (and (> (length s) 0)
                      (eql (char s (- (length s) 1)) #\Linefeed))
                 s
                 (uiop:strcat s uiop:+lf+))))
    (equal (ensure-last-lf out-string)
           (with-output-to-string (out)
             (let ((*standard-output* out))
               (with-input-from-string (*standard-input* (ensure-last-lf in-string))
                 (funcall func)))))))

#+swank
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

#+swank (defparameter *this-pathname* (uiop:current-lisp-file-pathname))
#+swank (defparameter *dat-pathname* (uiop:merge-pathnames* "test.dat" *this-pathname*))

#+swank
(defun run (&optional thing (out *standard-output*))
  (let ((*standard-output* out))
    (etypecase thing
      (null ; Runs #'MAIN with the string on clipboard
       (with-input-from-string (*standard-input* (delete #\Return (get-clipbrd)))
         (main)))
      (string
       (with-input-from-string (*standard-input* (delete #\Return thing))
         (main)))
      (symbol (5am:run! thing))
      (pathname ; Runs #'MAIN with the string in a text file
       (with-open-file (*standard-input* thing)
         (main))))))

#+swank
(defun gen-dat ()
  (uiop:with-output-file (out *dat-pathname* :if-exists :supersede)
    (format out "")))

#+swank
(defun bench (&optional (out (make-broadcast-stream)))
  (time (run *dat-pathname* out)))


Measured memory_bytes: 15720
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    _, _ = map(int, rl().split())
    a = list(map(int, rl().split()))
    
    max_a = max(a)
    d = sum(a) - max_a
    d = max_a - d
    print(max(0, d - 1))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <array>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <uint64_t N>
class Combination {
  using _Tp = long long;
public: 
  array<_Tp, N> fac, finv, inv;

  constexpr
  Combination() {
    init();     
  }

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

  // n!! * k!^(-1) * ((n - k)!)^(-1)   
  constexpr
  _Tp comb(_Tp n, _Tp k) const {
    if (n < k) return 0;        
    if (n < 0 || k < 0) return 0;       
    return fac[n] * (finv[k]* finv[n - k] % MOD) % MOD; 
  }

  constexpr
  _Tp operator ()(_Tp n, _Tp k) const {
    return comb(n, k);
  }
};

void add(int64_t & a, const int64_t b) {
  a = (a + b) % MOD;
}

void mul(int64_t & a, const int64_t b) {
  a = (a * b) % MOD;
}

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  Combination<3000100> comb;

  int64_t ans1 = 0, ans2 = 0;
  for (int i = 1; i < n; ++i) {
    add(ans1, i * (n - i));
  }
  mul(ans1, m * m % MOD);
  
  for (int i = 1; i < m; ++i) {
    add(ans2, i * (m - i));
  }
  mul(ans2, n * n % MOD);
  
  add(ans1, ans2);
  
  mul(ans1, comb(n * m - 2, k - 2));
  // debug(comb(n * m - 2, k - 2));
  cout << ans1 << endl;
}


Measured memory_bytes: 70528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[n];
		int[] r = new int[n];
		int count = 0;

		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();

			count = count + r[i] - l[i] + 1;
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LL unsigned long long
#define LD long double
#define REP(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define RREP(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define int LL
using namespace std;

typedef pair<int,int> PII;
typedef pair<int,PII> PIII;
typedef vector<int> VI;


const int MX = 1e5+1;

signed main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int k,a,b;
    cin>>k>>a>>b; 
    int ans;
    if(a+2>=b || a+1>k)
    	ans = k+1;
    else
    {
    	k -= (a+1);
    	ans = b;
    	ans += (k/2)*(b-a) + k%2;
    }
    cout<<ans;
    return 0;
}
 

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String T = scan.next();
		int A = scan.nextInt();
		int B = scan.nextInt();
		String U = scan.next();

		if (S.equals(U)) {
			A -= 1;
		} else {
			B -= 1;
		}
		System.out.println(A + " " + B);
	}

}


Measured memory_bytes: 20948
#include<bits/stdc++.h>//万能头文件
using namespace std;
int a,b,ans;
int main(){//主函数
    cin>>a>>b;//输入
    if((a+b)%2==0)
    ans=(a+b)/2;
    else 
    ans=(a+b)/2+1;//向上取整
    cout<<ans<<endl;//输出
    return 0;
}

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

void reset(int*);

int main()
{
	int n;
	int mx=0;
	int nuln[20000] = {0};
	int num , fa , sc ;
	int mnum;
	int i;
	cin >> n;
	while (n != 0)
	{
		mx = 0;
		reset(nuln);
		for (i = 0; i < n; i++)
		{
			cin >> num >> fa >> sc;
			nuln[num] = fa + sc;
		}
		for (i = 1; i <= 10000; i++)
		{
			if (nuln[i] > mx)
			{
				mnum = i;
				mx = nuln[i];
			}
		}
		cout << mnum << ' ' << nuln[mnum] << endl;
		cin >> n;
	}
	return 0;
}

void reset(int *re)
{
	int i;
	for (i = 1; i <= 10000; i++)
	{
		re[i] = 0;
	}
	return;
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int a,b,c,d;
int main()
{
    
    cin>>a>>b>>c>>d;
    if(a*b>=c*d)
        cout<<a*b;
    else
        cout<<c*d;
}




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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, l;
    cin >> n >> l;
    vector<string> s;
    while(n--){
        string x;
        cin >> x;
        s.PB(x);
    }
    sort(ALL(s));
    for(auto &x : s){
        cout << x;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll sz = 1e5+5;

vector <ll> dp[11][11];

int main()
{
    ll k;
    cin >> k;

    if(k < 10) {
        cout << k << endl;
        return 0;
    }

    for(ll i=0; i<10; i++) dp[1][i].push_back(i);

    ll tot = 9;
    for(ll d=2, t=10; ; d++, t*=10) {
        for(ll i=0; i<10; i++) {
            ll f=t*i;
            for(ll j=0; j<10; j++) {
                if(abs(i-j)<2) {
                    for(ll x : dp[d-1][j]) {
                        dp[d][i].push_back(f+x);

                        if(i) tot++;
                        if(tot==k) {
                            printf("%lld\n", f+x);
                            exit(0);
                        }
                    }
                }
            }
        }
        for(ll i=0; i<10; i++) dp[d-1][i].clear();
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        cin>>n>>m;
        vector<string> v;
        string s;
        for(i=0;i<n;i++)
        {
            cin>>s;
            v.pb(s);
        }
        ll dp[1001][1001];
        clr(dp,0);
        dp[0][0]=1;
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                if(v[i][j]=='#')
                    continue;
                if(i!=0)
                    dp[i][j]=(dp[i][j]+dp[i-1][j])%hell;
                if(j!=0)
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%hell;
            }
        }
        cout<<dp[n-1][m-1];
    }
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

ll ans = 0;
ll n,a;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a;
  ll x = a;
  vector<ll> v(n);
  rep(i,n){
    cin >> v[i];
    x = max(x,v[i]);
    v[i] -= a;
  }
  vector<vector<ll>> dp(n+5,vector<ll>(2*n*x+10,0));
  dp[0][n*x] = 1;
  REP(j,0,n+1){
    rep(t,2*n*x+1){
      if(0 <= t - v[j] && t - v[j] <= 2 * n * x){
        dp[j+1][t] += dp[j][t-v[j]];
      }
      dp[j+1][t] += dp[j][t];
    }
  }
  cout << dp[n][n*x]-1 << endl;
  return 0;
}



Measured memory_bytes: 2432
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long int keytype;

//quicksort(<#keytype *a#>, <#int first#>, <#int last#>)

void quicksort(keytype a[], long long int first, long long int last){
    long long int i, j;
    keytype x, t;
    
    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main() {
    char s[10],t[10],u[10];
    int a,b;
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    
    if(strcmp(s, u) == 0){
        printf("%d %d",a-1,b);
    }else{
        printf("%d %d",a,b-1);
    }
    
    return 0;
}


Measured memory_bytes: 128
import Control.Monad
 
import Data.Ord
import Data.List
import Data.Function
import Data.Maybe
 
import qualified Data.ByteString.Char8 as BS
 
import Debug.Trace
 
tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined
 
readInt = read :: String -> Integer
readIntTuple = tuplify2 . map readInt . words
readIntList = map readInt . words
 
getInt = readInt <$> getLine
getIntList = readIntList <$> getLine
getIntMatrix = map readIntList . lines <$> getContents
getIntTuple = readIntTuple <$> getLine
getIntTuples = map readIntTuple . lines <$> getContents
 
main = do
  [n,m] <- getIntList
  as <- concat <$> getIntMatrix
  let guard = n+1
  print $ f n 1 1 0 (sort (guard:as))

-- maxN段目への移動方法の組み合わせ数を求める
-- maxN: 最終段の段数
-- n: 現在の段数
-- prevCombo: n-1段目への移動方法
-- prevPrevCombo: n-2段目への移動方法
-- as : 壊れている段 (sorted)
-- 0段目への移動方法: 1通り
-- -1段目への移動方法: 0通り
f maxN n prevCombo prevPrevCombo as@(a:as')
  | n == maxN = (prevCombo + prevPrevCombo) `mod` 1000000007
  | n == a    = f maxN (n+1) 0 prevCombo as'
  | otherwise = f maxN (n+1) newCombo prevCombo as
  where newCombo = (prevCombo + prevPrevCombo) `mod` 1000000007

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

struct Card{
    char picture;
    int  num;
};

int partition(Card A[], int p, int r) {
    int i = p;
    for (int j = p; j < r; j++) {
        if (A[j].num <= A[r].num) {
            swap(A[i++], A[j]);
        }
    }
    swap(A[i], A[r]);
    return i;
}

int merge_sort(Card C[], int left, int right) {
    int cnt = 0;
    if (left == right) return cnt;
    int mid = (left + right) / 2;
    cnt += merge_sort(C, left   , mid  );
    cnt += merge_sort(C, mid + 1, right);
    queue<Card> A;
    queue<Card> B;
    for (int i = left; i <= mid; i++) {
        A.push(C[i]);
    }
    Card tmp;
    tmp.num = 1e9 + 1;
    A.push(tmp);
    for (int i = mid + 1; i <= right; i++) {
        B.push(C[i]);
    }
    B.push(tmp);

    for (int i = left; i <= right; i++) {
        cnt++;
        if (A.front().num <= B.front().num) {
            C[i] = A.front();
            A.pop();
        } else {
            C[i] = B.front();
            B.pop();
        }
    }
    return cnt;
}

void quicksort(Card A[], int p, int r) {
    if (p >= r) return;
    int q = partition(A, p, r);
    quicksort(A, p    , q - 1);
    quicksort(A, q + 1, r    );
}

int main(){
    int n;
    cin >> n;
    Card C_1[n];
    Card C_2[n];
    for (int i = 0; i < n; i++) {
        char c_in;
        int num_in;
        cin >> c_in >> num_in;
        C_1[i].picture = c_in;
        C_2[i].picture = c_in;
        C_1[i].num = num_in;
        C_2[i].num = num_in;
    }
    bool is_unstable = false;
    quicksort(C_1, 0, n - 1);
    merge_sort(C_2, 0, n - 1);
    bool is_stable = true;
    for (int i = 0; i < n; i++) {
        if (C_1[i].picture != C_2[i].picture) {
            is_stable = false;
            break;
        }
    }
    if (is_stable == true) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    for (int i = 0; i < n; i++) {
        cout << C_1[i].picture << " " << C_1[i].num << endl;
    }

    return 0;
}

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

int n, a[100001];
long long sum[100001];
int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
	for(int i = n-1; i >= 0; i--) {
		if(a[i+1] > 2*sum[i]) {
			cout << n-i;
			return 0;
		}
	}
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const ll MOD = 1000000007;

ll add(ll a, ll b) { return (a+b)%MOD; }
ll mul(ll a, ll b) { return (a*b)%MOD; }

ll power(ll a,ll b) {
  if (b==0) return 1;
  if (b%2) return (a*power(a,b-1))%MOD;
  else {
    ll x=power(a,b/2);
    return (x*x)%MOD;
  }
}

vector<int> divisors(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) {
        res.push_back(n / i);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main() {
  int N, K;
  while (cin >> N >> K) {
    auto divs = divisors(N);

    int L = divs.size();
    ll dp[L];
    for (int i : range(L)) {
      ll d = divs[i];
      ll ret = power(K, (d + 1) / 2);
      for (int j : range(i)) {
        if (divs[i] % divs[j] == 0) {
          ret = add(ret, MOD - dp[j]);
        }
      }
      dp[i] = ret;
      //cout << divs[i] << " " << ret << endl;
    }

    ll res = 0LL;
    for (int i : range(L)) {
      ll dup = divs[i];
      if (divs[i] % 2 == 0) dup /= 2;
      res = add(res, mul(dp[i], dup));
    }
    printf("%lld\n", res);
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A, B, C, D, ans;
  
  scanf("%d %d %d %d", &A, &B, &C, &D);
  if(A >= C && B >= D){
    ans = D - A;;
  } else if(A >= C && B < D){
    ans = B - A;
  }	 else if(A < C && B >= D){
    ans = D - C;
  } else if(A < C && B < D){
    ans = B - C;
  }
  
  if(ans < 0){
    ans = 0;
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int n, S[100000], q, t;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);

	int count = 0;

	for (int i = 0; i < q; ++i)
	{
		scanf("%d", &t);

		int L = -1;
		int U = n;
		int x;
		while (U - L > 1)
		{
			x = (U + L) / 2;
			if (S[x] >= t)
			{
				U = x;
			}
			else
			{
				L = x;
			}
		}

		if (S[U] == t)
		{
			++count;
		}
	}

	printf("%d\n", count);
}


Measured memory_bytes: 3008
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> strv;
    REP(i, h){
        string s;
        cin >> s;
        strv.push_back("#" + s + "#");
    }
    string header;
    REP(i, w + 2) header += '#';

    cout << header << "\n";
    REP(i, h){
        cout << strv[i] << "\n";
    }
    cout << header << "\n";

    return 0;
}


Measured memory_bytes: 256
nums = int(input())
ary = list(range(nums))

for i in range(nums):
    ary[i] = int(input())

ary.sort()
a = {}
result = 0

for i in ary :
    if i in a:
        a[i] = a[i]+1
    else:
        a[i] = 1

for i in a.keys():
    if a[i] % 2 == 1:
        result += 1

print (result)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){//yがいくつ集まったらx以上になるか
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	
	ll N,M; cin>>N>>M;
	vector<ll> x(N);
	vector<ll> y(N);
	vector<ll> z(N);
	rep(i,N) cin>>x[i]>>y[i]>>z[i];

	ll ans=0;
	vector<ll> cake(N);
	for(int s1=-1;s1<=1;s1+=2){
		for(int s2=-1;s2<=1;s2+=2){
			for(int s3=-1;s3<=1;s3+=2){
				rep(i,N){
					cake[i]=s1*x[i]+s2*y[i]+s3*z[i];
				}
				sort(cake.bg,cake.ed,greater<ll>());
				ll tmp=0;
				rep(i,M) tmp+=cake[i];

				ans=max(ans,tmp);
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
ll T[205];
ll B[61];
bool dodaj(ll x)
{
    for(int i=59;i>=0;i--)
    {
        if(x&(1LL<<i))
        {
            if(!B[i])
            {
                B[i]=x;
                return 1;
            }
            else
                x^=B[i];
        }
    }
    return 0;
}
void czysc()
{
    for(int i=0;i<=59;i++)
        B[i]=0;
}
int32_t main()
{
    speed
    int t;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++)
            cin>>T[i];
        string napis;
        cin>>napis;
        bool czy=0;
        for(int i=n-1;i>=0;i--)
        {
            bool x=dodaj(T[i]);
            if(napis[i]=='1'&&x)
                czy=1;
        }
        if(czy)
            cout<<"1\n";
        else
            cout<<"0\n";
        czysc();
    }
    return 0;
}


Measured memory_bytes: 3580
#include <cstdio>
#include <algorithm>
using namespace std;
static_assert(sizeof(long) >= 8, "sizeof(long) >= 8");
int main() {
    int q, h, s, d, n;
    scanf("%d %d %d %d %d", &q, &h, &s, &d, &n);
    h = min(h, q * 2);
    s = min(s, h * 2);
    d = min(d, s * 2);
    printf("%ld\n", (long) n / 2 * d + n % 2 * s);
}


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

int main()
{

        int n = 0;

        cin >> n;

        int a[n+2];

        for (int i = 0; i < n+2; ++i) {
                if (i == 0 || i == n + 1) {
                        a[i] = 0;
                }
                else {
                        cin >> a[i];
                }
        }

        int base = 0;
        for (int i = 0; i < n+1; ++i) {

                base += abs(a[i+1] - a[i]);

        }

        int minus = 0;
        int plus = 0;
        for (int i = 1; i < n+1; ++i) {

                minus = abs(a[i] - a[i-1]) + abs(a[i+1] - a[i]);
                plus = abs(a[i+1] - a[i-1]);

                cout << base - minus + plus << endl;

        }


}


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

typedef long long ll;
using namespace std;

#define all(x) x.begin(), x.end()
#define f(i,a,b) for(int i = (a); i <= (b); i++)
#define fd(i,a,b) for(int i = (a); i >= (b); i--)
#define mp make_pair
#define faster_io() ios_base::sync_with_stdio(false)
#define pb push_back
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define vii vector<pair<int,int>>

const int INF = 1000000005;
const ll INFLL = 1000000000000000002ll;
const ll MOD = 1000000007;

inline ll min(ll a, ll b, ll c){return min(min(a,b),c);}
inline ll min(ll a, ll b, ll c, ll d){return min(min(min(a,b),c),d);}
inline ll max(ll a, ll b, ll c){return max(max(a,b),c);}
inline ll max(ll a, ll b, ll c, ll d){return max(max(max(a,b),c),d);}

// -------------------------------------------------------------------------------------------------------------

const ll M = 998244353;
ll A, B, N, K;
ll T[300005];

ll exp(ll n, ll e)
{
    if(e == 0) return 1;
    if(e&1) return (exp(n,e-1) * n) % M;
    ll k = exp(n,e/2);
    return (k*k)%M;
}

int main()
{
    cin >> N >> A >> B >> K;
    T[0] = 1;
    f(i,1,N)
    {
        T[i] = T[i-1] * (N-i+1);
        T[i] %= M;
        T[i] *= exp(i,M-2);
        T[i] %= M;
    }
    ll ans = 0;
    f(a,0,N)
    {
        ll val = A * a;
        if(val > K) continue;
        ll rem = K - val;
        if(rem % B != 0) continue;
        ll b = rem / B;
        if(b > N) continue;
        ans += T[a] * T[b];
        ans %= M;
    }
    cout << ans;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi; 
typedef vector<pi> vpi;

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define bk back()
#define pb push_back
#define ins insert
#define del erase
#define inf INT_MAX

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7;
const ld PI = acos((ld)-1);
mt19937 rng; // or mt19937_64
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a = 1 ;
	while(a--)
	{
		ll n;
		cin >> n;
		ll arr[n];
		F0R(i,n)
		{
			cin >>  arr[i];
			arr[i] = arr[i]%MOD ;
		}
		ll pre[n];
		pre[0]=arr[0]%MOD;
		ll ans = 0 ;
		FOR(i,1,n)
		{
			pre[i]=(pre[i-1]+arr[i])%MOD;
			ans+=(arr[i]*pre[i-1])%MOD;
			ans%=MOD;
		}
		cout << ans << endl;
		
		
			
		
	}	
}


Measured memory_bytes: 6748
#include<iostream>
using namespace std;
int i, ans;
string s;
int main()
{
	cin>>s;
	for(i=0; i<s.size()/2; i++)
	{
		if(s[i]!=s[s.size()-i-1])
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char g[2][55];

int main() {
  int len;
  scanf("%d\n%s%s", &len, g[0], g[1]);
  vector<char> v;
  int c = 0;
  while(c < len) {
    if(c+1 == len) {
      v.push_back('V');
      c++;
    }
    else if(g[0][c] == g[1][c]) {
      v.push_back('V');
      c++;
    }
    else {
      v.push_back('H');
      c += 2;
    }
  }
  ll ret = v[0] == 'V' ? 3 : 6;
  for(int i = 1; i < v.size(); i++) {
    if(v[i] == 'V' && v[i-1] == 'V') {
      ret *= 2;
    }
    if(v[i] == 'V' && v[i-1] == 'H') {
      ret *= 1;
    }
    if(v[i] == 'H' && v[i-1] == 'V') {
      ret *= 2;
    }
    if(v[i] == 'H' && v[i-1] == 'H') {
      ret *= 3;
    }
    ret %= 1000000007;
  }
  printf("%lld\n", ret);
}


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

int main() {
  int N;
  cin >> N;
  int j = 0;

  // ここにプログラムを追記
  for (int i=0; i<N; ++i){
    string A;
    cin >> A;
    if (A == "Y"){
      j = 1;
    }
  }
  if (j == 0) {
    cout << "Three" << endl;
  }else {
    cout << "Four" << endl;
  }   
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>
#include <chrono>
#include <climits>

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

using namespace std;

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

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
default_random_engine generator;
// mt19937 rnd(1);

const int MAXN = 200200;

int dp[MAXN][3];

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);      

    string s;
    cin >> s;
    int n = sz(s);


    dp[1][1] = 1;
    dp[2][2] = 1;

    for (int i = 1; i < n; ++i) {
        for (int j = 1; j <= 2; ++j) {
            if (dp[i][j] == 0) {
                continue;
            }
            for (int k = 1; k <= 2; ++k) {
                if (i + k > n) {
                    continue;
                }
                if (s.substr(i - j, j) != s.substr(i, k)) {
                    dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
                }
            }
        }
    }

    cout << max(dp[n][1], dp[n][2]) << endl;

}


Measured memory_bytes: 2964
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int n = int.Parse(Console.ReadLine());
      double ans = 0;
      
      for (int i=1;i<100001;i++)
      {
        if (n>=Math.Pow(i,2))
        {
          ans=Math.Pow(i,2);
        }
        else
        {
          Console.WriteLine(ans);
          break;
        }
      }
    }
}


Measured memory_bytes: 27524
n, k, c = map(int, input().split())
s = input() + "?"

l, r = [], []
cur = 0
count = 0

while cur <= n:
    if s[cur] == "o":
        count += 1
        l.append((count, cur+1))
        cur += c

    cur += 1

cur = n
count = k

while cur >= 0:
    if s[cur] == "o":
        r.append((count, cur+1))
        count -= 1
        cur -= c

    cur -= 1

ans = (i[1] for i in set(l) & set(r))
for i in sorted(ans):
    print(i)

Measured memory_bytes: 88500
n = int(input())

div_cnt = [0] * n

def search_div(data, n):
    while n != 1:
        for i in range(2, n + 1):
            if n % i == 0:
                data[i - 1] += 1
                n = int(n / i)
                break
        

for i in range(2, n + 1):
    search_div(div_cnt, i)

cnt_2 = 0
cnt_4 = 0
cnt_14 = 0
cnt_24 = 0
cnt_74 = 0
if max(div_cnt) < 4:
    print(0)
    exit()

for i in range(n):
    if div_cnt[i] >= 74:
        cnt_2 += 1
        cnt_4 += 1
        cnt_14 += 1
        cnt_24 += 1
        cnt_74 += 1
    elif div_cnt[i] >= 24:
        cnt_2 += 1
        cnt_4 += 1
        cnt_14 += 1
        cnt_24 += 1
    elif div_cnt[i] >= 14:
        cnt_2 += 1
        cnt_4 += 1
        cnt_14 += 1
    elif div_cnt[i] >= 4:
        cnt_2 += 1
        cnt_4 += 1
    elif div_cnt[i] >= 2:
        cnt_2 += 1
    
ans = cnt_74 + cnt_24 * (cnt_2 - 1) + cnt_14 * (cnt_4 - 1) + (cnt_4 * (cnt_4 - 1)) / 2 * (cnt_2 - 2)
print(int(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int w, d;
    while(cin >> w >> d, w||d){
        vector<int> a;
        vector<int> b;

        rep(i, w){
            int inp;
            cin >> inp;
            a.emplace_back(inp);
        }
        rep(i, d){
            int inp;
            cin >> inp;
            b.emplace_back(inp);
        }

        int sum = 0;
        rep(i,w){
            if(a[i] == 0) continue;
            rep(j,d){
                if(a[i] == b[j]){
                    sum+=a[i];
                    a[i] = 0;
                    b[j] = 0;
                    break;
                }
            }
        }
        rep(i, w) sum+=a[i];
        rep(i, d) sum+=b[i];

        cout << sum << endl;
    }
}

Measured memory_bytes: 3016
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string s;
int l;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cin>>s;
	l=s.size();
	for(register int i=0;i<l;i++){
		if(s[i]=='C'){
			for(register int j=i+1;j<l;j++){
				if(s[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
// AGC 017C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
int a[222222],s[222222],t[222222];
int main()
{
	int n,m,i,x,y,z,ans;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i=i+1){
		scanf("%d",&x);
		a[i]=x;
		if(x>s[x]) t[x-s[x]]++;
		s[x]++;
	}
	ans=0;
	for(i=1;i<=n;i=i+1)
		if(!t[i])
			ans++;
	for(i=1;i<=m;i=i+1){
		scanf("%d%d",&x,&y);
		z=a[x];
		s[z]--;
		if(z>s[z]){
			t[z-s[z]]--;
			if(!t[z-s[z]])
				ans++;
		}
		a[x]=y;
		if(y>s[y]){
			if(!t[y-s[y]])
				ans--;
			t[y-s[y]]++;
		}
		s[y]++;
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 3712