akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 102;

int n, a[MAXN];
/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();
    cin >> n;
    REP (i, n) {
        cin >> a[i];
    }

    int ans = numeric_limits<int>::max();
    for (int i=-100; i<=100; i++) {
        int sum = 0;
        REP (j, n) {
            sum += SQ(a[j] - i);
        }

        ans = min(ans, sum);
    }

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


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

int main(){
    int n;
    cin >> n;
    long long name[5];
    for(int i=0; i<5; i++){
        name[i] = 0;
    }
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(s[0]=='M'){
            name[0] += 1;
        }else if(s[0]=='A'){
            name[1] += 1;
        }else if(s[0]=='R'){
            name[2] += 1;
        }else if(s[0]=='C'){
            name[3] += 1;
        }else if(s[0]=='H'){
            name[4] += 1;
        }
    }

    long long ans = 0;

    for(int i=0; i<3; i++){
        for(int j=i+1; j<4; j++){
            for(int k=j+1; k<5; k++){
                ans += name[i] * name[j] * name[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void swap(char &a, char &b) {
    char t = a;
    a = b;
    b = t;
}

int main()
{
    long long int n;
    cin >> n;
    string ans = "";
    bool diff1;
    while(n) {
        diff1 = false;
        if(!(n % 26)) {
            ans += ('a' + 26 - 1);
            diff1 = true;
        }
        else ans += ('a' + (n % 26) - 1);
        n /= 26;
        if(diff1) n--;
    }
    for(int i = 0; i < ans.length() / 2; i++) {
        swap(ans[i], ans[ans.length() - 1 - i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3612
n, c = map(int, input().split())
dl = []
for i in range(c):
    dl.append(list(map(int, input().split())))
cl = []
for i in range(n):
    cl.append(list(map(int, input().split())))

d = {i: [0]*c for i in range(3)}

for i in range(n):
    for j in range(n):
        d[(i+j)%3][int(cl[i][j])-1] += 1
cost = {i: [0]*c for i in range(3)}
for i in range(3):
    for j in range(c):
        for k in range(c):
            cost[i][j] += int(dl[k][j]) * d[i][k]
ans = float('inf')
for i in range(c):
    for j in range(c):
        for k in range(c):
            if i != j and j !=k and k != i:
                ans = min(ans, cost[0][i]+cost[1][j]+cost[2][k])
print(ans)
        


Measured memory_bytes: 44380
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a%d==0) a/=d;
  else a=a/d+1;
  if(c%b==0) c/=b;
  else c=c/b+1;
  if(c>a) cout << "No";
  else cout << "Yes";
}

Measured memory_bytes: 3632
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    int n, m, c;
    int b[21];
    cin >> n >> m >> c;
    REP(i, m) {
        cin >> b[i];
    }

    int res = 0;
    REP(i, n) {
        int tot = c;
        int tmp;
        REP(j, m) {
            cin >> tmp;
            tot += tmp * b[j];
        }
        if (tot > 0) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<b; i++)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ull M=1e6,N=1e7+5,INF=1e18;

void solve()
{
    ll k,a,b,n;
    bool is=false;

    cin >> k >> a >> b;
    
    n=a/k;
    n=n*k;

    while(n<=b)
    {
        if(n>=a && n<=b)
        {
            is =true;
        }
        n+=k;
    }

    if(is)
        cout << "OK" << endl;
    else
    {
        cout << "NG" << endl;
    }
    
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 3640
# まあ最小公倍数lcmでしょう lcmのアルゴリズムはしらんけどたしかgcdを求めてからなんかするやつ

n = int(input())
x = int(input())


def gcd(x, y):
    if x > y:
        return gcd(y, x)
    while x != 0:
        x, y = y % x, x
    return y


def lcm(x, y):
    return (x*y)//gcd(x, y)


for _ in range(n - 1):
    y = int(input())
    x = lcm(x, y)

print(x)


Measured memory_bytes: 3060
#include <stdio.h>

#define MAX 1000

void calculator(int a, int b, char op){
    if (op == '+')
        printf("%d\n", a + b);
    else if (op == '-')
        printf("%d\n", a - b);
    else if (op == '*')
        printf("%d\n", a * b);
    else if (op == '/')
        printf("%d\n", a / b);    
}

int main(void){
    int i, a, b;
    char op;
    for(i = 0; i < MAX; i++){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?')
            break;
        else
            calculator(a, b, op);
    }

    return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

	public static long inf = 1000000001;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long l = sc.nextLong();
		long[][] dist = new long[n][n];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i != j)
					dist[i][j] = inf;
			}
		}
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			long c = sc.nextLong();
			dist[a][b] = c;
			dist[b][a] = c;
		}
		for(int k = 0; k < n; k++) {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
					dist[j][i] = dist[i][j];
				}
			}
		}
		long[][] dist2 = new long[n][n];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i != j)
					dist2[i][j] = inf;
			}
		}
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				if(dist[i][j] <= l) {
					dist2[i][j] = 1;
					dist2[j][i] = 1;
				}
			}
		}
		for(int k = 0; k < n; k++) {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					dist2[i][j] = Math.min(dist2[i][j], dist2[i][k] + dist2[k][j]);
					dist2[j][i] = dist2[j][i];
				}
			}
		}
		int q = sc.nextInt();
		for(int i = 0; i < q; i++) {
			int s = sc.nextInt() - 1;
			int t = sc.nextInt() - 1;
			if(dist2[s][t] >= inf) {
				System.out.println(-1);
			} else {
				System.out.println(dist2[s][t] - 1);
			}
		}
	}

}


