akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(void) {
	long long N;
	cin >> N;
	vector<long long> A;
	vector<long long> abs_vals;
	long long sum = 0;
	long long sign = 1;
	for(int i = 0; i < N; ++i) {
		long long a;
		cin >> a;
		if(a < 0) sign *= -1;
		A.push_back(a);
		abs_vals.push_back(abs(a));
		sum += abs(a);
	}
	sort(abs_vals.begin(), abs_vals.end());
	if(sign == 1) {
		cout << sum << '\n';
	} else {
		cout << (sum - 2 * abs_vals[0]) << '\n';
	}
	return 0;
}



Measured memory_bytes: 2036
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    std::string X;
    std::cin >> X;

    std::stack<bool> s;
    for (size_t i = 0; i < X.size(); ++i) {
        if (X[i] == 'S') {
            s.push(true);
        }
        else {
            // 'T'
            if (!s.empty() && s.top()) {
                s.pop();
            }
            else {
                s.push(false);
            }
        }
    }

    std::cout << s.size() << std::endl;

    return 0;
}


Measured memory_bytes: 644
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node
{
  int id;
  struct node *parent;
  struct node *child[2];
} *nodePointer;
nodePointer root;
nodePointer make1node(int);
void insert(nodePointer);
int find(nodePointer,int);
void preorderWalk(nodePointer);
void inorderWalk(nodePointer);
int main(void)
{
  int i;//counter
  int n;//the number of operation
  char op[10];//operation
  int id;//inserted or found number
  nodePointer p;
  root=NULL;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s",op);
      if(strcmp(op,"insert")==0)
        {
          scanf("%d",&id);
          p=make1node(id);
          insert(p);
        }
      else if(strcmp(op,"find")==0)
        {
          scanf("%d",&id);
          if(find(root,id)==1) printf("yes\n");
          else printf("no\n");
        }
      else if(strcmp(op,"print")==0)
        {
          inorderWalk(root);
          preorderWalk(root);
        }
      else
        {
          printf("undefined operation\n");
          exit(1);
        }
    }
  return 0;
}
nodePointer make1node(int id)
{
  nodePointer p;
  p=(nodePointer)malloc(sizeof(struct node));
  p->id=id;
  p->parent=NULL;
  p->child[0]=NULL;
  p->child[1]=NULL;
  return p;
}
void insert(nodePointer p)
{
  nodePointer parent=NULL;//parent of p
  nodePointer temp=root;
  while(temp!=NULL)
    {
      parent=temp;
      if(p->id < temp->id) temp=temp->child[0];
      else temp=temp->child[1];
    }
  p->parent=parent;
  if(parent==NULL) root=p;
  else if(p->id < parent->id) parent->child[0]=p;
  else parent->child[1]=p;
}
int find(nodePointer p,int id)
{
  if(p==NULL) return 0;
  if(p->id < id) return find(p->child[1],id);
  if(p->id == id) return 1;
  if(p->id > id) return (find(p->child[0],id));
}
void preorderWalk(nodePointer p)
{
  if(p!=NULL)
    {
      printf(" %d",p->id);
      preorderWalk(p->child[0]);
      preorderWalk(p->child[1]);
      if(p==root)
        {
          printf("\n");
        }
    }
}
void inorderWalk(nodePointer p)
{
  if(p!=NULL)
    {
      inorderWalk(p->child[0]);
      printf(" %d",p->id);
      inorderWalk(p->child[1]);
      if(p==root)
        {
          printf("\n");
        }
    }
}



Measured memory_bytes: 20516
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <bitset>
#include <climits>
#include <iterator>
#include <set>
#include <iomanip>
#define ll long long
#define mod  1000000007

using namespace std;

int main()

