akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define len(val) static_cast<long long>(val.size())
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
typedef pair<int, int> P;


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

    int K, T;
    cin >> K >> T;
    priority_queue<pair<int, int>> pq;
    rep(i, T){
      int tmp;
      cin >> tmp;
      pq.push(make_pair(tmp, i));
    }
    if(len(pq) == 1){
      cout << pq.top().first-1 << endl;
      return 0;
    }
    int old = -1;
    while(len(pq) != 1){
      auto a = pq.top();
      pq.pop();
      if(a.first == 0){
        continue;
      }
      if(a.second != old){
        pq.push(make_pair(a.first-1, a.second));
        old = a.second;
        //cout << "a: " << a.first << " " << a.second << endl;
        continue;
      }
      auto b = pq.top();
      if(b.first == 0){
        pq.pop();
        pq.push(a);
        continue;
      }
      pq.pop();
      pq.push(a);
      pq.push(make_pair(b.first-1, b.second));
      old = b.second;
      //cout << "b: " << b.first << " " << b.second << endl;
    }
    cout << pq.top().first << endl;
}


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

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int &i:a) cin >> i;
	int ans = 1;
	for(int i = 0, f = -1; i < n - 1; i++){
		if(a[i] == a[i + 1]) continue;
		if(f == -1){
			f = a[i] < a[i + 1];
			continue;
		}
		if(f != a[i] < a[i + 1]){
			ans++;
			f = -1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 998244353;
	static long inf = (long) 1e16;
	static int[] l, r;
	static int n, m, id;
	static long all, ans;
	static ArrayList<Integer>[] ad;
	static long[][][] memo;
	static long[] a;
	static ArrayList<Integer> h;
	static boolean vis[];

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = sc.nextInt();
		n = 1 << n;
		int[] a = sc.nextArrInt(n);
		pair[] dp = new pair[n];
		int[] ans = new int[n];
		for (int i = 0; i < n; i++)
			dp[i] = new pair(i, -1);
//		System.out.println(Arrays.toString(dp));
		for (int i = 1; i < n; i++) {
			for (int b = 0; b < 19; b++) {
				if ((i & (1 << b)) != 0) {
					int id = (i ^ (1 << b));
					PriorityQueue<Integer> ts = new PriorityQueue<>((x, y) -> a[y] - a[x]);
					ts.add(dp[id].x);
					ts.add(dp[i].x);
					if (dp[i].y != -1)
						ts.add(dp[i].y);
					if (dp[id].y != -1)
						ts.add(dp[id].y);
					dp[i].x = ts.poll();
					if(ts.peek()==dp[i].x)
						ts.poll();
					dp[i].y = ts.poll();
				}
			}
	//		System.err.println(i + " " + Arrays.toString(dp));
		}
		int max = 0;
		for (int i = 1; i < n; i++) {
			max = Math.max(max, a[dp[i].x] + a[dp[i].y]);
			ans[i] = max;
		}
		for (int i = 1; i < n; i++)
			out.println(ans[i]);
		out.flush();
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		@Override
		public int compareTo(pair o) {
			return x - o.x;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 70924
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  map<char, int> a;
  char c;
  rep(i,N) {
    cin >> c;
    a[c]++;
  }

  ll retval = 1;
  ll MOD = 1000000007;
  for (auto p : a){
    (retval *= (p.second+1)) %= MOD;
  }
  cout << retval -1  << endl;

  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
typedef long long ll;

int
main(int argc, char *argv[])
{
  int n, m;
  scanf("%d%d", &n, &m);
  int a[100000], b[100000];
  for(int i = 0; i < m; i++){
    scanf("%d%d", &a[i], &b[i]);
    a[i]--; b[i]--;
  }

  int r[100000]; ll t[100000];
  for(int i = 0; i < n; i++){
    r[i] = i; t[i] = 1;
  }
 

  ll c[100000];
  c[m - 1] = ((long long)n * ((long long)n - 1)) / 2; 

  
  for(int i = m - 1; i > 0; i--){
    int temp;
    temp = a[i];
    while(r[temp] != temp){
      temp = r[temp];
    }
    r[a[i]] = temp;
    temp = b[i];
    while(r[temp] != temp){
      temp = r[temp];
    }
    r[b[i]] = temp;
    if(r[a[i]] != r[b[i]]){
      c[i - 1] = c[i] - t[r[a[i]]] * t[r[b[i]]];
      t[r[a[i]]] += t[r[b[i]]];
      r[r[b[i]]] = r[a[i]];
    }else{
      c[i - 1] = c[i];
    }
  }
  for(int i = 0; i < m; i++){
    printf("%lld\n", c[i]);
  }
  return 0;
}

  
  


Measured memory_bytes: 3968
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, now = 0, a, n;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    if(a == now + 1) now++;
  }
  printf("%lld", now ? n - now : -1);
  return 0;
}

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

int main() {
	string s;
	cin >> s;

	if (s.size() != 26) {
		for (char c = 'a'; c <= 'z'; c++) {
			bool ok = true;
			for (int i = 0; i < s.size(); i++) {
				if (s[i] == c) {
					ok = false;
				}
			}
			if (ok) {
				s.push_back(c);
				cout << s << endl;
				return 0;
			}
		}
	}
	else {
		
		if (s == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
			return 0;
		}

		map<char, int> mp;
		for (int i = 25; i > 0; i--) {
			mp[s[i]] = 1;
			s.pop_back();
			for (auto x: mp) {
				if (x.first > s[i - 1]) {
					s[i - 1] = x.first;
					cout << s << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

//素因数分解
void factoring(ll n, map<ll, ll> &mp) {
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1)
        mp[n]++;
}

void solve() {
    ll a, b;
    cin >> a >> b;
    ll d = gcd(a, b);
    map<ll, ll> mp;
    factoring(d, mp);
    cout << mp.size() + 1 << en;
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t)
    solve();
    */

    return 0;
}


Measured memory_bytes: 3656
N = int(input())

def ok(s):
    result = True if 'AGC' not in s else False
    for i in range(len(s)-1):
        s_swap = s[:i] + s[i+1] + s[i] + s[i+2:]
        if 'AGC' in s_swap:
            result = False
    return result

CANDIDATE = 'AGCT'

prev = {}
for i in CANDIDATE:
    for j in CANDIDATE:
        for k in CANDIDATE:
            str_ = i + j + k
            if ok(str_):
                prev[str_] = 1

depth = 3
while depth < N:
    next_ = {}
    for item in prev:
        for i in CANDIDATE:
            str_ = item[-3:] + i
            if ok(str_):
                if str_ in next_:
                    next_[str_] += prev[item]
                else:
                    next_[str_] = prev[item]
    depth += 1
    prev = next_

print(sum(prev.values()) % 1000000007)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]

    return (n, )


def solve(n, ):


    result = sum([i for i in range(1, n+1) if i % 3 !=0 and i % 5 != 0])

    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 103604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    int N;
    cin >> N;
    ve<ll> A(N);
    in(N,A);
    if(A[0] != 0) {
        out(-1);
        return 0;
    }
    ll ans = 0;
    reps(i,1,N){
        if(A[i] > A[i-1]+1){
            out(-1);
            return 0;
        }
        
        if(A[i] == 0) continue;
        
        if(A[i] == A[i-1]+1) ans++;
        else ans += A[i];
        
        
    }

    out(ans);


    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N;
	string S;

	cin >> N >> S;

	rep(i, (int)S.length()) {
		if (S[i] + N > 'Z') S[i] += N - 26;
		else S[i] += N;
	}

	cout << S << endl;

	return 0;
}


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

using namespace std;

const int INF = 1231231234;

struct pt
{
    int x, y, type;

    pt(){}
    pt(int a, int b, int c = 0) : x(a), y(b), type(c) {}
    int dist(pt o)
    {
        return !type ? abs(x - o.x) + abs(y - o.y) : max(abs(x - o.x), abs(y - o.y));
    }
};

pt toChebyshev(pt p)
{
    return {p.x + p.y, p.x - p.y, 1};
}

pt toManhattan(pt p)
{
    return {(p.x + p.y) / 2, (p.x - p.y) / 2, 0};
}

char getColor(pt p, int minx, int miny, int d)
{
    int xPartition = (p.x - minx + 1) / d, yPartition = (p.y - miny + 1) / d;
    if (xPartition & 1)
    {
        return yPartition & 1 ? 'R' : 'B';
    }
    else
    {
        return yPartition & 1 ? 'G' : 'Y';
    }
}

int main()
{
    int h, w, d;
    cin>>h>>w>>d;

    vector <pt> corners = {{0, 0}, {h, 0}, {0, w}, {h, w}}, converted(4);
    int minX = INF, maxX = -INF, minY = INF, maxY = -INF;
    for (int i = 0; i < 4; i++)
    {
        converted[i] = toChebyshev(corners[i]);
        minX = min(minX, converted[i].x), maxX = max(maxX, converted[i].x);
        minY = min(minY, converted[i].y), maxY = max(maxY, converted[i].y);
    }

    char grid[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            pt p = toChebyshev({i, j});
            grid[i][j] = getColor(p, minX, minY, d);
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout<<grid[i][j];
        }
        cout<<'\n';
    }



    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;

void solve(){
    ll n,k;
    cin >> n >>k;
    if(k%2==1){
        ll ans=pow(n/k,3);
        cout << ans << endl;
    }
    else{
        ll ans=pow(n/k,3);
        if(n%k<k/2){
            ans+=pow(n/k,3);
        }
        else{
            ans+=pow(n/k+1,3);
        }
        cout << ans << endl;
    }
}

int main(){
    solve();
}



Measured memory_bytes: 256
def cal(data):
	res = 0
	num = data
	while True:
		if(num%2==0):
			res += 1
			num /= 2
		else:
			return res

def main():
	n = int(input())
	maxe = 0 #割れる回数
	res = 0;
	for i in range(1,n+1):
		if(cal(i)>=maxe): #割れる回数がmaxeよりも多ければ
			maxe = cal(i) #maxeをcal(i)にする
			res = i #resをその時の数字にする
	print(res)

if(__name__ == '__main__'):
	main()

Measured memory_bytes: 3060
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    d = {"Sunny":1 , "Cloudy":2, "Rainy":0}
    a = ["Sunny", "Cloudy", "Rainy"]
    print(a[d[input().rstrip()]])
    return

#B
def B():
    s = S()
    for i, si in enumerate(s):
        if i % 2:
            if si == "R":
                print("No")
                return
        else:
            if si == "L":
                print("No")
                return
    print("Yes")
    return

#C
def C():
    n, k, q = LI()
    d = [0] * n
    for _ in range(q):
        a = II() - 1
        d[a] += 1
    for a in d:
        if k - (q - a) > 0:
            print("Yes")
        else:
            print("No")
    return

#D
def D():
    n, = LI()
    a = LI()
    q = []
    for ai in a:
        heappush(q, ai)
    for _ in range(m):
        heappush(q, heappop(q) / 2)
    ans = 0
    while q:
        ans += int(heappop(q))
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38640
#include<stdio.h>
int main()
{
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}



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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a[10000000],b,c,cmp=0,cmpp=0,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;

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

       cin >> n;
       rep(i,n)cin >> a[i];
       //偶数を正に
       rep(i,n){
           sum+=a[i];
           if(i%2==0){
               if(sum<=0){
                  cmp+=1-sum; 
                  sum=1;
               }
           }
           else{
               if(sum>=0){
                   cmp+=sum+1;
                   sum=-1;
               }
           }
       }
       //はい
       sum=0;
       rep(i,n){
           sum+=a[i];
           if(i%2==0){
               if(sum>=0){
                   cmpp+=sum+1;
                   sum=-1;
               }
           }
           else{
               if(sum<=0){
                   cmpp+=1-sum;
                   sum=1;
               }
           }
       }
       Cout(min(cmp,cmpp));
       
return 0;
}


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

int main() {
  int n;
  int h[100000];
  cin >> n;
  for(int i = 0; i < n; ++i)
    cin >> h[i];
  
  int k = h[n-1];
  for(int i = n-2; i >= 0; --i) {
    if (h[i] > k + 1) {
      cout << "No\n";
      return 0;
    }
    if (h[i] == k + 1) {
      h[i] = h[i] - 1;
    }
    k = h[i];
  }
  
  cout << "Yes\n";
  return 0;
}

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

int main(void){
  char c;
  cin >> c;
  if(c == 'a' ||c == 'e' ||c == 'i' ||c == 'o' ||c == 'u')cout << "vowel" <<endl;
  else cout << "consonant" << endl;
}

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

int main() {
  map<int,int> cnt;
  int n, l;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> l;
    cnt[l]++;
  }
  long long a = 0, b = 0;
  for ( auto i:cnt ) {
    if ( i.second >= 2 ) {
      b = a;
      a = i.first;
    }
    if ( i.second >= 4 ) {
      b = a;
      a = i.first;
    }
  }
  cout << a * b << "\n";
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  REP(i,n) cin>>x[i];

  ll t=INF;
  for(int i=0;i+k<=n;i++){
    ll temp=INF;
    if(x[i]>=0) temp=x[i+k-1];
    else if(x[i+k-1]<=0) temp=-x[i];
    else temp=min(-x[i]*2+x[i+k-1],x[i+k-1]*2-x[i]);
    t=min(t,temp);
  }
  cout<<t<<endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
    cin>>a>>b;
    string s;
    int size=a.size()+b.size();
    for(int i=0;i<size;i++){
        if(i%2==0){
            s+=a[i/2];
        }else{
            s+=b[i/2];
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char c = sc.next().charAt(0);
		boolean ans = false;

		char [] array = {'a', 'i', 'u', 'e', 'o'};
		for(char v : array) {
			if (v == c) {
				ans = true;
				break;
			}
		}

		System.out.println(ans ? "vowel" : "consonant");

	}

}

Measured memory_bytes: 35496
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint Q;
	cin >> Q;
	lint b, e;
	rep(t, Q) {
		cin >> b >> e;
		for (int i = b; i <= b + (e - b) / 2 + (e - b) % 2 - 1;i++){
			swap(A[i], A[b + e - 1 - i]);
}
	}
	rep(i, N) {
		cout << A[i];
		if (i != N - 1) {
			cout << ' ';
		}
		else {
			cout << endl;
		}
	}
}




Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)


