akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

int N;
vector<vector<int>> pos, pos2;
int C[200010];
int DP[200010];

int solve(const int idx) {
   if (idx == N)
      return 1;
   if (DP[idx] != -1)
      return DP[idx];
   DP[idx] = solve(idx + 1);
   int nxt = idx + 2;
   auto itc = lower_bound(pos2[C[idx]].begin(), pos2[C[idx]].end(), idx);
   if (itc != pos2[C[idx]].end() && *itc == idx) {
      auto it = lower_bound(pos2[C[idx]].begin(), pos2[C[idx]].end(), nxt);
      if (it != pos2[C[idx]].end())
         DP[idx] = (DP[idx] + solve(*it)) % MOD;
   }//if
   return DP[idx];
}//solve

int main() {
   scanf("%d", &N);
   pos.assign(200010, vector<int>());
   pos2.assign(200010, vector<int>());
   for (int i = 0; i < N; i++)
      scanf("%d", &C[i]), pos[C[i]].push_back(i);
   for (int i = 0; i <= 200000; i++) {
      if (!pos[i].empty())
         pos2[i].push_back(pos[i][0]);
      for (int j = 1; j < (int)pos[i].size(); j++)
         if (pos[i][j] > pos[i][j - 1] + 1)
            pos2[i].push_back(pos[i][j]);
   }//for
   memset(DP, -1, sizeof(DP));
   printf("%d\n", solve(0));
   return 0;
}//main


Measured memory_bytes: 29952
#include <stdio.h>
#include <stdlib.h>
/* #define debug */

int checkarray[10000][3]={0};
int counter=0;

void checkset(int x, int y, int z);

int main(int argv, char *argc[]){
    int input, target, x, y ,z;
    
    while(1){
        scanf("%d %d\n", &input, &target);
        if(0 == input && 0 == target) break;
        
        /*組み合わせを総当りしてcheckset関数に投げる*/
        for(x=1; input-2>=x; x++){
            for(y=x+1; input-1>=y; y++){
                for(z=y+1; input>=z; z++){
                    if(target == x+y+z){
                        checkset(x, y, z);
                    }
                }
            }
        }
        
        /*結果を表示する*/
        printf("%d\n", counter);
        
        /*次のチェック用に初期化する*/
        
        counter=0;
        x=1;
        y=2;
        z=3;
    }
    
    return 0;
}

void checkset(int min, int mid, int max){
    int buf, loop;
    
    /*整理の為に大中小で分ける*/
    while(!(min <= mid && mid <= max)){
        if(min > mid){
            buf = min;
            min = mid;
            mid = buf;
        }
        if(mid > max){
            buf = mid;
            mid = max;
            max = buf;
        }
    }
    
    /*大きい数字から、過去に見つけた組でないか探す*/
    for(loop=0; counter>loop; loop++){
        if(max == checkarray[loop][0]){
            if(mid == checkarray[loop][1]){
                if(min == checkarray[loop][2]){
                    return; /*過去に見つけた組だったので戻る*/
                }
            }
        
        }
    }
    /*過去に見つけた組では無かったので保存してカウンタを１増やす*/
    checkarray[counter][0] = max;
    checkarray[counter][1] = mid;
    checkarray[counter][2] = min;
    counter += 1;
    #ifdef debug
    printf("debug-checkset1:%d:%d+%d+%d=%d\n",counter, max, mid, min, min+mid+max);
    #endif
    return;
}