{


    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int m=2,n,i,j;

    cin>>n;

    int a[m+10][n+10]={0},can[m+10][n+10]={0};

    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            cin>>a[i][j];
        }
    }

    can[0][0] = a[0][0];

    for(i=1;i<m;i++){
        can[i][0] = can[i-1][0] + a[i][0];
    }

    for(j=1;j<n;j++){
        can[0][j] = can[0][j-1] + a[0][j];
    }

    for(i=1;i<m;i++){
        for(j=1;j<n;j++){
            can[i][j] = max(can[i-1][j],can[i][j-1]) + a[i][j];
        }
    }

    cout<<can[m-1][n-1]<<endl;

    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            a[i][j]==0;
            can[i][j]==0;
        }
    }
    
    return 0;
}






Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

char in[11000];
long long dp[11000][110][2];
int main(){
	scanf("%s",in);
	int a;scanf("%d",&a);
	int n=strlen(in);
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<a;j++){
			for(int k=0;k<2;k++){
				if(!dp[i][j][k])continue;
				for(int l=0;l<10;l++){
					int tk=k;
					if(tk==0&&in[i]-'0'<l)continue;
					if(in[i]-'0'>l){
						tk=1;
					}
					dp[i+1][(j+l)%a][tk]=(dp[i+1][(j+l)%a][tk]+dp[i][j][k])%mod;
				}
			}
		}
	}
	long long ret=dp[n][0][0]+dp[n][0][1]+mod-1;
	ret%=mod;
	printf("%lld\n",ret);
}

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

