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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {

	set<string> s;
	int n;
	cin >> n;
	REP(i, n) {
		string t;
		cin >> t;
		s.insert(t);
	}

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



}

Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 2003;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	FOR(i,0,n)cin>>a[i];
	ll ans=0,ans2=0;
	ll wa=0;
	// a1<0
	FOR(i,0,n){
		wa += a[i];
		if(i%2==0&&wa>=0){
			ans += wa+1;
			wa = -1;
		}
		if(i%2&&wa<=0){
			ans -= wa-1;
			wa = 1; 
		}
	}
	// a1>0
	wa = 0;
	FOR(i,0,n){
		wa += a[i];
		if(i%2==0&&wa<=0){
			ans2 -= wa-1;
			wa = 1;
		}
		if(i%2&&wa>=0){
			ans2 += wa+1;
			wa = -1; 
		}
	}
	pri(min(ans,ans2));
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAXN 1001
#define INF 987654321
using namespace std;

int h, w, maior;
char A[MAXN][MAXN];
int T[MAXN][MAXN];
queue<pair<int,int>> q;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> A[i][j];
			T[i][j] = INF;
			if(A[i][j] == '#'){
				q.push({i,j});
				T[i][j] = 0;
			}
		}
	}
	
	while(!q.empty()){
		int i =  q.front().first;
		int j =  q.front().second;
		q.pop();
		if(i < h - 1 && T[i+1][j] == INF){
			q.push({i+1,j});
			T[i+1][j] = T[i][j] + 1;
		}
		if(i > 0 && T[i-1][j] == INF){
			q.push({i-1,j});
			T[i-1][j] = T[i][j] + 1;
		}
		if(j < w - 1 && T[i][j+1] == INF){
			q.push({i,j+1});
			T[i][j+1] = T[i][j] + 1;
		}
		if(j > 0 && T[i][j-1] == INF){
			q.push({i,j-1});
			T[i][j-1] = T[i][j] + 1;
		}
	}
	
	
	maior = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			maior = max(T[i][j],maior);
		}
	}
	
	cout << maior << "\n";
	
    return 0;
}

Measured memory_bytes: 13328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while (scanf("%s", &s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());

	return 0;
}

Measured memory_bytes: 548
a,b,c,x,y=gets.split.map(&:to_i)
m=0
if a+b>2*c then
  i=[x,y].min
  x-=i
  y-=i
  m+=i*c*2
end
m+=x*[a,2*c].min
m+=y*[b,2*c].min
p m