int main(){
	while(true){
		int z;
		cin >> z;			if(!z) return 0;
		int re=0;
		int x;
		for(x=1;x<z;x++){
			int y=INT(pow(pow(z,3)-pow(x,3),1.0/3));
			if(y==0)continue;
			re = max(re, INT(pow(x,3))+INT(pow(y,3)) );
		}
		cout<<INT(pow(z,3))-INT(re)<<endl;
	}
}

Measured memory_bytes: 1224
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u;
        scanf("%d %d", &t, &u);
        d.merge(t-1, u-1);
    }
    printf("%d",d.groups().size()-1);
    return 0;
}


Measured memory_bytes: 8128
#include<stdio.h>


int main(){
  int n,data,i,max,min;

scanf("%d",&n);

scanf("%d",&min);

for(i=1;i<n;i++){
scanf("%d",&data);
if(i==1)
max=data-min;
if(max<(data-min))
    max=data-min;
    if(min>data)
    min=data;
 }

 printf("%d\n",max);

 
   return 0;
}




Measured memory_bytes: 2104
/***     
 * When I wrote this
 * only God & I understood
 * what I was doing
 * Now, God only knows 
 /***/ 
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
//fixed<< setprecision(2)
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll t;
    while (cin >> t)
    {
        ll d;
        double x,y;
        cin>>d;
        ll ans=0;
        for(int i=0;i<t;i++)
        {
            cin>>x>>y;
            if((x*x+y*y)<=d*d)ans++;
        }cout<<ans<<'\n';
    }
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    vec<ll> v;
    int N = 13;
    auto dfs = [&](auto&& self,ll n,int c,int len)->void{
        if(len==N) return ;
        v.push_back(n);
        for(int a=c-1;a<=c+1;a++){
            if(a<0 || 10<=a) continue;
            self(self,10*n+a,a,len+1);
        }
    };
    for(int i=1;i<=9;i++) dfs(dfs,i,i,1);
    sort(v.begin(),v.end());
    cout << v[K-1] << "\n";
}

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

