akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	class Mark {
		int id;
		int correct;
		int time;
		int[] wrong;
		Mark(int id, int p) {
			this.id = id;
			correct = 0;
			time = 0;
			wrong = new int[p];
		}
	}
	
	void sort(Mark[] a) {
		int n = a.length;
		for (int i = n-1; i > 0; i--) {
			for (int j = 0; j < i; j++) {
				if (a[j].correct < a[j+1].correct ||
						(a[j].correct == a[j+1].correct && a[j].time > a[j+1].time)) {
					Mark temp = a[j];
					a[j] = a[j+1];
					a[j+1] = temp;
				}
			}
		}
	}
	
	void run() {
		int t, p, r;
		while (true) {
			t = sc.nextInt(); p = sc.nextInt(); r = sc.nextInt();
			if (t == 0) return;
			
			Mark[] result = new Mark[t];
			for (int i = 0; i < t; i++)
				result[i] = new Mark(i+1, p);
			
			for (int i = 0; i < r; i++) {
				int tid = sc.nextInt()-1, pid = sc.nextInt(), time = sc.nextInt();
				if (sc.next().equals("CORRECT")) {
					result[tid].correct++;
					result[tid].time += time + result[tid].wrong[pid-1]*1200;
				} else {
					result[tid].wrong[pid-1]++;
				}
			}
			
			sort(result);
			
			for (int i = 0; i < t; i++)
				out.printf("%d %d %d\n", result[i].id, result[i].correct, result[i].time);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main()
{
	int n;
	cin >> n;
	int A[3][101];
	for (int i = 1; i <= 2; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			cin >> A[i][j];
		}
	}
	int dp[3][101] = {};
	for (int i = 1; i <= 2; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + A[i][j];
		}
	}
	cout << dp[2][n] << endl;
	return 0;
}

Measured memory_bytes: 256
# include<stdio.h>
# include<string.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a[2][n],b[n],max;
	memset(b,0,sizeof(b));
	for(int i=0;i<2;i++)
		for(int j=0;j<n;j++)
			scanf("%d",&a[i][j]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<i+1;j++)
			b[i]+=a[0][j];
		for(int j=i;j<n;j++)
			b[i]+=a[1][j];
	}
	max=b[0];
	for(int i=0;i<n;i++)
	{
		if(max<b[i])
		max=b[i];
	}	
	printf("%d",max);
	return 0;	
 } 

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll nPr(int n, int r) {
    if (n < 0 || r < 0 || n < r) return 0;
    return fac[n] * finv[n - r] % mod;
}

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;

int main(){
    COMinit();
    ll n,m;cin>>n>>m;
    mint ans=nPr(m,n)*nPr(m,n);
    mint minus=0;
    for (int i = 1; i <= n; ++i) {
        if(i%2==0)minus-=COM(n,i)*nPr(m-i,n-i);
        else minus+=COM(n,i)*nPr(m-i,n-i);
    }
    minus*=nPr(m,n);
    ans-=minus;
    cout <<ans <<endl;
}