Measured memory_bytes: 616
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#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 long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << ' ' << max(0, a + b - n) << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(){
            Main main = new Main();
            main.solve();
        }
    }

    class Main
    {
        public void solve()
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToList();
            int N = l[0];int M = l[1];
            List<(int,int)> ab = new List<(int, int)>();
            for(int i = 0;i < M;i++){
                l = Console.ReadLine().Split().Select(int.Parse).ToList();
                ab.Add((l[0], l[1]));
            }
            ab.Sort((a, b) => b.CompareTo(a));
            int ta = int.MaxValue; int tb = int.MaxValue;
            int ans = 0;
            foreach ((int a, int b) in ab)
            {
                if(ta < b){
                    // すでに切断済み
                }else{
                    // これから切る
                    ans++;
                    ta = a;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 48868
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[] s = S.toCharArray();
        int ans = 0;
        int x = 0;
        for (int i = 0; i < N; i++) {
            if (s[i] == 'I') {
                x++;
            } else {
                x--;
            }
            ans = Math.max(x, ans);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		int c = Integer.parseInt(s[2]);
		int d = Integer.parseInt(s[3]);
		int op1 = 0, op2 = 0, op3 = 0;
		boolean comp = false;
		for (op1 = 0; op1 <= 1; op1++) {
			for (op2 = 0; op2 <= 1; op2++) {
				for (op3 = 0; op3 <= 1; op3++) {
					int ans = a + ((op1 == 0)? b : -b) + ((op2 == 0)? c : -c) + ((op3 == 0)? d : -d);
					if (ans == 7) {
						comp = true;
						break;
					}
				}
				if (comp)
					break;
			}
			if (comp)
				break;
		}
		System.out.println(a + ((op1 == 0)? "+" : "-") + b + ((op2 == 0)? "+" : "-") + c + ((op3 == 0)? "+" : "-") + d + "=7");
	}
}

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

string a[105];
int n, l;

int main() {
  cin>>n>>l;
  for (int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  for (int i=0;i<n;i++) cout<<a[i];
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,c=0;
    string b;
    cin>>a>>b;
    for(int i=0;i<a;i++){
	if(b[i]=='A'){
	    if(b[i+1]=='B'){
		if(b[i+2]=='C') c++;
	    }
	}
    }
    cout<<c<<"\n";
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
#define EPSILON 0.0001
 
int isSameSide(double x1, double y1, double x2, double y2,
    double xa, double ya, double xb, double yb)
{
    double sa, sb;
 
    sa = (x2 - x1) * (ya - y1) + (y2 - y1) * (x1 - xa);
    sb = (x2 - x1) * (yb - y1) + (y2 - y1) * (x1 - xb);
    if (-EPSILON <= sb && sb <= EPSILON) return 0;   // xb,yb in line
    if (sa * sb >= 0) return 1;                      // xa,ya xb,yb at same side
    return -1;                                       //
}
 
int main()
{
    double x1, y1, x2, y2, x3, y3, x4, y4;
 
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
        &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4) == 8) {
        if (isSameSide(x1, y1, x3, y3, x2, y2, x4, y4) != -1) goto NO;
        if (isSameSide(x2, y2, x4, y4, x1, y1, x3, y3) != -1) goto NO;
        puts("YES");
        continue;
    NO: puts("NO");
    }
    return 0;
}


Measured memory_bytes: 1916
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int X, Y; cin >> X >> Y;
    bool b = false;
    for (int i = 0; i <= X; i++) {
        if (i * 4 + (X - i) * 2 == Y) {
            b = true;
            break;
        }
    }
    if (b)puts("Yes");
    else puts("No");
}




Measured memory_bytes: 3556
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#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>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    vector<long long> ABC(3);
    for (int i = 0; i < 3; i++)cin >> ABC[i];

    for (int i = 0; i < 3; i++) {
        if (ABC[i] % 2 == 0) {
            cout << 0;
            return 0;
        }
    }

    sort(ABC.begin(), ABC.end());
    long long ans = ABC[0] * ABC[1];

    cout << ans << endl;

}
















































Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

struct ed
{
	int be;
	int to;
	double dist;
}G[100005];

double px[100005];
double py[100005];
int father[100005];

struct cmp
{
	bool operator()(const ed &a, const ed &b)
	{
		return a.dist > b.dist;
	}
};

inline double mdist(int a, int b)
{
	return sqrt(pow(px[a] - px[b], 2) + pow(py[a] - py[b], 2));
}

int find(int x)
{
	if(father[x] != x)
		return find(father[x]);
	return father[x];
}

int main()
{
	//用总数减最大 
	double sum = 0.0;
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%lf%lf", &px[i], &py[i]);
		father[i] = i;
	}	
		
	int tx, ty;
	//ed tmp;
	for(int i = 1; i <= m; ++i)
	{
		scanf("%d%d", &tx, &ty);
		G[i].be = tx;
		G[i].to = ty;
		G[i].dist = mdist(tx, ty);
		sum += G[i].dist;
	}
	
	double f = 0.0;
	sort(G + 1, G + m + 1, cmp());
	for(int i = 1; i <= m; ++i)
	{
		int x = find(G[i].be);
		int y = find(G[i].to);
		if(x != y)
		{
			father[x] = y;
			//printf("%.3lf\n", G[i].dist);
			//break;
			f += G[i].dist;
		}
	}
	printf("%.3lf\n", sum-f);
}


Measured memory_bytes: 3828
#include <cstdio>