Measured memory_bytes: 91876
#include<cstdio>
#include<cstring>
using namespace std;
char a[100];
char b[100];
int gb(char a[],char b[],int n,int m){
	int i,j;
	char x;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
				x=a[j];
				a[j]=a[i];
				a[i]=x;  
				          
			}
		}
	}
	for(i=0;i<m-1;i++){
		for(j=i+1;j<m;j++){
			if(b[i]<b[j]){
				x=b[j];
				b[j]=b[i];
				b[i]=x;
			}
		}
	}
	for(i=0;i<n;i++){
		if(a[i]>b[i])
			return 0;
		if(a[i]<b[i])
			return 1;
		}
}
int main(){
	int i,n,m;
	while(~scanf("%s%s",a,b)){
	int f=0;
	n=strlen(a);
	m=strlen(b);
	for(i=0;i<n;i++){
		if(a[i]<b[i]){
		f=1;
		printf("Yes\n");
		break;
		}
		if(a[i]>b[i]){
		f=-1;
		if(gb(a,b,n,m)==0)
		printf("No\n");
		if(gb(a,b,n,m)==1)
			printf("Yes\n");
		break;
		}
	}
	if(f==0&&n<m)
	printf("Yes\n");
	if(f==0&&n==m)
	printf("No");
	}
}
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
    REP(i, a.size()) {
        cin >> a[i];
        a[i]--;
    }
}

ll mod = 1000000007;

