akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a<b && a!=1 && b!=1) {
			System.out.println("Bob");

		}else if(a>b && a!=1 && b!=1) {
			System.out.println("Alice");
		}else if(a==1 && b!=1) {
			System.out.println("Alice");
		}else if(b==1 && a!=1) {
			System.out.println("Bob");
		}else if(a==b) {
			System.out.println("Draw");
		}
	}

}


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

using namespace std;




int main()
{
    int n,i,a,d=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        int flag=0;
        if (a%2==0) {if (a==2) d++;}
        else
        {
            for(int j=3;j<=sqrt(a);j+=2)
            {
                if (a%j==0) {flag=1; break;}
            }
            if (flag==0) d++;
        }

    }
    cout<<d<<endl;


}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int W = sc.nextInt();

		int[] w = new int[N + 10];
		int[] v = new int[N + 10];
		long[][] dp = new long[N + 10][100010];

		for (int i = 0; i < N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}

		for (int i = 0; i < N + 10; i++) {
			for (int j = 0; j < 100010; j++) {
				dp[i][j] = Integer.MAX_VALUE;
			}
		}

		dp[0][0] = 0;

		for (int i = 0; i < N; i++) {
			for (int sum_v = 0; sum_v < 100010; sum_v++) {

				if (sum_v - v[i] >= 0) {
					dp[i + 1][sum_v] = Math.min(dp[i + 1][sum_v], dp[i][sum_v - v[i]] + w[i]);
				}

				dp[i + 1][sum_v] = Math.min(dp[i + 1][sum_v], dp[i][sum_v]);

			}
		}

		long ans = 0l;
		for (int sum_v = 0; sum_v < 100010; sum_v++) {
			if (dp[N][sum_v] <= W) {
				ans = sum_v;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 127828
#include <iostream>
#include <map>

using namespace std;

typedef pair<int,int> pii;

int n;
int v[100005];

int main() {
        cin >> n;
        for (int i=0; i<n; i++) {
                cin >> v[i];
        }

        map<int,int> cts[2];
        for (int i=0; i<n; i++) {
                cts[i%2][v[i]]++;
        }


        pii one[2];
        pii two[2];
        for (int i=0; i<2; i++) {
                one[i] = pii(-1,0);
                two[i] = pii(-1,0);

                for (auto p : cts[i]) {
                        if (p.second > one[i].second) {
                                two[i] = one[i];
                                one[i] = p;
                        } else if (p.second > two[i].second) {
                                two[i] = p;
                        }
                }
        }

        int ret=n;
        if (one[0].first != one[1].first) {
                ret -= one[0].second + one[1].second;
        } else {
                ret -= max(one[0].second + two[1].second, two[0].second + one[1].second);
        }

        cout << ret << endl;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
#define make_pair mp
#define first f
#define second s
int n,num=0;
char ans[30];
char str[101][105];
bool a=true;
int main(){
scanf("%d",&n);
scanf("%s",&ans);
int ppp=strlen(ans);
char s1=ans[0],s2=ans[1];
for(int i=0;i<n;i++){
	scanf("%s",&str[i]);
	int length=strlen(str[i]);
	for(int j=0;j<length;j++){
		if(str[i][j]==s1){
			for(int k=j+1;k<length;k++){
				if(str[i][k]==s2){
					int br=k-j,now=j;
					for(int g=2;g<ppp;g++){
						if(now+br*g<length && str[i][now+br*g]==ans[g]){
						}else{
							a=false;
													}
					}
					if(a){ num++; goto we; }
					a=true;
				}
			}
		}
	}
	we:;
}
printf("%d\n",num);
return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int par[10000000];
int ranks[10000000];

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    ranks[i]=0;
  }
}

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

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y){
    return ;
  }
  if(ranks[x]<ranks[y]){
    par[x]=y;
  }
  else{
    par[y]=x;
  }
  if(ranks[x]==ranks[y]){
    ranks[x]++;
  }
}

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



int par2[10000000];
int ranks2[10000000];

void init2(int n){
  for(int i=0;i<n;i++){
    par2[i]=i;
    ranks2[i]=0;
  }
}

int find2(int x){
  if(par2[x]==x){
    return x;
  }else{
    return par2[x]=find2(par2[x]);
  }
}

void unite2(int x,int y){
  x=find2(x);
  y=find2(y);
  if(x==y){
    return ;
  }
  if(ranks2[x]<ranks2[y]){
    par2[x]=y;
  }
  else{
    par2[y]=x;
  }
  if(ranks2[x]==ranks2[y]){
    ranks2[x]++;
  }
}