int main()
{
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int k=0;
      while(((i>>k)&1)==((j>>k)&1)){
	k++;
      }
      printf("%d ",k+1);
    }
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 384
/* Mere paradesiyaan ki yahi hai nishaani
   Ankhiyaan bilor ki, shishe ki jawaani
*/
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define LOG1(a)			  cerr<< #a << " = " << (a) << "\n"
#define LOG2(a, b)		  cerr<< #a << " = " << (a) << ", " << #b << " = " << (b) << "\n"
#define endl "\n"

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr1[nax], arr2[nax];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> arr1[i], arr1[i] += arr1[i - 1];
    for(int i = 1; i <= n; i++) cin >> arr2[i], arr2[i] += arr2[i - 1];

    ll maxans = 0;
    for(int i = 1; i <= n; i++)
    {
        ll curans = arr1[i];
        curans += (arr2[n] - arr2[i - 1]);
        maxans = max(maxans, curans);
    }
    cout << maxans;
    return 0;
}


Measured memory_bytes: 2304
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {

		int n = sc.nextInt();

		calc(n);


	}
	public void calc(int n){
		int[][] costs = new int[n][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				costs[i][j] = sc.nextInt();
			}
		}
		long sum = 0;
		for(int i = 0; i < n; i++){
			for(int j = i+1; j < n; j++){
				sum += Math.min(costs[i][j], costs[j][i]);
			}
		}
		
		System.out.println(sum);
	}

	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 31352
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
const int MAX = 2000000;
const int EL_MAX = 10001;

void countingSort(int N, int A[], int B[]) {
    int C[EL_MAX];
    for (int i = 0; i <= EL_MAX; i++) {
        C[i] = 0;
    }
    
    for (int i = 0; i < N; i++) {
        C[A[i]]++;
    }
    
    for (int i = 0; i < EL_MAX; i++) {
        if (i != 0) {
            C[i] = C[i] + C[i-1];
        }
    }
    
    for (int j = N - 1; j >= 0; j--) {
        B[C[A[j]]-1] = A[j];
        C[A[j]]--;
    }
}

int main() {
    int N;
    int A[MAX], B[MAX];

    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        B[i] = 0;
    }
    
    countingSort(N, A, B);
    
    
    for (int i = 0; i < N; i++) {
        if (i != 0) cout << " ";
        cout << B[i];
    }
    
    cout << endl;

    return 0;
}


Measured memory_bytes: 18816
//幅優先探索（bfs）
//迷路の最短路

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#include<queue>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
typedef pair<int,int> P;
int ceil(int a,int b){// a以上でbの倍数の最小値を出力//
    return (a+b-1)/b*b;
}

//シフト演算　(1<<k) 2のk乗

int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}

const int max_n=51,max_m=51;
int N,M;
char maze[max_n][max_m]; //迷路を表す文字の配列
int inf=100000;
int sx,sy;//startの座標
int gx,gy;//goalの座標
int d[max_n][max_m];//各点までの最短距離の配列

//移動４方向のvector
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//(sx,sy)⇒(gx,gy)への最短距離を求める
//たどりつけなかったらINF

int bfs(){
    queue<P> que;
    //すべての点をINFで初期化
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            d[i][j]=inf;
        }
    }
    //スタート地点をqueueに入れ、その点の距離を0とする
    que.push(P(sx,sy));
    d[sx][sy]=0;

    //キューが空になるまでループ
    while(que.size()){
        //queueの先頭を取り出す
        P p =que.front();
        que.pop();
        //取り出してきた状態が、goalなら探索をやめる
        if(p.first==gx && p.second==gy)break;
        //移動４方向をループ
        for(int i=0;i<4;i++){
            //移動した後の点をnx,nyとする
            int nx=p.first+dx[i],ny=p.second+dy[i];

            //移動が可能かの判定はd[nx][ny]!=INFなら訪れたことがある
            if(0<=nx && nx<N && 0<=ny && ny<M && maze[nx][ny]!='#' &&
            d[nx][ny]==inf){
            //移動できるならキューに入れて、その点の距離をｐからの距離＋１で確定する
            que.push(P(nx,ny));
            d[nx][ny]=d[p.first][p.second]+1;
            }
        }    
    }
    return d[gx][gy];    
}