Measured memory_bytes: 1788
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    a = [int(input()) for _ in range(5)]
    res = 1000000
    for i in range(5):
        for j in range(5):
            if i == j:
                continue
            for k in range(5):
                if i == k or j == k:
                    continue
                for s in range(5):
                    if i == s or j == s or k == s:
                        continue
                    for t in range(5):
                        if i == t or j == t or k == t or s == t:
                            continue
                        res = min(res, ((a[i]-1)//10+1)*10+((a[j]-1)//10+1)*10+((a[k]-1)//10+1)*10+((a[s]-1)//10+1)*10+a[t])
    print(res)

if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> pro(n);
    for (int i=0; i<n; ++i) {
        cin >> pro.at(i).first >> pro.at(i).second;
        ++pro.at(i).second;
    }

    int maxl1 = 0, maxl2 = 0, minr1 = INF+1, minr2 = INF+1;
    for (auto p : pro) {
        int l = p.first, r = p.second;
        if (l > maxl1) maxl2 = maxl1, maxl1 = l;
        else if (l > maxl2) maxl2 = l;
        if (r < minr1) minr2 = minr1, minr1 = r;
        else if (r < minr2) minr2 = r;
    }
    int res = 0;
    for (auto p : pro) {
        int l = p.first, r = p.second;
        int maxl = maxl1 == l ? maxl2 : maxl1;
        int minr = minr1 == r ? minr2 : minr1;
        chmax(res, r - l + max(0, minr - maxl));
    }
    sort(pro.begin(), pro.end());
    vector<int> dp(n-1);
    int l = 0, r = INF+1;
    for (int i=0; i<n-1; ++i) {
        chmax(l, pro.at(i).first);
        chmin(r, pro.at(i).second);
        dp.at(i) += max(0, r - l);
    }
    l = 0, r = INF+1;
    for (int i=n-1; i>0; --i) {
        chmax(l, pro.at(i).first);
        chmin(r, pro.at(i).second);
        dp.at(i-1) += max(0, r - l);
    }
    for (auto x : dp) chmax(res, x);
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 1408
a,b,c,d=map(int,input().split())
if b<c or d<a:
    print(0)
else:
    if a<=c:
        if b<=d:
            print(b-c)
        else:
            print(d-c)
    else:
        if d<=b:
            print(d-a)
        else:
            print(b-a)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int R, C;
inline bool in(int r, int c) { return 0 <= r and r < R and 0 <= c and c < C; }

int bfs(vector<vector<int>> B) {
  int sr = 0, sc = 0, gr = 0, gc = 0;
  REP(i, R) REP(j, C) {
    if (B[i][j] == 2) sr = i, sc = j;
    if (B[i][j] == 3) gr = i, gc = j;
  }

  vector<vector<bool>> board(R, vector<bool>(C, false));
  REP(i, R) REP(j, C) board[i][j] = B[i][j] == 0;
  board[sr][sc] = board[gr][gc] = true;

  queue<tuple<int, int, vector<vector<bool>>, int>> que;
  que.emplace(sr, sc, board, 0);
  while (not que.empty()) {
    int r, c, cnt; vector<vector<bool>> board; tie(r, c, board, cnt) = que.front(); que.pop();

    REP(i, 4) {
      int nr = r + dr[i], nc = c + dc[i];
      if (in(nr, nc) and board[nr][nc]) {
        while (in(nr, nc) and board[nr][nc]) {
          if (nr == gr and nc == gc) return cnt + 1;
          nr += dr[i], nc += dc[i];
        }
        if (in(nr, nc) and cnt < 9) {
          vector<vector<bool>> next_board = board;
          next_board[nr][nc] = true;
          que.emplace(nr - dr[i], nc - dc[i], next_board, cnt + 1);
        }
      }
    }
  }
  return -1;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  while (true) {
    cin >> C >> R;
    if (R == 0 and C == 0) break;
    vector<vector<int>> B(R, vector<int>(C)); REP(i, R) REP(j, C) cin >> B[i][j];
    cout << bfs(B) << endl;
  }


  return 0;
}

Measured memory_bytes: 40744
MOD = 10**9 + 7
N,M= map(int,input().split())
S= list(map(int,input().split()))
T= list(map(int,input().split()))

def dpinit(ps, val=0):
    res = [val for i in [0]*ps[-1]]
    for i in ps[:-1][::-1]:
        res = [res[:] for k in [0]*i]
    return res

dp = dpinit((N+1,M+1))
for i in range(N+1):
    dp[i][0] = 1
for j in range(M+1):
    dp[0][j] = 1

for i in range(1,N+1):
    s = S[i-1]
    for j in range(1,M+1):
        t = T[j-1]
        dp[i][j] += dp[i-1][j] + dp[i][j-1]
        if s != t:
            dp[i][j] -= dp[i-1][j-1]
        dp[i][j] %= MOD

print(dp[N][M])




Measured memory_bytes: 73308
#include<bits/stdc++.h>
using namespace std;
int main()
{
  //定義
  int n;
  //Nをインプット
  cin >> n;
  //n個のベクター
  vector<double> vec;
  //ベクターに標準入力を入れる
  int a;
  for(int i = 0; i<n; ++i){
  cin >> a;
    vec.push_back(a);
  }
  //ソートしたーい
  sort(vec.begin(), vec.end());//ソート実行
  double answer;
  answer = (vec[0] + vec[1])/2;
  for(int i = 2; i<n; ++i){
    answer = (answer + vec[i])/2;
             }
      cout << answer <<endl;
    		return 0;
             
}

Measured memory_bytes: 256
import itertools
x,y=map(int,input().split())
if x>y:
    x,y=y,x
a=y-x
x-=a
y-=a*2
#print(x,y)
if x!=y or x%3!=0 or y%3!=0 or x<0 or y<0:
    print(0)
else:
    b=x//3
    ans=0
    #print(a,b)
    def modinv(a, mod=10**9+7):
        return pow(a, mod-2, mod)
    def combination(n, r, mod=10**9+7):
        r = min(r, n-r)
        res = 1
        for i in range(r):
            res = res * (n - i) * modinv(i+1, mod) % mod
        return res
    print(combination(a+2*b, b, mod=10**9+7))


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>v(n,0);
	for(int i=0,tmp;i<n;++i){
		cin>>tmp;
		++v.at(tmp);
	}
	int i,ans=1;
	if(n%2==1&&v.at(0)==1)i=2;
	else i=1;
	for(;i<n;i+=2){
		if(v.at(i)!=2||v.at(i-1)!=0)break;
		ans*=2;
		ans%=1000000007;
	}
	if(i-1==v.size())cout<<ans<<"\n"s;
	else cout<<"0\n"s;
}

Measured memory_bytes: 640
use std::collections::HashMap;
use petgraph::unionfind::UnionFind;
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize, usize); m],
    }

    let mut uf:UnionFind<usize> = UnionFind::new(n+1);
    for (a, b) in ab {
        uf.union(a, b);
    }
    let mut map = HashMap::new();
    for i in 1..=n {
        *map.entry(uf.find(i)).or_insert(0) += 1;
    }
    println!("{}", map.values().max().unwrap())
}