Measured memory_bytes: 15580
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    int n;
    cin >> n;
    vector<vector<int>> d(n);
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        d[i].push_back(a);
        d[i].push_back(b);
    }
    bool ok;
    rep(i,n-2) {
        ok = true;
        rep(j,3) {
            if(d[i+j][0] != d[i+j][1]) ok = false;
        }
        if(ok) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");

    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python

if __name__ == '__main__':
    while True :
        h, w = map(int, raw_input().split())
        if h == 0 and w == 0:
            break

        ht = "#"*w+"\n"
        md = "#"+"."*(w-2)+"#\n"
        print ht + md*(h-2) + ht



Measured memory_bytes: 4668
from collections import defaultdict as dd

class UnionFind(object):
    def __init__(self,n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self,a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def unite(self,a,b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self,a,b):
        return self.find(a)==self.find(b)

n,k,l=map(int,input().split())
uft_road=UnionFind(n)
uft_train=UnionFind(n)

for _ in range(k):
    p,q=map(int,input().split())
    uft_road.unite(p,q)

for _ in range(l):
    r,s=map(int,input().split())
    uft_train.unite(r,s)

dc=dd(int)
du={}
for i in range(1,n+1):
    du[i]=(uft_road.find(i),uft_train.find(i))
    dc[du[i]]+=1

print(*(dc[du[i]] for i in range(1,n+1)))

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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;
typedef vector<int> vi;
const int maxn = 100 + 10;

void printLCS(string& res, const vector<vector<int>>& memo, string s, int i, int j) {
    if (i == 0 || j == 0) {
        return;
    }
    if (memo[i][j] == 1) {
        printLCS(res, memo, s, i - 1, j - 1);
        res += s[i - 1];
    } else if (memo[i][j] == 2) {
        printLCS(res, memo, s, i - 1, j);
    } else {
        printLCS(res, memo, s, i, j - 1);
    }
}

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1));
    vector<vector<int>> memo(s.length() + 1, vector<int>(t.length() + 1));
    for (int i = 1; i <= s.length(); ++i) {
        for (int j = 1; j <= t.length(); ++j) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                memo[i][j] = 1;
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    memo[i][j] = 2;
                } else {
                    memo[i][j] = 3;
                }
            }
        }
    }
    string res;
    printLCS(res, memo, s, s.length(), t.length());
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 71040
using System;

namespace AOJ.Volume2
{
    public class WalkingInTheHospital
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }

                int no = 0;
                int dist = 0;
                for (int i = 0; i < n; i++)
                {
                    var input = Console.ReadLine().Split(' ');
                    int tmp = int.Parse(input[1]) + int.Parse(input[2]);
                    if (tmp > dist)
                    {
                        no = int.Parse(input[0]);
                        dist = tmp;
                    }
                }

                Console.WriteLine("{0} {1}", no, dist);
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9388
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n");
}



static int count = 0;
vector<int> insertionSort(vector<int> list, int gap){
    for(int i = 0; i < list.size(); i++){
        int firstValue = list[i];
        int j = i - gap;
        for(; 0 <= j && firstValue < list[j]; j -= gap){            
            list[j + gap] = list[j];
            count++;
        }
        list[j + gap] = firstValue;
    }
    return list;
} 


vector<int> createGaps(int max) {
    vector<int> gaps;
    gaps.push_back(1);
    for (int i = 0; i < max; i++){
        int gap = 3 * gaps[i] + 1;
        if (max <= gap) break;
        gaps.push_back(gap);
    }
    std::reverse(gaps.begin(), gaps.end());
    return gaps;
}

void solve() {
    int n;
    scanf("%d", &n);
    vector<int> list(n);
    for (int i = 0; i < n; i++) {
        int v;
        scanf("%d", &v);
        list[i] = v;
    }    

    auto result = list;
    auto gaps = createGaps(n);
    for(int i = 0; i < gaps.size(); i++){
        result = insertionSort(result, gaps[i]);
    }
    printf("%zu\n", gaps.size());
    printList(gaps);
    printf("%d\n", count);
    for(auto each: result) {
        printf("%d\n", each);
    }
    // printList(result);    
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    
    solve();
    
    return 0;
}


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

int main() {
	int n; cin>>n;
	int k; cin>>k;
	int arr[1005];
	int total=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	for(int i=0;i<k;i++)
	{
		total+=arr[i];
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 3632
n = int(input())
l = list()
for i in range(n):
    l.append(list(map(int, input().split())))

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

t = 0
for i in range(n):
    t += l[i][0]
    if t > l[i][1]:
        print("No")
        exit()

print("Yes")

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n,x,y;
    cin>>n>>x>>y;
    x--;
    y--;

    vi ans(n);

    rep(i,n-1){
        repa(j,i+1,n){
            int d=j-i;
            cmin(d,abs(i-x)+abs(j-y)+1);
            cmin(d,abs(j-x)+abs(i-y)+1);
            ans[d]++;
        }
    }

    repa(i,1,n){
        cout<<ans[i]<<"\n";
    }

    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
XY = [list(map(int,input().split())) for _ in [0]*N]

iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}

c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y in XY:
    c[Y[y]+1][X[x]+1] = 1

for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i+1][j]
for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i][j+1]

