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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
#define PI acos(-1.0)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

int main()
{
 
    ll n, x, i, c=0;
    cin>>n;
    while(n--){
    	cin>>x;
    	if(x%2==0){
    		while(x%2==0){
    			c++;
    			x/=2;
    		}
    	}
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
@c = {}

1.upto(n) do |i|
  str_i = i.to_s
  key = [str_i[0], str_i[-1]]
  @c[key] ||= 0
  @c[key] += 1
end

sum = 0
(1..9).to_a.map(&:to_s).repeated_permutation(2) do |p|
  sum += @c[[p[0], p[1]]].to_i * @c[[p[1], p[0]]].to_i
end
puts sum


Measured memory_bytes: 1788
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
int gcd(int a,int b) {
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b) {
    return a/gcd(a,b)*b;
}
struct Bar {
    int p,q,r,b;
    Bar (int _p,int _q,int _r,int _b) {
        p=_p,q=_q,r=_r,b=_b;
    }
};
struct Fraction {
    int bunbo,bunshi;
    Fraction (int _bunbo,int _bunshi) {
        int G=gcd(_bunbo,_bunshi);
		bunbo=_bunbo/G,bunshi=_bunshi/G;
    }
};
int n;
vector<Bar> Bars;
vector<Fraction> Fractions;
bool child[100];
void solve(int X,Fraction C) {
    if(Bars[X].r>0) solve(Bars[X].r-1,Fraction(C.bunbo*(Bars[X].p+Bars[X].q),C.bunshi*Bars[X].q));
    else Fractions.push_back(Fraction(C.bunbo*(Bars[X].p+Bars[X].q),C.bunshi*Bars[X].q));
    if(Bars[X].b>0) solve(Bars[X].b-1,Fraction(C.bunbo*(Bars[X].p+Bars[X].q),C.bunshi*Bars[X].p));
    else Fractions.push_back(Fraction(C.bunbo*(Bars[X].p+Bars[X].q),C.bunshi*Bars[X].p));
}
int main() {
    while(scanf("%d",&n),n) {
        Bars.clear();
        Fractions.clear();
        memset(child,0,sizeof(child));
        for(int i=0;i<n;i++) {
            int p,q,r,b;
            scanf("%d %d %d %d",&p,&q,&r,&b);
            if(r>0) child[r-1]=true;
            if(b>0) child[b-1]=true;
            Bars.push_back(Bar(p,q,r,b));
        }
        int par=0;
        for(int i=0;i<n;i++) {
            if(!child[i]) {par=i;break;}
        }
        solve(par,Fraction(1,1));
        int L=1;
        for(int i=0;i<Fractions.size();i++) {
            L=lcm(L,Fractions[i].bunbo);
        }
        printf("%d\n",L);
    }
}

Measured memory_bytes: 1044
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	
	ll a, b;
	cin >> a >> b;

	if (a + b == 15) { cout << "+"; }
	else if (a*b == 15) { cout << "*"; }
	else { cout << "x"; }


	system("PAUSE");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int best[100005];
  int a[100005];
  for( i=0;i<n;i++)
  {    cin>>a[i];
   
  }
  //best[i]=best option to reach ith stone
  best[0]=0;//standing on 1st stone
  
    best[1]=abs(a[1]-a[0]);

    
  for(i=2;i<=n-1;i++)
  {    best[i]=min((abs(a[i]-a[i-2])+best[i-2]),(best[i-1]+abs(a[i]-a[i-1])));
 //    cout<<best[i];
   }
  cout<<best[n-1];
}

Measured memory_bytes: 1024
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.List (transpose, sortBy)

main :: IO ()
main = do
  [n, m] <- f
  unless (n == 0 && m == 0) $ do
    solve <$> replicateM n f >>= putStrLn
    main
  where f = map read <$> words <$> getLine
  
solve :: [[Int]] -> String
solve = unwords . map (show . fst) . sortBy f . zip [1..] . map sum . transpose
  where f (a, b) (c, d) | b == d = compare a c
                        | otherwise = compare d b



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

int main(){
        string number;
        cin >>number;
        int result=0;
        for(int i=0;i<number.length();i++){
        result+=(number[i]-'0');
        }
        if(result % 9 ==0 ){
        cout<< "Yes"; 
        }
        else{
      cout<<"No";
        }       


}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>
#include <algorithm>

using namespace std;
//--------------------
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

void func() {
    string s;
    cin >> s;
    int a = 0;
    for (auto ch: s) {
        if( ch == 'A') {
             a += 1;
        }
    }
    cout << ((a == 3 || a == 0) ? "No" : "Yes") << endl;
}

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

Measured memory_bytes: 256
a, b = $stdin.read.split("\n")
b = b.split(" ").map{|c| c.to_i}
a = a.to_i
result = 0
i = 1
loop do
  break if i-1 >= a - 1
  a1 = b[i-1]
  a2 = b[i]
  a3 = b[i+1]
  if a1 == a2 || a3 == a2
    if a1 == a2 && a1 == a2
      b[i] = b[i] + 1
      result += 1
    elsif a1 == a2
      b[i] = b[i+1] +  1
      result += 1
    elsif a2 == a3
      b[i+1] = a2+b[i+2]
      result += 1
    end
  end
  i+=2
end
puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=4000012;
int get(int l,int r,int x)
{
      int ans=r/x;
      ans-=((l-1)/x);
      return ans;
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      int ans=get(a,b,c);
      ans+=get(a,b,d);
      ans-=get(a,b,c/__gcd(c,d)*d);
      cout<<(b-a+1)-ans;
}     
// I never lose. I either win or I learn

Measured memory_bytes: 256
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

M = 10**9+7
n = inp()
x = ip()

sm = sum(x)
sq = sm*sm
ans = 0
for i in x: ans += i*i
ans = (sq-ans)//2
print(ans%M)

Measured memory_bytes: 92048
function main(input){
  input = input.split(' ');
  var N = parseInt(input[0],10);
  
  if((N % 2) === 0){
    console.log(N / 2);
  }else{
    console.log((N + 1) / 2 );
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a + w < b){
        cout << b - (a + w) << endl;
    }else if(b + w < a){
        cout << a - (b + w) << endl;
    }else{
        cout << 0 << endl;
    }
}

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

int main()
{

        string S;
        cin >> S;
        string S2 = S;
        int len = S.length();
        for (int i = 0; i < len; ++i) {

                S2[i] = S[len-1-i];

        }

        int p = 0;
        while (1) {
                if (len == 0) {
                        cout << "YES" << endl;
                        break;
                }

                string sub = S2.substr(p, 5);
                p += 5;
                if (sub == "resar") {
                        sub = S2.substr(p, 1);
                        if (sub != "e") {
                                cout << "NO" << endl;
                                exit(0);
                        }
                        p += 1;
                        len -= 6;
                }
                else if (sub == "esare") {
                        len -= 5;
                }
                else if (sub == "maerd") {
                        len -= 5;
                }
                else if (sub == "remae") {
                        sub = S2.substr(p, 2);
                        if (sub != "rd") {
                                cout << "NO" << endl;
                                exit(0);
                        }
                        p += 2;
                        len -= 7;
                }
                else {
                        cout << "NO" << endl;
                        exit(0);
                }


        }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int num;
    cin >> n;
    vector<int>ans(n);

    for(int x = 1; x< 100; x++)
    {
        for(int y = 1; y < 100; y++)
        {
            for(int z = 1; z < 100; z++)
            {
                num = x * x + y * y + z * z + x * y + y * z + z * x;
                if(num <= 10000)
                    ans[num]++;
            }
        }
    }
    for(int i = 1; i <= n; i++)
    {
        cout << ans[i] << endl;
    }
}


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

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



Measured memory_bytes: 3168
from sys import stdin
rs = stdin.readline
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    K = ri()
    A, B = ril()
    for i in range(A, B + 1):
        if i % K == 0:
            ans = 'OK'
            break
    else:
        ans = 'NG'
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> InputList = new List<int>();
            List<List<int>> ResultList = new List<List<int>>();

            string oputputstring = string.Empty;
            string outputpoint = string.Empty;

            while (true)
            {
                var Input = Console.ReadLine().Split(' ');
                int H = int.Parse(Input[0]);
                int W = int.Parse(Input[1]);

                if (H == 0 && W == 0) break;

                InputList = new List<int>();

                InputList.Add(H);
                InputList.Add(W);
                ResultList.Add(InputList);
            }


            foreach (var InThelist in ResultList)
            {
                //#?????°?????£????????????(W)
                for (int x = 0; x < InThelist[1]; x++)
                {
                    oputputstring += "#";
                }

                //???#???#?????¨?????¨???????????????????????????
                for(int z = 0; z < InThelist[1]; z++)
                {
                    if(z == 0 || z == InThelist[1] - 1) outputpoint += "#";
                    else outputpoint += ".";
                }

                //?????????Consle.WriteLine???????????????
                for (int y = 0; y < InThelist[0]; y++)
                {
                    if(y == 0 || y == InThelist[0] - 1) Console.WriteLine(oputputstring);
                    else Console.WriteLine(outputpoint);
                }

                oputputstring = string.Empty;
                outputpoint = string.Empty;
                Console.WriteLine();   
            }

        }

    }

}