// #define int long long

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int32_t main() {
	long long n;
	int x, m;
	cin >> n >> x >> m;

	long long res = 0;
	vector<int> seen(m);

	// int prev = x;
	// for(int i = 0; i )
	int ele = 0, st = 0, p = 0;

	for(int i = 0, cur = x; ; i++) {
		// debug(cur);
		if(seen[cur]) {
			p = i + 1 - seen[cur];
			st = seen[cur];
			ele = cur;
			debug(1, cur, p, st, ele);
			break;
		}
		seen[cur] = i + 1;
		cur = (long long) cur * cur % m;
		// deg(cur);
		// debug(cur);
	}

	debug(p, st, ele);

	for(int i = 0, cur = x; i < st - 1 && n > 0; i++, n--) {
		res += cur;
		cur = (long long) cur * cur % m;
	}

	long long sum = 0;

	
	
	for(int i = 0, cur = ele; i < p; i++) {
		sum += cur;
		cur = (long long) cur * cur % m;
	}


	debug(n, sum, p);
	res += (long long) sum * (n / p);

	n %= p;

	for(int i = 0, cur = ele; i < n; i++) {
		res += cur;
		cur = (long long) cur * cur % m;
	}

	cout << res << '\n';

}


Measured memory_bytes: 3772
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#define rep(N) for (int i = 0; i < N; i++)
#define For(i, N) for (i = 0; i < N; i++)
#define rev(N) 	for (int i = N - 1; i >= 0; --i)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T1, typename T2>
void say(T1 s1, T2 s2) {
	cout << s1 << " " << s2 << endl;
}