Measured memory_bytes: 10628
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		
		int red[] = new int [a];
		int green[] = new int [b];
		int non[] = new int [c];
		
		for(int i = 0 ; i < a ;i++) {
			red[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < b ; i++) {
			green[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < c ; i++) {
			non[i] = Integer.parseInt(sc.next());
		}
 		
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
	
		Arrays.sort(red);
		Arrays.sort(green);
		
		for(int i = a-1 ; i >= Math.max(0, a-x) ; i--) {
			pq.add(red[i]);
		}

		for(int i = b-1 ; i >= Math.max(0, b-y) ; i--) {
			pq.add(green[i]);
		}
		
		for(int i = 0 ; i < c ;i++) {
			pq.add(non[i]);
		}
		
		while(pq.size() > x + y) {
			pq.poll();
		}
		
		long sum = 0;
		
		for(int i = 0 ; i < x+ y ; i++) {
			sum += (long)pq.poll();
		}
		
		System.out.println(sum);
		
	
	}
	

}


Measured memory_bytes: 63464
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  REP(i,n){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  double tmp=v[0];
  for(int i=1;i!=n;i++){
    tmp=(tmp+v[i])/2;
  }
  cout << setprecision(12) << tmp << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;



public class Main {

	public static long MOD = 1_000_000_007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		long aa = 1;
		long bb = 1;
		for (int i=0;i<a;i++) {
			aa=div(aa*(n-i)%MOD, i+1)%MOD;
		}
		for (int i=0;i<b;i++) {
			bb=div(bb*(n-i)%MOD, i+1)%MOD;
		}
		 System.out.println((power(2, n)-aa-bb-1+MOD*3)%MOD);



	
	}
	
	static long power (long x, long y) {
		if (y==0) {
			return 1;
		} else if (y%2==0) {
			long a = power(x, y/2);
			return a*a%MOD;
		} else {
			long a = power(x,y/2);
			return a*a%MOD*x%MOD;
		}
	}
	
	static long div (long x, long y) {
		return (x * power(y,MOD-2))%MOD;
	}
	

}





Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 100010
#define MOD 1000000007

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
   cout.precision(10);

   int n;
   cin >> n;
   double a[n];
   for (int i = 0; i < n; ++i)
   {
      cin >> a[i];
   }
   sort(a, a + n);

   double ans = a[0];
   for(int i = 1; i < n; ++i)
   {
      ans = (ans + a[i]) / 2;
   }
   cout << fixed << ans;
   return 0;	
}

      // while(b)
      // {
      //    if(b & 1)
      //    {
      //       an = (an * a);
            
      //       if(an > 1e18) 
      //          an /= 1e18;
      //    }
      //    a = (a * a);
      //    if(a > 1e18)
      //       a /= 1e18;
      //    b >>= 1;
      // }


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

int main() {
	int n;
	cin>>n;
	vector<int> v(n);
	for(int &i : v) {
		cin>>i;
	}
	
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);
	
	for(int i=2;i<n;i++) {
		dp[i] = min(abs(v[i]-v[i-1])+dp[i-1], abs(v[i]-v[i-2]) + dp[i-2]);
	}
	
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    for (ll g = 1; g <= sqrt(m) + 1; ++g) {
        if (m % g != 0)
            continue;

        ll k = m / g;
        if (k * n <= m) {
            ans = max(ans, k);
        }

        if (g * n <= m) {
            ans = max(ans, g);
        }
    }

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

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

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

        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        int[] Y = new int[N];
        System.arraycopy(X,0,Y,0,N);
        Arrays.sort(Y);

        for (int i = 0; i < N; i++) {
            if (X[i] <= Y[(N / 2) - 1]) {
                System.out.println(Y[(N/2) ]);
            }else{
                System.out.println(Y[(N/2) - 1]);
            }
        }
    }
}


