akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
  int n = 0;
  scanf("%d", &n);
  int i = 0;
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  for(i=0;i<n;i++){
    if (a[i] % 2 == 0){
      if(a[i] % 3 == 0 || a[i]%5==0){
        
      }else{
        printf("DENIED");
        return 0;
      }
    }
  }
  printf("APPROVED");
  return 0;
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N; cin>>N;
  //  vector<string> s(N);                                                                 
  int cnta = 0, cntb = 0, cntab = 0;
  int ans = 0;
  REP(i,N) {
    string s; cin>>s;
    int len = s.length();
    if(s[0] == 'B' && s[len-1] == 'A') cntab++;
    else if(s[0] == 'B') cntb++;
    else if(s[len-1] == 'A') cnta++;
    for(int i = 1; i < len; i++) {
      if(s[i-1] == 'A' && s[i] == 'B') ans++;
    }
  }
  //  cout << ans << "," << cntab << "," << cnta << "," << cntb << endl;                   
  if(cntab > 0) {
    if(cnta > 0) {
      cnta--;
      ans += cntab;
    } else {
      ans += cntab-1;
    }
    //  cout << ans << "," << cntab << "," << cnta << "," << cntb << endl;                 
    if(cntb > 0) {
      ans ++;
      cntb--;
    }
  }
  //  cout << ans << "," << cntab << "," << cnta << "," << cntb << endl;                   
  ans += min(cnta, cntb);
  cout << ans << endl;
  return 0;
}


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

#define MAX 10000

int n, pos, k;
int pre[MAX], in[MAX], post[MAX];

int find(int u){
  int i;

  for(i = 0; i < n; i++){
    if(u == in[i])  return i;
  }
  return 0;
}

void rec(int l, int r){
  int root;
  if(l >= r)  return;
  root = pre[pos++];
  rec(l, find(root));
  rec(find(root) + 1, r);
  post[k++] = root;
}

void solve(){
  int i;
  pos = 0;
  rec(0, n);

  for(i = 0; i < n; i++){
    if(i) printf(" ");
    printf("%d", post[i]);
  }
  printf("\n");
}

int main(void){
  int i;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &pre[i]);
  }

  for(i = 0; i < n; i++){
    scanf("%d", &in[i]);
  }
solve();

  return 0;
}



Measured memory_bytes: 2108
let n = stdin.ReadLine() |> int

let rec diceRoll i count =
    if i >= n then false
    else
        let d1,d2 = stdin.ReadLine().Split() |> Array.map int |> fun x -> x.[0],x.[1]
        if d1 = d2 && count > 1 then true
        else diceRoll (i+1) (if d1=d2 then count+1 else 0)
        
(if diceRoll 0 0 then "Yes" else "No") |> stdout.WriteLine    

Measured memory_bytes: 28000
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int n;
	string s, t;
	cin >> n;
	cin >> s >> t; 
	
	for(int i = 0; i < n; i++){
		cout << s[i] << t[i];
	}
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long 
#define MOD 1000000007
 
using namespace std;
 
signed main(){
 
    int a,b,c;
    cin >> a>>b>>c;

    if(a==b && b==c){
        cout <<"Yes"<<endl;
    }

    else{
        cout <<"No"<<endl;
    }

 	return 0;
 
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/02  Problem: 002_agc_c / Link: https://agc002.contest.atcoder.jp/tasks/agc002_c?lang=en  ----- */
/* ------問題------

N 本のロープがあります。 ロープは 1 から N まで番号が振られています。 ロープ i の長さは ai です。
最初、1≤i≤N−1 について、ロープ i の右端とロープ i+1 の左端が結ばれています。 高橋君は次の操作を N−1 回行い、すべての結び目をほどこうとしています。
ひと繋がりのロープのうち、長さの総和が L 以上のものをひとつ選ぶ。 選んだひと繋がりのロープに結び目があれば、結び目のうちどれかひとつをほどく。
高橋君は結び目をほどく順番を工夫し、すべての結び目をほどくことができるでしょうか？ 可能か判定し、可能ならば結び目をほどく順番をひとつ求めてください。

-----問題ここまで----- */
/* -----解説等-----

ケツに着目すると、L以上のものがつながっていないといけない。
逆にこれが繋がっているときはどう切ってもいいので、Lの周りをはしから削除していく。

----解説ここまで---- */

LL N, L;


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

	cin >> N >> L;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	LL pos = -1;
	FOR(i, 0, N - 1) {
		if (a[i] + a[i + 1] >= L) {
			pos = i;
		}
	}
	if (pos == -1) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		VI ans(N - 1);
		FOR(i, 0, pos) {
			cout << i + 1 << " ";
		}
		FORR(i, N - 1, pos) {
			cout << i << " ";

		}cout << endl;
	}

	return 0;
}