int main() {
	int X, Y;
	cin >> X >> Y;
	if (X%Y == 0) {
		say(-1);
		re;
	}
	else say(X);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> p(N); REP(i, N) cin >> p[i];
  int res = 0;
  REP(i, N) {
    if((i + 1) != p[i]) res++;
  }
  if(res == 2 || res == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3620
using System;
using System.Linq;

namespace ITP1_4_D
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var nums = Console.ReadLine().Split(' ')
                .Select(s => long.Parse(s))
                .OrderBy(s => s);
            var min = nums.First();
            var max = nums.Last();
            var sum = nums.Sum();
            Console.WriteLine("{0} {1} {2}", min, max, sum);
        }
    }
}

Measured memory_bytes: 11696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, u;
  in2(n, k);
  u = k;
  rep(i, n - 1)
    u = u * (k - 1);
  out(u);
  memi;
}

Measured memory_bytes: 256
#include <stdio.h>

int cards(int n)
{
	int i=1,num;
	int S[14], H[14], C[14], D[14];
	char mark;
	while(i<=n*2){
		scanf("%c %d", &mark, &num);
		if (mark == 'S')
			S[num] = 1;
		else if (mark == 'H')
			H[num] = 1;
		else if (mark == 'C')
			C[num] = 1;
		else if (mark == 'D')
			D[num] = 1;
		i += 1;
	}

	for (i = 1; i <= 13; i++){
		if (S[i] != 1)
			printf("S %d\n", i);
	}

	for (i = 1; i <= 13; i++){
		if (H[i] != 1)
			printf("H %d\n", i);
	}

	for (i = 1; i <= 13; i++){
		if (C[i] != 1)
			printf("C %d\n", i);
	}

	for (i = 1; i <= 13; i++){
		if (D[i] != 1)
			printf("D %d\n", i);
	}
}