Measured memory_bytes: 8928
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128
const int maxn = 100005;
int dp[maxn];

signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, m;
  cin >> n >> m;
  fill(dp, dp + maxn, inf);
  dp[0] = 0;
  for(int i = 0; i < m; ++i) {
  	int a, b;
  	cin >> a >> b;
  	int t = 0;
  	for(int j = 0; j < b; ++j) {
  		int x;
  		cin >> x;
  		--x;
  		t |= 1 << x;
  	}
  	for(int j = 0; j < (1 << n); ++j) {
  		dp[j | t] = min(dp[j] + a, dp[j | t]);
  	}
  }
  if(dp[(1 << n) - 1] >= inf) {
  	cout << -1 << endl;
  } else {
  	cout << dp[(1 << n) - 1] << endl;
  }
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define ll long long
#define name "knapsack1"
#define maxn 100005

using namespace std;

ll n,m,w[105],v[105],res,a[maxn];

int main()
{
    ios_base::sync_with_stdio();
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>m;
    f(i,1,n)
    {
        cin>>w[i]>>v[i];
        fd(j,m,w[i])
        {
            a[j]=max(a[j],a[j-w[i]]+v[i]);
            res=max(res,a[j]);
        }
    }
    cout<<res;

}


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

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> c(30);
    rep(i, m) cin >> c[i];

    int INF = 1001001001;
    vector<int> dp(50001);
    rep(i, 50001) dp[i] = INF;
    dp[0] = 0;

    // dp[i] := i円払うときの最小の枚数
    rep(i, m) {
        for(int j = 0; j + c[i] <= n; j++) {
            dp[j+c[i]] = min(dp[j+c[i]], dp[j] + 1);
        }
    }


    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