Measured memory_bytes: 90676
/// b.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,D;
    scanf("%d%d\n",&n,&D);
    static int s[1 << 20];
    for (int i = 1;i <= n;++i)
        scanf("%d",&s[i]);
    static int v[1 << 20];
    static int answer[1 << 20];
    v[0] = D;
    for (int i = 1;i <= n;++i)
        v[i] = min(v[i - 1],abs(v[i - 1] - s[i]));
    ll cnt = 0;
    for (int i = n;i;--i)
    {
        if (cnt < v[i - 1])
            answer[i] = 1;
        if (cnt * 2 + 1 >= s[i])
            cnt += s[i];
    }
    int q;
    scanf("%d",&q);
    while (q --)
    {
        int pos;
        scanf("%d",&pos);
        if (answer[pos])
            printf("YES\n");
        else
            printf("NO\n");
    }
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
int cntDiv(int n){
	int ans = 0;
	for (int i= 1;i*i<=n;i+=2){
		if(n%i==0){
			if(i*i==n)ans++;
			else ans +=2;
		}
	}
	return ans;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 1;i<= n;i+=2){
		if(cntDiv(i) == 8)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll n,i;
    scanf("%lld",&n);
    char s[n+5];
    scanf("%s",s);
    ll w[n],change[n];
    for(i=0;i<n;i++){
        if(i==0){
            w[i]=0;
            if(s[i]=='W') w[i]++;
            continue;
        }
        w[i]=w[i-1];
        if(s[i]=='W') w[i]++;
    }
    for(i=0;i<n;i++){
        if(i==0){
            change[i]=(n-1)-(w[n-1]-w[i]);
            continue;
        }
        if(i==n-1){
            change[i]=w[n-2];
            continue;
        }
        change[i]= w[i-1] + (n-i-1)-(w[n-1]-w[i]) ;
    }
    qsort(change,n,sizeof(ll),compare);
    printf("%lld\n",change[0]);
    return 0;
}


Measured memory_bytes: 7548
i,j,m,a[1005],c[1005];main(n){for(scanf("%d%d",&n,&m);i<n;scanf("%d",++i+a));for(;m--;c[j]++)for(j=!scanf("%d",&i);a[++j]>i;);for(;n;m=c[n--]>c[m]?n+1:m);i=!printf("%d\n",m);}

Measured memory_bytes: 604
h, w = map(int, input().split())
s = [input() for i in range(h)]

dirx = [-1, -1, 0, 1, 1, 1, 0, -1]
diry = [0, 1, 1, 1, 0, -1, -1, -1]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#': continue
        
        bumb_num = 0
        for d in range(len(dirx)):
            tempi = i + dirx[d]
            tempj = j + diry[d]

            if tempi < 0 or tempi >= h or tempj < 0 or tempj >= w: continue 
            if s[tempi][tempj] == '#': bumb_num += 1
        
        s[i] = s[i].replace('.', str(bumb_num), 1)

for i in range(h):
    print(s[i])


Measured memory_bytes: 3064
n,y = map(int,input().split()) #n枚,y円
a = -1
b = -1
c = -1
for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if i*10000+j*5000+k*1000 == y and k >= 0 :
            a = i
            b = j
            c = k
            break

print(a,b,c)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);

int main()
{ 
   
//  OJ;
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
 ll int n;
 cin>>n;
 ll int temp=n,i=1;

while(temp%360!=0)
{
    i++;
  temp=n*i;
 
 
}
cout<<i<<endl;
//cout<<temp/n;
}

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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(),a.end());
	int ansn=a[n-1];
	double bestr=double(ansn)/2;
	int ansr=0;
	for(int i=0;i<n;i++){
		if(abs(bestr-double(a[i]))<abs(bestr-double(ansr))){
			ansr=a[i];
		}
	}
	cout<<ansn<<' '<<ansr<<endl;
	return 0;
}


Measured memory_bytes: 640
// Bismillahirrahmanirrahim
// AgriCoder IPB
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <clocale>
#include <ctime>
#include <climits>
#include <cassert>
//#include <unordered_map>
using namespace std;

#define FOR(i, agri, coder) for (int i = (int)agri; i <= (int)coder; i++)
#define REP(agri,coder) for (int agri = 0; agri < (int)coder; agri++)
#define FOREACH(i,agricoder) for (typeof((agricoder).end()) i = (agricoder).begin(); i != (agricoder).end(); ++i)
//for (auto& it: agricoder)
#define RESET(agri,coder) memset(agri, coder, sizeof(agri))
#define pb push_back
#define mp make_pair
#define NL printf("==========================\n")
#define getchar_unlocked getchar // for codeforces

