akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mo 998244353
long long n,i,j,m[100005],ha[100005],ans,sum;
char s[100005][15];
long long read(){
	long long xx=0,flag2=1;
	char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')
		ch=getchar();
	if(ch=='-'){
		flag2=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		xx=xx*10+ch-'0';
		ch=getchar();
	}
	return flag2*xx;
}
int main(){
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		m[i]=strlen(s[i]+1);
		sort(s[i]+1,s[i]+m[i]+1);
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=m[i];j++)
			ha[i]=ha[i]*26+s[i][j]-'a'+1;
	sort(ha+1,ha+n+1);
	for(i=1;i<=n;i++)
		if(ha[i]==ha[i-1]||i==1){
			ans+=sum;
			sum++;
		}
		else{
			sum=1;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  h,w,i,j,count,x,y,sw,m,n,c,a,b:Integer;
  //a:array of string;
  s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Readln(b);

    if a+b>=10 then
      Writeln('error')
    else
      Writeln(a+b);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), ans = 0;
		if(b * 2 <= a){
			ans = a - (b * 2);
		}else {
			ans = 0;
		}
		System.out.println(ans);
	}
}

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

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

int main(){
    int h,w;
    cin>>h>>w;
    char m[25][25];
    for(int i=0;i<h;i++) cin>>m[i];

    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(m[i][j]=='#') continue;
            queue<pair<int,int>> q;
            vector<vector<int>> d(h,vector<int>(w,1e9));
            d[i][j]=0;
            q.push(make_pair(j,i));
            while(!q.empty()){
                int x=q.front().first;
                int y=q.front().second;
                q.pop();
                for(int i=0;i<4;i++){
                    int nx=x+dx[i];
                    int ny=y+dy[i];
                    if(nx<0||nx>=w||ny<0||ny>=h||m[ny][nx]=='#'||d[ny][nx]!=1e9) continue;
                    d[ny][nx]=d[y][x]+1;
                    q.push(make_pair(nx,ny));
                }
            }
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(d[i][j]==1e9) continue;
                    ans=max(ans,d[i][j]);
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, c;
    cin >> a >> b >> c;

    ll ans = 0;
    if (a < b) {
        if (b < c) {
            ans = a+b;
        } else {
            ans = a+c;
        }
    } else {
        if (a < c) {
            ans = a+b;
        } else {
            ans = b+c;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    ll x;
    cin >> x;
    ll cnt = 0;
    ll m = 100;
    while(m<x)
    {
        m *= 1.01;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  cout << 6 - A - B << endl;
  return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 0 , 1 } ;
const int dy[] = { 0 , -1 , 1 , 0 } ;

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    ll a , b , c ;
    cin >> a >> b >> c ;

    ll s = a + b + c ;
    if ( s >= 22 ) cout << "bust" ;
    else cout << "win" ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
N_str, K=input().split()
K=10-int(K)
N_digit=list(map(int,list(N_str)))
D=sorted(list(map(int,input().split())))
D=[d for d in range(10) if d not in D]

l_digit=[n>D[-1] for n in N_digit]

if any(l_digit):
  N_n=l_digit.index(True)
  if not any([n is not D[-1] for n in N_digit[0:N_n]]):
    out=list(str(D[1] if D[0]==0 else D[0]))
    out+=[str(D[0]) for i in range(len(N_digit))]
  else:
    flag=False
    out=[]
    for i in range(N_n):
      if not flag:
      	for j in range(K):
          if D[j]>=N_digit[i]:
            out.append(str(D[j]))
            if D[j]!=N_digit[i]:
              flag=True
              break
      else:
        out.append(str(D[0]))
    for i in range(N_n,len(N_digit)):
      out.append(str(D[0]))
else:
  out=[]
  flag=False
  for n in N_digit:
    if not flag:
      for j in range(K):
        if D[j]>=n:
          out.append(str(D[j]))
          if D[j]>n:
            flag=True
          break
    else:
      out.append(str(D[0]))
      
print(int("".join(out)))

Measured memory_bytes: 3064
N=int( input() )
S=input().split(" ")

for i in range ( N ) :
    S[i] = int(S[i])

A = []
num = 0
for i in range ( N - 2 ) :
    A.append ( ( S[i+2]-S[i+1] ) * ( S[i+1]-S[i] ) )
    if A[i] > 0:
        num = num + 1

print ( num )    


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

bool is_leap(int n) {
    if (n % 400 == 0) {
        return true;
    } else if (n % 100 == 0) {
        return false;
    } else if (n % 4 == 0) {
        return true;
    }
    return false;
}

void solve(int b, int e) {
    bool leap_exist = false;
    for (int i = b; i <= e; i++) {
        if (is_leap(i)) {
            leap_exist = true;
            cout << i << endl;
        } 
    }
    if (!leap_exist) {
        cout << "NA" << endl;
    }
}

int main() {
    int b, e;
    if (cin >> b >> e) {
        if (b == 0 && e == 0) return 0;
        solve(b, e);
    }
    while (cin >> b >> e) {
        if (b == 0 && e == 0) break;
        cout << endl;
        solve(b, e);
    }
    return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, m = LI()
    par = [i for i in range(n)]
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]
    def unite(x, y):
        x = root(x)
        y = root(y)
        if y < x: x, y = y, x
        par[y] = x
        return
    ling = [[] for i in range(m)]
    for i in range(n):
        kl = LI()
        for l in kl[1:]:
            ling[l-1].append(i)
    for l in ling:
        if l:
            l0 = l[0]
            for li in l[1:]:
                unite(l0, li)
    for i in range(n):
        root(i)
    print("YES" if len(set(par)) == 1 else "NO")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 74160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    if(n >= 30){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    char s[4];
    int cnt=0,max=0;
    scanf("%s",s);
    for(int i=0;i<3;i++){
        if(s[i]=='R') cnt++;
        else{
            if(cnt>max) max=cnt;
            cnt=0;
        }
    }
    if(cnt>max) max=cnt;
    printf("%d",max);
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    string t=s;
    reverse(s.begin(),s.end());
    int n=s.size();
    n/=2;
    int ans=0;
    rep(i,n){
        if (s[i]!=t[i])ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL a(n + 2);
  REP(i, 0, n) {
    cin >> a[i + 1];
  }
  a[n + 1] = a[0] = 0;
  ll tot = 0;
  REP(i, 0, n + 1) {
    tot += abs(a[i + 1] - a[i]);
  }
  REP(i, 1, n + 1) {
    cout << tot + abs(a[i + 1] - a[i - 1]) - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) << endl;
  }
}


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

int main() {
  int n;
  cin >> n;
  int all_data = 0; //重りすべての重さ
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
    all_data += data.at(i);
  }
  int b = 0;
  vector<int> s1(n); //i番目で区切った時のs1
  vector<int> s2(n); //s2
  for(int i = 0; i < n; i++){
    b += data.at(i);
    s1.at(i) = b;
    s2.at(i) = all_data - b; //エラーでるかも
  }
  vector<int> answer(n - 1);
  for(int i = 0; i < n - 1; i++){
    answer.at(i) = abs(s1.at(i) - s2.at(i));
  }

  sort(answer.begin(), answer.end());
  cout << answer.at(0) << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m,tmp1,tmp2,flag=1;
  cin >> n >> m;
  vector<int> vec(n,0);
  map<int,int> mp;
  rep(i,m){
    cin >> tmp1 >> tmp2;
    if(mp.count(tmp1)){
      if(tmp2!=vec.at(tmp1-1)){
        flag=0;
        break;
      }
    }
    mp[tmp1]=1;
    vec.at(tmp1-1)=tmp2;
  }
  if(n>1){
  	if(mp.count(1)&&vec.at(0)==0)flag=0;
  	if(!mp.count(1))vec.at(0)=1;
  }
  if(!flag)cout << -1 << endl;
  else{
    rep(i,n)cout << vec.at(i);
    cout << endl;
  }
}

Measured memory_bytes: 256
from typing import List, Tuple


def selection_sort(A: List[int]) -> Tuple[List[int], int]:
    count: int = 0

    for i in range(len(A)):
        min_j: int = i
        for j in range(i, len(A)):
            if A[j] < A[min_j]:
                min_j = j
        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            count += 1

    return A, count


def main():
    _ = input()
    A: List[int] = list(map(int, input().split()))

    lst, count = selection_sort(A)
    print(*lst, sep=" ")
    print(count)


if __name__ == "__main__":
    main()



Measured memory_bytes: 7188
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
using namespace std;

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' '<< x << ' ' << y << endl;
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  cin >> n;
  int k;
  cin >> k;
  k = min(k, n);

  vector<int> ps(n);
  for (int i = 0; i < n; i++) {
    cin >> ps[i];
    ps[i]--;
  }

  int ans = 0;
  if (ps[0] != 0) {
    ps[0] = 0;
    ans++;
  }

  vector<vector<Edge>> graph(n);
  for (int v = 1; v < n; v++) {
    int p = ps[v];
    graph[p].push_back(Edge(p, v));
  }

  vector<int> ds(n, -1);
  function<void(int, int)> dfs_1_fn = [&](int v, int p) {
    if (p == -1) ds[v] = 0;
    else ds[v] = ds[p] + 1;

    for (const auto& e : graph[v]) {
      dfs_1_fn(e.to, v);
    }
  };
  dfs_1_fn(0, -1);

  // cout << "ds: " << ds << endl;

  // (v, d)
  vector<tuple<int, int>> vds;
  for (int v = 0; v < n; v++) {
    vds.push_back({v, ds[v]});
  }
  sort(vds.begin(), vds.end(), [](const auto& vd1, const auto& vd2) {
    return get<1>(vd1) > get<1>(vd2);
  });

  vector<int> covered(n);
  // for (int v = 0; v < n; v++) {
  //   if (ds[v] <= k) {
  //     covered[v] = 1;
  //   }
  // }

  function<void(int)> dfs_2_fn = [&](int v) {
    if (covered[v]) return;
    covered[v] = true;
    for (const auto& e : graph[v]) {
      dfs_2_fn(e.to);
    }
  };

  for (const auto& vd : vds) {
    int v = get<0>(vd);
    if (ds[v] <= k) continue;
    if (covered[v]) continue;
    for (int i = 0; i < k - 1; i++) {
      if (ps[v] != -1) v = ps[v];
    }
    dfs_2_fn(v);
    ans++;
  }

  cout << ans << endl;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		int x,y,a,b,c;
		cin >> x >> y >> a >> b >> c;
		vii v;
		rep(i,1,a)
		{
			int x;
			cin >> x;
			v.pb({x,1});	
		}
		rep(i,1,b)
		{
			int x;
			cin >> x;
			v.pb({x,2});	
		}
		rep(i,1,c)
		{
			int x;
			cin >> x;
			v.pb({x,3});	
		}	
		sort(all(v));
		reverse(all(v));
		int ans = 0;
		int tot = x+y;
		int i=0;
		while(tot>0)
		{
			if(v[i].second==1 && x>0)
			{
				x--;
				ans += v[i].first;
				tot--;
			}
			else if(v[i].second==2 && y>0)
			{
				y--;
				ans += v[i].first;
				tot--;
			}
			else if(v[i].second==3)
			{
				ans += v[i].first;
				tot--;
			}
			i++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 10604
A, B, C, X, Y = map(int, input().split())

TotalPrice = 2 * 5000 * 10**5
for i in range(max(X, Y) + 1):
    priceA = A * max(X - i, 0)
    priceB = B * max(Y - i, 0)
    priceC = 2 * C * i
    TotalPrice = min(TotalPrice, priceA + priceB + priceC)

print(TotalPrice)


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

a = list(enumerate(a))
a.sort(key=lambda x: x[1])

# dp[left + right][left]
dp = [[] for _ in range(n+1)]
dp[0].append(0)

for i in range(1, n+1): # i = left + right
    ind, act = a.pop(-1)

    # all right
    dp[i].append(dp[i-1][0] + act * (n - i - ind))

    # middle
    for j in range(1, i): # j = left
        ar = dp[i-1][j] + act * (n - i + j - ind) # rightに追加
        al = dp[i-1][j-1] + act * (ind - j + 1) # leftに追加
        dp[i].append(max([ar, al]))

    # all left
    dp[i].append(dp[i-1][i-1] + act * (ind - i + 1))

print(max(dp[n]))

Measured memory_bytes: 109904
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	public void solve(InputReader in, PrintWriter out) {
		long x = in.nextLong();
		long a = in.nextLong();
		long b = in.nextLong();
		long c = b - a;
		
		if (c <= 0)
			out.println("delicious");
		else if (c <= x)
			out.println("safe");
		else
			out.println("dangerous");
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int x;
    cin >> x;
    if(x < 1200) cout << "ABC";
    else cout << "ARC";
    return 0;
}


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

int main() {
	vector <int> array(3);
	for (int i = 0; i < 3; i++) {
		cin >> array.at(i);
	}
	sort(array.begin(), array.end());
	int sum = abs(array.at(0) - array.at(1)) + abs(array.at(1) - array.at(2));
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int nm = n - m;
    cout << (1 << m) * (1900 * m + 100 * nm) << '\n';
}


Measured memory_bytes: 888
#[allow(dead_code)]
fn main() {
    let (a, b, c, d) = (i::i(), i::i(), i::i(), i::i());
    let mut a = a;
    let mut c = c;
    loop {
        c -= b;
        if c <= 0 {
            println!("{}", "Yes");
            return;
        }
        a -= d;
        if a <= 0 {
            println!("{}", "No");
            return;
        }
    }
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2132
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a>b){
			System.out.println("a > b");
		} else if (a == b){
			System.out.println("a == b");
		} else {
			System.out.println("a < b");
		}
	}
}

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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i=0; i<a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    int n;
    cin>>n;
    vector<int>t(n),a(n),ht(n),ha(n);
    rep(i,n)cin>>t[i];
    rep(i,n)cin>>a[i];
    ht[0]=t[0];
    ha[n-1]=a[n-1];
    for(int i=1; i<n; ++i){
        if(t[i-1]<t[i])ht[i]=t[i];
        else ht[i]=-1;
        if(a[i]<a[i-1])ha[i-1]=a[i-1];
        else ha[i-1]=-1;
    }
    vector<int>h(n);
    rep(i,n){
        if(ht[i]!=-1&&ha[i]!=-1){
            if(ht[i]!=ha[i])h[i]=0;
            else h[i]=1;
        }
        else if(ht[i]==-1&&ha[i]!=-1){
            if(t[i]<ha[i])h[i]=0;
            else h[i]=1;
        }
        else if(ht[i]!=-1&&ha[i]==-1){
            if(ht[i]>a[i])h[i]=0;
            else h[i]=1;
        }
        else{
            h[i]=min(t[i],a[i]);
        }
    }
    mint ans=1;
    rep(i,n)ans*=h[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 5092
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a>b){
            int n=a;
            a=b;
            b=n;
        }
        if(b>c){
            int n=b;
            b=c;
            c=n;
        }
        if(a>b){
            int n=a;
            a=b;
            b=n;
        }
        System.out.println(a+" "+b+" "+c);
    }
}


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