int main()
{
	int n;
	while (1){
		scanf("%d", &n);
		if (0 <= n&&n <= 52)
			break;
	}
	cards(n);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n); for(int (i)=0;(i)<(n);(i)++)
using namespace std;
 
int main(){
  int n; cin>>n;
  vector<int> num(n);
  
  rep(i,n) cin>>num[i];
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  
  int ans=0;
  int b=0;
  for (int i=0;i<n;i= i+2){
    b = num[i]- num[i+1];
    ans += b;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import permutations
N, M = map(int, input().split())
dic = defaultdict(list)
for i in range(M):
  a, b = map(int, input().split())
  dic[a-1] += [b-1]
  dic[b-1] += [a-1]

ans = 0
ls = permutations(range(1,N))
for l in ls:
  l = [0]+list(l)
  for i in range(N-1):
    if not l[i+1] in dic[l[i]]:
      break
    if i==N-2:
      ans += 1
print(ans)

Measured memory_bytes: 40432
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=100001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++)

int main()
{
    int a,b,id=-1;
    cin>>a>>b;
   fo(i,1,100000)
   {
       int j=(i*8)/100;
       int y=(i*10)/100;
       if(j==a&&y==b) 
       {
           id=i;
           break;
       }
       
   }
   cout<<id<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int X, cnt[31], ans;
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		X = X ^ a;
		int res = 0;
		res = __builtin_ctz(a);
		cnt[res]++;
	}
	
	for(int i = 30; i >= 0; i--) {
		if((X >> (i)) & 1) {
			if(cnt[i] > 0) {
				X = X ^ ((1LL << (i + 1) )- 1);
				ans++;
			}
			else 
				return cout << -1, 0;
		}
	}
	return cout << ans, 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 10000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int long long

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, A[100000]; cin >> N;
  REP(i, N) cin >> A[i];
  int ans = 0;
  REP(i, N-1){
    if(i+1 == A[i]) swap(A[i], A[i+1]), ans++;
  }
  if(A[N-1] == N) ans++;
  cout << ans << endl;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	int res = 0;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		N -= A[i];
	}
	if (N < 0) N = -1;
	cout << N << endl;
}