Measured memory_bytes: 2048
#include<set>   
#include<map>  
#include<stack> 
#include<cmath>   
#include<cstdio>   
#include<queue>   
#include<vector>   
#include<climits>   
#include<cstring>   
#include<iostream>   
#include<algorithm>   
using namespace std;
#define MAXN 100
#define INF 0x3f3f3f3f 
int read()  
{  
    int f=1,x=0;  
    char c=getchar();  
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}  
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}  
    return f*x;  
}
struct node{
	int x,y;
}red[MAXN+5],blue[MAXN+5];
bool vis[2*MAXN+5];
vector<int> G[2*MAXN+5];
int n,match[2*MAXN+5];
bool DFS(int u){
	for(int i=0;i<int(G[u].size());i++){
		int v=G[u][i];
		if(vis[v]) continue;
		vis[v]=1;
		if(!match[v]||DFS(match[v]))
		{
			match[v]=u;
			match[u]=v;
			return 1;
		}
	}
	return 0;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)
		red[i].x=read(),red[i].y=read();
	for(int i=1;i<=n;i++)
	{
		blue[i].x=read(),blue[i].y=read();
		for(int j=1;j<=n;j++)
			if(red[j].x<blue[i].x&&red[j].y<blue[i].y)
				G[n+i].push_back(j),G[j].push_back(n+i);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(!match[i])
		{
			memset(vis,0,sizeof vis);
			if(DFS(i)) ans++;
		}
	printf("%d\n",ans);
	return 0;  
} /**/

Measured memory_bytes: 256
A,B,C,K=input().split(' ')
A=int(A)
B=int(B)
C=int(C)
K=int(K)
S=0
if (A>=K):
    S=K
elif (A+B>=K):
    S=A
else:
    S=A-(K-A-B)
print(S)


Measured memory_bytes: 61832
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b;
    cin >> a >> b;
    ll c = a^b;
    out(c);
    re0;
}

Measured memory_bytes: 256
from fractions import gcd


class SegmentTree:
    def __init__(self, n, init_value, ide_ele):
        self.num = 2 ** (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [ide_ele] * 2 * self.num
        
        for i in range(n):
            self.seg[i + self.num - 1] = init_value[i]
        for i in range(self.num - 2, -1, -1):
            self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2])
    
    def update(self, _k, x):
        k = _k + self.num - 1
        self.seg[k] = x
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])
    
    def query(self, _p, _q):
        p = _p
        q = _q
        if q <= p:
            return self.ide_ele
        p += self.num - 1
        q += self.num - 2
        res = self.ide_ele
        while 1 < q - p:
            if p & 1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q & 1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
    
    @staticmethod
    def segfunc(a, b):
        return gcd(a, b)


def solve():
    N = int(input())
    A = list(map(int, input().split()))
    
    seg_tree = SegmentTree(N, A, 0)
    ans = -1
    for i in range(N):
        ans = max(ans, gcd(seg_tree.query(0, i), seg_tree.query(i + 1, N)))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 92128
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
#define INF (1e9)

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

int main() {
	int n, k;
	cin >> n >> k;
    vector<int> vi(n);
    REP(i, n) {
        cin >> vi[i];
    }
    sort(ALL(vi));
    int opt = INF;
    REP(i, vi.size() - k + 1) {
        int tmp = vi[i + k - 1] - vi[i];
        if (tmp < opt) opt = tmp;
    }
    printf("%d", opt);
}

Measured memory_bytes: 640
#1166
import queue