int main() {
    ll N;
    cin >> N;
    string ans = "";
    if (N % 10 == 3) {
        ans = "bon";
    } else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
        ans = "pon";
    } else {
        ans = "hon";
    }

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

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[200001];
P ord(int a, int b) {
  if (a > b) swap(a, b);
  return P(a, b);
}
vector< vector<P> > solve() {
  vector< vector<P> > ret(N);
  long long sum = 0, cur = 0;
  int til = -1;
  rep(i, N) {
    sum += A[i];
    if (i > 0) {
      while (til+1 < i && 2LL*(cur+A[til+1]) <= sum) cur += A[til+1], til++;
      ret[i].pb(ord(cur, sum-cur));
      if (til+1 < i) ret[i].pb(ord(cur+A[til+1], sum-(cur+A[til+1])));
    }
  }
  return ret;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  vector< vector<P> > left = solve();
  reverse(A, A+N);
  vector< vector<P> > right = solve();
  reverse(all(right));

  long long m = 1LL<<60;
  for (int i=1; i<N-2; i++) {
    for (P p1 : left[i]) {
      for (P p2 : right[i+1]) {
        m = min(m, max(p1._2, p2._2) - min(p1._1, p2._1));
      }
    }
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 29952
n = int(input())
an = [int(x) for x in input().split()]
an_sum = sum(an)
x_sum = 0
ans = 1e10
for x in range(0,n-1):
    x_sum += an[x]
    ans = min(ans, abs(an_sum-2*x_sum))
print(ans)


Measured memory_bytes: 24812
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		int k = sc.nextInt();
    		int x = sc.nextInt();

    		int min = Math.max(x - (k-1), -1000000);
    		int max = Math.min(x + (k-1),  1000000);
    		for (int i=min; i<=max; i++) {
    			System.out.print(i);
    			System.out.print(" ");
    		}
    		System.out.println();

    	} finally {
    		sc.close();
    	}
    }
}



Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<cassert>
#include<ctime>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define all(n) n.begin(),n.end()
using namespace std;
int a,b;