int main(){
    int num[5];
    vector<int> kekka(1000,10000);
    int kaisu=-1;
    while(1){
        bool k=1;
        for(int i=0;i<5;i++){
            cin>>num[i];
            if(num[i]!=0)k=0;
        }
        if(k)break;
        kaisu++;
        int stop[10000],ans=-1;
        for(int i=0;i<num[0];i++)cin>>stop[i];
        for(int i=0,n=num[4],j=0;i<10001&&j<num[0];i++){
            if(n==stop[j])j++;
            if(j==num[0])ans=i;
            n=(num[1]*n+num[2])%num[3];
        }
        kekka[kaisu]=ans;
    }
    for(int i=0;i<kaisu+1;i++) cout<<kekka[i]<<endl;
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

template<typename T>
vector<vector<T>> MakeVector2D(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

tuple<vector<FiniteField>, vector<FiniteField>> MakeFactorialTables(int n) {
  vector<FiniteField> factorials(n + 1);
  vector<FiniteField> inverse_factorials(n + 1);
  factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    factorials[i] = factorials[i - 1] * i;
  }
  inverse_factorials[n] = FiniteField(1) / factorials[n];
  for (int i = n; i >= 1; i--) {
    inverse_factorials[i - 1] = inverse_factorials[i] * i;
  }
  return make_tuple(factorials, inverse_factorials);
}

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

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

  vector<FiniteField> fs, i_fs;
  tie(fs, i_fs) = MakeFactorialTables(n + 1);
  auto c_fn = [&fs, &i_fs](int a, int b) -> FiniteField {
    if (b < 0 || b > a) return 0;
    return fs[a] * i_fs[b] * i_fs[a - b];
  };

  auto dp = MakeVector2D<FiniteField>(k + 1, n + 1, 0);
  dp[0][0] = 1;
  for (int i = 0; i < k; i++) {
    int x = xs[i];
    for (int j = 0; j <= n; j++) {
      for (int a = 0; a <= x; a++) {
        if (j + a > n) continue;
        dp[i + 1][j + a] += dp[i][j] * c_fn(n - j, a) * c_fn(n - a, x - a);
      }
    }
  }
  cout << dp[k][n] << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main(void) {
  string s;
  cin >> s;
  char last = s[s.length() - 1];
  if (last == '3') {
    cout << "bon" << endl;
  } else if (last == '0' || last == '1' || last == '6' || last == '8') {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
	int a[200],b=0,c,i,n;
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%d",&a[i]);
    do
	{
		c=0;
		for (i=0;i<n;i++)
		{
			if (a[i]%2==0)
			c++;
			a[i]=a[i]/2;
		}
		if (c==n)
		b++;
	}while (c==n);
	printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
    
		// 出力
		System.out.println(n * n - a);
	}
}


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

using ll=long long;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll h;
  cin>>h;
  ll n=floor(log2(h))+1;
  cout<<(1ll<<n)-1;
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){

    int x[10000],y[10000],i,temp;

    for(i=1;i<=10000;i++)
    {
      scanf("%d %d",&x[i],&y[i]);
      if(x[i]!=0 || y[i]!=0){
         if(x[i]>y[i]){
           temp=x[i];
           x[i]=y[i];
           y[i]=temp;
         }
         printf("%d %d\n",x[i],y[i]);
      }else{
         break;
      }
     }
      
    return 0;

}