while True:
    tmp = input().split(" ")
    w = int(tmp[0])
    h = int(tmp[1])
    if w == 0:
        break

    yoko_wall = []
    tate_wall = []

    for i in range(2*h-1):
        if i%2 == 0:
            omega = []
            for k in input().split(" ")[1:]:
                omega.append(int(k))
            yoko_wall.append(omega)
            #縦向きの壁の事
        else:
            omega2 = []
            for r in input().split(" "):
                omega2.append(int(r))
            tate_wall.append(omega2)

    #print("yoko_wall")
    #print(yoko_wall)
    #print("tate")
    #print(tate_wall)

    map_count = []
    for i in range(h):
        tmp = []
        for j in range(w):
            tmp.append(1000)
        map_count.append(tmp)

    q = queue.Queue()
    q.put([0,0])
    map_count[0][0] = 0

    #tans
    while True:
        if q.empty():
            print("0")
            break

        start = q.get()

        if start[0] == h-1 and start[1] == w-1:
            print(str(map_count[h-1][w-1]+1))
            break

        #4houkounoidou
        ue = [start[0]-1,start[1]]
        sita = [start[0]+1,start[1]]
        migi = [start[0],start[1]+1]
        hidari = [start[0],start[1]-1]

        #print("where to start" + str(start[0]) + ", " + str(start[1]))

        if ue[0] >= 0 and ue[0] < h and ue[1] >= 0 and ue[1] < w:
            #print("ue")
            #print(ue[0])
            #print(ue[1])
            if tate_wall[ue[0]][ue[1]] == 0:
                if map_count[ue[0]][ue[1]] == 1000:
                    map_count[ue[0]][ue[1]] = map_count[start[0]][start[1]] + 1
                    q.put(ue)
                    #print("new pattern ue")
                #else:
                    #print("already been there")

        if sita[0] >= 0 and sita[0] < h and sita[1] >= 0 and sita[1] < w:
            #print("sita")
            #print(sita[0])
            #print(sita[1])
            if tate_wall[start[0]][start[1]] == 0:
                #print("sita1")
                if map_count[sita[0]][sita[1]] == 1000:
                    #print("sita2")
                    map_count[sita[0]][sita[1]] = map_count[start[0]][start[1]] + 1
                    q.put(sita)
                    #print("new pattern sita")


        if migi[0] >= 0 and migi[0] < h and migi[1] >= 0 and migi[1] < w:
            #print("migi")
            #print(migi[0])
            #print(migi[1])
            if yoko_wall[start[0]][start[1]] == 0:
                if map_count[migi[0]][migi[1]] == 1000:
                    map_count[migi[0]][migi[1]] = map_count[start[0]][start[1]] + 1
                    q.put(migi)
                    #print("new pattern migi")
        #    else:
            #    print("couldnt go migi")

        if hidari[0] >= 0 and hidari[0] < h and hidari[1] >= 0 and hidari[1] < w:
            #print("hidari")
            #print(hidari[0])
            #print(hidari[1])
            if yoko_wall[hidari[0]][hidari[1]] == 0:
                if map_count[hidari[0]][hidari[1]] == 1000:
                    map_count[hidari[0]][hidari[1]] = map_count[start[0]][start[1]] + 1
                    q.put(hidari)



Measured memory_bytes: 7028
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

const int MAX = 510000;

ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    ll N, M;
    cin >> N >> M;

    string s, t;
    cin >> s >> t;

    ll d = N * M / gcd(N, M);

    ll t1 = d / M;
    ll t2 = d / N;

    for (int i = 0; i < gcd(N, M); ++i)
    {
        if (s[i * t1] != t[i * t2])
        {
            d = -1;
            break;
        }
    }
    cout << d << endl;

    return 0;
}