int arahbar[8] = {0,1,0,-1,1,1,-1,-1};
int arahkol[8] = {1,0,-1,0,1,-1,-1,1};
int kudabar[8] = {-2,-1,1,2, 2,1 , -1 ,-2};
int kudakol[8] = {1 ,2 ,2,1,-1,-2 , -2,-1};

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned int UNi;

template<typename T>
T getNum() {
   T res=0;
   char c;
   while(1)
   {
      c=getchar_unlocked();
      if(c==' ' || c=='\n') continue;
      else break;
   }
   bool negatif;
   if (c=='-') {
       negatif = true;
       res = 0;
   }
   else {
       res=c-'0';
       negatif = false;
   }
   while(1)
   {
      c=getchar_unlocked();
      if('0'<=c && c<='9') res=res*10 + c-'0';
      else break;
   }
   if (negatif) res*=-1;
   return res;
}

inline void boost() { //dont use with cstdio, dont use in interactives
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
}
//freopen("badmilk.in", "r", stdin);
//freopen("badmilk.out", "w", stdout);
//fclose(stdin);
//fclose(stdout);

#define INF 1000000000
#define EPS 1e-9
#define MAX_N 100005

// ================================  TEMPLATE ENDS HERE ================================================== //

int main() {
	int deg[100005];
	int n,m;
	scanf("%d %d",&n,&m);
	RESET(deg,0);
	REP(i,m) {
		int x,y;
		scanf("%d %d",&x,&y);
		deg[x]++; deg[y]++;
	}
	FOR(i,1,n) if (deg[i]&1) {
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	return 0;
}
//Alhamdulillahirabbilalamin


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

static const int INFTY = 1e+9 + 7;

int power(int a, int n){
    if(n == 0) return 1;
    if(a == 0) return 0;
    return (a * power(a, n - 1)) % INFTY;
}

int main(){
    int n; cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    sort(A.begin(), A.end());

    bool flag = true;
    if(n % 2){
        if(A[0] != 0) flag = false;
        rep(i, n / 2){
            if(A[2 * i + 1] != 2 * (i + 1)) flag = false;
            if(A[2 * i + 2] != 2 * (i + 1)) flag = false;
        }
    } else
        rep(i, n / 2){
            if(A[2 * i + 0] != 2 * i + 1) flag = false;
            if(A[2 * i + 1] != 2 * i + 1) flag = false;
        }

    if(flag) cout << power(2, n / 2) << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  int z = min(x, y);
  int m = max(x, y);
  int oldz = 0;
  while (m % z != 0) {
    oldz = z;
    z = m % z;
    m = oldz;
  }
  cout << z << endl;
  
  return 0;
}



Measured memory_bytes: 3112
#include <stdio.h>

int main(void) {
    int a, b, c, i;
    int cnt = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (i = a; i <= b; i++) {
        if (c % i == 0) cnt++;
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 2104
def main():#やり直し
    #input
    N=int(input())
    l=list("abcdefghijklmnopqrstuvwxyz")
    n=N
    name=""
    while n>=26:
        n-=1
        name+=l[n%26]
        n//=26
    if n!=0:
        name+=l[n-1]
    print(name[::-1])

if __name__=="__main__":
    main()

Measured memory_bytes: 9180
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


int main() {
    int N, K;
    cin >> N >> K;

    double res = 0;
    for (int n = 1; n <= N; n++) {
        int k = n;
        double tmp = 1.0 / N;
        while (k < K) {
            tmp *= 0.5;
            k *= 2;
        }
        res += tmp;
    }

    cout.precision(17);
    cout << fixed << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
string k;
ll mx,p,i;
int main(){
	cin>>k;
	set<char>pk = {'A','C','G','T'};
	for(i = 0,mx = 0,p = 0;i<ll(k.size());i++){
		if(pk.count(k[i])){
			p++;
		}else{
			mx = max(mx,p);
			p = 0;
		}
	}
	mx = max(mx,p);
	cout<<mx<<'\n';
}

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

int main(void)
{
    int n;
    int a[100];
    int sum = 0;
    int cost = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    double average = round((double)sum / (double)n);
    for (int i = 0; i < n; i++)
    {
        cost += (a[i] - average)*(a[i] - average);
    }
    cout << cost << endl;
    
    
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    x %= b;

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
    int n;
    scanf("%d", &n);

    if (n%10 ==7 || (n/10)%10==7 || (n/100)%10==7){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1612
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
int a[1000];
int main()
{
	int sum = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		sum += a[i];
	}
	int t1 = sum / n;
	int t2 = t1 + 1;
	int sum1 = 0; int sum2 = 0;
	for (int i = 0; i < n; i++)
	{
		sum1 += (a[i] - t1)*(a[i] - t1);
	}
	for (int i = 0; i < n; i++)
	{
		sum2 += (a[i] - t2)*(a[i] - t2);
	}
	int mins = min(sum1, sum2);
	printf("%d", mins);
}


Measured memory_bytes: 256
fun main(args: Array<String>) = yorukatsu17d()

fun yorukatsu17d() {
    val (startX, startY, toX, toy) = readLine()!!.split(' ').map { it.toInt() }

    val diffY = toy - startY
    val diffX = toX - startX

    val answer = buildString {
        append("U".repeat(diffY))
        append("R".repeat(diffX))
        append("D")
        append("L".repeat(diffX - 1))
        append("D".repeat(diffY - 1))
        append("L".repeat(2))
        append("U".repeat(diffY + 1))
        append("R".repeat(diffX + 1))
        append("D")
        append("R")
        append("D".repeat(2))
        append("L".repeat(diffX - 1))
        append("D".repeat(diffY - 1))
        append("L".repeat(2))
        append("U")
    }

    println(answer)
}


Measured memory_bytes: 38016
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const int mod = 10000;

int sche[100];
int dp[100][3][3]; // dp[??\??°][?????\][??¨??\]

signed main()
{
	int N, K; cin >> N >> K;

	memset(sche, -1, sizeof(sche));

	rep(i, K) {
		int a, b; cin >> a >> b, -- a, -- b;
		sche[a] = b;
	}

	if (~sche[0]) {
		dp[0][sche[0]][0] = 1;
	} else {
		rep(i, 3) {
			dp[0][i][0] = 1;
		}
	}

	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (~sche[1]) {
				dp[1][sche[1]][i] += dp[0][i][j];
			} else {
				for (int k = 0; k < 3; ++k) {
					dp[1][i][j] += dp[0][j][k];
				}
			}
		}
	}

	for (int i = 2; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (~sche[i]) {
					if (sche[i] == j && j == k) continue;
					dp[i][sche[i]][j] += dp[i - 1][j][k];
					dp[i][sche[i]][j] %= mod;
				} else {
					for (int l = 0; l < 3; ++l) {
						if (j == k && k == l) continue;
						dp[i][j][k] += dp[i - 1][k][l];
						dp[i][j][k] %= mod;
					}
				}
			}
		}
	}
	int ans = 0;

	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			ans += dp[N - 1][i][j];
			ans %= mod;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1164
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        if (N - (R * r) - (G * g)) % B == 0 and 0 <= ((N - (R * r) - (G * g)) // B) <= 3000:
            ans += 1
print (ans)


Measured memory_bytes: 41196
#include<bits/stdc++.h>
using namespace std;
int main(){
string s1,s2="";
cin>>s1;
for(int i=0;i<5;i++){
s2 = s2 + "hi";
if(s2 == s1) {
  cout<<"Yes"<<endl;
  return 0;
}
}
cout<<"No"<<endl;
} 

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int s = Integer.parseInt(st.nextToken());
		int w = Integer.parseInt(st.nextToken());
		
		if(s > w)
			sb.append("safe\n");
		else
			sb.append("unsafe\n");
		
		System.out.println(sb);
	}

}

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

const ll mod=998244353;
const int N=1005;
int n,x[N],y[N];

ll fpow(ll a,ll p){
	ll res=1;
	while(p){
		if(p&1) res=res*a%mod;
		a=a*a%mod;
		p>>=1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>x[i]>>y[i];
	ll res=fpow(2,n);
	res=(res-1+mod)%mod;
	res=(res-n+mod)%mod;
	res=(res-n*(n-1)/2+mod)%mod;
	for(int i=0;i<n;++i)
		for(int j=i+1;j<n;++j){
			int a=y[j]-y[i];
			int b=x[i]-x[j];
			int c=-a*x[i]-b*y[i];
			ll cnt=2;
			for(int k=0;k<n;++k)
				if(k!=i&&k!=j){
					int t=a*x[k]+b*y[k]+c;
					if(t!=0) continue;
					if(k<j) break;
					cnt++;
				}
			cnt%=mod;
			res=(res-fpow(2,cnt)+mod)%mod;
			res=(res+1)%mod;
			res=(res+cnt)%mod;
			res=(res+cnt*(cnt-1)/2)%mod;
		}
	cout<<res<<'\n';
}




Measured memory_bytes: 3644
#include <iostream>
#include <vector>

int main()
{
    long long n, k;
    std::cin >> n >> k;

    std::vector<int> a(n, 0);

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

    const int mod = 1000000007;
    long long p = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                p++;
                p %= mod;
            }
        }
    }

    long long q = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) {
                q++;
                q %= mod;
            }
        }
    }

    long long p_ans = p * k % mod;

    long long q_ans = k * (k - 1) / 2 % mod;
    q_ans *= q;
    q_ans %= mod;

    long long ans = p_ans + q_ans;
    ans %= mod;

    std::cout << ans << std::endl;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double hh, mm;
  hh = (double) h * 30 + (0.5 * m);
  mm = (double) m * 6;