Measured memory_bytes: 2044
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n;
  ll a, x, ans = 0LL;
  cin >> n >> a;
  x = a;
  for (int i = 0; i < n - 1; i++) {
    cin >> a;
    ans += max(0LL, x - a);
    x = max(x, a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>

typedef struct{
  double x,y;
}point;

void Koch(int n,point p1,point p2){
  point s,t,u;
  if(n <= 0)return;
  s.x = (2*p1.x + p2.x)/3;
  s.y = (2*p1.y + p2.y)/3;
  t.x = (p1.x + 2*p2.x)/3;
  t.y = (p1.y + 2*p2.y)/3;
  u.x = (t.x - s.x)/2 - (t.y - s.y)/2*(sqrt(3)) + s.x;
  u.y = (t.x - s.x)/2*(sqrt(3)) + (t.y - s.y)/2 + s.y;
  Koch(n-1,p1,s);
  printf("%lf %lf\n",s.x,s.y);
  Koch(n-1,s,u);
  printf("%lf %lf\n",u.x,u.y);
  Koch(n-1,u,t);
  printf("%lf %lf\n",t.x,t.y);
  Koch(n-1,t,p2);
}


int main(){
  int i,n;
  point p1 = {0.00000000,0.00000000};
  point p2 = {100.00000000,0.00000000};
  scanf("%d",&n);
  printf("%lf %lf\n",p1.x,p1.y);
  Koch(n,p1,p2);
  printf("%lf %lf\n",p2.x,p2.y);
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

int N,M,Q;
vector<vector<int>> g;
vector<bool> vis;
vi v,d,c,already,color;
void dfs(int i,int d,int c) {
    if(already[i]>=d) return;
    already[i]=d;
    if(color[i]==0) color[i]=c;
    if(d==0) return;
    FORE(j,g[i]) {
        if(vis[j]) continue;
        vis[j]=true;
        dfs(j,d-1,c);
        vis[j]=false;
    }
}
signed main() {
    cin>>N>>M;
    g=vector<vector<int>>(N);
    color=vector<int>(N,0);
    REP(i,M) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin>>Q;
    v=vi(Q),d=vi(Q),c=vi(Q);
    already=vi(N,-1);
    REP(i,Q) {
        cin>>v[i]>>d[i]>>c[i];
        v[i]--,d[i],c[i];
    }
    REPR(i,Q-1) {
        vis=vector<bool>(N,false);
        vis[v[i]]=true;
        dfs(v[i],d[i],c[i]);
    }
    cout<<color<<endl;
    return 0;
}


Measured memory_bytes: 10868
#coding: utf-8
A = list(map(int, input().split()))
N = A[0]
K = A[1]

n = 0
sw = 0
while True:
  if N%K == 0:
    N = 0
    break
  if (N/K) //1:
    C = N//K
    N = N-C*K

  sw = abs(N-K)
  n += 1
  if N > sw:
    N = sw
  else:
    break
print(N)

Measured memory_bytes: 38412
n,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
x,y,ans = [0],[0],0
for i in range(n):
	x.append(x[-1]+a[i])
	y.append(y[-1]+max(0,a[i]))
for i in range(1,n-k+2):
	num,num2 = y[i-1]+y[n]-y[i+k-1],x[i+k-1]-x[i-1]
	ans = max(ans,num,num+num2)
print(ans)

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

int main(){
    int n, num;
    string s;
    list<int> L;

    cin >> n;

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

        if(s[0] == 'i'){
            cin >> num;
            L.push_front(num);
        }else if(s[6] == 'F'){
            L.pop_front();
        }else if(s[6] == 'L'){
            L.pop_back();
        }else if(s[0] == 'd'){
            cin >> num;
            for(list<int>::iterator it = L.begin(); it != L.end(); it++){
                if(*it == num){
                    L.erase(it);
                    break;
                }
            }
        }
    }

    int i=0;
    for(list<int>::iterator it = L.begin(); it != L.end(); it++){
        if(i > 0) cout << " ";
        cout << *it;
        i++;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 34344
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] remainder_mapping = new int[2019];
        remainder_mapping[0]++;
        Scanner sc = new Scanner(System.in);
        String target_string = sc.next();
        int remainder = 0;
        int pow_of_ten = 1;
        for(int i = target_string.length()-1 ;i >= 0; i--){
            int target_number = (target_string.charAt(i) - '0');
            remainder += target_number*pow_of_ten;
            remainder %= 2019;
            remainder_mapping[remainder]++;
            pow_of_ten *= 10;
            pow_of_ten %= 2019;
        }
        int answer = 0;
        for(int i = 0;i < 2019;i++){
            int candidates = remainder_mapping[i];
                answer += ((candidates-1)*candidates)/2;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 40332
n,k = map(int, input().split())
a = list(map(int, input().split()))

route = [0]
visited = [0]*n
visited[0]=1

while visited[a[route[-1]]-1]==0:
    visited[a[route[-1]]-1]=1
    route.append(a[route[-1]]-1)

if k<len(route):
    print(route[k]+1)
else:
    b = route.index(a[route[-1]]-1)
    ans = (k-b)%(len(route)-b)
    print(route[b+ans]+1)





Measured memory_bytes: 95192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	string a = "Christmas";
	int n; cin>>n;
	n = 25-n;
	rep(i,n) a += " Eve";
	cout<<a<<endl;
}

Measured memory_bytes: 256
double h(double a,double b){double s=(a+a+b)/2;return sqrt((s-a)*(s-a)*(s-b)*s);}
main(){double a,l,x;for(;~scanf("%lf%lf%lf",&a,&l,&x);)
printf("%lf\n",h(l,a)+2*h(((l+x)/2),l));exit(0);}

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

char ch[] = {'m', 'c', 'x', 'i'};
int value[] = {1000, 100, 10, 1};


int to_val(string s) {
  
  int ret = 0;
  for(int i = 0; i < s.size(); i++) {
    int v = 1;
    if('2' <= s[i] && s[i] <= '9') {
      v = s[i] - '0';
      i++;
    }
    for(int j = 0; j < 4; j++) {
      if(s[i] == ch[j]) ret += value[j] * v;
    }
  }

  return ret;
}
  
signed main()
{
  int N;
  
  cin >> N;
  for(int i = 0; i < N; i++) {
    string a, b;

    cin >> a >> b;
    
    int val = to_val(a) + to_val(b);
    
    string ans;
    
    for(int j = 0; j < 4; j++) {
      if(val >= value[j]) {
	if(val >= value[j] * 2) {
	  ans += '0' + val / value[j];
	}
	ans += ch[j];
	val -= (val / value[j]) * value[j];
      }
    }
    cout << ans << endl;
  }

  return 0;
}
    

Measured memory_bytes: 3112
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 10000010;
const int INF = 2147483600;
const LL Mod = 1e9+7;

LL N,A; LL fac[MAXN+1],inv[MAXN+1],ifac[MAXN+1];
inline LL C(LL n,LL m){ if(n<m) return 0; return fac[n]*ifac[m]%Mod*ifac[n-m]%Mod; }
inline LL F(LL a,LL b,LL c){ return fac[a+b+c]*a%Mod*inv[a+b]%Mod; }
inline void Add(LL &a,LL b){ a=(a+b>=Mod?a+b-Mod:a+b); }

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),A=read(); fac[0]=inv[1]=ifac[0]=1; LL ans=0;
	for(int i=1;i<=N;i++) fac[i]=fac[i-1]*i%Mod;
	for(int i=2;i<=N;i++) inv[i]=(Mod-(Mod/i)*inv[Mod%i]%Mod)%Mod;
	for(int i=1;i<=N;i++) ifac[i]=ifac[i-1]*inv[i]%Mod;
	for(LL a=1;a<=A+1;a++){
		LL b=N-A,c=A-min(a,A); LL op=1;
		for(int j=0;j<=a-1;j++)
			Add(ans,op*F(a-1-j,b,c)%Mod*C(a-1,j)%Mod),op=Mod-op;
	} printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 238080
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 200010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <int,pi>
#define ull unsigned long long int
using namespace std;
int main() {

   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    ll a,b;
    cin >> a >> b;
    ll fans = 0;
    if(b - a <= 10)
    {
    	for(ll i = a; i <= b; i++)
    		fans ^= i;
    	cout << fans << '\n';
    	return 0;
    }
    while(a % 4 != 0)
    {
    	fans ^= a;
    	a++;
    }
    while(b % 4 != 3)
    {
    	fans ^= b;
    	b--;
    }
    cout << fans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main()
{
long N, K;

scanf("%ld %ld", &N, &K);

long V1 = N % K;
long V2 = V1 - K;
if (V2 < 0) { V2 = -V2; }

//printf("%ld %ld\n", N, K);
//printf("%ld %ld\n", V1, V2);

long min = (V1 < V2) ? V1 : V2;

printf("%ld\n", min);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        long N = long.Parse(Console.ReadLine());
        
        List<char> tmp = new List<char>();

        while(N != 0){
            long a = N % 26;
            tmp.Add((char)(a == 0 ? 122 : a + 96));
            N = N / 26;
            if(a == 0){
                N--;
            }
        }

        tmp.Reverse();

        Console.WriteLine(new String(tmp.ToArray()));
    }
}

Measured memory_bytes: 27820
use std::io;
use std::str::FromStr;
use std::collections::VecDeque;

type Point = (usize, usize);

fn input_int_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn push_queue(x: usize, y: usize, queue: &mut VecDeque<Point>, field: &mut Vec<Vec<char>>, count: &mut Vec<Vec<usize>>) {
    if count[x+1][y] == 0 && field[x+1][y] == '.' {
        queue.push_front((x+1, y));
        field[x+1][y] = '#';
        count[x+1][y] = count[x][y] + 1;
    }
    if count[x-1][y] == 0 && field[x-1][y] == '.' {
        queue.push_front((x-1, y));
        field[x-1][y] = '#';
        count[x-1][y] = count[x][y] + 1;
    }
    if count[x][y+1] == 0 && field[x][y+1] == '.' {
        queue.push_front((x, y+1));
        field[x][y+1] = '#';
        count[x][y+1] = count[x][y] + 1;
    }
    if count[x][y-1] == 0 && field[x][y-1] == '.' {
        queue.push_front((x, y-1));
        field[x][y-1] = '#';
        count[x][y-1] = count[x][y] + 1;
    }
}

fn main() {
    let (h, w) = input_int_tuple();
    let mut field: Vec<Vec<char>> = Vec::new();
    let mut count: Vec<Vec<usize>> = Vec::new();
    field.push(vec!['#'; w+2]);
    count.push(vec![0; w+2]);
    for _ in 0..h {
        let line: String = input();
        let mut line: Vec<char> = line.chars().collect();
        line.insert(0, '#');
        line.insert(w+1, '#');
        field.push(line);
        count.push(vec![0; w+2]);
    }
    field.push(vec!['#'; w+2]);
    count.push(vec![0; w+2]);
    // println!("{:?}", field);
    // println!("{:?}", count);

    let mut queue: VecDeque<Point> = VecDeque::new();
    for i in 1..(h+1) {
        for j in 1..(w+1) {
            if field[i][j] == '#' {
                queue.push_front((i, j));
            }
        }
    }

    while queue.len() != 0 {
        let now = queue.pop_back().unwrap();
        push_queue(now.0, now.1, &mut queue, &mut field, &mut count);
    }

    let mut max = 0;
    for line in &count {
        for c in line {
            if *c > max {
                max = *c;
            }
        }
    }
    println!("{}", max);

}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	ll x, y = 1;
	cin >> x;
	while (y <= 1000) {
		for (ll i = -y; i <= y; ++i) {
			ll A = y, B = i;
			for (int j = 1; j < 5; ++j) A *= y, B *= i;
			if (A - B > 1e9) continue;
			if (A - B == x) {
				cout << y << ' ' << i;
				return 0;
			}
		}
		++y;
	}
}

Measured memory_bytes: 3644
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector<ll>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		ll dp[n];
		dp[0]=0;
		dp[1]=abs(v[1]-v[0]);
		for(ll i=2;i<n;i++){
			dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
		}
		cout<<dp[n-1]<<endl;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int D, G;
    cin >> D >> G;

    vector<int> p(D);
    vector<int> c(D);
    REP(i, D){
        cin >> p[i] >> c[i];
    }

    int ans = 1e+9;
    for(int pos = 0; pos < (1<<D); pos++){
        int s = 0, num = 0, rest_max = -1;
        REP(i, D){
            if (1 & pos >> i){
                s += 100 * (i+1) * p[i] + c[i]; //ボーナス迄考慮する
                num += p[i];
            }
            else{
                rest_max = i;
            }
        }
        if(s < G){
            int s1 = 100*(rest_max + 1);
            int need = (G - s + s1 - 1)/s1;
            if(need >= p[rest_max]){
                continue;   //選ばなかった中でも最大の者で満たせないならcontinue
            }
            num += need;    //満たせるならその回数を加算
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import numpy as np

  
def alpha2num(alpha):
    num=0
    for index, item in enumerate(list(alpha)):
        num += pow(26,len(alpha)-index-1)*(ord(item)-ord('A')+1)
    return num

N,L=map(int,input().split())
S=[]
l=[]
for i in range(N):
  S.append(input())
  l.append(alpha2num(S[i]))
l=np.array(l)
l=l.argsort()
s=""
for j in range(N):
  s+=S[l[j]]
print(s)


Measured memory_bytes: 12484
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	string ans = "No";
	if ((C > A && C < B) || (C > B && C < A))
		ans = "Yes";

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main(){
    int i,n,ans=0;
    cin>>n;
    vector<int> x;
    set<int> y;
    for(int j=0;j!=n;++j){
        cin>>i;
        x.push_back(i);
    }
    for(int j=0;j!=n;++j){
        if(y.find(j+1)==y.end() && x[x[j]-1]==j+1){
            ++ans;
            y.insert(x[j]);
        }
        else
            continue;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2936
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
// Seiranchan!
    int A,B,K;
    cin >> A >> B>> K;

    for(int i=A;i<=min(B,A+K-1);i++) cout << i << endl;
    for(int i=max(B-K+1,A+K);i<=B;i++) cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdbool.h>

int main(){
  char s[100];
  std::cin >> s;

  bool well = true;

  int i = 0;
  while(s[i]){
    if(i % 2 == 1 && s[i] == 'R'){
      well = false;
      break;
    }
    else if(i % 2 == 0 && s[i] == 'L'){
      well = false;
      break;
    }
    i++;
  }

  if(well == true) std::cout << "Yes\n";
  else std::cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[3][3];
        int[][] an = new int[3][3];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                a[i][j] = sc.nextInt();
                an[i][j] = 0;
            }
        }
        int n = sc.nextInt();
        for(int k=0;k<n;k++){
            int tmp = sc.nextInt();
            for(int i=0;i<3;i++){
                for(int j=0;j<3;j++){
                    if(tmp==a[i][j]){
                        an[i][j] = 1;
                    }
                }
            }
        }

        // for(int i=0;i<3;i++){
        //     for(int j=0;j<3;j++){
        //         System.out.print(an[i][j]);
        //     }
        //     System.out.println();
        // }

        

        // たて
        for(int i=0;i<3;i++){
            if(an[i][0]==1 && an[i][1]==1 && an[i][2]==1){
                System.out.print("Yes");
                return;
            }
        }

        // よこ
        for(int i=0;i<3;i++){
            if(an[0][i]==1 && an[1][i]==1 && an[2][i]==1){
                System.out.print("Yes");
                return;
            }
        }

        if(an[0][0]==1 && an[1][1]==1 && an[2][2]==1){
            System.out.print("Yes");
            return;
        }
        if(an[0][2]==1 && an[1][1]==1 && an[2][0]==1){
            System.out.print("Yes");
            return;
        }
        System.out.print("No");
    }
}


Measured memory_bytes: 23760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
struct node{
	int money;
	int a[15];
}c[15];

int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	int n,m,x;
	cin >> n >> m >> x;
	for(int i=0;i<n;i++){
		cin >> c[i].money;
		for(int j=0;j<m;j++){
			cin >> c[i].a[j];
		}
	}
	int minn=0x3f3f3f3f;
	for(int i=0;i<(1<<n);i++){
		node p;
		p.money=0;
		for(int j=0;j<m;j++)p.a[j]=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				p.money+=c[j].money;
				for(int k=0;k<m;k++){
					p.a[k]+=c[j].a[k];
				}
			}
		}
		int f=0;
		for(int j=0;j<m;j++){
			if(p.a[j]<x) f=1;
		}
		if(f==0){
			minn=min(minn,p.money);
		}
	}
	if(minn==0x3f3f3f3f)minn=-1;
	cout << minn << endl;
	return 0;	
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <unordered_set>
#define vector std::vector
#define string std::string
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define min(a, b) std::min(a, b)
#define max(a, b) std::max(a, b)