Measured memory_bytes: 640
/*input

*/
/*
***IT'S OUR LONG WAY TO THE OIILLLL***
 
 
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀🔥░░░░░░░░███░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░█▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▀██████████████████████████████████████████████████
░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▄████▄████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████
░░░░░░░░░░░░░░░░░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█████████▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀🔥░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████░░░░░░░░░░░░░░░
*/
//010000000010
#include<bits/stdc++.h>
#define ll          long long
#define pb          emplace_back
#define endl        '\n'
#define pi         pair<ll int,ll int>
#define vi          vector<int>
#define vll          vector<ll int>
#define vpi          vector<pair<int,int>>
#define vpll          vector<pair<ll int,ll int>>
#define all(a)      (a).begin(),(a).end()
#define allr(a)      (a).rbegin(),(a).rend()
#define sz(x)       (ll int)x.size()
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define tr(x,t)      for(t=x.begin();t!=x.end();t++)
#define mp          make_pair
#define inf 1000000000
#define hell 1000000000
#define fi first
#define se second
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    ll t=1;
    //cin >> t;
    while(t--)
    {
        string s;
        cin >>s;
        for (int i = 0; i < s.length(); ++i)
        {
            /* code */
            if(s[i]=='7'){
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
    }

    return 0;
}   

Measured memory_bytes: 3652
from collections import deque
class csr:
    def __init__(self,N,edges):
        self.start = [0]*(N+1)
        self.elist = [0]*len(edges)
        for e in edges:
            self.start[e[0]+1] += 1
        for i in range(1,N+1):
            self.start[i] += self.start[i-1] 
        counter = self.start[:]
        for e in edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1

class scc_graph:
    def __init__(self,N):
        self.N = N
        self.edges = []
    
    def add_edge(self,v,w):
        self.edges.append((v,w))

    def scc_ids(self):
        g = csr(self.N,self.edges)
        now_ord = group_num = 0
        visited = deque()
        low = [0]*self.N
        order = [-1]*self.N
        ids = [0]*self.N
        parent = [-1]*self.N
        stack = deque()
        for i in range(self.N):
            if order[i] == -1:
                stack.append(i)
                stack.append(i)
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        visited.append(v)
                        for i in range(g.start[v],g.start[v+1]):
                            to = g.elist[i]
                            if order[to] == -1:
                                stack.append(to)
                                stack.append(to)
                                parent[to] = v
                            else:
                                low[v] = min(low[v],order[to])
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = self.N
                                ids[u] = group_num
                                if u == v:
                                    break
                            group_num += 1
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]],low[v])
        for i,x in enumerate(ids):
            ids[i] = group_num-1-x

        return group_num,ids
    
    def scc(self):
        group_num,ids = self.scc_ids()
        groups = [[] for _ in range(group_num)]
        for i,x in enumerate(ids):
            groups[x].append(i)
        return groups
    
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
N,M = map(int,readline().split())
ab = list(map(int,read().split()))
sg = scc_graph(N)

it = iter(ab)
for a,b in zip(it,it):
    sg.add_edge(a,b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(str(len(group))+' '+' '.join(map(str,group)))


Measured memory_bytes: 214248
#include <bits/stdc++.h>
#define int long long
using pii=std::pair<int,int>;
using namespace std;

int n, m, a;
multiset<int, greater<int>> prices;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        cin >> a;
        prices.insert(a);
    }
    for(int i = 0; i < m; i++)
    {
        int largest = *prices.begin();
        prices.erase(prices.begin());
        prices.insert(largest / 2);
    }
    int ans = 0;
    for(auto x : prices)
        ans += x;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8312
n = int(input())
s = input()
ans = 0
for i in range(1, n):
    tmp = 0
    for a in 'abcdefghijklmnopqrstuvwxyz':
        if a in s[:i] and a in s[i:]:
            tmp += 1
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3060
a = list(map(int,input().split()))
N = a[0]
L = a[1]
  

 
def if_test(N,L):
  taste = 0
  if L > 0:
     for i in range(N):
      taste += (L + i)
#      print("L>0"+str(taste))
       
     taste = taste - L
     print(taste)
      
  elif (L+N-1) < 0:
     for i in range(N):
      taste = taste + L + i 
#      print("<0"+str(taste))
          
     taste = taste - (L + N - 1)   
     print(taste)
        
  else:
     for i in range(N):
      taste = taste + L + i
#      print(taste)
     print(taste)
    
if_test(N,L)

Measured memory_bytes: 3064
from functools import reduce

N, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