bool same2(int x,int y){
  return find2(x)==find2(y);
}


int main(){
  int N,K,L;
  int p,q,r,s;
  map<pair<int, int>, int> cnt;
  cin>>N>>K>>L;
  init(N);
  init2(N);
  for(int i=0;i<K;++i){
    cin>>p>>q;
    unite(p-1,q-1);
  }
  for(int i=0;i<L;++i){
    cin>>r>>s;
    unite2(r-1,s-1);
  }
  for(int i=0;i<N;++i){
    cnt[make_pair(find(i),find2(i))]++;
  }
  for(int i=0;i<N;++i){
    cout<<cnt[make_pair(find(i),find2(i))]<<" ";
  }  
return 0;
}


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

int main()
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    cout << char(s1[0]-32)<< char(s2[0]-32) << char(s3[0]-32) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
num_list = [1]
dp = [0] * (n+1)
dp[1] = 1


def recursion(n, li):
    min_n = 10**9
    for i in li:
        if n - i < 0:
            continue
        num = dp[n - i]
        if min_n > num:
            min_n = num
    return min_n + 1


for i in range(1, 9):
    a = 6 ** i
    b = 9 ** i
    if a <= n:
        num_list.append(a)
    if b <= n:
        num_list.append(b)

for i in range(2, n+1):
    dp[i] = recursion(i, num_list)

print(dp[n])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> &t, ll &score){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        rep(j, 26){
            p-=c[j]*(i+1-a[j]);
        }
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        t[day]=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M2=0;
vector<pair<int,int>> m2(D);
vector<int> a(26);
rep(i, 26){
    a[i]=0;
}
int M=0;
rep(i, D){
}
vector<int> t(D);

int m=0;
ll score=0;
rep(i, D){
    M=0;
    rep(j, 26){
        score-=c[j]*(i+1-a[j]);
        if(s[i].at(j)+c[j]*(i+1-a[j])>M){
            M2=M;
            M=s[i].at(j)+c[j]*(i+1-a[j]);
            m2[i].second=m;
            m=j;
        }else if(s[i].at(j)+c[j]*(i+1-a[j])>M2){
            M2=s[i].at(j)+c[j]*(i+1-a[j]);
            m2[i].second=j;
        }
    }
    score+=M;
    m2[i].first=M-M2;
    a[m]=i+1;
    t[i]=m;
}
sort(m2.begin(), m2.end());
rep(i, D){
    calculate(c, s, m2[i].second, i, t, score);
}
rep(i, D){
    cout<<t[i]+1<<endl;
}
}


Measured memory_bytes: 3736
#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N+2,0);
  for(int i=1;i<=N;i++){
    cin >> a[i];
  }
  int cost=abs(a[1]);
  for(int i=1;i<=N;i++){
    cost = cost + abs(a[i+1]-a[i]);
  }
  for(int i=0;i<N;i++){
    if(a[i]<a[i+2]){
      if(a[i]<=a[i+1]&&a[i+1]<=a[i+2]){
	cout << cost << "\n";
      }
      else{
	if(a[i+1]<a[i]){
	  cout << cost - abs((a[i]-a[i+1])*2) << "\n";
	}
	else{
	  cout << cost - abs((a[i+1]-a[i+2])*2) << "\n";
	}
      }
    }
    else{
      if(a[i+2]<=a[i+1]&&a[i+1]<=a[i]){
	cout << cost << "\n";
      }
      else{
	if(a[i]<a[i+1]){
	  cout << cost - abs((a[i+1]-a[i])*2) << "\n";
	}
	else{
	  cout << cost - abs((a[i+2]-a[i+1])*2) << "\n";
	}
      }
    }
  }




  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,a[SZ];