Measured memory_bytes: 3696
let () =
  let open Hashtbl in
  let n = read_int () in
  let tbl = create ~random:true n in
  let rec doit i =
    if i < n then begin
      match Scanf.scanf "%s %s\n" (fun x y -> (x, y)) with
      | ("insert", x) -> (add tbl x true; doit (i + 1))
      | ("find", x) -> (print_endline (if mem tbl x then "yes" else "no"); doit (i + 1))
      | _ -> exit 1
    end
  in
  doit 0

Measured memory_bytes: 44012
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


using Edge = pair<int, int>;  //(頂点番号, 辺番号)
using Graph = vector<vector<Edge>>;

Graph g;
int N;
vector<int> ans;


void dfs(int v, int p, int c) {
    int color = 1;
    for (auto e : g[v]) {
        if (e.first == p) continue;
        if (color == c) color++;
        ans[e.second] = color;
        dfs(e.first, v, color);
        color++;
    }
}


void solve() {
    cin >> N;
    g.resize(N);
    ans.resize(N-1);

    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(make_pair(b, i));
        g[b].push_back(make_pair(a, i));
    }

    int num = 0;
    for (auto e : g) num = max(num, (int)e.size());

    dfs(0, -1, -1);

    cout << num << endl;
    for (auto v : ans) cout << v << endl;
}


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

Measured memory_bytes: 11000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		scan.nextLine();
		int[][] A = new int[n][m];
		int[][] B = new int[m][1];
		
		for (int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				A[i][j] = scan.nextInt();
			}
			scan.nextLine();
		}
		
		for (int i=0; i<m; i++) {
			B[i][0] = scan.nextInt();
			scan.nextLine();
		}
		
		for (int i=0; i<n; i++) {
			int sum=0;
			for(int j=0; j<m; j++) {
				sum += A[i][j] * B[j][0];
			}
			System.out.println(sum);
		}
	}
}



Measured memory_bytes: 46348
n = gets.to_i
a = gets.split.map(&:to_i)
sum = 0
for i in 1...a.size
  sum += a[i]
end

ans = 0