bool judge(const vector<int>& bs)
{
	for(int i = 0; i < (int)bs.size(); ++i) {
		if(bs[i] != i + 1) return false;
	}
	
	return true;
}

int main() {
	int N;
	while(cin >> N, N) {
		
		vector<int> bs(N);
		for(int i = 0; i < N; ++i) {
			cin >> bs[i];
		}
		
		int cnt = 0;
		bool flag = false;
		
		while(cnt <= 10000) {
			if(judge(bs)) {
				flag = true;
				break;
			}
			
			for(int i = 0; i < (int)bs.size(); ++i) {
				bs[i]--;
			}
			bs.push_back(bs.size());
			
			vector<int> next;
			for(int i = 0; i < (int)bs.size(); ++i) {
				if(bs[i] != 0) next.push_back(bs[i]);
			}
			
			bs.swap(next);
			cnt++;
		}
		
		if(flag) {
			cout << cnt << endl;
		} else {
			cout << -1 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1244
import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._
  loop()
  @tailrec def loop(): Unit = {
    val date = readLine.trim.split('.')
    if (date.head == "#") return
    if (date.length == 3) {
      println(Maya(Gregorio(date(0).toInt, date(1).toInt, date(2).toInt).toLong - Gregorio(2012, 12, 21).toLong))
    }else {
      println(Gregorio(Maya(date(0).toInt, date(1).toInt, date(2).toInt, date(3).toInt, date(4).toInt).toLong + Gregorio(2012, 12, 21).toLong))
    }
    loop()
  }
}

object Gregorio {
  def isLeapYear(year: Int): Boolean = (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))
  val cycle = (0 until 400).map{
    case y if isLeapYear(y) ⇒ 366L
    case _ ⇒ 365L
  }.toArray
  for (i ← cycle.indices.tail) cycle(i) += cycle(i - 1)
  val months = Array(31L, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
  for (i ← months.indices.tail) months(i) += months(i - 1)
  val monthsForLeapYear = Array(31L, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
  for (i ← monthsForLeapYear.indices.tail) monthsForLeapYear(i) += monthsForLeapYear(i - 1)
  def apply(day: Long): Gregorio = {
    val y400 = day / cycle.last
    val y = cycle.upperBound(day % cycle.last)
    make(y400.toInt * 400 + y, day % cycle.last - (if (y == 0) 0 else cycle(y - 1)))
  }
  private[this] def make(year: Int, day: Long): Gregorio = {
    val month = if (isLeapYear(year)) {
      monthsForLeapYear
    }else {
      months
    }
    val m = month.upperBound(day)
    Gregorio(year, m + 1, (day - (if (m == 0) 0 else month(m - 1)) + 1).toInt)
  }
  implicit class Wrap[T](val array: Array[T]) {
    def lowerBound(target: T)(implicit ord: Ordering[T]): Int = {
      var left = 0
      var right = array.length
      while (left < right) {
        val mid = (left + right) / 2
        if (ord.compare(array(mid), target) < 0) left = mid + 1
        else right = mid
      }
      right
    }
    def upperBound(target: T)(implicit ord: Ordering[T]): Int = {
      var left = 0
      var right = array.length
      while (left < right){
        val mid = (left + right) / 2
        if (ord.compare(array(mid), target) <= 0) left = mid + 1
        else right = mid
      }
      right
    }
  }
}
case class Gregorio(year: Int, month: Int, day: Int) {
  def toLong: Long = {
    val y400 = Gregorio.cycle.last * (year / 400)
    val y = if (year % 400 == 0) 0 else Gregorio.cycle((year % 400) - 1)
    val months = if (Gregorio.isLeapYear(year)) Gregorio.monthsForLeapYear else Gregorio.months
    y400 + y + (if (month == 1) day - 1 else (months(month - 2) + day - 1))
  }
  override def toString: String = List(year, month, day).mkString(".")
}
object Maya{
  def apply(day: Long): Maya = {
    Maya(day / (20 * 20 * 18 * 20) % 13, day / (20 * 18 * 20) % 20, day / (18 * 20) % 20, day / 20 % 18, day % 20)
  }
}
case class Maya(bactun: Long, katun: Long, tun: Long, winal: Long, kin: Long) {
  def toLong: Long = {
    (((bactun * 20 + katun) * 20 + tun) * 18 + winal) * 20 + kin
  }

  override def toString: String = List(bactun, katun, tun, winal, kin).mkString(".")
}


Measured memory_bytes: 45404
// Hack it and have it ;) //
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows!* * * * * * */
#include      <bits/stdc++.h>
using namespace std;
#define IOS       ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC      cout.precision (10); cout << fixed
#ifdef CONVICTION
#include "/home/convict/Dropbox/myfiles/sport_coding/cplib/snippets/debug.h"
#else
#define debug(x...)
#endif
//Don’t practice until you get it right. Practice until you can’t get it wrong

void preproc() {
}

void solve() {
   int N;
   cin >> N;
   int res = 0;
   int ai;
   for (int i = 1; i <= N; ++i) {
      cin >> ai;
      res += (i % 2 == 1) && (ai % 2 == 1);
   }
   cout << res << '\n';
}

signed main() {
  IOS; PREC;
  preproc();

  int tc = 1;
  // cin >> tc;
  for (int Tt = 1; Tt <= tc; ++Tt) {
    // cout << "Case #" << Tt << ": ";
    solve();
  }
  return EXIT_SUCCESS;
}


Measured memory_bytes: 3608
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, M = map(int, input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

def check(x, y):
    for i in range(M):
        for j in range(M):
            if y + i >= N or x + j >= N:
                return False
            if A[y + i][x + j] != B[i][j]:
                return False
    return True

for i in range(N):
    for j in range(N):
        if check(i, j):
            print("Yes")
            exit()
print("No")



Measured memory_bytes: 9340
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint a(9);
    REP(i,9){
        cin >> a[i];
    }
    int n;
    cin >> n;
    vint b(9,0);
    REP(i,n){
        int x;
        cin >> x;
        REP(j,9){
            if(a[j]==x){
                b[j]=1;
            }
        }
    }
    REP(i,3){
        bool f = true;
        REP(j,3){
            if(b[3*i+j]==0){
                f=false;
            }    
        }
        if(f){
            cout << "Yes" << endl;
            return 0;
        }
    }
    REP(i,3){
        bool f = true;
        REP(j,3){
            if(b[i+j*3]==0){
                f=false;
            }    
        }
        if(f){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(b[0]==1&&b[4]==1&&b[8]==1){
        cout << "Yes" << endl;
        return 0;
    }
    if(b[2]==1&&b[4]==1&&b[6]==1){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

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

func main() {
	var n, m, tmp int
	fmt.Scan(&n,&m)

	// calcCost
	s := [100001]int{1,1,2,3}

	for i := 0; i < m; i++ {
		fmt.Scan(&tmp)
		s[tmp] = -1
	}
	if s[1] == -1 {
		s[1] = 0
	}

	for i:=2; i<=n; i++ {
		if s[i] == -1 {
			s[i] = 0
			continue
		}
		s[i] = (s[i-1] + s[i-2]) % 1000000007
	}

	ans := s[n] % 1000000007
	fmt.Println(ans)
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    cin >> n ;
    vll a(n) ;
    vll pow ;
    pow.PB(1) ;
    for(int i=1;i<=60;i++){
        int m = SZ(pow) - 1 ;
        pow.PB(pow[m]*2%MOD) ;
    }
    vll cnt(60,0) ;
    REP(i,n){
        ll a ;
        cin >> a ;
        stringstream ss ;
        ss << bitset<60>(a) ;
        string s = ss.str() ;
        REP(j,60){
            if(s[j]=='0'){
                cnt[60-j-1]++ ;
            }
        }
    }
    ll ans = 0 ;
    REP(i,60){
        ll res ;
        res = cnt[i]*(n-cnt[i])%MOD ;
        res *= pow[i] ;
        res %= MOD ;
        ans += res ;
        ans %= MOD ;
    }

    cout << ans <<endl;



    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 2560
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let nx = (read::<usize>(), read::<i64>());
    let mut x = vec![0; nx.0];
    x[0] = (read::<i64>() - nx.1).abs();
    let mut y = x[0];
    for i in 1..nx.0 {
        x[i] = (read::<i64>() - nx.1).abs();
        y = gcd(x[i], y);
    }
    println!("{}", y);
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {a} else {gcd(b, a%b)}
}

Measured memory_bytes: 4352
#include <iostream>
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 && c!=a){
        cout << 3 << endl;
    } else {
        cout << 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<queue>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,g[2010][2010],a[2010],vis[2010],in[2010];
int first[2010],cnte;
struct edge{
	int to,next;
}e[10010];
inline void add(int u,int v){
	e[++cnte]=(edge){v,first[u]};first[u]=cnte;in[v]++;
}
int gcd(int x,int y){
	if(y==0) return x;
	return gcd(y,x%y);
}
void dfs(int u){
//	cout<<"dfs "<<u<<'\n';
	vis[u]=1;int i;
	for(i=1;i<=n;i++){
//		cout<<"	try "<<i<<" from "<<u<<' '<<g[u][i]<<'\n';
		if(!vis[i]&&!g[u][i]) add(u,i),dfs(i);
	}
}
struct gaygayquan{
	int val,id;
};
inline bool operator <(gaygayquan x,gaygayquan b){
	return x.val<b.val;
}
gaygayquan mp(int l,int r){
	return (gaygayquan){l,r};
}
priority_queue<gaygayquan>q;
int main(){
	memset(first,-1,sizeof(first));
	n=read();int i,j,v;gaygayquan gay;
	for(i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++){
		for(j=1;j<i;j++){
			if(gcd(a[i],a[j])==1) g[i][j]=g[j][i]=1;
//			cout<<i<<' '<<j<<' '<<a[i]<<' '<<a[j]<<' '<<g[i][j]<<'\n';
		}
	}
	for(i=1;i<=n;i++) if(!vis[i]) dfs(i);
	for(i=1;i<=n;i++) if(!in[i]) q.push(mp(a[i],i));
	while(!q.empty()){
		gay=q.top();q.pop();
		printf("%d ",gay.val);
		for(i=first[gay.id];~i;i=e[i].next){
			v=e[i].to;in[v]--;
			if(in[v]==0) q.push(mp(a[v],v));
		}
	}
}


Measured memory_bytes: 16256
#include<iostream>
#include<vector>
#include<cstring>
#include<string>
#include<algorithm>
#include<list>

using namespace std;
typedef long long int lli;

int n,m,l,r;
double p[3000];
double dp[3000][3000];

int main() {
	scanf("%d",&n);
	for(int i=0;i<=n;i+=1){
	    for(int j=0;j<=n;j+=1){
	        dp[i][j]=1;
	    }
	}
	for(int i=1;i<=n;i+=1){
	    scanf("%lf",&p[i]);
	}
	for(int i=1;i<=n;i+=1){
	    if(i==1){
	        dp[i][0]=1-p[i];
	        continue;
	    }
	    dp[i][0]=dp[i-1][0]*(1-p[i]);
	}
	dp[1][1]=p[1];
	for(int i=2;i<=n;i+=1){
	    for(int j=1;j<=i;j+=1){
	        if(i==j){
	            dp[i][j]=dp[i-1][j-1]*(p[i]);
	            continue;
	        }
	        dp[i][j]=dp[i-1][j]*(1-(p[i]))+dp[i-1][j-1]*(p[i]);
	    }
	}
	double res=0;
	for(int i=(n/2+1);i<=n;i+=1){
	    res+=dp[n][i];
	}
	printf("%0.12lf",res);
}


Measured memory_bytes: 70528
using System;

class Program
{
  static void Main()
  {
    string[] data;
    int n, m, c, i, j;

    data = Console.ReadLine().Split(' ');
    n = int.Parse(data[0]);
    m = int.Parse(data[1]);

    int[,] a = new int[n, m];
    int[] b = new int[m];

    for (i = 0; i < n; i++)
    {
      data = Console.ReadLine().Split(' ');
      for (j = 0; j < m; j++)
      {
        a[i, j] = int.Parse(data[j]);
      }
    }

    for (i = 0; i < m; i++)
    {
      b[i] = int.Parse(Console.ReadLine());
    }

    for (i = 0; i < n; i++)
    {
      c = 0;
      for (j = 0; j < m; j++)
      {
        c += a[i, j] * b[j];
      }
      Console.WriteLine(c);
    }
  }
}

Measured memory_bytes: 9340
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int MOD = 1000000000 + 7;

constexpr int arithmeticSeries(int n, int a1 = 0, int d = 1) {
    return n * (2 * a1 + (n - 1) * d) / 2;
}

constexpr int frontSum(int n) { return arithmeticSeries(n, 0, 1); }
constexpr int backSum(int n, int a1) { return arithmeticSeries(n, a1, -1); }

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

    int n, k;
    cin >> n >> k;

    int count = 0;

    for (int i = k; i <= n + 1; i++) {
        const int way = backSum(i, n) - frontSum(i) + 1;
        (count += way % MOD) %= MOD;
    }

    cout << count << endl;
}


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

int main(){
    int N,t,x,y,sum,tsum;
  	cin >>N;
    bool ans = true;
    vector<int>tvec(N+1,0);
    vector<int>xvec(N+1,0);
    vector<int>yvec(N+1,0);
    for(int i=0;i<N;i++){
        cin >> tvec[i+1] >> xvec[i+1] >> yvec[i+1];
    }
    for(int i=0;i<N;i++){
        sum = abs(xvec[i+1]-xvec[i])+abs(yvec[i+1]-yvec[i]);
        tsum =tvec[i+1]-tvec[i];
        if(tsum%2 == sum%2 && tsum >= sum){
        }
        else{
            ans = false;
            break;
        }
    }
    if(ans == true){
        cout <<"Yes"<< endl;
    }
    else{
        cout <<"No" << endl;
    }
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll INF = (ll)1e16;

ll dp[100107], n, w;
pt a[107];

int main () {
    fastIO;
    cin >> n >> w;
    for(li i = 0; i < n; i ++) cin >> a[i].fi >> a[i].se;

    for(li i = 0; i < 1e5+7; i ++) dp[i]=INF;

    dp[0] = 0;

    for(li i = 0; i < n; i ++) {
        for(li j = 100000; j >= 0; j --) {
            if(dp[j]!=INF) dp[j+a[i].se] = min(dp[j+a[i].se], dp[j]+a[i].fi);
        }
    }

    for(li i = 1e5; i >= 0; i --) {
        if(dp[i]!=INF && dp[i]<=w) { cout << i; break; }
    }
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    HashMap<Integer, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      int tmp = sc.nextInt();
      if (map.containsKey(tmp)) {
        map.put(tmp, map.get(tmp) + 1);
      } else {
        map.put(tmp, 1);
      }
    }
    int count = 0;
    Set keySet = map.keySet();
    for (Object key : keySet) {
      if (map.get(key) % 2 == 1) {
        count++;
      }
    }
    System.out.println(count);
  }
}

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

const ll INF = 1001001001;

int main(){
    int n; cin >> n;
    ll c; cin >> c;
    vector<ll> x(n), v(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> v[i];
    }
    vector<ll> clock(n+1), c_clock(n+1);
    // colckwise, couterclockwiseにi個とった
    for(int i = 0; i < n; i++){
        clock[i + 1] = clock[i] + v[i];
    }
    for(int i = 0; i < n; i++){
        c_clock[i + 1] = c_clock[i] + v[n - 1 - i];
    }
    vector<ll> opt_clock(n+1), opt_c_clock(n+1);
    //左からi個まで取れる時の最大
    ll clock_max = 0, c_clock_max = 0;
    for(int i = 1; i - 1 <= n; i++){
        clock_max = max(clock_max, clock[i-1] - (i - 1 >= 1 ? x[i - 2] : 0));
        c_clock_max = max(c_clock_max, c_clock[i-1] - (i - 1 >= 1 ? c - x[n - i + 1] : 0));
        opt_clock[i - 1] = clock_max;
        opt_c_clock[i - 1] = c_clock_max;
    }
    ll ans = 0;
    ll tmp;
    for(int i = 0; i <= n; i++){
        tmp = c_clock[i] - (i > 0 ? 2 * (c - x[n - i]) : 0);
        tmp += opt_clock[n - i];
        ans = max(ans, tmp);
    }
    for(int i = 0; i <= n; i++){
        tmp = clock[i] - (i > 0 ? 2 * x[i - 1] : 0);
        tmp += opt_c_clock[n - i];
        ans = max(ans, tmp);
    }
    cout << ans << endl;

}


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

int main(){
	while(1){
		int n, s[100]={0};
		
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i){
			for(int j=0; j<5; ++j){
				int a;
				scanf(" %d", &a);
				s[i]+=a;
			}
		}
		sort(s, s+n);
		
		printf("%d %d\n", s[n-1], s[0]);
	}
}

Measured memory_bytes: 1208
def minkowski_distance(arr1, arr2, p):
    if p == 'inf':
        cmp_arr = [abs(x-y) for x, y in zip(arr1, arr2)]
        return max(cmp_arr)
    sum_cmp_arr = sum([pow(abs(x-y), p) for x, y in zip(arr1, arr2)])
    return pow(sum_cmp_arr, 1/p)


n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
for p in [1, 2, 3, 'inf']:
    print(f'{minkowski_distance(arr1,arr2,p):.8f}')


Measured memory_bytes: 5664