akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;
        ll ans = 0;
        if (M - 2*N > 0) {
                M -= 2*N;
                ans = N + M / 4; 
        } else {
                ans = M / 2;
        }

        cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    set<int> t;
    rep(i, s.size()){
        t.insert(s[i]);
    }
    string temp = "abcdefghijklmnopqrstuvwxyz";
    rep(i, temp.size()){
        if(t.find(temp[i]) == t.end()){
            cout << temp[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
a_tmp = input().split()
a = []
ans = 0
for _ in a_tmp:
    a.append(int(_))
i = 0
same = 1
while i < n-1:
    tmp = a[i]
    i += 1
    if a[i] == tmp:
        same += 1
        if same == 3:
            ans += 1
            same = 1
    else:
        if same >= 2:
            ans += 1
            same = 1
if same >= 2:
    ans += 1

print(ans)


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

const int mo=1e9+7;
int n,k,dp[2010][2010][2];

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&k);
	dp[n][0][0]=1;
	for (i=n;i>=1;i--)
	{
		for (j=n;j>=0;j--)
			(dp[i][j][1]+=dp[i][j+1][1])%=mo;
		for (j=0;j<=n;j++)
		{
			(dp[i-1][j+1][0]+=dp[i][j][0])%=mo;
			(dp[i-1][j+1][0]+=dp[i][j][1])%=mo;
			(dp[i-1][j][1]+=dp[i][j][0])%=mo;
			(dp[i-1][j][1]+=dp[i][j][1])%=mo;
		}
	}
	int Ans=(dp[1][n-k][0]+dp[1][n-k][1])%mo;
	for (i=1;i<n-k;i++) Ans=(Ans+Ans)%mo;
	printf("%d\n",Ans);
}


Measured memory_bytes: 31616
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair


void solve()
{
    ll x, y;
    cin >> x >> y;
    
    ll l = 0;
    while(x <= y)
    {
        x *= 2;
        l++;
    }
    cout << l;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 384
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;


void print() { std::cout << std::endl; }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail){
  std::cout << head << ",";
  print(std::forward<Tail>(tail)...);
}

using namespace std;

void solve0(){
  int64_t N, Q;
  scanf("%lld%lld", &N, &Q);
  vector<char> s(N);
  vector<pair<char, char>> td(Q);
  getc(stdin);
  for (int i = 0; i < N; i++)
  {
    s[i] = getc(stdin);
  }
  getc(stdin);
  for (int i = 0; i < Q; i++)
  {
    char t, d;
    scanf("%c %c\n", &t, &d);
    td[i] = make_pair(t, d);
    // print(t,d);
  }

  int L = 0;
  for (int i = Q - 1; i >= 0; i--)
  {
    char t = td[i].first;
    char d = td[i].second;
    if (d == 'L')
    {
      L = L + (t == s[L]);
    }
    else if (L > 0)
    {
      L = L - (t == s[L - 1]);
    }
    if (L < 0)
    {
      L = 0;
    }
    else if (L >= N)
    {
      // L = N - 1;
      break;
    }
  }
  

  int R = N - 1;
  for (int i = Q - 1; i >= 0; i--)
  {
    char t = td[i].first;
    char d = td[i].second;

    if (d == 'R')
    {
      R = R - (t == s[R]);
    }
    else if (R < N - 1)
    {
      R = R + (t == s[R + 1]);
    }
    if (R < 0)
    {
      // R = 0;
      break;
    }
    else if (R >= N)
    {
      R = N - 1;
    }
  }
  // print(L, R);
  cout << (L <= R ? R - L + 1 : 0) << endl;
}

int main(int argc, char **argv)
{
  solve0(); //wrong answer

  // int64_t N, Q;
  // scanf("%lld%lld",&N,&Q);
  // vector<char> s(N);
  // vector<pair<char, char>> td(Q);
  // getc(stdin);
  // for(int i=0;i<N;i++){
  //   s[i] = getc(stdin);
  // }
  // getc(stdin);
  // for(int i=0;i<Q;i++){
  //   char t, d;
  //   scanf("%c %c\n",&t,&d);
  //   td[i] = make_pair(t,d);
  // }

  // int s,t;
  // for(int i=0;i<Q;i++){

  // }


  return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(){
  string s;
  int i,n;
  bool cf = false;
  bool ff = false;

  cin >> s;

  for(i = 0;i < s.size();i++){
    if(s[i] == 'C'){
      cf = true;
    }
    else if(s[i] == 'F' && cf){
      ff = true;
    }
  }

  if(ff){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
fun main(args :Array<String>){ 
  val (M, N) = readLine()!!.split(" ").map { x -> x.toInt() } 

  val ms = (1..M).toList().map { x ->
    readLine()!!.toList()
  }
  val ns = (1..N).toList().map { x ->
    readLine()!!.toList()
  }
  val k = (0..M-N).map { x ->
    val a = (0..M-N).map { y ->
      val s = (0..N-1).map { ty ->
        (0..N-1).map { tx -> 
          //println("$ty, $tx")
          ns[ty][tx] == ms[y + ty][x + tx]
        }
      }.flatMap { x -> 
        x 
      }.all { x ->
        x 
      }
      s
    }.any { x ->
      x
    }
    a
  }.any { x ->
    x 
  }
  if( k == true ) {
    println("Yes")
  } else {
    println("No")
  }
}


Measured memory_bytes: 45184
#include <bits/stdc++.h>
using namespace std; 
#define priority_queue pq;
#define int long long
#define pu push
#define loop for(int i=0;i<n;i++)
int32_t main(){
int n;
cin>>n;
int ans=0;
ans+=(n/500)*1000;
ans+=((n%500)/5)*5;
cout<<ans;
}


Measured memory_bytes: 256
n = input()
lis = []
ans = 0
for i in xrange(n):
    com = raw_input()
    if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:ans += 1
  
print ' '.join( map(str, reversed(lis[ans:])) )

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

a.append(0); a.append(0);
inf = int(1e9)
dp = [inf]*(n+3)
dp[0] = 0

for i in range(n):
  dp[i+1] = min(dp[i+1], dp[i] + abs(a[i+1] - a[i]))
  dp[i+2] = min(dp[i+2], dp[i] + abs(a[i+2] - a[i]))

print(dp[n-1])


Measured memory_bytes: 83224
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;
#define ll long long
#define pb push_back
int N;

unsigned GetDigit(unsigned num)
{
  return log10(num);
}

int main()
{
  cin >> N;
  int cnt = 0;
  vector<vector<ll>> c(9,vector<ll>(9,0));

  for (int k = 1; k <= N; k++)
  {
    int a = k / pow(10, GetDigit(k));
    int b = k % 10;
    if (k < 10) // bが１桁の時
      b = k;
    a--;
    b--;
    if (b < 0)
      continue;
    c[a][b]++;
  }

  ll result = 0;
  for (int i = 0; i < 9; i++)
  { // O(1)
    for (int j = 0; j < 9; j++)
    { // O(1)
      result += c[i][j] * c[j][i];
    }
  }

  cout << result << endl;
}


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

bool vis[100005];
int poo[100005];

int32_t main(){
	
	int n,m;
	cin>>n>>m;
	
	int correct=0,penalties=0;
	
	for (int i=0;i<m;i++){
		
		int x;
		string h;
		cin>>x>>h;
		
		if (vis[x])continue;
		else if (h=="AC") correct++,vis[x]=1;
		else penalties++,poo[x]++;
	}
	
	for (int i=1;i<=n;i++){
		if (!vis[i])
			penalties-=poo[i];
	}
	
	cout<<correct<<" "<<penalties;
}	


Measured memory_bytes: 1152
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
int c[3] = { 3,5,7 };
ll n;
ll rec(ll v) {

	if (n < v) return 0;
	ll tv = v;
	ll sum = 0;
	
	map<int ,int > m;
	int cou = 0;
	while (tv > 0)
	{
		int t = tv % 10;
		m[t]++;
		if (m[t] == 1) {
			cou++;
		}
		if (cou == 3) {
			sum++;
			break;
		}
		tv /= 10;
	}

	for (size_t i = 0; i < 3; i++)
	{
		sum += rec(v * 10 + c[i]);
	}
	return sum;
}
void p755() {
	cin >> n;

	cout << rec(0) << endl;
}

int main() {
	p755();
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		String s = sc.next();
		String p = "keyence";
		
		if(s.indexOf(p) != -1){
			System.out.println("YES");
			return;
		}
		
		for(int i = 0; i < s.length(); i++){
			for(int j = i + 1; j < s.length(); j++){
				String ss = s.substring(0, i) + s.substring(j, s.length());
				//System.out.println(ss);
				if(ss.equals(p)){
					System.out.println("YES");
					return;
				}
			}
		}
		
		System.out.println("NO");
		
	}//end main
	
}//end Main

class Pair{
	int a; int b; long c;
	public Pair(int a, int b, long c){
		this.a = a;
		this.b = b;
		this.c = c;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    n--; m--;
    cout << n * m << endl;

    return 0;
}


Measured memory_bytes: 256
X = int(input())
if 400 <= X < 600:
    print(8)
elif 600<= X < 800:
    print(7)
elif 800<= X < 1000:
    print(6)
elif 1000<= X < 1200:
    print(5)
elif 1200<= X < 1400:
    print(4)
elif 1400<= X < 1600:
    print(3)
elif 1600<= X < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9184
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
#define int long long
using namespace std;
char c;
signed main()
{
	cin>>c;
	if(c>='A'&&c<='Z')
	{
		cout<<'A';
	}
	else
	{
		cout<<'a';
	}
}

Measured memory_bytes: 3560
#include<stdio.h>
int main(){
    int N,T,c[1001],t[1001];
    int ans = 1001,d = 0;
    scanf("%d %d", &N, &T);
    for (int a = 0; a < N;a++){
        scanf("%d %d", &c[a], &t[a]);
    }

    for (int b = 0; b < N;b++){
        if(t[b]<=T && c[b]<=ans){
            ans = c[b];
          d++;
        }
    }
  if(d>0){
    printf("%d", ans);
  }else{
    printf("TLE");
  }
    return 0;
}

Measured memory_bytes: 128
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

c = 0

for i in range(n):
    for j in range(i+1, n):
        s = sum([(y - z)**2 for (y, z) in zip(x[i], x[j])])
        if int(math.sqrt(s))**2 == s:
            c += 1
print(c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
	int n;
	cin>>n;
	cout<<"Christmas";
	rep(i,25-n) cout<<" Eve";
	cend;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  string S,T;
  cin >> S >> T;

  if(T.substr(0,T.size()-1)==S){
  	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,t,x,y;
  cin>>n>>t>>x;
  if(n==1){
  }
else {
  cin>>y;
  if(y>=t){
    x+=t;
  }
  else {
    x+=y;
  }
  for(int i=2;i<n;i++){
    long long k;
    cin>>k;
      if((k-y)>=t){
        x+=t;
        y=k;
      }
      else{
        x+=(k-y);
        y=k;
      }
    } 
}
   x+=t;
    cout<<x<<endl;
}

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

using namespace std;

typedef long long LL;
#define N 2200

const int mod=998244353;
int n,x,y,ans,f[N][N],a[N],C[N][N];
char s[N];

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=1;i<=n;++i) a[i]=s[i]-'0';
	f[0][0]=1;
	for (int i=1;i<=n;++i){
		x+=a[i]; y+=2-a[i];
		for (int j=0;j<=x;++j){
			if (j) f[i][j]=f[i-1][j-1];
			if (i-j<=y) f[i][j]=(f[i][j]+f[i-1][j])%mod;
		}
	}
	for (int i=0;i<=n;++i){
		C[i][0]=1;
		for (int j=1;j<=i;++j) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	for (int i=0;i<=n;++i)
		ans=(ans+(LL)f[n][i]*C[n][x-i])%mod;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 36096
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int a;
    char s[20];
    
    scanf("%d",&a);
    scanf("%s",s);
    
    if(a >= 3200){
        printf("%s\n",s);
    }else{
        printf("red\n");
    }
   
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	string  S;
	int K;
	cin >> S >> K;
	int ans = 0;

	for (int i = 0; i < K; i++) {
		if (S[i] != '1') {
			ans = i;
			break;
		}
	}
	cout << S[ans] << endl;




	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static double a, b, c, d, e, f;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())
			return false;
		a = sc.nextDouble();
		b = sc.nextDouble();
		e = sc.nextDouble();
		c = sc.nextDouble();
		d = sc.nextDouble();
		f = sc.nextDouble();
		return true;
	}
	static void solve(){
		double det = a*d - b*c;
		double x = (d*e - b*f)/det, y = (-c*e + a*f)/det;
		x = Math.floor(x*1000 + 0.5)/1000;
		y = Math.floor(y*1000 + 0.5)/1000;
		System.out.printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
#include<regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9

int ctoi(char c) {
	switch (c) {
	case '1':
		return 1; break;
	case '2':
		return 2; break;
	case '3':
		return 3; break;
	case '4':
		return 4; break;
	case '5':
		return 5; break;
	case '6':
		return 6; break;
	case '7':
		return 7; break;
	case '8':
		return 8; break;
	case '9':
		return 9; break;
	case '0':
		return 0; break;
	}

}

int calc(int a, int b, int c) {
	if (c == 0) return a + b;
	else return a - b;
}

int main() {
	int a[4];
	for (int i = 0; i < 4; i++) {
		char temp; cin >> temp;
		a[i] = ctoi(temp);
	}

	int op1, op2, op3; // 0 : +
					   // 1 : -

	for (int i1 = 0; i1 < 2; i1++) {
		for (int i2 = 0; i2 < 2; i2++) {
			for (int i3 = 0; i3 < 2; i3++) {
				int ans = calc(a[0], a[1], i1);
				ans = calc(ans, a[2], i2);
				ans = calc(ans, a[3], i3);

				if (ans == 7) {
					op1 = i1;
					op2 = i2;
					op3 = i3;
					break;
				}
			}
		}
	}

	cout << a[0];
	if (op1 == 0) cout << "+";
	else cout << "-";
	cout << a[1];
	if (op2 == 0) cout << "+";
	else cout << "-";
	cout << a[2];
	if (op3 == 0) cout << "+";
	else cout << "-";
	cout << a[3] << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, l;
	cin >> n >> l;
	vector<int> a(n);
	int sum = 0, ab = 1e9, di = 0;
	rep(i,n){
		a[i] = l + i;
		sum += a[i];
		if(abs(a[i]) < ab){
			ab = abs(a[i]);
			di = a[i];
		}
	}
	sum -= di;
	cout << sum << endl;
	return 0;
}

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

typedef long long ll;

int main()
{
    ll i,j;
    int n;
    cin >> n;
    vector<double> x(n);
    vector<double> y(n);
    for(i = 0;i < n;++i){
        cin >> x.at(i) >> y.at(i);
    }
    vector<int> c(n);
    for(i = 0;i < n;++i){
        c.at(i) = i;
    }
    double sum = 0;

    int time = 0;

    do{
        double temp = 0;
        for(i = 0;i < n-1;++i){
            temp += sqrt(pow(x.at(c.at(i+1)) - x.at(c.at(i)), 2.0) + pow(y.at(c.at(i+1)) - y.at(c.at(i)), 2.0));  
        }
        sum += temp;
        ++time;
    }while(next_permutation(c.begin(), c.end()));
    double tn = (double)time;
    double ans = sum/tn;
    printf("%f\n", ans);

    return 0;
}

Measured memory_bytes: 256
a, b = map(str, input().split())

x = a*int(b)
y = b*int(a)

for i in range(min(len(x), len(y))):
  if int(x[i]) > int(y[i]):
    print(y)
    exit()
  elif int(x[i]) < int(y[i]):
    print(x)
    exit()
  else:
    continue
else:
  print(x)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;
    vector<ll> A; vector<ll> B; vector<ll> C;
    ll ans=0;
    for(int i=0; i<3*N;i++){
      ll tmp; cin>>tmp;
      if(i<N) A.push_back(tmp);
      else if(i<2*N)  B.push_back(tmp);
      else C.push_back(tmp);
    }

    sort(A.begin(), A.end()); sort(B.begin(), B.end()); sort(C.begin(), C.end());
    // cout<<endl;
    for(int i=0; i<N;i++){
      ll b = B[i];
      ll KA = upper_bound(A.begin(), A.end(), b-1) - A.begin();
      ll KC = C.end() - upper_bound(C.begin(), C.end(), b);
      // cout<<a<<" "<<upb<<" "<<B[upb]<<" "<<KB<<" "<<KC<<endl;
      ans += KA * KC;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {

  string s;
  cin >> s;
  int min_i, max_z;
  int count=0;

  for(int i=0; i<s.size(); i++) {
    if(s[i] == 'A' && count==0) {
     min_i = i;
     count++;
    }
    if(s[i] == 'Z') {
      max_z = i;
    }
  }

  cout << max_z - min_i + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <math.h>
using namespace std;

void a()
{
    int k, n;
    cin >> n >> k;
    cout << n - k + 1;
}
void b()
{
    int a, b, c, n;
    cin >> a >> b >> c >> n;
    int am = n / a;
    int bm = n / b;
    int cm = n / c;
    long long int num = 0;

    for (int i = 0; i <= am; i++)
    {
        if (a * i > n)
            break;
        for (int j = 0; j <= bm; j++)
        {
            if (a * i + b * j > n)
                break;
            if ((n - a * i - b * j) % c == 0)
                num++;
        }
    }
    cout << num;
}
void c()
{
    int n;
    cin >> n;
    int inc = 0;
    int outa = 0;
    int outb = 0;
    int bothc = 0;
    for (int i = 0; i < n; i++)
    {
        string tmp;
        cin >> tmp;
        int flag = 0;
        for (int i = 0; i < tmp.length() - 1; i++)
        {
            if (i == 0)
            {
                if (tmp[i] == 'B')
                {
                    outb++;
                    flag++;
                }
            }
            if (tmp.substr(i, 2) == "AB")
            {
                inc++;
            }
        }
        if (tmp[tmp.length() - 1] == 'A')
        {
            outa++;
            flag++;
        }
        if (flag == 2)
            bothc++;
    }
    int sum = 0;
    if (outa == 0 || outb == 0)
        sum = inc;
    else if (outa == bothc && outb == bothc)
        sum = inc + outa - 1;
    else
    {
        int min;
        if (outa < outb)
            min = outa;
        else
            min = outb;

        sum = min + inc;
    }
    cout << sum;
}
void d()
{
    long long int N = 0ll;
    cin >> N;
    long long int sum = 0ll;
    for (long long int i = 1ll; i * i + i < N; i++)
    {
        if ((N % i) == 0)
        {
            sum += (long long int)((double)N / i) - 1ll;
            // cout << (long long int)((long double)N / i) - 1ll;
        }
    }
    cout << sum;
}
int main(void)
{
    d();
    //c();
    //b();
    //a();
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
ll mod = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modd(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main(void)
{
    ll n;
    cin>>n;

    if(n<2)
    {
        cout<<0<<endl;
        return 0;
    }

    
    ll al = modpow(10,n,mod);
    ll notzeronine = modpow(8,n,mod);

    ll notzero = modpow(9,n,mod);

    ll ans = (al  -2*notzero + notzeronine);
    ans = modd(ans,mod);

    cout<<ans<<endl;
    
}

Measured memory_bytes: 3192
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void makeAns(char now = 'a', string ans = "")
{
	if( ans.size() == n ) 
	{
		cout << ans << endl;
		return;
	}
	fo(i,'a',now+1)
	{
		char ch = (char)i;
		char nch = (ch == now) ? now+1 : now;
		makeAns( nch , ans + ch );
	}
}

void go()
{
	cin >> n;

	makeAns();
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 6784
#include<iostream>
#include<string.h>

using namespace std;
int a=0, b=-1, c=-1, la, lb, lc;
char sa[102], sb[102], sc[102], t;

int dplus(char ss[102],int i);
	
int main(){

	cin>>sa;
	cin>>sb;
	cin>>sc;
	
	sa[101]='A';
	sb[101]='B';
	sc[101]='C';
	
	dplus(sa,0);
	
	cout<<t<<endl;
}

int dplus(char ss[102],int i){
	if(strlen(ss)<=i) {
		t=ss[101];
		return 0;
	}
	
	if(ss[i]=='a') dplus(sa,++a);
	else if(ss[i]=='b') dplus(sb,++b);
	else if(ss[i]=='c') dplus(sc,++c);
	
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = []

n.times do |i|
	a << gets.to_i
end
min = 1
ans = 0

n.times do |i|
	if i == 0
		ans += a[0] -1
		min = 2
	else
		if a[i] < min
			next
		elsif a[i] == min
			min += 1
		else
			if a[i] % min == 0
				ans += a[i]/min -1
			else
				ans += a[i]/min
			end 
		end
	end
end

puts ans

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int distx = x2 - x1, disty = y2 - y1;
    int x3 = x2 - disty, y3 = y2 + distx;
    int x4 = x1 - disty, y4 = y1 + distx;
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define s(v)       sort(v.begin(),v.end())
#define r(v)       reverse(v.begin(),v.end())
#define pf         printf
#define sf         scanf
#define GCD(x,y)   __gcd(x, y)
#define pb         push_back
#define ll         long long
#define vs         v.size()
#define ss         s.size()
using namespace std;

int  main()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(d<=t*s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;
int main()
{
    int N;
    cin >> N;
    rep(i, 1, N + 1)
    {
        if (N % i == 0)
        {
            int j = N / i;
            if (j <= 9 && i <= 9)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    long[] numSumList = new long[n + 1];
    long all = 0;

    for(int i = 0 ; i < n ; i++){
      a[i] = sc.nextInt();
      numSumList[a[i]]++;
    }
      for(int i = 1 ; i <= n ; i++){
        long j = numSumList[i];
        all += j * (j - 1L) / 2L;
	}
      String s = "";
      StringBuilder sb = new StringBuilder(s);
      for(int i = 0 ; i < a.length ; i++){
        long k = numSumList[a[i]];
        sb.append(all - (k - 1) + "\n");
      }
      System.out.println(sb.toString());
    }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,k;
    cin >> n >> k;
    int64 ans = 0;
    FOR(k2,k,n){
        ans += n-k2;
        if(k == 0)ans--;
        int i = 2;
        while(true){
            int64 x = max<int64>(0, n - i * k2) / (i - 1);
            if(x == 0)break;
            ans += x;
            i++;
        }
    }
    ANS(ans);
    return 0;
}

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

int main(){
    int n, i, k, count;
    float sqr;
    int input_list[10000];
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        scanf("%d", &input_list[i]);
    }
    
    count = 0;
    for(i = 0; i < n; i++){
        sqr = sqrt(input_list[i]);
        for(k = 2; k <= sqr; k++){
            if(input_list[i] % k == 0){
                break;
            }
        }
        if(k > (int)sqr){
            count++;
        }
    }
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 2064
#include <stdlib.h>
#include <iostream>
#include <string>

int main(int argc, char* argv[])
{
	int a,b,c;
    std::cin>>a>>b>>c;
	if(a<0 || a>100) return 0;
	if(b<0 || b>100) return 0;
	if(b<0 || b>100) return 0;
	if(a<b && b<c) std::cout<<"Yes"<<std::endl;
	else std::cout<<"No"<<std::endl;
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <cmath>
#define rep(i, n)for(int i=0; i<n; i++)
using ll = long long int;
using namespace std;

int main(){
    int a, b, c;
    double radc, s, l, h;
    double pi = acos(-1);
    cin >> a >> b >> c;
    radc = c * pi / 180;
    s = a * b * sin(radc) / 2;
    l= a + b + sqrt(a*a+b*b-2.0*a*b*cos(radc));
    h= b * sin(radc);

    cout << fixed << setprecision(5) << s << endl;
    cout << l << endl;
    cout << h << endl;
    
    return 0;
}


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

int main(){
    long long x,k,d;
    scanf("%lld%lld%lld", &x, &k, &d);
    long long a = (double)(-1)*x/d;
    long long b = (abs(a) < abs(k) ?  a : (a < 0 ? -1*k : k));
    if(abs(k) <= abs(a)){
        printf("%lld", abs(x+b*d));
        return 0;
    }
    if(abs(abs(k)-abs(a))%2 == 0){
        printf("%lld", abs(x+b*d));
    }
    else{
        printf("%lld", min(abs(x+b*d-d), abs(x+b*d+d)));
    }
    return 0;
}

Measured memory_bytes: 3824
// AGC024 A - fairness
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	if k%2 == 0 {
		fmt.Println(a - b)
	} else {
		fmt.Println(b - a)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll INF = 100000007;

int main() {
  IN(ll, A);
  IN(string, op);
  IN(ll, B);
  if(op == "+")
    OUT(A + B);
  else
    OUT(A - B);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



//monoid,結合律が成り立ち,単位元が存在するものに対しての演算をクエリに対してO(logn)で
//1-indexed  n(親)->2n,2n+1(子)  k(子)->k/2(親)
template<typename Monoid>
struct SegmentTree{
    using F = function< Monoid(Monoid, Monoid) >;
    //sz:size->完全二分木なのでszはnよりも大きい最小の2のべき乗数
    int sz;
    vector<Monoid> seg;
 
    const F f;
    const Monoid M1;
    SegmentTree(int n,const F f,const Monoid &M1) : f(f), M1(M1) {

    sz=1;
    while(sz<n) sz<<=1;
    seg.assign(2*sz, M1);
    }
 
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
 
    void build(){
        for(int k=sz-1;k>0;k--){
        seg[k]=f(seg[2*k+0], seg[2*k+1]);
        }
    }
 
    void update(int k,const Monoid &x){
        k+=sz;
        seg[k]=x;
        
    while(k>>=1){
        seg[k]=f(seg[2*k+0],seg[2*k+1]);
        }
    }
    //query聞くときは区間は[a,b)で(a<=x<b)
    Monoid query(int a, int b) {
        Monoid L=M1,R=M1;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
            if(a&1) L=f(L, seg[a++]);
            if(b&1) R=f(seg[--b], R);
        }
        return f(L,R);
    }   
    Monoid operator[](const int &k) const{
        return seg[k+sz];
    }
};


ll f(ll a,ll b){if(a>b) return b;else return a;}
int main(){
    int n;ll x;
    cin>>n>>x;
    SegmentTree<ll> seg(2*n, f, LINF);
    ll a[n];
    rep(i,n) cin>>a[i];
    rep(i,n) seg.set(i,a[i]);
    rep(i,n) seg.set(i+n,a[i]);
    seg.build();
    //魔法を放つ回数をkで固定
    ll ans=LINF;
    rep(k,n){
        ll tmp=x*k;
        rep(i,n){
            tmp+=seg.query(i,i+k+1);
        }
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int gcd(int a, int b)
{
	while (b) {
		int t = a % b;
		a = b;
		b = t;
	}
	return a;
}

int N, A[2020];
vector<int> dv[2020];
vector<int> rdiv[50505];
int RC;

bool isok[2020], used[2020];
bool rdivvis[50505];
bool vis[2020];

bool chk(int iic)
{
	for (int i = 0; i < N; ++i) vis[i] = false;
	for (int i = 0; i < RC; ++i) rdivvis[i] = false;

	queue<int> Qa, Qb;
	// place [0, iic] first
//	printf("chk %d\n", A[iic]);
	for (int i = 0; i <= iic; ++i) if (!used[i] && isok[i]) {
		Qa.push(i);
		vis[i] = true;
	}
	while (!Qa.empty()) {
		int v = Qa.front(); Qa.pop();
		for (int p : dv[v]) if (!rdivvis[p]) {
			rdivvis[p] = true;
			for (int i : rdiv[p]) if (!used[i] && !vis[i]) {
				vis[i] = true;
				if (i <= iic) Qa.push(i);
				else Qa.push(i);
			}
		}
	}
	/*
	while (!Qb.empty()) {
		int v = Qb.front(); Qb.pop();
		for (int p : dv[v]) if (!rdivvis[p]) {
			rdivvis[p] = true;
			for (int i : rdiv[p]) if (!used[i] && !vis[i]) {
				vis[i] = true;
				if (i <= iic) {
					puts("><");
					exit(0);
				} else Qb.push(i);
			}
		}
	}
	*/
	for (int i = 0; i < N; ++i) if (!used[i] && !vis[i]) return false;
	return true;
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", A + i);
	}
	sort(A, A + N);
	for (int i = 0; i < N; ++i) {
		int v = A[i];
		for (int j = 2; j * j <= v; ++j) {
			if (v % j == 0) {
				dv[i].push_back(j);
				while (v % j == 0) v /= j;
			}
		}
		if (v > 1) dv[i].push_back(v);
	}
	vector<int> alldv;
	for (int i = 0; i < N; ++i) {
		for (int p : dv[i]) alldv.push_back(p);
	}
	sort(alldv.begin(), alldv.end());
	alldv.erase(unique(alldv.begin(), alldv.end()), alldv.end());
	for (int i = 0; i < N; ++i) {
		for (int &p : dv[i]) {
			p = lower_bound(alldv.begin(), alldv.end(), p) - alldv.begin();
			rdiv[p].push_back(i);
		}
	}
	RC = alldv.size();

	for (int i = 0; i < N; ++i) {
		isok[i] = true;
		used[i] = false;
	}

	vector<int> ans;
	for (int i = 0; i < N; ++i) {
		vector<int> cand;
		for (int j = 0; j < N; ++j) if (!used[j]) cand.push_back(j);

		int left = 0, right = cand.size() - 1;
		while (left < right) {
			int mid = (left + right) / 2;
			if (chk(cand[mid])) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}
		int v = A[cand[left]];
		ans.push_back(v);
	//	printf("%d\n", v);
		used[cand[left]] = true;
		for (int j = 0; j < N; ++j) {
			if (A[j] > v) {
				isok[j] = false;
			}
			if (gcd(A[j], v) != 1) {
				isok[j] = true;
			}
		}
	}

	for (int i = 0; i < N; ++i) printf("%d%c", ans[i], i == N - 1 ? '\n' : ' ');

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<deque>
#include<set>
#define inf 1e9
#define eps 1e-6
#define N 1010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
const int mod=1e9+7;
struct matrix
{
	int a[3][3];
	matrix(){memset(a,0,sizeof(a));}
};
inline int Z(int x){return x>=mod?x-mod:x;}
inline int ksm(int a,ll b)
{
	int ans=1;
	while(b){if(b&1)ans=1LL*ans*a%mod;b>>=1;a=1LL*a*a%mod;}
	return ans;
}
matrix operator *(matrix a,matrix b)
{
	matrix c;
	for(register int i=1;i<=2;i++)
	{
		for(register int j=1;j<=2;j++)
		{
			for(register int k=1;k<=2;k++)
			{
				c.a[i][j]=Z(c.a[i][j]+1LL*a.a[i][k]*b.a[k][j]%mod);
			}
		}
	}
	return c;
}
inline matrix ksm(matrix a,ll b)
{
	matrix ans=a;b--;
	while(b){if(b&1)ans=ans*a;b>>=1;a=a*a;}
	return ans;
}
char s[N];
int b[N][N];
int n,m;ll k;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read();k=read();
	if(k==1){printf("1\n");return 0;}
	for(register int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(register int j=1;j<=m;j++)
		{
			b[i][j]=(s[j]=='#');
		}
	}
	int tag0=0,tag1=0;
	int A=0,B=0,C=0;
	for(register int i=1;i<=m;i++)if(b[1][i]&&b[n][i])tag0=1;
	for(register int i=1;i<=n;i++)if(b[i][1]&&b[i][m])tag1=1;
	for(register int i=1;i<=n;i++)
	{
		for(register int j=1;j<=m;j++)if(b[i][j])C++;
	}
	if(tag0&&tag1){printf("1\n");}
	else if(!tag0&&!tag1){printf("%d\n",ksm(C,k-1));}
	else
	{
	    matrix I;
		if(tag0)
		{
			for(register int i=1;i<=m;i++)if(b[1][i]&&b[n][i])B++;
			for(register int i=2;i<=n;i++)
			{
				for(register int j=1;j<=m;j++)
				{
					if(b[i][j]&&b[i-1][j])A++;
				}
			}
			I.a[1][1]=C;I.a[1][2]=A;I.a[2][2]=B;
			I=ksm(I,k-1);
		}
		else
		{
			for(register int i=1;i<=n;i++)if(b[i][1]&&b[i][m])B++;
			for(register int i=1;i<=n;i++)
			{
				for(register int j=2;j<=m;j++)
				{
					if(b[i][j]&&b[i][j-1])A++;
				}
			}
			I.a[1][1]=C;I.a[1][2]=A;I.a[2][2]=B;
			I=ksm(I,k-1);
		}
//		cout<<"WTF:"<<A<<" "<<B<<" "<<C<<" "<<I.a[1][1]<<" "<<I.a[1][2]<<endl;
		printf("%d\n",Z(I.a[1][1]+mod-I.a[1][2]));
	}
	return 0;
}


Measured memory_bytes: 7776
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
int gcd(int x, int y) {
  int z = x % y;
  if (z == 0) {
    return y;
  } else {
    return gcd(y, z);
  }
}
int f(int x, const int *p, const int *q) {
  if (p == q) {
    return x;
  }
  int y = gcd(x, *p++);
  int z1 = f(y, p, q);
  if (x == y) {
    return z1;
  }
  int z2 = x;
  while (p != q && (z2 == 0 || z1 < z2)) {
    z2 = gcd(z2, *p++);
  }
  return std::max(z1, z2);
}
int main() {
  int n;
  std::cin >> n;
  std::vector<int> a;
  a.resize(n);
  for (auto &ai: a) std::cin >> ai;
  std::sort(a.begin(), a.end());
  std::cout << f(0, &a[0], &a[a.size()]);
}

Measured memory_bytes: 5376
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >>N;
  long long int H[N];
  for(int i=0;i<N;i++)
    cin >>H[i];
  
  for(int i=N-1;i>0;i--){
    if(H[i]<=H[i-1])
      H[i]=0;
  }
  int count=0,ans=0;
    for(int i=0;i<N;i++){
      if(H[i]==0)
	count++;
      else if(H[i]!=0){
	if(count>ans)
	  ans=count;
	count=0;
      }      
    }
    if(count>ans)
      ans=count;
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt()
	A := make([]int, N+1)
	for n := 0; n < N+1; n++ {
		A[n] = nextInt()
	}
	B := make([]int, N)
	for n := 0; n < N; n++ {
		B[n] = nextInt()
	}

	sum_1 := 0
	for _, a := range A {
		sum_1 += a
	}

	for n := 0; n < N; n++ {
		if B[n] < A[n] {
			A[n] -= B[n]
		} else {
			A[n+1] -= B[n] - A[n]
			if A[n+1] < 0 {
				A[n+1] = 0
			}
			A[n] = 0
		}
	}

	sum_2 := 0
	for _, a := range A {
		sum_2 += a
	}
	fmt.Println(sum_1 - sum_2)
}


Measured memory_bytes: 5120