const int MOD = (int)1e9 + 7;
const int NMAX = 200000;
ll fact[1 + NMAX];

ll lgput(ll a, int p) {
    ll ans = 1;
    while(p) {
        if(p % 2)
            ans = (ans * a) % MOD;
        a = (a * a) % MOD;
        p /= 2;
    }

    return ans;
}

inline ll comb(int n, int k) {
    return (((fact[n] * lgput(fact[k], MOD - 2)) % MOD) * lgput(fact[n - k], MOD - 2)) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    fact[0] = 1;
    for(int i = 1; i <= NMAX; i ++)
        fact[i] = (i * fact[i - 1]) % MOD;

    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int, int>> v(n + 2, {0, 0});
    for(int i = 1; i <= n; i ++)
        cin >> v[i].first >> v[i].second;
    sort(v.begin() + 1, v.end() - 1);
    if(!(v[n].first == h && v[n].second == w))
        v[++ n] = {h, w};

    vector<int> dp(n + 1, 0);
    for(int i = 1; i <= n; i ++) {
        dp[i] = comb(v[i].first + v[i].second - 2, v[i].first - 1);
        for(int j = 1; j < i; j ++) {
            if(v[i].first >= v[j].first && v[i].second >= v[j].second) {
                int x = v[i].first - v[j].first + 1;
                int y = v[i].second - v[j].second + 1;
                dp[i] = (MOD + dp[i] - ((dp[j] * comb(x + y - 2, x - 1)) % MOD)) % MOD;
            }
        }
    }
    cout << dp[n];

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  string a[55][55];
  for (int i=0; i<H; i++) {
    string str;
    cin >> str;
    for (int j=0; j<W; j++) {
      a[i][j] = str[j];
    }
  }

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

  string b[55][55];
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (a[i][j] == "#") {
        int num = 0;
        for (int d = 0; d < 4; ++ d) {
          const int ni = i + dy[d];
          const int nj = j + dx[d];
          if (ni < 0 or H <= ni) continue;
          if (nj < 0 or W <= nj) continue;
          if (a[ni][nj] == "#") {
            num = 1;
            break;
          }
        }
        b[i][j] = char(num + '0');
      } else {
        b[i][j] = ".";
      }
    }
  }
  string result;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (b[i][j] == "0") {
        result = "No";
        goto OUT;
      } else {
        result = "Yes";
      }
    }
  }
  OUT: cout << result << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rg register