def f(A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD


ans = pow(2, N, MOD) - f(A) - f(B) - 1
ans %= MOD
print(ans)


Measured memory_bytes: 3572
#include <stdio.h>

int main(void){

  int k,a,b;
  scanf("%d %d %d", &k, &a, &b);
  int count_a = (a-1)/k;
  int count_b = b/k;
  if (count_b > count_a) {
    printf("OK\n");
  } else {
    printf("NG\n");
  }

  return 0;
}

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

using namespace std;



class Node {
public:
	int parent;
	int counter;
	vector<int> next;

	Node(int _parent = -1)
		:parent(_parent),counter(0),next(vector<int>(0))
	{}


};

int N, Q;
vector<Node> node;

void check_parent(int id, int parent);
void cumulative_sum(int id, int add);

int main()
{
	cin >> N;
	cin >> Q;
	node = vector<Node>(N + 1);

	for (int i = 0; i < N-1; i++)
	{
		int a, b;
		cin >> a;
		cin >> b;

		node.at(a).next.push_back(b);
		node.at(b).next.push_back(a);
	}

	for (int i = 0; i < Q; i++) {
		int p, x;
		cin >> p;
		cin >> x;

		node.at(p).counter += x;
	}

	check_parent(1, -1);
	cumulative_sum(1, 0);

	cout << node.at(1).counter;
	for (int i = 2; i < N+1; i++) {
		cout << " " << node.at(i).counter;
	}
	cout << endl;

	return 0;
}


void check_parent(int id,int parent)
{
	Node &n = node.at(id);
	n.parent = parent;

	for (unsigned i = 0; i < n.next.size(); i++) {
		int c = n.next.at(i);
		if (c != parent) {
			check_parent(c,id);
		}
	}

}

void cumulative_sum(int id,int add)
{
	Node &n = node.at(id);
	n.counter += add;

	for (unsigned i = 0; i < n.next.size(); i++) {
		int c = n.next.at(i);
		if (c != n.parent) {
			cumulative_sum(c, n.counter);
		}
	}

}

Measured memory_bytes: 24320
import java.util.Scanner;
public class Main {
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String str = stdIn.next();
        int q = stdIn.nextInt();
        for(int i = 0; i < q; i++) {
            String stt = stdIn.next();
            if(stt.equals("print")) {
                int a = stdIn.nextInt();
                int b = stdIn.nextInt();
                String tmp = str.substring(a, b+1);
                System.out.println(tmp);
            }
            else if(stt.equals("reverse")) {
                int a = stdIn.nextInt();
                int b = stdIn.nextInt();
                String tmp = str.substring(a,b+1);
                String tmp2 = "";
                for(int j = tmp.length()-1; j >= 0; j--) {
                    tmp2 += String.valueOf(tmp.charAt(j));
                }
                String ck1 = str.substring(0, a);
                String ck2 = str.substring(b+1,str.length());
                str = ck1 + tmp2 + ck2;
            }
            else if(stt.equals("replace")) {
                int a = stdIn.nextInt();
                int b = stdIn.nextInt();
                String p = stdIn.next();
                String ck1 = str.substring(0, a);
                String ck2 = str.substring(b+1,str.length());
                str = ck1 + p + ck2;
                 
            }
        }
    }
}


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int main(){
    int n;
    str s;
    cin>>n>>s;

    int coR = 0;
    int coL = 0;

    for(int i=0;i<n;i++){
        if(s.at(i)=='('){
            coR++;
            continue;
        }else{
            if(coR==0){
                coL++;
            }else{
                coR--;
            }
            continue;
        }
    }

    for(int i=0;i<coL;i++){
        cout<<'(';
    }
    cout<<s;
    for(int i=0;i<coR;i++){
        cout<<')';
    }


}

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

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

    int Cx, Cy, H; 
    Cx = 0;
    Cy = 0;
    H = 0;

    vector<int> x(N);
    vector<int> y(N);
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
        H = max(H, h[i]);
    }

    vector<int> res(N);
    for (int g = H; g <= pow(10, 9) + 1000; g++) {
        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                for (int k = 0; k < N; k++) {
                    res[k] = max(g - (abs(x[k] - i) + abs(y[k] - j)), 0);
                }

                bool flag = true;
                for (int k = 0; k < N; k++) {
                    if (h[k] != res[k]) {
                        flag = false;
                    }
                }

                if (flag) {
                    Cx = i;
                    Cy = j;
                    H = g;
                    g = pow(10, 9) + 1001;
                }
            }
        }
    }

    cout << Cx << " " << Cy << " " << H << endl;
}

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


int main(){
    int h,w,n;
    cin>>h>>w>>n;
    vector<int> row(h),col(w);
    set<p> map;
    rep(i,n){
        int r,c;
        cin>>r>>c;
        r--;c--;
        row[r]++;col[c]++;
        map.emplace(r,c);
    }

    int mr=0;int mc=0;
    rep(i,h)mr=max(mr,row[i]);
    rep(i,w)mc=max(mc,col[i]);
    vector<int> is,js;
    rep(i,h)if(mr==row[i])is.push_back(i);
    rep(j,w)if(mc==col[j])js.push_back(j);

    int ans=mr+mc;

    for(int i:is)for(int j:js){
        if(map.count(p(i,j)))continue;
        cout<<ans<<endl;
        return 0;
    }

    ans--;
    cout<<ans<<endl;
    return 0;


    
}

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