int main()
{
    ll ans = 0;
    string N;
    cin >> N;
    for (int i = 0; i < N.size(); ++i)
    {
        const char a = N[i];

        ans += atoi(&a);
    }
    cout << ((ans % 9 == 0) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3732
/*
 * @Author: Kaizyn
 * @Date: 2020-03-22 19:57:48
 * @LastEditTime: 2020-03-22 20:18:02
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 1e2+7;
const int MOD = 1e9+7;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;

string s;

inline void solve()
{
    cin >> s;
    int n = s.size();
    string l = s.substr(0, n/2), r = s.substr(n/2+1, n/2);
    string rs = s, rl = l, rr = r;
    reverse(rs.begin(), rs.end());
    reverse(rl.begin(), rl.end());
    reverse(rr.begin(), rr.end());
    cout << (s == rs && l == rl && r == rr ? "Yes" : "No") << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

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

int x1, x2, x3, x4;
int y1, y2, y3, y4;

int main() {
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

  int vx = x2 - x1, vy = y2 - y1;
  x3 = x2 - vy;
  y3 = y2 + vx;
  x4 = x3 - vx;
  y4 = y3 - vy;
  
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}


Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;



int32_t main(){
    FAST;

    string s;   cin >> s;
    set<char> f;
    for(char c : s) f.insert(c);

    if(f.size() != 2)
        cout << "No" << endl;
    else {
        char one = *f.begin() , two = *f.rbegin();
        int _1 = 0 , _2 = 0;
        for(char ch : s)
            _1 += one == ch , _2 += two == ch;

        if(_1 == 2 and _2 == 2)
            cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

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

        if ((a + b) % 2 == 1) {
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println((a + b) / 2);
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=300005;
//i_am_noob
int n;

template <int mod>
struct Modint{
    int val;
    Modint(int _val=0){val=_val;}
    operator int() const {return (*this).val;}
    Modint operator +(const Modint& o) const {return val+o.val>=mod?Modint(val+o.val-mod):Modint(val+o.val);}
    Modint operator -() const {return val?Modint(mod-val):*this;}
    Modint operator -(const Modint& o) const {return val-o.val<0?Modint(val-o.val+mod):Modint(val-o.val);}
    Modint operator *(const Modint& o) const {return Modint(val*o.val%mod);}
    Modint operator +=(const Modint& o){*this=(*this)+o;return *this;}
    Modint operator -=(const Modint& o){*this=(*this)-o;return *this;}
    Modint operator *=(const Modint& o){*this=(*this)*o;return *this;}
    Modint Pow(int b) const {
        Modint tmp(val),ret(1);
        while(b){
            if(b&1) ret*=tmp;
            b>>=1;tmp*=tmp;
        }
        return ret;
    }
    Modint Pow(const Modint& a, int b) const {return a.Pow(b);}
    inline Modint inv() const {return (*this).Pow(mod-2);}
    Modint operator /(const Modint& o) const {return *this*o.inv();}
    bool operator ==(const Modint& o) const {return val==o.val;}
};
#define modint Modint<MOD>

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    print1(modint(10).Pow(n)-modint(9).Pow(n)*modint(2)+modint(8).Pow(n));
    return 0;
}


Measured memory_bytes: 3632
def main():
    N = int(input())

    count = 0
    for i in range(1, N+1, 2):
        divisor_num = 0
        for j in range(1, N+1):
            if i % j == 0:
                divisor_num += 1
        if divisor_num == 8:
            count += 1
    print(count)


if __name__ == "__main__":
    main()


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

int main(){
    int n; cin >> n;
    vector<vector<int>> a;
    for(int i=0; i<n; i++){
        int val; cin >> val;
        a.push_back(vector<int>{val, i});
    }
    sort(a.begin(), a.end());
    int ans = 0;
    // for(auto& line:a){
    //     for(auto& v:line){
    //         cout << v << " ";
    //     }
    //     cout << endl;
    // }
    for(int i=0; i<n; i++){
        if(abs(i - a[i][1]) % 2 == 1){
            ans++;
        }
    }
    cout << (ans + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 6836
cards = []
n = int(input())
for _ in range(n):
    cards.append(input())

# カードを全部用意する
suits = ('S', 'H', 'C', 'D')
res_cards = []
for suit in suits:
    for i in range(1, 14):
        res_cards.append(suit+' '+str(i))

for card in cards:
    res_cards.remove(card)

for card in res_cards:
    print(card)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
const ll MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100001
using namespace std;
const int mod=1e9+7;
int a[N],inv[N];

int Pow(int p,int q)
{
    int s=1;
    for(;q;q>>=1,p=1LL*p*p%mod)
        if(q&1) s=1LL*s*p%mod;
    return s;
}

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;++i) inv[i]=Pow(i,mod-2); 
    long long p=1,ans=a[k];
    for(int i=k+1;i<=n;++i)
    {
         p=p*(i-1)%mod;
         p=p*inv[i-k]%mod;
         ans=(ans+a[i]*p%mod)%mod;
    }
    ans-=a[n-k+1];
    p=1;
    for(int i=k+1;i<=n;++i)
    {
         p=p*(i-1)%mod;
         p=p*inv[i-k]%mod;
         ans=(ans-a[n-i+1]*p%mod)%mod;
    }
    if(ans<0) ans+=mod;
    printf("%d",ans);
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int W, a, b;
	int l, r;
	if (scanf("%d%d%d", &W, &a, &b) != 3) return 1;
	if (a <= b) {
		l = a;
		r = b;
	} else {
		l = b;
		r = a;
	}
	printf("%d\n", l + W >= r ? 0 : r - (l + W));
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<ll> a(n);
  vector<ll> b(m);
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a.rbegin(),a.rend());
  for(int i = 0;i < m;i++)cin >> b[i];
  sort(b.begin(),b.end());
  for(int i = a[0] + 1;i <= b[0];i++){
    if(i > x && i <= y){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

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

        int[] X = new int[5];
        int result = 0;

        for (int i = 0; i < 5; i++) {
            X[i] = scanner.nextInt();
            if (X[i] == 0) {
                result = i+1;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 26992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n; cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 1; i < n - 1; ++i){
        int l = p[i-1];
        int c = p[i];
        int r = p[i+1];
        if( (l < c && c < r) || (r < c && c < l) ){
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long

int main() {
	ll n, k,ans = 0;
	cin >> n >> k;
	if (k == 0) cout << n * n << endl;
	else {
		FOR(i, k + 1, n + 1) {
			ans += (n / i) * (i - k);
			ans += max(0ll, (n % i) - k + 1);
		}
		cout << ans << endl;
	}
}




Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
// queue: first in first out
// stack: first in last out
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
const ll NUM = 1e5+1;
// ll dp[100005][13];
ll dp[10005];

ll parent[NUM], treeSize[NUM], hasConnected[NUM];

long long modinv(long long a, long long m) {
    long long 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;
}

ll findParent(int child) {
  if (child == parent[child]) {
    return child;
  } else {
    return parent[child] = findParent(parent[child]);
  }
}

void init(int N) {
  rep(i, N) {
    parent[i] = i;
    treeSize[i] = 1;
    hasConnected[i] = 0;
  }
}

signed main(void) {
  ll N, M, K;
  cin >> N >> M >> K;
  init(N);
  rep(i, M) {
    ll A, B;
    cin >> A >> B;
    A--;
    B--;
    hasConnected[A]++;
    hasConnected[B]++;
    A = findParent(A);
    B = findParent(B);
    if (A != B) {
      parent[B] = A;
      treeSize[A] += treeSize[B];
    }
  }
  rep(i, K) {
    ll A, B;
    cin >> A >> B;
    A--;
    B--;
    if (findParent(A) == findParent(B)) {
      hasConnected[A]++;
      hasConnected[B]++;
    }
  }

  // print out
  rep(i, N) {
    cout << (treeSize[findParent(i)] - hasConnected[i] - 1) << " ";
  }
  cout << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const double PI=acos(-1.0);

int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double th = double(60*h + m)/720 * double(2*PI);
    double tm = double(m)/60 * double(2*PI);
    double rad = th - tm;
    double ans = double(a*a + b*b) - double(2*a*b*cos(rad));
    
    printf("%.10f", sqrt(ans));

    return 0;
}

Measured memory_bytes: 4152
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    cout << 3 * N * N << nn;
    return 0;
}

Measured memory_bytes: 256
H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result)


calculate(H, W, M, ARR)


Measured memory_bytes: 138152
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    int ans = 0;
    ans += B;
    if(C-B >= 0){
      ans += B;
      C -= B;
    }else{
      ans += C;
      C = 0;
    }
    
    if(C-A >= 1){
      ans += (A+1);
    }else if(C-A == 0){
      ans += A;
    }else{
      ans += C;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

typedef map<string, int> M;
typedef pair<int, string> P;

int main() {
    int n;
    int m[20], count[30];
    int d[20][30];
    string name[20];
    P characters[20];
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int i = 0; i < n; ++i) {
            cin >> name[i] >> m[i];
            for (int j = 0; j < m[i]; ++j) {
                cin >> d[i][j];
            }
        }
        for (int i = 0; i < 30; ++i) {
            count[i] = 0;
        }
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m[i]; ++j) {
                ++count[d[i][j]];
            }
        }
        for (int i = 0; i < n; ++i) {
            characters[i].first = 0;
            characters[i].second = name[i];
            for (int j = 0; j < m[i]; ++j) {
                characters[i].first += n + 1 - count[d[i][j]];
            }
        }
        sort(characters, characters + n);
        cout << characters[0].first << ' ' << characters[0].second << endl;
    }
}

Measured memory_bytes: 1224
n,x = map(int,input().split())
x -= 1

p = [1]
l = [1]
for i in range(n):
    p.append(p[-1]*2+1)
    l.append(l[-1]*2+3)

res = 0
while n >= 0:
    if n == 0:                 # レベル1のバーガーはこれ以上細分化できない
        res += 1
        break
    elif x == 0:               # 左端
        break
    elif x == l[n] - 1:        # 右端
        res += p[n]
        break
    elif x == l[n] // 2:       # 中心
        res += p[n-1] + 1
        break
    elif x > l[n] // 2:        # 1個包含している
        res += p[n-1] + 1
        x -= l[n-1] + 2
        n -= 1
    else:                      # 包含していない
        n -= 1
        x -= 1

print(res)


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

int main(){
  double x1,x2,y1,y2,ans;
  cin>>x1>>y1>>x2>>y2;
  ans=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
  cout<<fixed<<ans<<endl;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps (1e-8)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    int id=-1,cnt=0;
    for(int i=sqrt(n);i>=2;i--){
        if(n%i==0){
            id=i;
            break;
        }
    }
    if(id==-1)id=n;
    
    cnt+=id+n/id;
    
    cout<<cnt-2;
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }

int main() {
  int n,h,w;
  cin >> n >> h >> w;
  cout << max(0,(n-h+1)*(n-w+1)) << '\n';
  return 0;
}


Measured memory_bytes: 3564
#include<stdio.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int n;
  scanf("%d",&n);
  int l[10];
  int max=0;
  int sum=0;
  for(int i=0;i<n;i++){
    scanf("%d",l+i);
    max=MAX(max,l[i]);
    sum+=l[i];
  }
  printf("%s\n",max<sum-max?"Yes":"No");
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main() {
	string s; cin >> s;
	if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

int main() {
  int m, f, r;
  int count = 0;
  
  while (count < 50) {
    cin >> m >> f >> r;
    char score;
    if (m==-1 && f==-1 && r==-1) break;
    else if (m == -1 || f == -1) score = 'F';
    else if (m+f >= 80) score = 'A';
    else if (m+f >= 65) score = 'B';
    else if (m+f >= 50 || (m+f >= 30 && r >= 50)) score = 'C';
    else if (m+f >= 30) score = 'D';
    else if (m+f < 30) score = 'F';
    
    cout << score << endl;
    count++;
  }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;   //author: madmin2619/mintu_agarwal
     
#define nfs() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int long long int
#define endl "\n"
#define pb push_back
#define pf push_front
#define forin(i, n) for(int i=0;i<n;i++)
#define tr(c, it) for(auto it=c.begin();it!=c.end();it++)
#define sz(c) c.size()
#define all(c) c.begin(),c.end()
#define ff first
#define ss second
#define m_p(x, y) make_pair(x, y)

//const int inf = 1e15L;     
const int M = 1e9 + 7;
     
int32_t main(){
    nfs()
    int n, i, j, k, W, sum=0;
    string s;
    string t;
    cin >> s >> t;
    int l1=(int)s.length();
    int l2=(int)t.length();
    int lcs[l1 + 1][l2 + 1];
    for(i=0;i<=l1;i++){
        for(j=0;j<=l2;j++)
            lcs[i][j]=0;
    }
    pair<int, int> prev[l1+1][l2+1];
    for(i=1;i<=l1;i++){
        for(j=1;j<=l2;j++){
            if(s[i-1]==t[j-1]){
                lcs[i][j]=lcs[i-1][j-1] + 1;
                prev[i][j]=m_p(i-1, j-1);
            }
            if(lcs[i][j-1]>lcs[i][j]){
                lcs[i][j]=lcs[i][j-1];
                prev[i][j]=m_p(i, j-1);
            }
            if(lcs[i-1][j]>lcs[i][j]){
                lcs[i][j]=lcs[i-1][j];
                prev[i][j]=m_p(i-1, j);
            }
        }
    }
    string str;
    pair<int, int> temp = m_p(l1, l2);
    while((temp.ff)!=0 || (temp.ss)!=0){
        if(lcs[temp.ff][temp.ss]!=lcs[prev[temp.ff][temp.ss].ff][prev[temp.ff][temp.ss].ss])
            str.pb(s[temp.ff - 1]);
        temp=prev[temp.ff][temp.ss];
    }
    reverse(all(str));
    cout << str << "\n";
    return 0;
}

Measured memory_bytes: 105856
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		if(S.equals("Sunny")){
			System.out.println("Cloudy");
		}
		else if(S.equals("Cloudy")){
			System.out.println("Rainy");
		}
		else{
			System.out.println("Sunny");
		}
		stdIn.close();
	}
}


Measured memory_bytes: 35552
#include <stdio.h>

int main(void) {
	unsigned int n,i,a=0,b=0,x,y;
	while(1) {
		scanf("%d",&n);
		if(n!=0) {
			for(i=0;i<n;i++) {
				scanf("%d %d",&x,&y);
				if(x==y) {
					a+=x;
					b+=y;
				}
				else if(x>y) {
					a+=(x+y);
				}
				else {
					b+=(x+y);
				}
			}
			printf("%d %d\n",a,b);
			a=b=0;
		}
		else break;
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll n,w,ar[102],cst[102],dp[102][100001],mx=-1;
ll fun(ll i,ll wt,ll cs)
{
    if(i>n){return 0;}
    if(dp[i][wt]!=0){
        return dp[i][wt];
    }
    ll v1,v2;
    if(ar[i]+wt<=w){
        v1=cst[i]+fun(i+1,ar[i]+wt,cs);
        v2=fun(i+1,wt,cs);
        v1=max(v1,v2);dp[i][wt]=v1;return dp[i][wt];
    }
    else{
        v1=fun(i+1,wt,cs);
        dp[i][wt]=v1;
        return v1;
    }


}
int main()
{
    ll i,j;n=100;w=100;
    cin>>n>>w;
    for(i=1;i<=n;i++){
        scanf("%lld %lld",&ar[i],&cst[i]);
    }
    cout<<fun(1,0,0);

    return 0;
}


Measured memory_bytes: 77056
#include <stdio.h>
int h, w, k, f, e, dp, fla, ans;
char s[10][1005];
int d[10];
int c[10];
int ta[10];
int main() {
	ans = 10000;
	scanf("%d%d%d", &h, &w, &k);
	for (int i = 0; i < h; i++) {
		scanf(" %s", s[i]);
	}
	f = 1;
	for (int i = 1; i < h; i++)f *= 2;
	for (int ee = 0; ee < f; ee++) {
		e = ee;
		dp = 0;
		for (int i = 0; i < h - 1; i++) {
			d[i] = e % 2;
			e /= 2;
			dp += d[i];
		}
		for (int i = 0; i < 10; i++) {
			c[i] = 0;
		}
		for (int i = 1; i < h; i++) {
			if (d[i - 1])ta[i] = ta[i - 1] + 1;
			else ta[i] = ta[i - 1];
		}
		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				if (s[j][i] == '1') {
					c[ta[j]]++;
				}
			}
			fla = 0;
			for (int j = 0; j < h; j++) {
				if (c[j] > k) {
					fla = 1;
				}
			}
			if (fla) {
				dp++;
				for (int j = 0; j < h; j++)c[j] = 0;
				for (int j = 0; j < h; j++) {
					if (s[j][i] == '1') {
						c[ta[j]]++;
					}
				}
				fla = 0;
				for (int j = 0; j < h; j++) {
					if (c[j] > k) {
						fla = 1;
					}
				}
				if (fla)dp = 10000;
			}
		}
		if (ans > dp) {
			ans = dp;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	long long n;
	cin >> n;
	cout << n*(n + 1) / 2 << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    deque<int> que;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < k; i++) {
        que.push_back(a[i]);
    }
    for(int i = k; i < n; i++) {
        int f = *que.begin();
        if(f < a[i]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
        que.push_back(a[i]);
        que.pop_front();
    }
}

Measured memory_bytes: 4712
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void)
{
    long long n, t;
    cin >> n >> t;

    long long mincost;
    bool flag = false;

    mincost = 100000;

    for (int i = 0; i < n; i++)
    {
        long long ci, ti;
        cin >> ci >> ti;
        if (ti <= t && ci < mincost)
        {
            flag = true;
            mincost = ci;
        }
    }

    if (flag)
    {
        cout << mincost << endl;
    }
    else
    {
        cout << "TLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  int ans = 0;
  loop(n) {
    int x; std::cin >> x;
    if (ans + 1 == x) ans++;
  }
  ans = n - ans;
  if (ans == n) ans = -1;
  std::cout << ans << std::endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int s = 0;
  int nn = n;
  for(int i = 0; i < 10; i++){
    s += n %10;
    n /= 10;
  }
  if (nn % s == 0){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;


signed main(){
    cin >> n;
    print(n*n*n);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main()
{
    int n,w;
    cin >> n >> w;
    ll weight[n];
    ll val[n];
    for (int q = 0; q < n; q++)
    {
        cin >> weight[q] >> val[q];
    }
    ll dp[n][w+1];
    for (int q = 0; q < n; q++)
    {
        for (int e = 0; e <= w; e++)
        {
            if (q==0)
            {
                if (e-weight[q]>=0)
                {
                    dp[q][e]=val[q];
                }
                else
                {
                    dp[q][e]=0;
                }
            }
            else
            {
                dp[q][e]=dp[q-1][e];
                if (e-weight[q]>=0)
                {
                    dp[q][e]=max(dp[q][e], dp[q-1][e-weight[q]]+val[q]);
                }
            }
        }
    }
    cout << dp[n-1][w];
    return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ran 100010
#define i64 long long int
int n,a[ran],s[ran];
i64 calc(int X){
	s[0] = 0;
	for(int i=1; i<=n; i++){
		s[i] = s[i-1];
		if(a[i] <= X)s[i] ++;
	}
	ordered_set<pair<int,int> > ss;
	i64 res = 0;
	for(int i=0; i<=n; i++){
		res += ss.order_of_key(make_pair(2*s[i]-i-1, n+1));
		ss.insert(make_pair(2*s[i]-i,i));
	}
	return res;
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	i64 All = n * (n + 1LL)/2;
	int lo = 1, hi = (int)1e9;
	while(lo != hi){
		int mi = (lo + hi) / 2;
		if(calc(mi) >= All / 2 + 1)
			hi = mi;
		else
			lo = mi + 1;
	}
	printf("%d\n",lo);
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; cin >> n;
  vl d(n); ina(d,n);
  ll ans = 0;
  rep(i,n) {
    REP(j,i+1,n) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m = min({a, b, c, d, e});
    cout << n / m + (n % m == 0 ? 4 : 5) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long
using namespace std;

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

    string s;
    cin >> s;

    ll r = 0, g = 0, b = 0;
    for(ll i = 0; i < n; i ++)
    {
    	if(s[i] == 'R')
    		r ++;
    	else if(s[i] == 'G')
    		g ++;
    	else
    		b ++;
    }

    ll ans = r * g * b;
    // cout << ans << endl;
    for(ll i = 0; i < n - 2; i ++)
    {
    	for(ll j = n - 1; j > i + 1; j --)
    	{
    		if(s[j] == s[i])
    			continue;
    		else if((j - i) % 2 == 1)
    			continue;
    		else
    		{
    			ll k = (j + i) / 2;
    			if(s[k] != s[i] && s[k] != s[j])
    				ans --;
    		}
    	}
    }
    cout << ans << endl;

}

Measured memory_bytes: 3632
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    int n;
    cin >> n;
    vint v(100001);
    ll a;
    FOR(i,0,n) {
        cin >> a;
        v[a]++;
        v[a+1]++;
        if (a!=0){
            v[a-1]++;
        }
    }

    int ans=0;
    FOR(i,0,100001){
        ans = max(ans,v[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
program test
implicit none
integer :: i,j,k,m,n,c
integer :: d(30,30),color(500,500),color_num(0:2,500)=0,iwakan(0:2,500)=0,iwa_total,temp

read(*,*) n,c
do i=1,c
	read(*,*) (d(i,j),j=1,c)
enddo

do i=1,n
	read(*,*) (color(i,j),j=1,n)
enddo

do i=1,n
	do j=1,n
		color_num(mod(i+j,3),color(i,j)) = color_num(mod(i+j,3),color(i,j)) + 1
	enddo
enddo

do j=1,c !塗り替える後の色
	do i=1,c	!塗り替える前の色
		do k=0,2
			iwakan(k,j) = iwakan(k,j) + d(i,j) * color_num(k,i)
		enddo
	enddo
enddo

iwa_total = 10 ** 9

do i=1,c
	do j=1,c
		do k=1,c
			if(i.ne.j .and. i.ne.k .and. j.ne.k) then
				temp = iwakan(0,i) + iwakan(1,j) + iwakan(2,k)
				iwa_total = min(iwa_total,temp)
			endif
		enddo
	enddo
enddo

write(*,*) iwa_total

end program

Measured memory_bytes: 1408