using namespace std;
int n,cnt;
int main(){
    scanf("%d",&n);
	for(rg int i=1;i<=n;++i)
		if(i&1)++cnt;
	double a=n*1.0,b=cnt*1.0;
	cout<<b*1.0/a*1.0;
	return 0;
}

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

// ??´?????????????????°???????????§

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  int n, m, a[3];
  cin >> n >> m;
  rep(i, 3) cin >> a[i];  
  
  bool rG[101][55][55] = {{{false}}}; 
  rep(i, m) {
    int u, v; cin >> u >> v;
    u--, v--;
    rG[0][v][u] = true;
  }

  // rG[i][j][k] := i????????£?????????j??????k????????????????????????????????????????????????
  reps(i, 1, 101) rep(j, n) rep(k, n) rep(l, n) {
    rG[i][k][l] |= rG[i-1][k][j] & rG[0][j][l]; // ??????????????????
  }

  queue<int> que;
  que.push(n-1);
  int d[55]; memset(d, -1, sizeof(d));
  d[n-1] = 0;
  int bit[55] = {0};
  while(!que.empty()) {
    int now = que.front(); que.pop();
    if(now == 0) {
      cout << d[now] << endl;
      return 0;
    }
    rep(i, 3) rep(j, n) {
      if(!rG[a[i]-1][now][j]) continue;
      bit[j] |= 1<<i;
      if(bit[j] == (1<<3)-1 && d[j] == -1) {
	d[j] = d[now] + 1;
	que.push(j);
      }
    }
  }
  puts("IMPOSSIBLE");
  
  return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    cin >> str;
    
    int counter=0;
    
    for(int i=0; i<3; ++i){
        if(str.at(i) == '1') ++counter;
        else continue;
    }
    
    cout << counter << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    r, g, b = ILI()
    return (r, g, b)


def solve(r, g, b):
    num = r * 100 + g * 10 + b
    num_div = num % 4
    if num_div == 0:
        ans = "YES"
    else:
        ans = "NO"
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 6340
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	vector<int> v(n);
	for(int& x : v)
		scanf("%d",&x);
	long long ans = 0;
	vector<long long> sum(n);
	sum[n-1] = v[n-1];
	for(int i = n-2; i >= 0; i--)
		sum[i] = (sum[i+1] + v[i])%M;
	for(int i = 0; i < n-1; i++)
		ans = (ans + v[i]*sum[i+1])%M;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5656
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int a[200001];
int main(){
	cin>>n;
	int now=1;
	rep(i,n){
		cin>>a[i];
		if(a[i]==now)
		now++;
	}
	if(now==1)
	cout<<-1;
	else
	cout<<n-now+1;
	re 0;
}


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

static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=200001;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int a,b;
	cin>>a>>b;
	if(a+b<10)
		cout<<a+b<<endl;
	else
		cout<<"error"<<endl;
	return 0;
}

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


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b));

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);

    int t = (c-a) + (c-b);
    if(t%2==0) cout << t/2 << endl;
    else cout << ((t+1) / 2) + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
	#include <iostream>
	#include <string.h>
	#include <cstring>
	#include <cmath>
	#include <math.h>
	#include <algorithm>
	#include <iomanip>
	#include <map>
	#include <set>
	#include <vector>
	#include <sstream>
	#include <queue>	
	#include <bitset>
	using namespace std;	
	#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
	#define FR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
	typedef long long int llong;
	
	llong s[3001],ss[3001];
	int main()
	{
		
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		
		llong a,b;
		cin>>a>>b;
		llong p=(a+b)%24;
		cout<<p;
		return 0;
	}


Measured memory_bytes: 256
N, x = map(int, input().split())
a=list(map(int, input().split()))
count = 0
for i in range(N):
    if a[i]>x:
        count+=a[i]-x
        a[i]=x