template <class T = int>
T in() { T x; std::cin >> x; return x; }
#define output(e) std::cout << e << "\n"

#ifdef LOCAL
#define db std::cout << "L" << __LINE__
#define de << "\n"
#define dv(x) << " " << #x << "->" << x
#else
#define db
#define de
#define dv(x)
#endif

//
// Implementation
//

#define MAX_N 100000

int N;
int M;
int p[MAX_N];

int par[MAX_N+1];
int rank[MAX_N+1];

void init(int n) {
  rep(i, n) {
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rank[x] < rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  scanf("%d %d", &N, &M);
  rep(i, N) scanf("%d", &p[i]);
  init(N);
  rep(i, M) {
    int x;
    int y;
    scanf("%d %d", &x, &y);
    unite(x, y);
  }

  int ans = 0;
  rep(i, N) {
    if (same(i+1, p[i])) {
      ans++;
    }
  }
  output(ans);
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,g;
inline int gcd(int a,int b) {
	return !b?a:gcd(b,a%b);
}
int main() {
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;++i) {
		int x;
		scanf("%d",&x);
		if (!i) g=x-m;
		else g=gcd(g,x-m);
	}
	printf("%d\n",g<0?-g:g);
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner in = new Scanner(System.in);
        String str1 = in.next();
        String str2 = in.next();
        int a = Integer.parseInt(str1);
        int b = Integer.parseInt(str2);
        int x = a * b;
        int y = ( a + b ) * 2;
        System.out.println(x+" "+y);
    }
}