map<int,int> m;
int main()
{
	scanf("%d",&n); int d=0;
	for(int i=1;i<=n;++i)
		scanf("%d",a+i),++m[a[i]],d=max(d,a[i]);
	int mi=1e9;
	for(int i=0;i<=d;++i)
		--m[max(i,d-i)],mi=min(mi,max(i,d-i));
	for(auto g:m)
	{
		if(g.se<0||(g.se&&g.fi<=mi))
		{
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
}


Measured memory_bytes: 256
//Jai Shree Ram
//#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define loopi(stop) for(int i=0; i<stop; i++)
#define loopj(stop2) for(int j=0; j<stop2; j++)
#define loopk(stop3) for(int k=0; k<stop3; k++)
#define loopi1(stop) for(int i=1; i<=stop; i++)
#define loopj1(stop2) for(int j=1; j<=stop2; j++)
#define loopk1(stop3) for(int k=1; k<=stop3; k++)
#define loopse(kt,sstart, eend) for(int kt = sstart; kt<eend; kt++)
#define faster_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define file_io_cf freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define p_b push_back
#define pii pair<int,int>
#define fi first
#define se second
#define prec_10 << fixed << setprecision(10)
#define DEB cout<<"DEBUG"<<'\n';
#define SRAND srand(time(0));

using namespace std;

int mod = 1000000007;

template <typename T>
void O(T x) {
    cout << x << '\n';
}

///////////////////////////////////CODE STARTS HERE///////////////////////////////////////////


int32_t main() {

    faster_io
    // file_io_cf
    
    string s;cin>>s;
    loopi(s.size()){
        if(s[i] == '7'){
            O("Yes");
            return 0;
        }
    }        

    O("No");
        

    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
int n,m,i,a[1002],j,k=0,c=0,temp,b;
scanf("%d %d",&n,&m);
for(i=0;i<m;i++){
scanf("%d %d",&a[i],&b);
}
for(i=0;i<m;i++){
for(j=m-1;j>i;j--){
if(a[i]<a[j]){
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
	for(i=0;i<m;i++){
		if(c>=m-1){
			break;
		}
		if(n<=a[i]){
			c++;
		}
		else{
		k=k+n-a[i];
		c++;
		}

	}
	printf("%d\n",k);
return 0;
}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    double x[N];
    string u[N];
    rep(i,N){
        cin >> x[i] >> u[i];
    }

    double ans=0;
    rep(i,N){
        if(u[i]=="BTC") ans+=x[i]*380000;
        else ans+=x[i];
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    K = inputInt()
    
    ans = 1
    for _ in range(N):
        if ans <= K:
            ans = ans * 2
        else:
            ans += K
    
    print(ans)
    
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define EPS 0.00001

void compute(int q){
  double x = q/2.0;
  while(1){
    if ( fabs(x*x*x - q) < EPS*q ) break;
    x = x - (x*x*x - q)/(3*x*x);


  }
  printf("%.6lf\n", x);
}

main(){
  int q;
  while( cin >> q && q >= 0 ) compute(q);
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n;
void solve(){
	cin >> n;
	
	cout << 3*n*n << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sstream>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#define maxsize 100000
#define ERROR -2
#define OK 1
#define maxi 100000
using namespace std;
typedef long long ll;
int main()
{
    int n,a[300],i;
    while(scanf("%d",&n)==1)
    {
        for(i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        printf("%d\n",a[n-1]-a[0]);
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int a, b;
    cin >> a >> b;
    if(a<b){
        rep(i, b) cout << a;
    }else{
        rep(i, a) cout << b;
    }
}

Measured memory_bytes: 256
unittest
{
	assert( [ "chokudai", "chokudaiz" ].parse.expand.solve == "Yes" );
	assert( [ "snuke", "snekee" ].parse.expand.solve == "No" );
	assert( [ "a", "aa" ].parse.expand.solve == "Yes" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto t = input.front.to!( dchar[] );
	return tuple( s, t );
}

auto solve( dchar[] s, dchar[] t )
{
	return ( s == t[ 0 .. $ - 1 ] ) ? "Yes" : "No";
}


Measured memory_bytes: 2816
x = input().split(' ')
x.sort
a = int(x[0])
b = int(x[1])
c = int(x[2])

if a<= b <=c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)

Measured memory_bytes: 6724
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean assess =false;
        for(int i=1;i<=9;i++){
            if(N%i==0&&(double)N/i<=9) {
                System.out.println("Yes");
                assess=true;
                break;
            }
        }
    if(!assess) System.out.println("No");
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<int> PQ;

int main(){
	int a, b, c;
	while(cin >> a >> b >> c){
		bool card[11];
		int ans = 0;
		clr(card,0);
		card[a] = true;
		card[b] = true;
		card[c] = true;
		for(int i = 1; i <= 20-a-b; i++) if(card[i] == false) ans++;
		if(ans >= 4) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
const int mod=1e9+7;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}
ll n,m,v,p;
ll a[maxn];
bool check(int x){
	ll temp=n*m,pos=x;
	while(pos<=n-p+1){
		if(a[pos]-a[x]>m) return 0;
		temp-=(a[pos]-a[x]);
		pos++;
	}
	return temp>=v*m;
}
int main(){
//	cin>>n;
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	int mid,l=1,r=n;
	while(l<=r){
		mid=l+r>>1;
		if(check(mid)) r=mid-1;
		else l=mid+1; 
	}
	cout<<n-l+1<<endl;
	
	return 0;
}
/*
2 98 1 1
1 100

*/



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int x[n];
  int minx = 100;
  int maxx = 0;
  for(int i=0;i<n;i++) {
    cin>>x[i];
    if(minx > x[i]) minx = x[i];
    if(maxx < x[i]) maxx = x[i];
  }
  long minsum = 10000000000;
  for(int i=minx; i <= maxx; i++){
    long sum = 0L;
    for(int j=0; j<n; j++){
      sum += pow(i-x[j], 2);
    }
    if(minsum > sum) minsum=sum;
  }

  cout << minsum << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<cstring>
#include<climits>
#include<algorithm>
#define ll long long int
using namespace std;
int main(){
	
		int k,a,b;
		cin>>k>>a>>b;
		bool flag=false;
		for(int i=a;i<=b;i++){
			if(i%k==0){
				flag=true;
			}
		}
		if(flag){
			cout<<"OK"<<endl;
		}
		else{
			cout<<"NG"<<endl;
		}
	
		}
		



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

template <typename Cost>
class Dijkstra {
private:
	struct Edge {
		int src, dst;
		Cost cost;
		bool operator < (const Edge &rhs) const {
			return cost > rhs.cost;
		}
	};
	
public:
	Dijkstra(int n) : g(n), INF(numeric_limits<Cost>::max()){}
	
	void addEdge(int src, int dst, Cost cost){
		g[src].push_back({src, dst, cost});
	}
	
	void solve(int s){
		const int n = g.size();
		
		d.assign(n, INF);
		p.assign(n, -1);
		
		priority_queue<Edge> pq;
		auto push = [&](int src, int dst, Cost sum){
			if (d[dst] > sum){
				d[dst] = sum;
				pq.push({src, dst, sum});
			}
		};
		auto pop = [&](){
			Edge e = pq.top(); pq.pop();
			p[e.dst] = e.src;
			return e;
		};
		
		push(-1, s, 0);
		while (!pq.empty()){
			Edge c = pop();
			for (Edge &e : g[c.dst]){
				push(c.dst, e.dst, c.cost + e.cost);
			}
		}
	}
	
	bool reach(int v){
		return d[v] != INF;
	}
	
	Cost dist(int v){
		return d[v];
	}
	
	vector<int> path(int v){
		vector<int> res;
		for (int u = v; ~p[u]; u = p[u]){
			res.push_back(u);
		}
		reverse(begin(res), end(res));
		return res;
	}

private:
	const Cost INF;
	vector<vector<Edge>> g;
	vector<Cost> d;
	vector<int> p;
};


int main()
{
	int n, m, r;
	scanf("%d %d %d", &n, &m, &r);
	
	Dijkstra<int> solver(n);
	
	for (int i = 0; i < m; i++){
		int s, t, d;
		scanf("%d %d %d", &s, &t, &d);
		
		solver.addEdge(s, t, d);
	}
	
	solver.solve(r);
	
	for (int i = 0; i < n; i++){
		if (solver.reach(i)) printf("%d\n", solver.dist(i));
		else puts("INF");
	}
}

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

int main(){
    int room[4][3][10];
    int n,b,f,r,v;
    
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                room[i][j][k]=0;
            }
        }
    }
    
    cin >> n;
    
    for(int i=1;i<=n;i++){
        cin >> b >> f >> r >> v;
        room[b-1][f-1][r-1]+=v;
    }
    
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout << " " << room[i][j][k];
            }
            cout << endl;
        }
        if(i<3)
        cout << "####################" << endl;
    }
    
    
}


Measured memory_bytes: 3092
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)


n,m = inm()
a = inl()
a.sort()
cs = [0,2,5,5,4,5,6,3,7,6]
dp = [-1]*(n+9)
dp[0] = 0
for i in range(n):
    if dp[i]>=0:
        for x in a:
            c = cs[x]
            dp[i+c] = max(dp[i+c], dp[i]+1)
ans = []
t = n
k = dp[n]
for j in range(k,0,-1):
    for i in range(m-1,-1,-1):
        x = a[i]
        c = cs[x]
        if t>=c and dp[t-c]==j-1:
            ans.append(str(x))
            t -= c
            break
print(''.join(ans))


Measured memory_bytes: 40816
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    // 引数の受け取り
    char A[100];
    scanf("%s",A);
    if (A[0]=='a' || A[0]=='i' || A[0]=='u'|| A[0]=='e'|| A[0]=='o'){
printf("vowel");
    }else{
printf("consonant");
    
    };

    return 0;
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 5010;

int n, k, tot[N], a[N];

bitset<N> pre[N], suf[N]; 

int main() {

	File();

	n = read(), k = read();
	For (i, 1, n) a[i] = read();

	pre[0][0] = suf[n + 1][0] = true;

	For (i, 1, n) {
		pre[i] = pre[i - 1];
		if (a[i] < k) pre[i] |= (pre[i - 1] << a[i]);
	}

	Fordown (i, n, 1) {
		suf[i] = suf[i + 1];
		if (a[i] < k) suf[i] |= (suf[i + 1] << a[i]);
	}

	int ans = n;
	For (i, 1, n) {
		if (a[i] >= k) -- ans;
		else {
			bool flag = false;
			int l = k - a[i], r = k - 1; 
			For (j, 0, k)
				tot[j] = (i ? tot[j - 1] : 0) + (suf[i + 1][j]);
			For (j, 0, k) if (pre[i - 1][j]) {
				int ll = max(0, l - j), rr = r - j;
				if (ll > rr) continue;
				flag |= tot[rr] - (ll ? tot[ll - 1] : 0);
			}
			if (flag) -- ans;
		}
	}
	printf ("%d\n", ans);

	return 0;

}

Measured memory_bytes: 6400
import collections
n = int(input())
s = [[] for _ in range(n)]
l = [collections.defaultdict(lambda:0) for _ in range(n)]
for i in range(n):
    s[i] = list(input())
    for j in s[i]:
        l[i][j] += 1
mind = [float("inf")]*26
for i in range(26):
    for j in range(n):
        mind[i] = min(mind[i],l[j][chr(97+i)])
ans = ""
for i in range(26):
    ans += chr(97+i)*mind[i]
print(ans)

Measured memory_bytes: 39920
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	min := math.Min(float64(a+b), float64(a+c))
	min = math.Min(min, float64(b+c))
	fmt.Println(int(min))
}


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


int main() {
    string s;
    cin >> s;

    int ans=0;
    for (int i = 0; i < s.size()-1; ++i){
        if(s[i]!=s[i+1])
            ans++;
    }

    cout << ans << endl;
}

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

ll f(int x, ll n){
    ll a = 1;
    rep(i, n){
       a*=x;
       if(a>mod)a%=mod;
    }
    return a;
}

int main(){
    ll n;
    cin >> n;
    ll ans = f(10, n);
    ans -= f(9, n)*2-f(8, n);
    ans %= mod;
    if(ans<0)ans+=mod;
    cout << ans << endl;
}

Measured memory_bytes: 3588
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func canBeTriangle(a, b, c int) bool {
	return a < b+c
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	l := make([]int, n)
	for i := 0; i < n; i++ {
		l[i] = nextInt()
	}

	sort.Ints(l)

	ans := 0
	for left := 0; left < n-2; left++ {
		r := left+2
		for m := left+1; m < n-1; m++ {
			if m >= r {
				r = m+1
			}
			for r < n && canBeTriangle(l[r], l[m], l[left]) {
				r++
			}

			ans += r - (m+1)
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>

int main()
{
  int N = 0;
  int A = 0;
  int count = 0;
  int minc = 100;
  
  scanf("%d", &N);
  for(int i = 0; i < N; i++)
  {
    scanf("%d", &A);
    count = 0;
    while(A % 2 == 0)
    {
      A = A / 2;
      count++;
    }
    minc = std::min(minc, count);
  }
  printf("%d", minc);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	struct UF {
		vector<int> r;

		UF( int n ): r( n, -1 ) {}
		int root( int x ) {
			if( r[x] < 0 ) { return x; }
			r[x] = root( r[x] );
			return r[x];
		}
		bool unite( int x, int y ) {
			x = root( x );
			y = root( y );
			if( x == y ) { return false; }
			if( r[x] > r[y] ) { swap( x, y ); }
			r[x] += r[y];
			r[y] = x;
			return true;
		}
		int size( int x ) {
			return -r[root( x )];
		}
	};

	void solve() {
		int N, M;
		cin >> N >> M;

		UF uf( N );
		for( int i = 0; i < M; ++i ) {
			int A, B;
			cin >> A >> B;
			uf.unite( A-1, B-1 );
		}

		int ans = 0;
		for( int i = 0; i < N; ++i ) {
			ans = max( ans, uf.size( i ) );
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 4048
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  [w, h, _] <- f
  p <- readLn
  solve w h <$> replicateM p f <*> replicateM h f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> [[Int]] -> [[Int]] -> Int
solve w h pss sss = sum $ zipWith (*) pl sl
  where
    idx x y = x + y * w
    f v [x,y,_] = V.accum (+) v [(idx x y, 1)]
    pl = V.toList $ foldl' f (V.replicate (w*h) 0) pss
    sl = concat sss



Measured memory_bytes: 5512
#include <bits/stdc++.h>
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp  make_pair
#define pb  push_back
#define  sz(x)   (int)x.size()
#define  all(x)  x.begin(), x.end()
#define	 allr(x)  x.rbegin(), x.rend()
#define  bit(x)  __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
int mul (int x, int y) { return ((ll)x * y) % mod; } 
int sub (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int) 3e5;
 
char a[500][500], b[500][500];

void solve () {
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= n; j ++) {
			cin >> a[i][j];
		}	
	}
	for (int i = 1; i <= m; i ++) {
		for (int j = 1; j <= m; j ++) {
			cin >> b[i][j];
		}	
	}

	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= n; j ++) {
			bool ok = true;
			for (int x = 1; x <= m; x ++) {
				for (int y = 1; y <= m; y ++) {
					if (i + x - 1 > n || j + y - 1 > n) {
						ok = false;
						break;
					}
					if (a[i + x - 1][j + y - 1] != b[x][y]) {
						ok = false;
						break;
					}
				}
	 		}
	 		if (ok) {
				cout << "Yes";
				return;
	 		}
		}
	}
	cout << "No";
}

main () { fast_in;
    int t = 1; //cin >> t;
    while (t --) {
    	solve ();    
    }
	return 0;
}

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


int main() {
  int N;
  cin >> N;
  vector<int> A;
  vector<int> B;
  long long  ans = 0;
  rep(i, N + 1) {
    int a; 
    cin >> a;
    A.push_back(a);
  }
  rep(i, N) {
    int b; 
    cin >> b;
    if (A[i] <= b) {
      ans += A[i];
      b -= A[i];
    } else {
      ans += b;
      b = 0;
    }
    if (A[i + 1] <= b) {
      ans += A[i + 1];
      A[i + 1] = 0;
    } else {
      ans += b;
      A[i + 1] -= b;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 892
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
S = readline().decode().rstrip()

ans = 0
for i in range(1000):
    i_ = '{:>03}'.format(i)
    idx = 0

    for s in S:
        if s == i_[idx]:
            idx += 1
        if idx == 3:
            ans += 1
            break

print(ans)


Measured memory_bytes: 41052
N,M = map(int,input().split())
MOD = 10**9 + 7
a = []
broken = [False for i in range(N+1)]
if M > 0:
	for i in range(M):
		x = int(input())
		a.append(x)
		broken[x] = True

	for i in range(M-1):
		if a[i+1]-a[i] == 1:
			print(0)
			exit()

dp = [0 for i in range(N+1)]
dp[0] = 1
for i in range(1, N+1):
	if broken[i]:
		continue
	if i == 1:
		dp[i] = dp[i-1]
	else:
		dp[i] = (dp[i-2] + dp[i-1]) % MOD
print(dp[N])


Measured memory_bytes: 8204
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int H,W;
    cin>>H>>W;
    int A,B;
    cin>>A>>B;
    vector<vector<int>> ans(H,vector<int>(W,0));    
    for(int i=0;i<H-B;i++){
        for(int j=0;j<W-A;j++){
            ans[i][j]=1;
        }
    }
    for(int i=0;i<B;i++){
        for(int j=0;j<A;j++){
            ans[H-1-i][W-1-j]=1;
        }
    }
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) cout<<ans[i][j];
        cout<<endl;
    }
    return 0;
}


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

int main(){
  
  int n;

  while(cin >> n){
    bool Prime[1000000] = {false};
    int i,j;

    for(i = 2; i <= n ; i++){
      if(Prime[i] == false){
        
	for(j = 2; i*j <= n ; j++){
	  Prime[i*j] = true;
	}
      }
    }
    int count = 0;
    for(i = 2 ; i <= n ; i++){
      if(Prime[i] == false){
	count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 2140
s = input()

cs = ['A', 'G', 'T', 'C']
ans = 0
for i in range(len(s)):
    cur = 0
    for j in range(i, len(s)):
        if s[j] in cs:
            cur += 1
        else:
            break
    ans = max(ans, cur)

print(ans)


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;
typedef pair<int, int> P;
typedef pair< P, vector<int> > Q;

#define MAX 100005
#define INF 1001001001

int n = 4;
int sft = log2(n*n)+0.5;
vector< vector<int> > board(n, vector<int>(n));
P xpos;
int heu;
ll bstat;
int min_res, next_min_res;
map<ll,int> step;

// i,jで指定した位置のピースについて、現在位置とゴールとのマンハッタン距離
int mh(int r, int c) {
  int num = board[r][c];
  if (num == n*n-1) return 0;
  return abs(num/n - r) + abs(num%n - c); 
}

void bmove(int r, int c) {
  int xr, xc;
  tie(xr,xc) = xpos;
  ll swpbit = board[r][c] ^ board[xr][xc];
  heu -= mh(r,c);
  swap(board[xr][xc], board[r][c]);
  heu += mh(xr,xc);
  bstat ^= swpbit << ((r*n+c)*sft);
  bstat ^= swpbit << ((xr*n+xc)*sft);
  xpos = {r,c};
}

bool dfs(int g) {
  if (g+heu > min_res) {
    next_min_res = min(next_min_res, g+heu);
    return false;
  }
  if (heu == 0) return true;
  if (step.count(bstat) && step[bstat] < g) return false;
  step[bstat] = g;

  vector<int> dx = { -1,  0,  1,  0 };
  vector<int> dy = {  0, -1,  0,  1 };
  rep(i,4) {
    int r, c;
    tie(r,c) = xpos;
    int nr = r + dx[i];
    int nc = c + dy[i];
    if (nr < 0 || nr >= n || nc < 0 || nc >= n) continue;
    bmove(nr,nc);
    if(dfs(g+1)) return true;
    bmove(r,c);
  }
  return false;
}

int main(int, char**)
{
  bstat = 0;
  rep(i,n)rep(j,n) {
    cin >> board[i][j];
    board[i][j]--;
    if (board[i][j] == -1) {
      xpos = {i, j};
      board[i][j] = n*n-1;
    }
    bstat |= (ll)board[i][j] << ((i*n+j)*sft);
  }
  heu = 0;
  rep(i,n)rep(j,n) {
    heu += mh(i,j);
  }
  min_res = heu;
  next_min_res = INF;
  while (!dfs(0)) {
    min_res = next_min_res;
    next_min_res = INF;
  }

  cout << min_res << endl;

  return 0;
}



Measured memory_bytes: 49604
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        int ans = 0;

        Integer n = sc.nextInt();
        Integer y = sc.nextInt();

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                int s = i * 10000 + j * 5000;
                if ((y - s) / 1000 == n - i - j) {
                    System.out.println("" + i + " " + j + " " + (y - s) / 1000);
                    sc.close();
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
        sc.close();
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back

#define pi 3.14

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

    int R;
    cin >> R;
    cout << 2*R*3.14 << endl;

    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h> 
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int a, b, ans = 0;
	cin >> a >> b;
	int x = gcd(a, b);
	vector<int>vec;
	for (int i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			vec.push_back(i);
			if (i * i != x) {
				vec.push_back(x / i);
			}
		}
	}
	sort(vec.begin(), vec.end());
	rep(i, vec.size()) {
		bool bou = true;
		rep(j, i) {
			if (gcd(vec[i], vec[j]) != 1) {
				bou = false;
				break;
			}
		}
		if (bou) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int n,a[200010];
int main() {
	scanf("%d",&n);
	int i,mn=1e9,r=0;
	for(i=0;i<n;i++) {
		scanf("%d",a+i);
		mn=min(mn,a[i]);
		if(mn>=a[i]) r++;
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int N;
    cin >> N;
    queue<int> q;
    for (int i = 0; i < pow(2, N); i++) {
        int a;
        cin >> a;
        q.push(a);
    }
    while (q.size() > 1) {
        int x = q.front();
        q.pop();
        int y = q.front();
        q.pop();
        if (x == y)q.push(x);
        else q.push(abs(x - y));
    }
    cout << q.front() << endl;
}

Measured memory_bytes: 1408
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func solve(n int) {
	ans := 0
	n /= 2
	for n > 0 {
		ans += n / 5
		n /= 5
	}
	out(ans)
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	if N%2 == 1 {
		out(0)
		return
	}

	solve(N)
}


Measured memory_bytes: 640
n, k = map(int, input().split())
s = [int(x) for x in list(input())]

state = 1
cnt = 0
l = []
for e in s:
    if e != state:
        l.append(cnt)
        cnt = 1
        state = e
    else:
        cnt += 1

if cnt != 0:
    l.append(cnt)


if len(l) % 2 == 1:
    l.append(0)

Add = 2 * k + 1
ruiseki = [0]

for i, e in enumerate(l):
    ruiseki.append(ruiseki[i] + l[i])

answer = 0
for i in range(0, len(l), 2):
    left = i
    right = min(i + Add, len(l))
    tmp = ruiseki[right] - ruiseki[left]
    answer = max(tmp, answer)

print(answer)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr lint MOD1 = 1532834020;
constexpr lint MOD2 = 2147482409;
constexpr lint MOD3 = 1388622299;
constexpr lint MOD4 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<pair<string, int>> S(N);
  REP(i, N) {
    string x;
    cin >> x;
    //REP(j, 500000) x += ('a' + j%26) ;
    S[i] = make_pair(x, x.size());
  }
  sort(ALL(S), [](auto const &a, auto const &b) { return a.second > b.second;});
  set<lint> rem;
  REP(i, N) {
    lint hash = 0;
    IFOR(j, 1, S[i].second) {
      hash = hash * MOD1 % MOD2;
      hash = (hash + (S[i].first[j] - 'a' + 1)) % MOD2;
    }
    rem.insert(hash);
  }
  //REP(i, N) cout << S[i].first << "\n";
  lint ans = 0;
  lint inv = power(MOD1, MOD2-2, MOD2);
  lint inv2 = power(MOD3, MOD4-2, MOD4);
  vector<map<lint, map<lint, lint>>> st(26);
  REP(i, N) {
    lint hash = 0;
    IFOR(j, 1, S[i].second) {
      hash = hash * MOD1 % MOD2;
      hash = (hash + (S[i].first[j] - 'a' + 1)) % MOD2;
    }
    lint hash2 = 0;
    IFOR(j, 1, S[i].second) {
      hash2 = hash2 * MOD3 % MOD4;
      hash2 = (hash2 + (S[i].first[j] - 'a' + 1)) % MOD4;
    }
    ans += st[S[i].first[0] - 'a'][hash][hash2];
    vector<bool> chr(26);
    REP(j, S[i].second) {
      //cout << hash << endl;
      if(j > 0) {
        hash = (hash - (S[i].first[j] - 'a' + 1) + MOD2) % MOD2;
        hash = hash * inv % MOD2;
        hash2 = (hash2 - (S[i].first[j] - 'a' + 1) + MOD4) % MOD4;
        hash2 = hash2 * inv2 % MOD4;
      }
      chr[S[i].first[j] - 'a'] = true;
      if(rem.find(hash) != rem.end()) REP(k, 26) if(chr[k]) st[k][hash][hash2]++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 80800
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        long N = nint();
        System.out.println(N*(N-1) / 2);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N; cin >> N;
  vector<INTV> G(N);
  vector<pair<INTP, int> > vec;
  INTV ans(N-1);
  INTV cnt(N);
  REP(i, N-1){
    int a, b; cin >> a >> b;
    a--; b--;
    vec.pb({{a, b}, i});
    G[a].eb(b); G[b].eb(a);
    cnt[a]++; cnt[b]++;
  }
  int cntall = 0;
  REP(i, N) chmax(cntall, cnt[i]);
  cout << cntall << endl;
  sort(ALL(vec));

  vector<pair<INTP, int> > tmp;
  vector<bool> visit(N, 0);
  visit[0] = 1;
  queue<INTP> que; que.push({0, -1});
  while(!que.empty()){
    INTP p = que.front(); que.pop();
    int pos = p.first, prev = p.second;
    int c = 1;
    for(auto next : G[pos]){
      if(!visit[next]){
        if(c == prev) c++;
        que.push({next, c});
        visit[next] = 1;
        tmp.pb({{min(pos, next), max(pos, next)}, c});
        c++;
      }
    }
  }
  sort(ALL(tmp));
  REP(i, N-1){
    ans[vec[i].second] = tmp[i].second;
  }
  REP(i, N-1){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 16304
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

op = []
for j in range(w):
    for i in range(h-1):
        if a[i][j] % 2 == 1:
            a[i][j] -= 1
            a[i+1][j] += 1
            op.append((i, j, i+1, j))

for j in range(w-1):
    if a[h-1][j] % 2 == 1:
        a[h-1][j] -=1
        a[h-1][j+1] +=1
        op.append((h-1, j, h-1, j+1))

print(len(op))
for y1, x1, y2, x2 in op:
    print(y1+1, x1+1, y2+1, x2+1)


Measured memory_bytes: 22808