count1=count
a1=a.copy()
for i in range(0, N, 2):
    ai=a1[i]
    if i==0:
        a1[i]=min(ai, x-a1[i+1])
    elif i==N-1:
        a1[i]=min(ai, x-a1[i-1])
    else:
        a1[i]=min(x-a1[i-1], x-a1[i+1], ai)
    count1+=ai-a1[i]

count2=count
a2=a.copy()
for i in range(1, N, 2):
    ai=a2[i]
    if i==0:
        a[i]=min(ai, x-a2[i+1])
    elif i==N-1:
        a2[i]=min(x-a2[i-1], ai)
    else:
        a2[i]=min(x-a2[i-1], x-a2[i+1], ai)
    count2+=ai-a2[i]

count3=count
prev=a[0]
for i in range(1, N):
    ai=a[i]
    if x-prev>=0 and x-prev<ai:
        a[i]=x-prev
    count3+=ai-a[i]
    prev=a[i]
print(count3)


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

typedef long long ll;

const int MAX_N = 1e5 + 5;;
int lp[MAX_N];
int pr[MAX_N];
int ind;
int psum[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	for (int i = 2; i < MAX_N; i++) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr[ind++] = i;
		}

		for (int j = 0; j < ind && pr[j] <= lp[i] && i * pr[j] < MAX_N; j++)
			lp[i * pr[j]] = pr[j];
	}

	for (int i = 3; i < MAX_N; i++) {
		psum[i] = psum[i - 1];
		if (lp[i] == i && lp[(i + 1) / 2] == (i + 1) / 2)
			psum[i]++;
	}

	int q;
	cin >> q;

	while (q--) {
		int l, r;
		cin >> l >> r;
		cout << psum[r] - psum[l - 1] << "\n";
	}
	return 0;
}

Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
 int N;cin>>N;
  map<string,int>M;M["AC"]=0;M["WA"]=0;M["TLE"]=0;M["RE"]=0;
  for(int i=0;i<N;i++){
  string s;cin>>s;
    M.at(s)++;
  }cout<<"AC"<<" "<<"x"<<" "<<M.at("AC")<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<M.at("WA")<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<M.at("TLE")<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<M.at("RE")<<endl;
  return 0;
  
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void) {
  int N,A,B,C,D,cnt1,cnt2,flag;
  scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
  char S[200002];
  scanf("%s", S);
  if(C < D) {
    flag = 1;
    cnt1 = 0;
    for(int i = A; i <= D-2; i++) {
      if(S[i] == '#') {
        cnt1++;
      }else{
        cnt1 = 0;
      }
      if(cnt1 == 2) {
        flag = 0;
        break;
      }
    }
  }else{
    cnt1 = 0;
    cnt2 = 0;
    flag = 0;
    for(int i = A-1; i <= C-1; i++) {
      if(B-2 <= i && i <=D) {
        if(S[i] == '.') {
          cnt2++;
        }else{
          cnt2 = 0;
        }
        if(cnt2 == 3) {
          flag = 1;
        }
      }
      if(S[i] == '#') {
        cnt1++;
      }else{
        cnt1 = 0;
      }
      if(cnt1 == 2) {
        flag = 0;
        break;
      }
    }
  }
  if(flag == 1) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        G[A].push_back({B});
        G[B].push_back({A});
    }
    
    vector<int> michi(N, -1);
    queue<int> q;
    q.push(0);
    while (q.size()) {
        int n = q.front();
        q.pop();
        for (auto e : G[n]) {
            if (michi[e.to] != -1) continue;
            michi[e.to] = n;
            q.push(e.to);
        }
    }
    cout << "Yes" << endl;
    REP(i, N) cout << michi[i] + 1 << endl;
    return 0;
}