struct Card
{
  char suit, value;
};

void printCards(Card c[], int n)
{
  for (int i = 0; i < n; i++)
  {
    if (i)
      cout << " ";
    cout << c[i].suit << c[i].value;
  }
  cout << endl;
}

void bubbleSort(Card c[], int n)
{
  bool flag = 1;
  for (int i = 0; flag; i++)
  {
    flag = 0;
    for (int j = n - 1; j >= i; j--)
    {
      if (c[j].value < c[j - 1].value)
      {
        swap(c[j], c[j - 1]);
        flag = 1;
      }
    }
  }
}

void selectionSort(Card c[], int n)
{
  int minj = 0;
  for (int i = 0; i < n; i++)
  {
    minj = i;
    for (int j = i + 1; j < n; j++)
    {
      if (c[minj].value > c[j].value)
        minj = j;
    }
    if (i != minj)
      swap(c[i], c[minj]);
  }
}

bool isStable(Card c1[], Card c2[], int n)
{
  bool flag = 1;
  for (int i = 0; i < n; i++)
  {
    if (c1[i].suit != c2[i].suit)
    {
      flag = 0;
      break;
    }
  }
  return flag;
}

int main(void)
{
  Card C1[36], C2[36];
  int N;
  cin >> N;

  for (int i = 0; i < N; i++)
  {
    cin >> C1[i].suit >> C1[i].value;
    C2[i] = C1[i];
  }

  bubbleSort(C1, N);
  printCards(C1, N);
  cout << "Stable" << endl;
  selectionSort(C2, N);
  printCards(C2, N);
  if (isStable(C1, C2, N))
  {
    cout << "Stable" << endl;
  }
  else
  {
    cout << "Not stable" << endl;
  }

  return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  ll sum = accumulate(begin(a),end(a),0ll);
  map<ll,ll> cnt;
  for(auto ai:a)cnt[ai]++;

  int q;
  cin>>q;
  vector<ll> ans(q);
  rep(i,q){
    ll b,c;
    cin>>b>>c;
    ll minus = cnt[b]*b;
    ll plus = cnt[b]*c;
    cnt[c] += cnt[b];
    cnt[b] = 0;
    sum -= minus;
    sum += plus;
    ans[i] = sum;
  }
  for(auto x:ans)cout<<x<<endl;

}