Measured memory_bytes: 17120
#include <stdio.h>

int main()
{
    int time;
    int h,m,s;

    scanf("%d",&time);

    h = time/3600;
    m = (time - h*3600)/60;
    s = time - h*3600 - m*60;

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

    return 0;
}

Measured memory_bytes: 592
<?php


fscanf(STDIN, "%d", $n);

$kane = 100000;
for($i = 0; $i < $n; $i++){
$kane = 1.05 * $kane;
$high = pow(10, -3);
$kane = ceil( $kane * $high )/$high;

}


echo sprintf("%d\n", $kane);

Measured memory_bytes: 15300
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        System.out.println(z + " " + x + " " + y);
    }

}

Measured memory_bytes: 21844
import java.util.*
fun main(args:Array<String>?): Unit {
    val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val nodes = Array(n){Stack<Edge>()}
    repeat(n - 1){
        val (a, b, c) = readLine()!!.trim().split(' ').map(String::toInt)
        nodes[a - 1].add(Edge(b - 1, c))
        nodes[b - 1].add(Edge(a - 1, c))
    }
    val servers = readLine()!!.trim().split(' ').map(String::toLong).toLongArray()
    println(solve(servers, nodes).let{
        list -> list.take(Math.min(list.size, m)).fold(0L){a, b -> a + b}
    })
}
data class Edge(val to: Int, val distance: Int)
fun solve(servers: LongArray, nodes: Array<out Collection<Edge>>): LongArray {
    val parents = IntArray(nodes.size){-1}
    val cache = Array(nodes.size){ listOf<Int>()}
    fun sub(current: Int, prev: Int): List<Int> {
        return if (parents[current] == prev) cache[current]
        else {
            parents[current] = prev
            cache[current] = nodes[current].filterNot{it.to == prev}.flatMap{(to, distance) ->
                val res = sub(to, current)
                if (res.isEmpty()) listOf(distance)
                else listOf(res.drop(1), listOf(res.first() + distance)).flatten()
            }.sortedDescending()
            cache[current]
        }
    }
    return servers.indices.flatMap{i -> sub(i, nodes.size).map{it * servers[i]}}.sortedDescending().toLongArray()
}


Measured memory_bytes: 745276