Measured memory_bytes: 10060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    static void Main()
    {
        int n;
        int k;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            k = int.Parse(words[1]);
        }

        string s = Console.ReadLine();

        int answer = 0;
        string before = s.Substring(0, 1);
        for (int i = 1; i < n; i++)
        {
            if (before.Equals(s.Substring(i, 1)))
            {
                answer++;
            }
            else
            {
                before = s.Substring(i, 1);
            }
        }
        int unique = n - answer;

        if (unique % 2 == 1)
        {
            answer += Math.Min(k, unique / 2) * 2;
        }
        else
        {
            if (unique / 2 > k)
            {
                answer += k * 2;
            }
            else
            {
                answer = n - 1;
            }
        }

        Console.WriteLine(answer);
    }
}

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a==5 && b==5 && c==7) ||(a==5 && b==7 && c==5) ||(a==7 && b==5 && c==5))
    {
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    
    }
    return 0;
}


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

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

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  let c = read::<i64>();
  let d = read::<i64>();

  let min1 = min((a - c).abs(), (a - b).abs());
  let min2 = min((a - c).abs(), (b - c).abs());

  if min1 <= d && min2 <= d {
    println!("Yes");
  } else {
    println!("No");
  }
}



Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string n;
    cin >> n;
    ll sum = 0;
    REP(i,n.length()){
        sum+=(ll)(n[i]-'0');
    }
    if(sum%9)cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3748
s=input()
t=input()

a=list("abcdefghijklmnopqrstuvwxyz")

rs=dict()
rt=dict()
for i in range(26):
    rs[a[i]]=-1
    rt[a[i]]=-1

yn="Yes"
for i in range(len(s)):
    if rs[s[i]]==-1:
        rs[s[i]]=t[i]
    else:
        if rs[s[i]]!=t[i]:
            yn="No"
            break
    if rt[t[i]]==-1:
        rt[t[i]]=s[i]
    else:
        if rt[t[i]]!=s[i]:
            yn="No"
            break
        
print(yn)

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){

    intf n,k;
    cin >>n >>k;
    vector<intf> l(n);
    for(auto &e :l) cin >>e;

    sort(l.begin(),l.end(),std::greater<intf>());

    cout << accumulate(l.begin(),l.begin()+k,0) <<endl;


}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws Exception{
 
        double r, area, circumference;
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        r = Double.parseDouble(br.readLine());
 
        area = r * r *  Math.PI;
        circumference = 2 * r *  Math.PI;
        System.out.println(String.format("%.6f", area) + " " + String.format("%.6f", circumference));
 
    }
 
}

Measured memory_bytes: 24704
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
	int n = rint;
	char[][] cf = new char[][](n, n);
	foreach(i; 0 .. n) foreach(j; 0 .. n) cf[i][j] = '.';

	void put(int i, int j, int x1, int y1, int x2, int y2, char b){
		cf[i + x1][j + y1] = cf[i + x2][j + y2] = b;
	}

	void make3(int i, int j){
		put(i, j, 0, 0, 0, 1, 'a');
		put(i, j, 1, 0, 2, 0, 'b');
		put(i, j, 0, 2, 1, 2, 'c');
		put(i, j, 2, 1, 2, 2, 'd');
	}

	void make4(int i, int j){
		put(i, j, 0, 0, 0, 1, 'a');
		put(i, j, 1, 0, 1, 1, 'b');
		put(i, j, 2, 2, 2, 3, 'c');
		put(i, j, 3, 2, 3, 3, 'd');
		put(i, j, 0, 2, 1, 2, 'e');
		put(i, j, 0, 3, 1, 3, 'f');
		put(i, j, 2, 0, 3, 0, 'g');
		put(i, j, 2, 1, 3, 1, 'h');
	}

	void make5(int i, int j){
		put(i, j, 0, 0, 0, 1, 'a');
		put(i, j, 0, 3, 1, 3, 'b');
		put(i, j, 0, 4, 1, 4, 'c');
		put(i, j, 1, 0, 2, 0, 'd');
		put(i, j, 2, 2, 2, 3, 'e');
		put(i, j, 2, 4, 3, 4, 'f');
		put(i, j, 3, 0, 4, 0, 'g');
		put(i, j, 3, 1, 3, 2, 'h');
		put(i, j, 4, 1, 4, 2, 'i');
		put(i, j, 4, 3, 4, 4, 'j');
	}

	void make7(int i, int j){
		put(i, j, 0, 0, 0, 1, 'a');
		put(i, j, 0, 2, 0, 3, 'b');
		put(i, j, 0, 4, 1, 4, 'c');
		put(i, j, 1, 0, 2, 0, 'd');
		put(i, j, 1, 5, 1, 6, 'e');
		put(i, j, 2, 1, 2, 2, 'f');
		put(i, j, 2, 6, 3, 6, 'g');
		put(i, j, 3, 1, 4, 1, 'h');
		put(i, j, 3, 4, 4, 4, 'i');
		put(i, j, 4, 5, 5, 5, 'j');
		put(i, j, 5, 0, 6, 0, 'k');
		put(i, j, 5, 2, 5, 3, 'l');
		put(i, j, 6, 3, 6, 4, 'm');
		put(i, j, 6, 5, 6, 6, 'n');
	}

	int a = -1, b = -1;
	foreach(i; 0 .. n) foreach(j; 0 .. n) if(i * 4 + j * 5 == n) a = i, b = j;

	if(a >= 0){
		foreach(i; 0 .. a) make4(i * 4, i * 4);
		foreach(i; 0 .. b) make5(a * 4 + i * 5, a * 4 + i * 5);
	}
	else if(n == 3){
		make3(0, 0);
	}
	else if(n == 6){
		make3(0, 0);
		make3(3, 3);
	}
	else if(n == 7){
		make7(0, 0);
	}
	else if(n == 11){
		make4(0, 0);
		make7(4, 4);
	}
	else{
		"-1".writeln;
		return;
	}
	foreach(cq; cf) cq.to!string.writeln;

}