ans = 10**20
for l in range(N):
    for u in range(N):
        for r in range(l+1,N):
            for d in range(u+1,N):
                if c[d+1][r+1]+c[u][l]-c[u][r+1]-c[d+1][l] >=K:
                    ans = min(ans,
                             (iX[r]-iX[l])*(iY[d]-iY[u]))
                    break

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main(){
  int N; cin >> N;
  vector<vector<int> > G(N);
  vector<P> vp;
  for( int i = 1; i < N; i++ ){
    int a, b; scanf("%d%d", &a, &b); --a; --b;
    G[a].push_back(b); G[b].push_back(a);
    vp.push_back(P(a, b));
  }
  vector<int> used(N, -1), color(N, 0);
  map<P, int> MAP;
  queue<int> que; que.push(0); used[0] = 0; 
  int MAX_COLOR = 0;

  while(que.size()){
    int v = que.front(); que.pop();
    int num = 1;
    for( int i = 0; i < G[v].size(); i++ ){
      int u = G[v][i];
      if( used[u] != -1 ) continue;
      if( color[v] == num ) num++;
      used[u] = 0; color[u] = num;
      MAP[P(u, v)] = num;
      MAP[P(v, u)] = num;
      num++;
      que.push(u);
    }
    MAX_COLOR = max(MAX_COLOR, int(G[v].size()));
  }
  cout << MAX_COLOR << '\n';
  for( auto p : vp ) cout << MAP[p] << '\n';
}