//  if (hh - mm == 0 || abs(hh - mm) == 360) {
//    cout << fixed << setprecision(15) << abs(a - b) << endl;
//  } else if (abs(hh - mm) == 180) {
//    cout << fixed << setprecision(15) << a + b << endl;
//  } else {
    double rad;
    if (hh > mm) {
      rad = ((double) hh - mm) * M_PI / 180.0;
    } else {
      rad = ((double) mm - hh) * M_PI / 180.0;
    }
//    if (rad > M_PI) {
//      rad -= M_PI;
//    }
    double tmp = (double) a * a + (double) b * b - ((double) 2 * a * b * cos(rad));
    double res = sqrt(tmp);
    cout << fixed << setprecision(15) << res << endl;
//  }
  return 0;
}


Measured memory_bytes: 4176
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<set>
using namespace std;
int main(){
	int w,h,n,a,x,y,left=0,down=0;
	cin >> w >> h >> n;
	for(int i = 1;i <= n;i++){
		cin >> x >> y >> a;
		if(a==1&&x > left){
			left = x;
			}
		if(a==2&&w>x)w = x;
		if(a==3&&down<y)down=y;
		if(a==4&&y<h)h=y;
		}
	if(w<=left||h<=down){
		puts("0");
		return 0;
		}//

	int ans = (w-left)*(h-down);
	printf("%d\n",ans);
	return 0;
	}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int map[20][5];