Measured memory_bytes: 5372
import copy
h,w,k = list(map(int,input().split()))
hw_origin = [[0]*w for i in range(h)]
for i in range(h) :
    c = input()
    for j in range(w) :
        hw_origin[i][j] = c[j]

ans = 0
for i in range(2**h) :
    for j in range(2**w) :
        hw = copy.deepcopy(hw_origin)
        for l in range(h) :
            if (i>>l)&1 :
                for m in range(w) :
                    hw[l][m] = 1
        for m in range(w) :
            if (j>>m)&1 :
                for l in range(h) :
                    hw[l][m] = 1
        countb = 0
        for l in range(h) :
            for m in range(w) :
                if hw[l][m] == '#' :
                    countb += 1
        if countb == k :
            ans += 1

print(ans)

Measured memory_bytes: 9336
#include <stdio.h>

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

Measured memory_bytes: 128
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,m ; cin >> n >> m ;
	vector<vector<pll>> g(n,vector<pll>(0)) ;
	vvll d(n,vll(n,INF)) ;
	for(int i=0;i<m;i++){
		ll a,b,c ;
		cin >> a >> b >> c ;
		a-- ; b-- ;
		g.at(a).emplace_back(b,c) ;
		g.at(b).emplace_back(a,c) ;
		d.at(a).at(b) = c ;
		d.at(b).at(a) = c ;
	}
	for(int i=0;i<n;i++) d.at(i).at(i) = 0 ;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) for(int k=0;k<n;k++) d.at(j).at(k) = min(d.at(j).at(k),d.at(j).at(i)+d.at(i).at(k)) ;
	ll cnt = 0 ;
	for(int i=0;i<n;i++){
		for(int j=0;j<g.at(i).size();j++){
			if(d.at(i).at(g.at(i).at(j).first)==g.at(i).at(j).second) cnt++ ;
		}
	}
	cnt /= 2 ;
	cout << m-cnt << endl ;
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 100000
#define INFTY 1000000000
struct Card{
  char suit;
  int value;
};

struct Card L[N/2+2],R[N/2+2];
void merge(struct Card*,int,int,int,int);
void mergeSort(struct Card*,int,int,int);
int partition(struct Card*,int,int,int);
void quickSort(struct Card*,int,int,int);

int main(){
  int i,n,v;
  struct Card A[N],B[N];
  char S[10];
  int stable=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)stable=0;;
}
if(stable==1)printf("Stable\n");
 else printf("Not stable\n");
 for(i=0;i<n;i++){
  printf("%c %d\n",B[i].suit,B[i].value);
}
  return 0;
}
void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1 = mid-left;
  int n2 = right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
 for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1].value=R[n2].value=INFTY;
  i=j=0;
  for(k=left;k<right;k++){
    if (L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else {
      A[k]=R[j++];
    }
  }
}
void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
      }
}
int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
}
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}
void quickSort(struct Card A[],int n,int p,int r){
   int q;
   if(p<r){
     q=partition(A,n,p,r);
     quickSort(A,n,p,q-1);
     quickSort(A,n,q+1,r);
   }
 }



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