Measured memory_bytes: 10748
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = 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; }
//ミョ(-ω- ?)
int main() {
    ll n,in;
    cin >> n ;
    ll maxv = LONG_LONG_MIN;
    ll minv = LONG_LONG_MAX;
    rep(i,n){
        ll a;
        cin >> a;
        maxv = max(maxv,a-minv);
        minv = min(minv,a);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int main()
{
    int n;
    int cnt = 0;

    scanf("%d", &n);

    for (int i = 1; i * 5 < 55555; i++) {
        int tmp = i * 5 + 1;
        int j = 2;

        while (j * j <= tmp &&
               tmp % j != 0) {
            j++;
        }

        if (j * j > tmp) {
            if (cnt) putchar(' ');
            printf("%d", tmp);
            cnt++;
        }

        if (cnt >= n) break;
    }
    putchar('\n');

    return 0;
}


Measured memory_bytes: 128
//In The Name Of GOD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 8*1001+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);

int main(){
  IO;
  int a,b;
  cin>>a>>b;
  b--;a--;
  cout<<(b/a)+(1&&b%a);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<int>t(n+1);
    vector<int>x(n+1);
    vector<int>y(n+1);
    for(int i=0;i<n;i++)
    {
        cin >> t[i] >> x[i] >> y[i];
        if (t[i]-t[i-1]<abs(x[i]-x[i-1])+abs(y[i]-y[i-1])||((t[i] - t[i - 1]) - (abs(x[i - 1] - x[i]) + abs(y[i - 1] - y[i]))) % 2 == 1) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4496
// Author - Saikat_7
#include <bits/stdc++.h> 
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define trav(i,cont) for(const auto& i:cont)
#define cs(x) cout<<x<<" "
#define cn(x) cout<<x<<" "<<endl
#define ll long long int
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007 //998244353 
#define inf 1e17
const int mx = 2000005; // 2* (10 to power 5);
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    int tc=1;
    // cin>>tc;
    while(tc-- > 0)
    {		
    		int n,k;
        	cin>>n;
            k=2;
        	ll dp[n+1]={0},arr[n+1]={0};
        	for(int i=1;i<=n;i++)
        	{
        		cin>>arr[i];
        		// cout<<arr[i];
        	}
        	dp[0]=0;
        	dp[1]=0;
        	// cout<<dp[2];
        	//dp[2]=abs(arr[2]-arr[1]);
        	for(int i=2;i<=n;i++)
        	{	ll max1=inf;
        		for(int j=max(1,i-k);j<i;j++)
        		{
        		max1=min(max1,dp[j]+abs(arr[i]-arr[j]));
        		}
        		dp[i]=max1;
        		// cout<<dp[i]<<endl;
        	}
        	cout<<dp[n];

    }
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

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

int main(){
  int n;
  cin >> n;
  unordered_map<int, int> m1, m2;
  int v;
  for(int i=0;i<n;i++){
    cin >> v;
    (i%2==0?m1:m2)[v] ++;
  }
  P mx1 = make_pair(-1,0), mx2 = make_pair(-1,0);
  int nx1 = 0, nx2 = 0;
  for(auto itr: m1){
    if(mx1.second <= itr.second){
      nx1 = mx1.second;
      mx1 = itr;
    }else if(itr.second > nx1) nx1 = itr.second;
  }

  for(auto itr: m2){
    if(mx2.second <= itr.second){
      nx2 = mx2.second;
      mx2 = itr;
    }else if(itr.second > nx2) nx2 = itr.second;
  }
  cout << (mx1.first != mx2.first ? n - (mx1.second + mx2.second) : n - max(mx1.second + nx2, nx1 + mx2.second)) << endl;
}


Measured memory_bytes: 4376
import math
n = int(input())
sqrtn = math.sqrt(n)
f = 0
ans = 10**10
for i in range(1, int(sqrtn)+1):
    div, mod = divmod(n, i)
    if mod == 0:
        f = max(len(str(div)), len(str(i)))
        if ans > f:
            ans = f
print(ans)

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, M; cin >> N >> M;
  
  //main
  ll ans = 0;
  if(N>=2){
    ans += N*(N-1)/2;
  }else{
     
  }
  if(M>=2){
    ans += M*(M-1)/2;
  }else{
     
  }
  
  // output
  cout << ans << endl;

  return 0;
}


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


string S;


void input() {
    cin >> S;
}


int main() {
    input();
    string ans = "Yes";
    if (S.size() % 2 == 1) ans = "No";
    for (int i = 0; i < S.size() - 1; i += 2)  {
        if (S[i] == 'h' && S[i+1] == 'i') continue;
        ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MP make_pair

int main(){
	int n,q,max=-1;
	cin >> n >> q;
	vector<pair<int,string> > v(n);
	for(int i=0;i<n;i++){
		int y;
		string s;
		cin >> y >> s;
		v[i] = MP(y,s);
		if(v[i].first <= q){
			max = i;
		}
	}
	if(max == -1){
		cout << "kogakubu10gokan" << endl;
	} else {
		cout << v[max].second << endl;
	}
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(void) {
	char input[32];
	int count=0;
	int left_end=-1;
	if(scanf("%s",input)!=1)return 1;
	do {
		int add=0,sub=0;
		int i;
		left_end++;
		if(input[left_end]=='0')continue;
		for(i=0;input[i]!='\0';i++) {
			if(i<left_end)sub=sub*10+input[i]-'0';
			else add=add*10+input[i]-'0';
		}
		/*  x-y==sub && x+y==add */
		if((add+sub)%2==0 && (add-sub)>=0 && (add-sub)%2==0)count++;
	} while(input[left_end]!='\0');
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 536
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class AFiveVariables {
public:
    void solve(std::istream &in, std::ostream &out) {
        vi X(5);
        in >> X;
        vi counter(6);
        trav(x, X) {
            counter[x]++;
        }
        int res = min_element(counter.begin() + 1, counter.end()) - counter.begin();
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    AFiveVariables solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

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

    int N=2*n;

    vector<int> L(N);
    rep(i,N) cin >>L[i];

    sort(all(L));

    int ans=0;
    for(int i=0; i<N; i+=2) ans+=L[i];

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


Measured memory_bytes: 256
import collections
import numpy as np
import sys
import copy
from functools import lru_cache
sys.setrecursionlimit(10**8)
#N,K=map(int,input().split())
#N=int(input())
#h=np.array(list(map(int,input().split())))
#ans=0
num2alpha = lambda c: chr(c+96)
s=list(input())
ans=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        ans+=1
print(ans)

Measured memory_bytes: 13500
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

unsigned long long fibNum[100002] = {};
unsigned long long fib(unsigned long long);

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

	int n, m;
	cin >> n >> m;

	fib(n);

	vector<int> a(m + 1);
	a[0] = -1;

	bool bl = true;
	for (int i = 1; i <= m; i++)
	{
		cin >> a[i];
		if (a[i] - a[i - 1] == 1)
		{
			bl = false;
		}
	}

	if (bl)
	{
		a.push_back(n + 1);

		for (int i = 0; i <= n + 1; i++)
		{
			fibNum[i] = 0;
		}

		fibNum[0] = 1;
		fibNum[1] = 1;

		unsigned long long cnt = 1;
		unsigned long long tmp = 0;

		for (int i = 1; i <= m + 1; i++)
		{
			tmp = fib(a[i] - a[i - 1] - 2);
			tmp%= 1000000007;
			cnt *= tmp;
			cnt %= 1000000007;
		}

		cout << cnt << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

unsigned long long fib(unsigned long long x) {
	if (x == 0) {
		return 1;
	}
	else if (x == 1) {
		return 1;
	}
	else if (fibNum[x] != 0) {
		return 	fibNum[x];
	}
	fibNum[x] = fib(x - 1) + fib(x - 2);
	fibNum[x] %= 1000000007;
	return fibNum[x];
}

Measured memory_bytes: 4608
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    M1, D1 = map(int, input().split())
    M2, D2 = map(int, input().split())

    if M1!=M2:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Measured memory_bytes: 63980
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(void) {
  ll N, K, tmp;
  vector<ll> h;
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> tmp;
    h.push_back(tmp);
  }
  sort(h.begin(), h.end(), less<ll>());

  ll diff = h[K - 1] - h[0];
  int index = 0;
  for (int i = 1; i < N - K + 1; ++i) {
    if (h[i + K - 1] - h[i] < diff) {
      diff = h[i + K - 1] - h[i];
      index = i;
      if (diff == 0)
        break;
    }
  }

  cout << h[index + K - 1] - h[index] << endl;

  return 0;
}


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


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

    std::vector<int> sum(n + 1);
    sum[0] = 100000000;
    for(int i = 1; i <= n; i++){
        sum[i] = std::min(a[i - 1], sum[i - 1]);
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(sum[i] > a[i])cnt++;
    }
    std::cout << cnt << std::endl;

}

Measured memory_bytes: 1792
///
// File:  2340.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 26 13:33:28 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t n;
  cin >> n;

  uint64_t lparen = 0;
  uint64_t rparen = 0;
  for (uint32_t i = 0; i < n; i++) {
    uint64_t p, n;
    char c;
    cin >> p >> c >> n;
    if (c == ')') {
      lparen += n;
    } else if (c == '(') {
      rparen += n;
    }

    if (lparen == rparen) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

int H, W; char c[109][109];
int dp[109][109];

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> c[i][j];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (i == 1 && j == 1) dp[i][j] = 0;
			else {
				dp[i][j] = (1 << 30);
				int score1 = (1 << 30), score2 = (1 << 30);
				if (i >= 2) {
					score1 = dp[i - 1][j];
					if (c[i - 1][j] == '#' && c[i][j] == '.') score1 += 1;
				}
				if (j >= 2) {
					score2 = dp[i][j - 1];
					if (c[i][j - 1] == '#' && c[i][j] == '.') score2 += 1;
				}
				dp[i][j] = min(score1, score2);
			}
		}
	}

	int r = 0; if (c[H][W] == '#') r = 1;
	cout << dp[H][W] + r << endl;
	return 0;
}

Measured memory_bytes: 3684