int main(){
 
  while(true){
    cin >> a >> b;
    if(a+b == 0)break;
    int ans = (1<<27);
    assert(a>=0 && b>=0);
    for(int i=1;i<=a/2+1;i++){
      if(a%i != 0)continue;
      vector<int> vec;
      //cout << "a = " << i << "," << a/i << " ";
      vec.push_back(i);vec.push_back((int)(a/i));
      for(int j=1;j<=b/2+1;j++){
	if(b%j != 0)continue;
	//cout << "b = " << j << "," << b/j << endl;
	vec.push_back(j); vec.push_back(b/j);
	sort(all(vec));
	//for(int k=0;k<4;k++){
	//cout << vec[k] << endl;
	//}
	//cout << "---" << endl;
	int sum = 0;
	sum = (vec[1]-vec[0])*(vec[1]-vec[0]) + (vec[2]-vec[1])*(vec[2]-vec[1]) + (vec[3]-vec[2])*(vec[3]-vec[2]);
	//cout << "sum -  " << sum << endl;
	ans = min(ans,sum);
	vec.clear();
	vec.push_back(i); vec.push_back(a/i);
      }
    }

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

Measured memory_bytes: 1212
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int GCD(int a,int b){
  if(b==0){
    return a;
  }
  else{
    return GCD(b,a%b);
  }
}

int main(){
  int N,X;
  cin >> N >> X;
  int ans=0;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    x=abs(x-X);
    ans=GCD(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        long A = cin.Long();
        long B = cin.Long();
        long C = cin.Long();

        if(C - A >= 0) {
            if(C - A <= B) {
                Console.WriteLine(B + C);
            }
            else {
                Console.WriteLine(A + 2 * B + 1);
            }
        }
        else {
            Console.WriteLine(C + B);
        }
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


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

int main(){
  int N;
  cin >> N;
  int s1,s2,s3;
  s1 = N / 100;
  s2 = (N % 100) / 10;
  s3 = (N % 100) % 10;
  int count = s1 + s2 +s3;
  cout << count << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
} 
 int A =0;
for (int i = 0; i < N; i++) {
  A += vec.at(i);
}  
  A /= N;
  int P = 0;
for (int i = 0; i < N; i++) {
  P += (vec.at(i)-A)*(vec.at(i)-A);
} 
  int Q = 0;
for (int i = 0; i < N; i++) {
  Q += (vec.at(i)-A-1)*(vec.at(i)-A-1);
}  
  int R = min(P,Q);
  cout << R << endl;  
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();

  int n = 1;
  REP(i, N) {
    int a = nextInt();
    if (a == n) {
      n++;
    }
  }
  if (n == 1) {
    cout << -1 << endl;
  } else {
    ll ans = N - n + 1;
    cout << ans << endl;
  }

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main(void) {
    std::string s, t;
    std::cin >> s >> t;
    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end(), std::greater<char>());
    if (s < t) {
        std::puts("Yes");
    }
    else {
        std::puts("No");
    }
    return 0;
}

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 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int x, ans;
  cin >> x;
  if(x >= 400 && x <= 599) {
    ans = 8;
  } else if(x >= 600 && x <= 799) {
    ans = 7;
  } else if(x >= 800 && x <= 999) {
    ans = 6;
  } else if(x >= 1000 && x <= 1199) {
    ans = 5;
  } else if(x >= 1200 && x <= 1399) {
    ans = 4;
  } else if(x >= 1400 && x <= 1599) {
    ans = 3;
  } else if(x >= 1600 && x <= 1799) {
    ans = 2;
  } else {
    ans = 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int sum=0;
  
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='+'){
      sum++;
    }
    else if(S.at(i)=='-'){
      sum--;
    }
  }
    cout<<sum<<endl;
  }
  
      

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

using namespace std;

int main()
{
    long long n,m;
    while(~scanf("%lld%lld",&n,&m))
    {
        cout << ((m/2<n)? m/2 : n+(m-n*2)/4) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n[2],c[2];
	while(cin>>n[0],n[0]){
		int h[2][110],r[2][110],mx[2][110];
		rep(q,2){
			rep(i,n[q])mx[q][i]=0,cin>>h[q][i]>>r[q][i];
			if(!q)cin>>n[1];
		}
		mx[0][0]=(h[0][0]>h[1][0]&&r[0][0]>r[1][0])+1;
		mx[1][0]=(h[0][0]<h[1][0]&&r[0][0]<r[1][0])+1;
		int p;
		c[0]=c[1]=p=0;
		while(c[0]<n[0]||c[1]<n[1]){
			int tmax=0,f;
			if(c[p]==n[p]){
				p^=1;
				goto NEXT;
			}
			rep(k,2){
				rep(i,n[k]){
					f=h[k][i]<h[p][c[p]]&&r[k][i]<r[p][c[p]];
					if(f&&tmax<mx[k][i])tmax=mx[k][i];
					if(f&&mx[k][i]==0){
						p^=1;
						goto NEXT;
					}
				}
			}
			mx[p][c[p]++]=tmax+1;
			NEXT:;
		}
		cout<<max(mx[0][n[0]-1],mx[1][n[1]-1])<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		
		int result = 8;
		if(x >= 1800){
			result = 1;
		}else if(x >= 1600){
			result = 2;
		}else if(x >= 1400){
			result = 3;
		}else if(x >= 1200){
			result = 4;
		}else if(x >= 1000){
			result = 5;
		}else if(x >= 800){
			result = 6;
		}else if(x >= 600){
			result = 7;
		}
		System.out.println(result);
	}
}


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

int main(){
    int d, n;
    cin >> d >> n;
    int num = 1;

    for(int i=0; i<d; i++){
        num *= 100;
    }
    
    if(n==100){
        if(d==0){
            cout << num * n + 1 << endl;       
            return 0;
        }else if(d==1){
            cout << num * n + 100 << endl;
            return 0;
        }else{
            cout << num * n + 10000 << endl;
            return 0;
        }
    }
    else{
        cout << num * n << endl;
        return 0;
    }
}

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

int main(){
	char ch[10][10];
	bool judged;
	
	while((scanf("%s", ch[0])) != EOF){
		for(int i = 1; i < 8; i++){
				scanf("%s", ch[i]);
		}
		
		judged = false;
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				if(ch[i][j] == '1'){
					//A
					if(i + 1 < 8 && ch[i + 1][j] == '1' &&
					 j + 1 < 8 && ch[i][j + 1] == '1' &&
					 ch[i + 1][j + 1] == '1'){
						printf("A\n");
						judged = true;
						break;
					}
					//B
					if(i + 3 < 8 && ch[i + 1][j] == '1' &&
					 ch[i + 2][j] == '1' && ch[i + 3][j] == '1'){
						printf("B\n");
						judged = true;
						break;
					}
					//C
					if(j + 3 < 8 && ch[i][j + 1] == '1' &&
					 ch[i][j + 2] == '1' && ch[i][j + 3] == '1'){
						printf("C\n");
						judged = true;
						break;
					}
					//D
					if(i + 2 < 8 && j - 1 >= 0 &&
					 ch[i + 1][j - 1] == '1' && ch[i + 1][j] == '1' &&
					 ch[i + 2][j - 1] == '1'){
						printf("D\n");
						judged = true;
						break;
					}
					//E
					if(i + 1 < 8 && j + 2 < 8 &&
					 ch[i][j + 1] == '1' && ch[i + 1][j + 1] == '1' &&
					 ch[i + 1][j + 2] == '1'){
						printf("E\n");
						judged = true;
						break;
					}
					//F
					if(i + 2 < 8 && j + 1 < 8 &&
					 ch[i + 1][j] == '1' && ch[i + 1][j + 1] == '1' &&
					 ch[i + 2][j + 1] == '1'){
						printf("F\n");
						judged = true;
						break;
					}
					//G
					if(i + 1 < 8 && j + 1 < 8 && j - 1 >= 0 &&
					 ch[i + 1][j] == '1' && ch[i][j + 1] == '1' &&
					 ch[i + 1][j - 1] == '1'){
						printf("G\n");
						judged = true;
						break;
					}
				}
			}
			
			if(judged) break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//円形リスト
template <typename Num>
struct circle {
    vector<Num> c;
    long long int _l;
    circle(long long int l) : _l(l) {
        c = vector<Num>(l);
    }
    Num& operator[](int k) {
        int temp = k % _l;
        if (temp < 0) temp += _l;
        return c[temp];
    }
};

int main() {
    int n;
    cin >> n;
    circle<lint> a(n), b(n);
    priority_queue<pair<int, int>> pq;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (a[i] != b[i]) {
            pq.push(make_pair(b[i], i));
        }
    }
    lint ans = 0;
    while (pq.size() > 0) {
        pair<int, int> now = pq.top();
        pq.pop();
        lint neighbor = b[now.second - 1] + b[now.second + 1];
        lint temp = (b[now.second] - a[now.second]) / neighbor;
        ans += temp;
        b[now.second] -= temp * neighbor;
        if (b[now.second] == a[now.second]) {
            continue;
        } else if (b[now.second] >= b[now.second - 1] &&
                   b[now.second] >= b[now.second + 1]) {
            cout << -1 << endl;
            return 0;
        } else {
            pq.push(make_pair(b[now.second], now.second));
        }
    }
    cout << ans << endl;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a[] = new long[5];
        for (int i = 0; i < 5; i++) {
            a[i] = sc.nextLong();
        }
        sc.close();
        Arrays.sort(a);
        long sho = n / a[0];
        long ans = 0;
        if (sho == 0) {
            ans = 5;
        } else {
            long ama = n % a[0];
            if (ama == 0) {
                ans = sho + 4;
            } else {
                ans = sho + 5;
            }

        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    int n=in(),m=in(),l=in();
    vector<vec> len(n,vec(n,1000000100)),ans(n,vec(n,n*n));
    rep(i,n)len[i][i]=ans[i][i]=0;
    rep(i,m){
        int a=in()-1,b=in()-1,c=in();
        len[a][b]=len[b][a]=c;
        if(c<=l)ans[a][b]=ans[b][a]=0;
    }
    rep(k,n)rep(i,n)rep(j,n){
        len[i][j]=min(len[i][j],len[i][k]+len[k][j]);
        if(len[i][j]<=l){
            ans[i][j]=0;
        }
    }
    rep(k,n)rep(i,n)rep(j,n){
        ans[i][j]=min(ans[i][j],ans[i][k]+ans[k][j]+1);
    }
    int q=in();
    rep(i,q){
        int a=in()-1,b=in()-1;
        if(ans[a][b]!=n*n)cout<<ans[a][b]<<endl;
        else cout<<-1<<endl;
    }
}

Measured memory_bytes: 1280
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N1 = 100000;
int N, T;
int A[MAX_N1];

const int MAX_N = 1 << 17;

int n, dat[2*MAX_N-1];

void init(int n_) {
  n = 1;
  while (n < n_) n *= 2;
  for (int i = 0; i < 2*n-1; ++i) dat[i] = INT_MAX;
}

void update(int k, int a) {
  k += n-1;
  dat[k] = a;
  while (k > 0) {
    k = (k-1)/2;
    dat[k] = min(dat[k*2+1], dat[k*2+2]);
  }
}

//range = [a,b), node number = k, node range = [l, r) 
int query(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return INT_MAX;

  if (a <= l && r <= b) return dat[k];
  else {
    int v1 = query(a, b, 2*k+1, l, (l+r)/2);
    int v2 = query(a, b, 2*k+2, (l+r)/2, r);
    return min(v1, v2);
  }
}

int main() {
  cin >> N >> T;
  for (int i = 0; i < N; ++i) cin >> A[i];

  init(N);
  for (int i = 0; i < N; ++i) {
    update(i, A[i]);
  }


  vector<int> prof;
  int max_prof = 0;
  for (int i = N-1; i > 0; --i) {
    int t = A[i] - query(0, i, 0, 0, n);
    max_prof = max(max_prof, t);
    prof.push_back(t);
  }

  sort(all(prof));

  int ans = 0;
  for (int i = prof.size()-1; i >= 0; --i) {
    if (prof[i] < max_prof) break;
    ++ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 2300
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll n, s = 0;
	cin >> n;
	vector<ll> w(n);
	rep(i, n) {
		cin >> w.at(i);
		s += w.at(i);
	}
	ll l = w.at(0), r = s - l;
	ll m = abs(l - r);
	rep(i, n - 2) {
		l += w.at(i + 1);
		r = s - l;
		if (m > abs(l - r)) m = abs(l - r);
	}
	cout << m;
	return 0;
}

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a>>b;
	A = a + b;
	while (A > 0) {
		ans++;
		A -= 2;
	}
	cout << ans;
	
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int h,w;
	while(cin>>h>>w,h||w){
		int dig =(h*h)+(w*w);
		bool ok =false;
		int ans =INF;
		int ansh =INF;
		int answ = INF;
		for(int i =1;i <=150&&!ok;i++){
			for(int j =i+1;j <=150&&!ok;j++){
				if(i==h&&j==w)continue;
				int tmp =(i*i)+(j*j);
				int diff=tmp-dig;
				if(tmp >dig){
					if(ans >diff){
						//if(i <h)continue;
						ans =diff;
						ansh =i;
						answ =j;
					}else if(ans==diff){
						if(i >ansh)continue;
						ans =diff;
						ansh =i;
						answ =j;
					}
				}else if(tmp==dig){
					if(i >h){
						ansh =i;
						answ =j;
						ok =true;
						break;
					}
				}
			}
		}
		cout <<ansh<<" "<<answ<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
}
int main(void)
{
    //ABC153E方針:Hに到達するまでのDPテーブルを生成する
    lli H, N;
    cin >> H >> N;
    lli a[10010], b[10010];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }
    lli dp[10010];
    for (int i = 0; i <= H; i++)
    {
        dp[i] = 1000000000000000;
    }
    dp[0] = 0;
    for (int i = 1; i <= H; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if (i > a[j])
            {
                chmin(dp[i], dp[i - a[j]] + b[j]);
            }
            else
            {
                chmin(dp[i], b[j]);
            }
        }
    }
    cout << dp[H] << endl;
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>

using namespace std;

int main() {
    int n, i, j, rank = 1, rank_num, cards[4][13] = { 0 };
    char design;


    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> design >> rank;

        rank_num = rank - 1;

        if (design == 'S') cards[0][rank_num] = 1;
        else if (design == 'H') cards[1][rank_num] = 1;
        else if (design == 'C') cards[2][rank_num] = 1;
        else if (design == 'D') cards[3][rank_num] = 1;
    }

    i = 0;
    j = 0;


    while(i < 4) {
        if (cards[i][j] != 1) {
            if (i == 0) design = 'S';
            else if (i == 1) design = 'H';
            else if (i == 2) design = 'C';
            else if (i == 3) design = 'D';
            cout << design << " " << (j + 1) << endl;
        }

        j++;

        if (j == 13) {
            j = 0;
            i++;
        }
    }


    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int h, w, k;
	cin >> h >> w >> k;
	vvector<char> cake(h, vector<char>(w));
	vvector<int> has(h, vector<int>(w, 0));
	rep(i, h){
		rep(j, w){
			char d;
			cin >> d;
			cake[i][j] = d == '#';
		}
	}
	int cnt = 0;
	rep(i, h){
		rep(j, w){
			if(cake[i][j]){
				++cnt;
				has[i][j]=cnt;
			}
			if(j+1<w&&has[i][j+1]==0){
				has[i][j+1] = has[i][j];
			}
		}
		per(j, w){
			if(j-1>=0&&has[i][j-1]==0){
				has[i][j-1] = has[i][j];
			}
		}
	}
	rep(j, w){
		rep(i, h){
			if(i+1<h&&has[i+1][j]==0){
				has[i+1][j]=has[i][j];
			}
		}
		per(i, h){
			if(i-1>=0&&has[i-1][j]==0){
				has[i-1][j] = has[i][j];
			}
		}
	}
	rep(i, h){
		rep(j, w){
			output(has[i][j]);
		}
		outendl();
	}

	return 0;
}


Measured memory_bytes: 1280
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,9)
    {
        f(j,1,9)
        {
            if(i*j==n)
            {
                cout<<"Yes"<<endl;
                return  0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;

}





































Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll modinv(ll x, ll n){
    return modpow(x, n - 2);
}


ll a[200010];
ll b[200010];

int main(){
    ll n, cnt0 = 0;
    cin >> n;
    rep(i, n) cin >> a[i] >> b[i];
    map<P, ll> mp;
    vector<P> lp;
    rep(i, n){
        if (a[i] == 0 && b[i] == 0) cnt0++;
        else if (a[i] == 0) mp[{0,1}]++, lp.push_back({0,1});
        else if (b[i] == 0) mp[{1,0}]++, lp.push_back({1,0});
        else if (b[i] > 0){
            ll g = __gcd(abs(a[i]),abs(b[i]));
            mp[{a[i]/g, b[i]/g}]++;
            lp.push_back({a[i]/g, b[i]/g});
        }
        else {
            ll g = __gcd(abs(a[i]),abs(b[i]));
            mp[{-a[i]/g, -b[i]/g}]++;
            lp.push_back({-a[i]/g, -b[i]/g});
        }
    }

    ll ans = 1;

    map<P,ll> check;
    ll m = lp.size();
    rep(i, m){
        ll x = lp[i].first;
        ll y = lp[i].second;
        ll c = mp[lp[i]];
        if (check[lp[i]] > 0) continue;

        check[lp[i]]++;

        ll d = 0, tmp = 1;
        if (x > 0 && y > 0){
            d = mp[{-y, x}];
            tmp = modpow(2, c) + modpow(2, d) - 1 + MOD;
            check[{-y, x}]++;
        }
        else if (x < 0 || y < 0){
            d = mp[{y, -x}];
            tmp = modpow(2, c) + modpow(2, d) - 1 + MOD;
            check[{y, -x}]++;
        }
        else if (x == 0 || y == 0){
            d = mp[{y, x}];
            tmp = modpow(2, c) + modpow(2, d) - 1 + MOD;
            check[{y, x}]++;
        }
        tmp %= MOD;
        ans *= tmp;
        ans %= MOD;
    }
    ans = (ans + cnt0 - 1 + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 59344
N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] + L[j] > L[k] and L[i] < L[j] < L[k]:
                ans += 1
print(ans)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

    string N, M = "";
    bool ans1 = false, ans2 = false, ans3 = false;
    cin >> N;
    //vector<int> A(N);
    for (int i = N.size() - 1; i >= 0; i--) { M.push_back(N[i]); }
    for (int i = 0; i < N.size(); i++) {
        if (N[i] != M[i])break;
        if (i == N.size() - 1)ans1 = true;
    }
    M = "";
    for (int i = (N.size() - 3) / 2; i >=0 ; i--) { M.push_back(N[i]); 
    }    int k = 0;
    for (int i = 0; i <= (N.size() - 3) / 2; i++) {
        if (N[i] != M[k])break;
        if (i == ((N.size() - 3) / 2) )ans2 = true;
        k++;
    }
    M = "";
    for (int i = N.size()-1; i >= (N.size() + 1) / 2; i--) {
        M.push_back(N[i]);      
    }k = 0; 
    for (int i = (N.size() + 1) / 2; i < N.size(); i++) {
        if (N[i] != M[k])break;
        if (i == N.size()-1)ans3 = true;
        k++;
    }
    if (ans2 && ans1 && ans3)cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		while(0 < 1) {
		int test[];
		double ave,sum = 0,ans = 0;
		int student = sc.nextInt();
		if(student == 0) break;
		test = new int[student];
		for(int i = 0 ; i < student ; i++) {
			test[i] = sc.nextInt();
			sum += test[i];
		}
		ave = sum / student;
		for(int i = 0 ; i < student ; i++) {
			ans += Math.pow(test[i] - ave, 2);
		}
		ans /= student;
		ans = Math.sqrt(ans);
		System.out.println(ans);
		}
		sc.close();
	}
}


Measured memory_bytes: 31192
def main():
    N, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))

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

    B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]

    ans = 0
    tmp = pow(2, 40)
    for _ in range(40):
        count = 0
        tmp //= 2
        tmp_ = ans + tmp
        for b in B:
            if ((b & (tmp_)) == (tmp_)):
                count += 1
            if count >= K:
                ans += tmp
                break

    print (ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 25004
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var nxm=arr.shift().split(" ").map(Number);
var n=nxm[0];
var x=nxm[1];
var m=nxm[2];
arr=arr.map(function(v){
   v=v.split(" ").map(Number);
   return [v[0]-1,v[1]-1,v[2]];
});
var all=[];
var  loop=function(ary){
   if(ary.length==n)all.push(ary);
   else{
      for(var i=0;i<=x;i++)loop(ary.concat(i))
   }
};
loop([]);
var ans=[-1];
var max=-1;
all.forEach(function(v){
   for(var i=0;i<m;i++){
      var sum=0;
      for(var j=arr[i][0];j<=arr[i][1];j++)sum+=v[j];
      if(sum!=arr[i][2])return;
   }
   sum=v.reduce(function(a,b){return a+b;});
   if(sum>max){ans=v;max=sum;}
});
console.log(ans.join(" "));

Measured memory_bytes: 206892
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n;scanf("%d",&n);
    int a[n];for(int i=0;i<n;i++)scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),asc_cmp);
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
}

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll n;cin>>n;
  ll i,j;
  ll cnt=0;
  ll tmp=sqrt(n);
  if(tmp*tmp<n) tmp++;
  //cout<<tmp<<endl;
  for(i=1;i<tmp;i++){
    if(n%i==0){
      //cout<<i<<endl;
      ll x=n/i;
      if(abs(x-i)==1) continue;
      x--;
      //cout<<x<<endl;
      cnt+=x;
    }
  }
  if(n<3) cnt=0;
  cout<<cnt<<endl;
}


Measured memory_bytes: 768
N = int(input())
H = list(map(int,input().split()))

ans = 0
while any(H):
    start = False
    for i in range(N):
        if not start and not H[i]: continue
        if H[i]:
            start = True
            H[i] -= 1
        else:
            break
    ans += 1
print(ans)

Measured memory_bytes: 3060