Measured memory_bytes: 20084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl                        '\n'
#define debug(x)                    cerr << #x << ": " <<  x << endl;
#define fast_io;                 ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll MAXN=1e6 + 10;
const ll INF=8e18;
const ll MOD=1e9 + 7; // 998244353; // 1e9 + 9;
void solve(){
ll n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++){
      cin>>a[i];
}
sort(a,a+n);
if(n%2==1){
      if(a[0]!=0){
            cout<<0<<endl;
            return;
      }
   for(int i=1;i<n;i++){
      if(i%2==1&&a[i]!=a[i+1]){
            cout<<0<<endl;
            return;
      }
      if(a[i]!=a[i-1]+2&&i%2==0&&a[i]!=a[i-1]){
            cout<<0<<endl;
            return;
      }
   }
   ll ans=1;
   n/=2;
   for(int i=0;i<n;i++){
      ans=((ans%MOD)*2)%MOD;
   }
   cout<<ans<<endl;
   return;
}
      if(a[1]!=1&&a[0]!=1){
            cout<<0<<endl;
            return;
      }
   for(int i=2;i<n;i++){
      if(i%2==0&&a[i]!=a[i+1]){
            cout<<0<<endl;
            return;
      }
      if(a[i]==a[i-1]+2&&i%2==1&&a[i]==a[i-1]){
            cout<<0<<endl;
            return;
      }
   }
      ll ans=1;
   n/=2;
   for(int i=0;i<n;i++){
      ans=((ans%MOD)*2)%MOD;
   }
   cout<<ans<<endl;
}
int main(){
	fast_io;
	ll t;
	//cin>>t;
     // while(t--){
        solve();
	//}
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [1]
for i in range(n-1):
  c = [c[0]*(i+1)] + c
#print(c)
A = 0
for i in range(n):
  now = a[i]
  cnt = 0
  for k in range(i+1,n):
    if a[k] < now:
      cnt += 1
  A += c[i] * cnt
B = 0
for i in range(n):
  now = b[i]
  cnt = 0
  for k in range(i+1,n):
    if b[k] < now:
      cnt += 1
  B += c[i] * cnt
print(abs(A-B))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5;
int n, h[N], k, dp[N];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	fw (i, 0, n) cin >> h[i];
	memset(dp, 63, sizeof dp);
	dp[0] = 0;
	fw (i, 0, n) {
		fw (j, 1, k + 1) if (i + j < n) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
		}
//		cout << "dp[" << i <<"] = " << dp[i] << "\n";
	}
	cout << dp[n - 1];
	return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if((a + b) >= k){
        cout << min(a, k) << endl;
    }
    else{
        cout << 2 * a + b - k << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
class modint{
public:
  long long x;
  constexpr modint(long long x=0):x((x%MOD+MOD)%MOD){}
  constexpr modint operator-() const{return modint(-x);}
  constexpr modint& operator+=(const modint& a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator-=(const modint& a){
    if((x+=MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator*=(const modint& a){
    (x*=a.x)%=MOD;
    return *this;
  }
  constexpr modint operator+(const modint& a) const{return modint(*this)+=a;}
  constexpr modint operator-(const modint& a) const{return modint(*this)-=a;}
  constexpr modint operator*(const modint& a) const{return modint(*this)*=a;}
  constexpr bool operator==(const modint& a) const{return this->x==a.x;}
  constexpr bool operator!=(const modint& a) const{return this->x!=a.x;}
  constexpr modint pow(long long expo) const{
    if(expo==0)  return 1;
    modint a=pow(expo>>1);
    a*=a;
    if(expo&1)  a*=(*this);
    return a;
  }
  //for prime MOD
  constexpr modint inv() const{return pow(MOD-2);}
  constexpr modint& operator/=(const modint& a){return (*this)*=a.inv();}
  constexpr modint operator/(const modint& a) const{return modint(*this)/=a;}
};
istream& operator>>(istream& is,const modint& a){return is >> a.x;}
ostream& operator<<(ostream& os,const modint& a){return os << a.x;}

//for binomial coefficients
const int MAX=510000;
vector<modint> fac(MAX,0);
vector<modint> finv(MAX,0);
vector<modint> inv(MAX,0);
void COMinit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(int i=2;i<MAX;i++){
    fac.at(i)=fac.at(i-1)*i;
    inv.at(i)=-inv.at(MOD%i)*(MOD/i);
    finv.at(i)=finv.at(i-1)*inv.at(i);
  }
}
modint COM(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0)  return 0;
  return fac.at(n)*finv.at(k)*finv.at(n-k);
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,S;
  cin >> N >> S;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);

  vector<vector<modint>> dp(N+1,vector<modint>(S+1,0));
  dp.at(0).at(0)=1;
  for(int i=1;i<N+1;i++){
    for(int j=0;j<S+1;j++){
      dp.at(i).at(j)+=dp.at(i-1).at(j)*2;
      if(j-A.at(i-1)>=0) dp.at(i).at(j)+=dp.at(i-1).at(j-A.at(i-1));
    }
  }
  cout << dp.at(N).at(S) << endl;

  return 0;
}

Measured memory_bytes: 85556
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  while(scanf("%d",&n), n){
    vector<pair<int,pair<int,pair<int,char> > > > v(n);
    REP(i,n){
      char c;
      scanf(" %c ",&c);
      int w=0, l=0;
      REP(j,n-1){
	int a; scanf("%d",&a);
	if(a == 0) w++;
	else if(a==1) l++;
      }
      v[i] = mp(-w, mp(l, mp(i, c)));
    }
    sort(v.begin(), v.end());
    REP(i,n)
      printf("%c\n",v[i].s.s.s);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
  long long A,B,K;

  cin >> A >> B >> K;

  if(A-K>0)
    A = A-K;
  else if(A+B>K)
    {
      B +=- K+A;
      A = 0;
    }
  else
    A=B=0;
  
  cout << fixed << setprecision(9);
  cout << A << " " << B;


  return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
	"math"
)

var INF int32 = math.MaxInt32
var INF64 int64 = math.MaxInt64

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineNum64s(bf *bufio.Reader) []int64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int64{}
	for _, field := range fields {
		num, _ := strconv.ParseInt(field, 10, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []float64{}
	for _, field := range fields {
		num, _ := strconv.ParseFloat(field, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func main() {
	bf := bufio.NewReader(os.Stdin)
	N := readLineNums(bf)[0]
	X := readLineNums(bf)
	ans := int(INF)
	for p:=1; p<=N*100; p++ {
		c := 0
		for _, x := range X {
			c += (x-p)*(x-p)
		}
		ans = min(ans, c)
	}
	fmt.Println(ans)
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n;
int a[N], l[N], r[N];

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
	
	for (int i = 1; i <= n; i ++ ) l[i] = gcd(l[i - 1], a[i]);
	for (int i = n; i >= 1; i -- ) r[i] = gcd(r[i + 1], a[i]);
	
	int res = 0;
	for (int i = 1; i <= n; i ++ ) res = max(res, gcd(l[i - 1], r[i + 1]));
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
pena = [0 for i in range(n)]
cor = set([])
for i in range(m):
    pi, si = input().split()
    pi = int(pi) - 1
    if si == 'AC':
        cor.add(pi)
    else:
        if pi not in cor:
            pena[pi] += 1

ans = 0
for i in cor:
    ans += pena[i]
print(len(cor), ans)

Measured memory_bytes: 88040
H,W=map(int,input().split())
S=[]
for _ in range(H):
    a=["."]
    a.extend(list(map(str,input())))
    a.append(".")
    S.append(a)

S.insert(0,["."]*(W+2))
S.insert(H+1,["."]*(W+2))

# print(S)

for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=='.':
            S[i][j]=str((S[i-1][j-1:j+2]+S[i][j-1:j+2]+S[i+1][j-1:j+2]).count('#'))
    print(''.join(S[i][1:-1]))

Measured memory_bytes: 3188
h, w = map(int, input().split())
a = []
for _ in range(h):
    x = input()
    if "#" in x:
        a.append(x)
    else:
        h -= 1
for i in range(w - 1, -1, -1):
    for j in range(h):
        if a[j][i] == "#":
            break
    else:
        for k in range(h):
            a[k] = a[k][:i] + a[k][i + 1 :]
print(*a, sep="\n")

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, M;
    string S;
    cin >> N >> M >> S;
    set<int> s[N][2];
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(S[a] == 'A') s[b][0].insert(a);
        else s[b][1].insert(a);
        if(S[b] == 'A') s[a][0].insert(b);
        else s[a][1].insert(b);
    }
    int cnt = 0;
    queue<int> que;
    bool able[N];
    fill_n(able, N, true);
    rep(i, N){
        if(s[i][0].size()*s[i][1].size() == 0){
            cnt++;
            able[i] = false;
            que.push(i);
        }
    }
    while(!que.empty()){
        int p = que.front();
        que.pop();
        rep(i, 2){
            set<int>::iterator ite = s[p][i].begin();;
            rep(j, s[p][i].size()){
                int q = *ite;
                if(S[p] == 'A') s[q][0].erase(p);
                else s[q][1].erase(p);
                if(able[q] && s[q][0].size()*s[q][1].size() == 0){
                    cnt++;
                    able[q] = false;
                    que.push(q);
                }
                ite++;
            }
        }
    }
    if(cnt == N) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 36740
import java.util.Scanner;

public class Main {

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

        long a = sc.nextLong();
        long b = sc.nextLong();

        long result =  a * b / gcd(a, b);

        System.out.println(result);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b && b==c) {
        cout<<"1"<<endl;
    }else if((a==b && b!=c) || (a==c && a!=b) || (b==c && a!=c)){
        cout<<"2"<<endl;
    }else{
        cout<<"3"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, ans;
vector<int> a;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) {
        while (a[i]%2 == 0) {
            a[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#if !testing
#define cerr if(0)cout
#endif
int A[105];
int32_t main() 
{
	IAMSPEED
	int n,k; cin >> n >> k;
	FOR(i,1,k) {
		int d; cin >> d;
		FOR(j,1,d) {
			int x; cin >> x;
			++A[x];
		}
	}
	int ans = 0;
	FOR(i,1,n)if(A[i]==0)++ans;
	cout<<ans;
}



Measured memory_bytes: 3644
#include <cstdio>
#include <complex>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

typedef complex<double> point_t;
typedef pair<point_t,double> circle_t;

const double eps=1e-9;

circle_t cs[62];
point_t meats[62];
double hardness[62];

int N,K;

void add_intersect(const circle_t & c1,const circle_t & c2,vector<point_t> & v){
    auto d=abs(c1.first-c2.first);
    auto rc=(d*d+c1.second*c1.second-c2.second*c2.second)/(2*d);
    auto diff=c1.second*c1.second-rc*rc;

    if (abs(diff)<eps) diff=0.;

    if (diff<0.) return;
    auto rs=sqrt(diff);

    auto dir=(c2.first-c1.first)/d;

    if (diff==0.) v.push_back(c1.first+dir*point_t(rc,rs));
    else {
        v.push_back(c1.first+dir*point_t(rc,rs));
        v.push_back(c1.first+dir*point_t(rc,-rs));
    }
}

int cnt(const point_t &  p){
    int ret=0;

    for(int i=1;i<=N;i++){
        // printf("r=%lf\n",cs[i].second);
        auto dist=abs(cs[i].first-p);
        // printf("dist=%lf\n",dist);
        if (dist < cs[i].second + eps) ret++;
    }
    // printf("pos=%lf,%lf ret=%d\n",p.real(),p.imag(),ret);
    return ret;
}

bool valid(){
    vector<point_t> candidate;
    for(int i=1;i<=N;i++) candidate.push_back(meats[i]);

    for(int i=1;i<=N;i++)
        for(int j=i+1;j<=N;j++)
             add_intersect(cs[i],cs[j],candidate);

    for(auto &p:candidate) if (cnt(p)>=K) return true;

    return false;
}

int main(){
    scanf("%d%d",&N,&K);
    for(int i=1;i<=N;i++){
        double x,y,c;
        scanf("%lf%lf%lf",&x,&y,&c);
        meats[i]=point_t(x,y);
        hardness[i]=c;

    }
    
    double l=0.0,r=1e6;
    double ans=r;
    for(int i=1;i<100;i++){
        auto mid=(l+r)/2.;
        for(int i=1;i<=N;i++)
            cs[i]=circle_t(meats[i],mid/hardness[i]);

        if (valid()) r=mid,ans=mid;
        else l=mid;
    }

    printf("%.7lf\n",r);
    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def lis(A):
    N = len(A)
    LIS = []

    for i in range(N):
        index = bisect_left(LIS, A[i])
        if index >= len(LIS):
            LIS.append(A[i])
        else:
            LIS[index] = A[i]

    return len(LIS)


def func(A):
    return lis(A), lis([-1 * a for a in A])


def solve(N, A, B):
    ans = []
    now = 1
    num = 0
    while now <= N:
        for i in range(min(N, now + B - 1), now - 1, -1):
            ans.append(i)
        now += B
        num += 1
        rest = N - now + 1
        if 1 + rest - B < A - num:
            break

    for _ in range(A - num - 1):
        ans.append(now)
        now += 1
        num += 1
        if now == N:
            break

    use = False
    for i in range(N, now - 1, -1):
        ans.append(i)
        use = True

    if num + use != A:
        return [-1]

    return ans


def check(N, A, B):
    for p in permutations(range(1, N + 1)):
        if (A, B) == func(list(p)):
            return list(p)
    return [-1]


def main():
    N, A, B = map(int, input().split())
    ans = solve(N, A, B)
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27696
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <stack>
using namespace std;
using ll = long long int;

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n+1);
    a[0] = 0;
    for(int i=0; i<n; i++){
        cin >> a[i+1];
        a[i+1] += a[i];
    }
    vector<ll> beauty;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n+1; j++){
            beauty.push_back(a[j] - a[i]);
        }
    }
    ll len = n*(n+1)/2;
    vector<int> discard(len, 0);
    ll ans = 0;
    for(ll i=40; i>-1; i--){
        int bit_count = 0;
        for(int j=0; j<len; j++){
            if(discard[j] == 1){continue;}
            if(beauty[j] & (1L << i)){bit_count++;}
        }
        if(bit_count >= k){
            ans += (1L << i);
            for(int j=0; j<len; j++){
                if(!(beauty[j] & (1L << i))){discard[j] = 1;}
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6260
import itertools
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# 解説AC
N = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()


def test(N, S):
    import numpy as np
    S = np.array(list(S))
    ret = 0
    for r in itertools.combinations(range(N * 2), r=N):
        r = np.array(np.bincount(r, minlength=N * 2), dtype=bool)
        red = ''.join(S[r])
        blue = ''.join(S[~r])
        ret += red == blue[::-1]
    return ret


# print(test(N, S))

S, T = S[:N], S[:N - 1:-1]

t_counts = defaultdict(int)
for choice in itertools.product([0, 1], repeat=N):
    t = ''
    rev = ''
    for i, c in enumerate(choice):
        t += T[i] if c else ''
        rev += '' if c else T[i]
    t_counts[(t, rev)] += 1

ans = 0
for choice in itertools.product([0, 1], repeat=N):
    s = ''
    rev = ''
    for i, c in enumerate(choice):
        s += S[i] if c else ''
        rev += '' if c else S[i]
    ans += t_counts[(s, rev)]
print(ans)


Measured memory_bytes: 166888
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			System.out.printf("#");
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
	
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    }

Measured memory_bytes: 61584
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
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 ALL(c) (c).begin(), (c).end()

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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    int array[] = {0, 3, 5, 7};
    REP(i, (int)1e7) {
        ll x = 0;
        ll tmp = i;
        int d = 0;
        while(tmp > 0) {
            x += array[tmp % 4] * (ll)pow(10, d);
            tmp /= 4;
            d++;
            if(d > 10) break;
        }
        if(x > (ll)n) break;
        // cerr << x << endl;
        string x_str = to_string(x);
        if(x_str.find('7') != string::npos and
            x_str.find('5') != string::npos and
            x_str.find('3') != string::npos and
            x_str.find('0') == string::npos
        ) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int c = scan.nextInt();
        int[] b = new int[m];
        for(int i = 0; i < m; i++) b[i] = scan.nextInt();
        int[][] a = new int[n][m];
        for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) a[i][j] = scan.nextInt();
        int out = 0;
        for(int i = 0; i < n; i++){
            int sum = 0;
            for(int j = 0; j < m; j++){
                sum += a[i][j] * b[j];
            }
            sum += c;
            if(sum > 0) out++;
        }
        System.out.println(out);
        scan.close();
    }
}


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

using namespace std;

long long n, k, s, p, r, ans;
string t;

int main() {
    cin >> n >> k;
    cin >> s >> p >> r;
    cin >> t;

    for (long long i = 0; i < k; i++) {
        bool flag = false;
        for (long long j = i; j < n; j += k) {
            if (j >= k && !flag && t[j] == t[j - k]) flag = true;
            else {
                flag = false;
                if (t[j] == 's') ans += s;
                if (t[j] == 'p') ans += p;
                if (t[j] == 'r') ans += r;
            } 
        }
    }

    cout << ans << '\n';
}

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

int main() {
  string S;
  cin >> S;
  if (S == "ARC") cout << "ABC" << endl;
  if (S == "ABC") cout << "ARC" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    ll h,a;
    cin >> h >> a;
    ll ans = 0;
    ans = h/a;
    if(h%a != 0){
        ans += 1;
    }
    cout << ans << endl;
}


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

int main(){
  int N,i,j;
  int A = 0;
  
  cin >> N; //
  vector <int> a(N); // 0 1 
 
  for(i=0; i<N; i++){
      cin >> a.at(i);  // 0:3 1:1
  }
  sort(a.begin(),a.end()); // 1 3
  reverse(a.begin(),a.end()); // 3 1
  
  for(i=0; i<N; i+=2){
      A = A + a.at(i); 
    }
  for(i=1; i<N; i+=2){
     A = A - a.at(i); 
    }
  cout << A << endl;

return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
dic = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0}
count = 0
for a in A:
  if a < 400:
    dic[1] += 1
  elif 400 <= a < 800:
    dic[2] += 1
  elif 800 <= a < 1200:
    dic[3] += 1
  elif 1200 <= a < 1600:
    dic[4] += 1
  elif 1600 <= a < 2000:
    dic[5] += 1
  elif 2000 <= a < 2400:
    dic[6] += 1
  elif 2400 <= a < 2800:
    dic[7] += 1
  elif 2800 <= a < 3200:
    dic[8] += 1
  else:
    count += 1
total = 0
for i in range(1, 9):
  if dic[i] != 0:
    total += 1
m = total + count
if total == 0:
  print(1, m)
else:
  print(total, m)


Measured memory_bytes: 3064
function main(input) {
const a = input.split("\n");
  console.log(a[0]=="a"? "vowel"
			 :a[0]=="e"? "vowel"
             :a[0]=="i"? "vowel"
		     :a[0]=="o"? "vowel"
			 :a[0]=="u"? "vowel"
			 :"consonant");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29404
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CSumOfGcdOfTuplesEasy {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int K; cin >> K;
      ll ans = 0;
      for(int i=1; i<=K; i++) {
        for(int j=1; j<=K; j++) {
          for(int k=1; k<=K; k++) {
            ans += gcd(gcd(i, j), k);
          }
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  CSumOfGcdOfTuplesEasy solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3656
// jha4032

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int 
#define mp make_pair
#define M 1000000007
#define N 1000006
void fast()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

ll power(ll a, ll b)
{
  if (b == 0)
    return 1;
  ll tmp = power(a, b / 2)%M;
  tmp = (tmp * tmp )%M ;
  if (b & 1)
    return (tmp * a )%M ;
  return tmp;
}
ll fact[N], invfact[N];
ll ans=0;
void pre1()
{
  fact[0] = 1;
  invfact[0] = power(fact[0], M - 2);
  for (int i = 1; i < N; i++)
  {
    fact[i] = (i * fact[i - 1]) % M;
    invfact[i] = power(fact[i], M - 2);
  }
}


ll n;
ll a[100005];	
ll dp[100005];
ll fn(int i){
   if(i==n-1) return 0; 
   if(dp[i]!=-1) return dp[i];
   ll a1 = 1e15 ,a2 = 1e15;
   a1 = abs(a[i+1]-a[i]) + fn(i+1);
   if(i<n-2)
   a2 = abs(a[i+2]-a[i]) + fn(i+2);
   return dp[i] = min(a1,a2);
}



int main(){
memset(dp,-1,sizeof dp);
//dp[0]=0;
cin>>n;
for(int i=0;i<n;i++){
	 cin>>a[i];
}
cout<<fn(0)<<endl;

}

Measured memory_bytes: 4992
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    A, B = readline() |> split |> parseMap
    C = 0

    for i = A:B
        temp = string(i)
        temp_r = reverse(temp)
        if temp == temp_r
            C = C + 1
        end
    end
    println(C)
end

main()

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int a = 0;
  for(char ch : s) {
    a += ch-'0';
  }
  if(a%9==0) {
    cout<<"Yes\n";
  } else {
    cout<<"No\n";
  }
  return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int c[3] = { };
  for (int i = 0; i < n; i++) {
	  int in;
	  cin >> in;
	  if (in <= a) {
		  c[0]++;
		} else if (in <= b) {
		  c[1]++;
		} else {
		  c[2]++;
		}
	}
  cout << min(c[0], min(c[1], c[2])) << endl;
  return 0;
}


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

int main() {
    int i,j,n;
    int f=0;
    int sum=0;
    cin >> n;
    int h[n];
    for(i=0; i<n; i++){
        cin >> h[i];
    }
    for(i=0; i<n; i++){
        for(j=0; j<i; j++){
            if(h[j]>h[i]){f=1;}
        }
        if(f==0){sum++;}
        f=0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import*
n,*t=map(int,open(0).read().split())
e={0}
for a in zip(t[1::2],t[2::2]):e|={a,a[::-1]}
print(sum(all(u in e for u in zip(t,t[1:]))for t in permutations(range(1,n+1))if t[0]<2))

Measured memory_bytes: 43100
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

bool overflow(long double a, long double b) {
	long double res = a * b;
	if(res > 1e18)
		return 1;
	return 0;
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	int n;
	ll res = 1, a;
	cin >> n;
	bool zero = 0;
	bool can = 1;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if(!a)
			zero = 1;
		if(overflow(res, a)) {
			can = 0;
			continue;
		}
		res *= a;
	}
	if(zero) {
		cout << 0;
		return 0;
	}
	if(!can)
		cout << -1;
	else
		cout << res;
	return 0;
}


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

string s;
int y,m,d;

int main(){
  int i,j;
  bool ch =0;
  while(1){
    cin >> s;
    if(s=="#")break;
    ch = 0;
    cin >> y >> m >> d;
    if(y>31)ch=1;
    else if(y==31&&m>4)ch=1;
    if(ch==1)cout << "? " <<y-30 <<" "<< m <<" " << d<<endl;
    else cout << s <<" " << y << " " << m << " " << d<<endl;
  }
  return 0;
}



Measured memory_bytes: 3044