for i in 0...(a.size-1)
  ans += a[i] * sum
  sum -= a[i+1]
  ans %= 10**9 + 7
end

puts ans

Measured memory_bytes: 33844
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

# MOD = 10**9 + 7
def main():
	f = 0; flag = 0
	for i in range(int(input())):
		a, b = read()
		if a == b:f+=1
		else:f = 0

		if f == 3:flag |= 1
	print("YNeos"[flag == 0::2])

		



	

if __name__ == "__main__":
	main()


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if ((100*r + 10*g + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
m = int(input())
dat = [input().split(" ") for i in range(n)]
s = [m]
for i in range(n):
    m += (int(dat[i][0])-int(dat[i][1]))
    if m < 0:
        print(0)
        sys.exit()
    s.append(m)
print(max(s))


Measured memory_bytes: 8536
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int n, q, m;
int A[20];
bool dp[21][2001];

bool solve(int i, int m) {
    if (dp[i][m]) return dp[i][m];

    if (m == 0) dp[i][m] = true;
    else if (i >= n) dp[i][m] = false;
    else if (solve(i+1, m)) dp[i][m] = true;
    else if (solve(i+1, m - A[i])) dp[i][m] = true;
    else dp[i][m] = false;

    return dp[i][m];
}

int main() {
    cin >> n;
    REP(i,n) cin >> A[i];
    cin >> q;
    REP(i,q) {
        cin >> m;
        if (solve(0,m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3124
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] w = sc.next().toCharArray();
        int n = w.length;
        int s0 = 0;
        int s1 = 0;
        for(int i = 0; i < n; i++){
            if(i % 2 == 0 && w[i] == '1' || i % 2 != 0 && w[i] == '0'){
                s0++;
            }
        }
        for(int i = 0; i < n; i++){
            if(i % 2 != 0 && w[i] == '1' || i % 2 == 0 && w[i] == '0'){
                s1++;
            }
        }
        System.out.println(Math.min(s0,s1));
    }
}


Measured memory_bytes: 26872
#include<iostream>
using namespace std;
class human{
public:
    int parent;
    int club;
    human():parent(-1),club(-1){}
};
human *line;
bool merge(int ,int);
bool set(int,int);
int getparent(int);
int main(){
    int N,M,K;
    cin>>N>>M>>K;
    line=new human[N+1];
    int i;
    for(i=0;i<K;++i){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==1){
            if(merge(b,c)){
                break;
            }
        }else{
            if(set(b,c)){
                break;
            }
        }
    }
    cout<<(i==K?0:i+1)<<endl;
    return 0;
}
bool set(int num,int club){
    num=getparent(num);
    if(line[num].club!=-1){
        if(line[num].club!=club){
            return true;
        }
        return false;
    }
    line[num].club=club;
    return false;
}

bool merge(int A,int B){
    A=getparent(A);
    B=getparent(B);
    if(A==B)return false;
    if(line[A].club!=-1&&line[B].club!=-1){
        if(line[A].club!=line[B].club){
            return true;
        }else{
            line[B].parent=A;
        }
    }else{
        if(line[A].club!=-1){
            line[B].parent=A;
        }else{
            line[A].parent=B;
        }
    }
    return false;
}
int getparent(int a){
    if(line[a].parent==-1){
        return a;
    }else{
        line[a].parent = getparent(line[a].parent);
        return line[a].parent;
    }
}

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

int main() {
	int64_t a; cin >> a;
	string _b; cin >> _b;
	int64_t b = (_b[0] - '0') * 100 + (_b[2] - '0') * 10 + (_b[3] - '0');
	cout << a * b / 100 << '\n';
	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define SIZE 1e+200000
int main(void)
{
    char s[1001], t[1001];
    scanf("%s%s", s, t);
    int i, j, k;
    int min = 10000;
    int count = 0;
    int slen = strlen(s);
    int tlen = strlen(t);
    for (i = 0; i < slen - tlen + 1; i++)
    {
        k = i;
        for (j = 0; j < tlen; j++, k++)
        {
            if (t[j] != s[k])
                count++;
        }
        if (min > count)
            min = count;
        count = 0;
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 1736
#!/usr/bin/env python3

import itertools
import sys


DELTAS = [(0, 1), (1, 0), (0, -1), (-1, 0)]


def in_stage(h, w, r, c):
    return 0 <= r < h and 0 <= c < w


def in_place_solve(h, w, stage):
    ops = []
    for r0, c0 in itertools.product(range(h), range(w)):
        tr, tc = None, None
        if stage[r0][c0] % 2 == 0:
            continue
        for dr, dc in DELTAS:
            r, c = r0 + dr, c0 + dc
            if in_stage(h, w, r, c) and stage[r][c] % 2 == 1:
                tr, tc = r, c
                break
        else:
            for dr, dc in DELTAS:
                r, c = r0 + dr, c0 + dc
                if in_stage(h, w, r, c):
                    tr, tc = r, c
                    break
        if tr is None or tc is None:
            continue
        ops.append((r0 + 1, c0 + 1, tr + 1, tc + 1))
        stage[r0][c0] -= 1
        stage[tr][tc] += 1
    return ops


def main():
    h, w = (int(x) for x in input().split())
    stage = [[int(x) for x in input().split()] for _ in range(h)]
    # print("Before: ", file=sys.stderr)
    # print(*stage, sep="\n", file=sys.stderr)
    ops = in_place_solve(h, w, stage)
    # print("After: ", file=sys.stderr)
    # print(*stage, sep="\n", file=sys.stderr)
    print(len(ops))
    for y0, x0, y, x in ops:
        print(y0, x0, y, x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26424
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;


int main()
{

	int N, M, K;

	cin >> N >> M >> K;


	for(int i=0;i<=N;++i)
	{
		for (int j = 0; j <= M; ++j)
		{

			if(i*(M-j)+j*(N-i)==K)
			{
				cout << "Yes" << endl;
				return 0;
			}

		}
	}

	cout << "No" << endl;


	return 0;

}

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

int main(){
    int n;
    cin >> n;
    for(int i=1; i < 50001;i++) {
        if(n == int(i * 1.08)){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N int(2e5+1)
#define M int(1e9+7)
#define LL long long int
using namespace std;
int perm2int(int x[8],int n)
{
	int factorial[9],position[8],i;
	factorial[0]=1;
	for(i=1;i<9;i++)
		factorial[i]=factorial[i-1]*i;
	for(i=0;i<8;i++)
		position[i]=0;
	for(i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			position[i]+=(x[i]>x[j]);
	int ans=0;
	for(i=0;i<n;i++)
		ans+=position[i]*factorial[n-i-1];
	return ans;
}
int main()
{
	int n,a[8],b[8],i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		cin>>b[i];
	cout<<abs(perm2int(a,n)-perm2int(b,n))<<endl;
	return 0;
}

Measured memory_bytes: 256
def examB():
    N = I()
    cur =  0
    for _ in range(N):
        l, r = LI()
        cur += (r-l+1)
    print(cur)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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

using namespace std;

bool is_integer( double x ){
    return floor(x)==x;
}

int main() {
    int A, B;
    cin >> A >> B;
    
    double res = (A+B) / 2.0;

    if (!is_integer(res)) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << int(res) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    int ans = 0;
    for(int i = 0; i < n; i++) cin >> v[i];

    for(int left = 0; left <= k; left++){
        for(int right = 0; right <= k; right++){
            if(right+left > min(n,k)) continue;
            int m = k-left-right;
            int can = 0;
            priority_queue<int,vector<int>,greater<int>> que;
            //cout << "OK" << endl;
            for(int i = 0; i < left; i++){
                que.push(v[i]);
                can += v[i];
            }
            //cout << "OK" << endl;
            for(int i = n-right; i < n; i++){
                que.push(v[i]);
                can += v[i];
            }
            //cout << "OK" << endl;
            for(int i = 0; i < m; i++){
                if(que.empty() || que.top() > 0) break;
                can -= que.top();
                que.pop();
            }
            //cout << "OK" << endl;
            if(ans < can) ans = can;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256