int h,ans;
void DFS(){
	bool move=false;
	for(int i=0;i<h;i++){
		int cnt=0,set=0;
		for(int j=0;j<5;j++){
			if(map[i][j]!=set){
				if(cnt>=3&&set!=0){
					for(int k=0;k<cnt;k++){
						ans+=map[i][j-k-1];
						map[i][j-k-1]=0;
					}
					//cout<<"$"<<set<<" "<<cnt<<endl;
					move=true;
				}
				cnt=1;
				set=map[i][j];
			}
			else cnt++;
		}
		if(cnt>=3&&set!=0){
			for(int k=0;k<cnt;k++){
				ans+=map[i][4-k];
				map[i][4-k]=0;
			}
			//cout<<"$"<<set<<" "<<cnt<<endl;
			move=true;
		}
	}
	for(int k=0;k<h;k++){
	for(int j=0;j<5;j++){
		for(int i=h-1;i>0;i--){
			if(map[i-1][j]==0){
				int tmp=map[i][j];
				map[i][j]=0;
				map[i-1][j]=tmp;
			}
		}
	}
	}
	if(move)DFS();
}
int main(){
	while(true){
	cin>>h;
	if(h==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<5;j++){
			cin>>map[h-i-1][j];
		}
	}
	ans=0;
	DFS();
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
h = list (map(int, input().split()))
count =0
count_max = 0

for i,v in enumerate(h):
    if i > 0:
        if h[i]-h[i-1] <=0:
            count+=1
        else:
            if count_max < count:
                count_max = count
            count = 0
    if count_max < count:
        count_max = count
print(count_max)

Measured memory_bytes: 14252
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

int main(){
	int l; cin >> l;
	vector<ll> da(l+1);
	rip(i,l,0) cin >> da[i];
	vector<vector<ll>> dp(l+2, vector<ll>(5)); // . n <>  n 1
	dp[0][0] = 0;
	rip(i,l+1,0){
		dp[i+1][0] = dp[i][0];
		rip(j, 5, 1){
			dp[i+1][j] = min(dp[i+1][j-1], dp[i][j]);
		}
		dp[i+1][0] += da[i];
		dp[i+1][4] += da[i];
		if(da[i] == 0){
			dp[i+1][1]+=2;dp[i+1][2]++;dp[i+1][3]+=2;
		}
		else{
			if(da[i]%2 == 0){
				dp[i+1][2]++;
			}
			else{
				dp[i+1][1]++;dp[i+1][3]++;
			}
		}
	}
	//vvdeb(dp);
	cout << dp[l+1][4] << endl; 
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define int long long
#define MAX 1000000000000000000LL
int inf=100000000000007;
using namespace std;
string alph="abcdefghijklmnopqrstuvwxyz";

signed main(){
    int n; cin>>n;
    string s;
    cin>>s;
    vector<int>key;
    for(int i=0; i<n; i++){
        if(s[i]==s[i+1]){
            key.push_back(1);
            i++;
        }
        else key.push_back(0);
    }
    int ans;
    if(key[0]==1)ans=6;
    else ans=3;
    for(int i=1; i<key.size(); i++){
        if(key[i]==0&&key[i-1]==1){
            ans%=1000000007;
        }
        else if(key[i]==1&&key[i-1]==1){
            ans*=3;
            ans%=1000000007;
        }
        else {
            ans*=2;
            ans%=1000000007;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;
  while (n) {
    if (n % 10 == 7) {
      cout << "Yes";
      return 0;
    }
    n /= 10;
  }
  cout << "No";

  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <cmath>

#define PI 3.14159265358979
#define deg(x) (x/180.*PI)

int main(int argc, char const* argv[])
{
	double a,b,c;
	unsigned degc;
	std::cin >> a >> b >> degc;

	auto radc = deg(degc);
	auto b_h = a * std::sin(radc);
	auto s = b_h * b / 2.;

	c = std::sqrt(std::pow((b - a * std::cos(radc)), 2) + std::pow(b_h, 2));

	auto h = std::sin(radc) * b;

	std::cout << std::setprecision(6) << std::fixed;
	std::cout << s << std::endl;
	std::cout << a + b + c << std::endl;
	std::cout << h << std::endl;


	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <string.h>
int cnt[3]={0},l[3]={0};
char a[101],b[101],c[101];
char sim(char s){
  switch(s){
  case 'a':return a[cnt[0]++];break;
  case 'b':return b[cnt[1]++];break;
  case 'c':return c[cnt[2]++];
  }
}
int main(void){
  char n;
  scanf("%s %s %s",a,b,c);
  l[0]=strlen(a);
  l[1]=strlen(b);
  l[2]=strlen(c);
  n='a';
  while(1){
    n=sim(n);
    int t=n-'a';
    if(cnt[t]==l[t]){
      printf("%c\n",(char)('A'+t));
	break;
      }
  }
  return 0;
}


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

const ll mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    // init struct with "n" of "nCk" (maximum number in other words)
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    // c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
    // i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }

    // nPk - permutation
    mint p(int n, int k) {
        return fact[n] * ifact[n - k];
    }
} c(100100);

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    mint ans;
    for (int i = 0; i < n; i++) {
        if (n - i - 1 >= k - 1)
            ans -= c(n - i - 1, k - 1) * mint(a[i]);
        if (i >= k - 1)
            ans += c(i, k - 1) * mint(a[i]);
    }
    cout << ans.x << endl;
}


Measured memory_bytes: 5584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

vector<int> sieve(int n){
  vector<int> ret;
  bool is_prime[n+1];
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<n+1;i++){
    if(is_prime[i]){
      ret.push_back(i);
      for(int j=2*i;j<n+1;j+=i)is_prime[j]=false;
    }
  }
  return ret;
}

int main(){
  int n;
  vector<int> prime1,prime2;
  while(cin>>n,n){
    prime1=sieve(n);
    prime2=sieve(n*2);
    cout<<prime2.size()-prime1.size()<<endl;
    prime1.clear();prime2.clear();
  }
  return 0;
}



Measured memory_bytes: 3584
#include <iostream>
#include <unordered_set>
 
using namespace std;
 
int main(void) {
 int N = 0, temp = 0;
	cin >> N;
	unordered_set<int> myset;
	std::unordered_set<int>::iterator it;
 
	for (int i = 0; i < N; i++) {
		cin >> temp;
		it = myset.find(temp);
		if (it == myset.end()) {
			myset.insert(temp);
		} else {
			myset.erase(it);
		}
	}
	cout << myset.size(); 
  
  return 0;
}

Measured memory_bytes: 4388