int main()
{
        int N, M;
        int cnt[100005];
        bool flag[100005] = {};

        cin >> N >> M;
        flag[0] = true;
        fill_n(cnt, 100005, 1);
        for ( int i = 0; i < M; i++ ) {
                int x, y;
                cin >> x >> y; --x, --y;
                if ( flag[x] ) flag[y] = true;
                if ( cnt[x] == 1 ) flag[x] = false;
                cnt[x]--, cnt[y]++;
        }

        int sum = 0;
        for ( int i = 0; i < N; i++ ) {
                if ( flag[i] ) sum++;
        }

        cout << sum << endl;

        return ( 0 );
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,x;
  cin >> N >> x;
  if(x == N*2-1 || x == 1){
    cout << "No" << endl;
    return 0;
  }
  if(N == 2){
    cout << "Yes" << endl;
    for(int i=1; i<=3; i++){
      cout << i << endl;
    }
    return 0;
  }
  cout << "Yes" << endl;
  if(x == 2){
    set<int> se;
    se.insert(x+1);
    se.insert(x);
    se.insert(x-1);
    se.insert(x+2);
    int k=1;
    for(int i=1; i<=N*2-1; i++){
      if(i == N-1){
        cout << x-1 << endl;
      }else if(i == N){
        cout << x << endl;
      }else if(i == N+1){
        cout << x+1 << endl;
      }else if(i == N+2){
        cout << x+2 << endl;
      }else{
        if(se.count(k)){
          while(se.count(k)){
            k++;
          }
        }
        cout << k << endl;
        k++;
      }
    }
  }else{
    set<int> se;
    se.insert(x-1);
    se.insert(x);
    se.insert(x+1);
    se.insert(x-2);
    int k=1;
    for(int i=1; i<=2*N-1; i++){
      if(i == N-1){
        cout << x+1 << endl;
      }else if(i == N){
        cout << x << endl;
      }else if(i == N+1){
        cout << x-1 << endl;
      }else if(i == N+2){
        cout << x-2 << endl;
      }else{
        if(se.count(k)){
          while(se.count(k)){
            k++;
          }
        }
        cout << k << endl;
        k++;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1536
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using S = int;
S op(S a, S b)
{
    return max(a, b);
}
S e()
{
    return 0;
}
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    segtree<S, op, e> seg(300010);
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int l = max(0, a[i] - k);
        int r = min(300000, a[i] + k);
        int tmp = seg.prod(l, r+1) + 1;
        ans = max(ans, tmp);
        seg.set(a[i], tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string in; cin >> in;
    int n = in.size();

    int res = inf;
    rep(i, n-2){
        string cur = in.substr(i, 3);
        stringstream ss; ss << cur;
        int x; ss >> x;

        chmin(res, abs(753 - x));
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
use proconio::input;
fn helper(mut v: usize) -> usize {
  let mut ret = 0;
  while v % 2 == 0 {
    v /= 2;
    ret += 1;
  }
  ret
}

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

fn lcm(a: usize, b: usize) -> usize {
  a * b / gcd(a, b)
}

fn main() {
  input! {
    n: usize,
    mut m: usize,
    mut ais: [usize;n] 
  }
  
  for i in 0..ais.len() {
    if ais[i] % 2 == 1 {
      println!("0");
      return
    }
    ais[i] /= 2;
  }
  
  let t = helper(ais[0]);
  for i in 0..ais.len() {
    if helper(ais[i]) != t {
      println!("0");
      return
    }
    ais[i] >>= t;
  }
  m >>= t;

  let mut lcm_val = 1;
  for i in 0..ais.len() {
    lcm_val = lcm(lcm_val, ais[i]);
    if lcm_val > m {
      println!("0");
      return
    }
  }
    
  let mut result = m / lcm_val; 
  result = (result + 1) / 2;
  
  println!("{}", result);
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
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;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    string s;
    cin>>s;
    int o=0,t=0;
    rep(i,0,s.size()){
        if(s[i]=='0')o++;
        else t++;
    }
    int res=s.size();
    cout<<res-abs(o-t)<<endl;
    return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N; cin >> N;
    vector<Int> h(N);
    rep(i, 0, N) cin >> h[i];
    
    vector<Int> dp(N, 0);
    dp[1] = abs(h[1]-h[0]);

    rep(i, 2, N) {
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792