akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a, b;
    cin >> a >> b;

    string res = "";

    if (a == b)
    {
        res = "Draw";
    }
    else
    {
        if (a == 1 || a > b && b != 1)
            res = "Alice";
        else
            res = "Bob";
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void init(int house[4][3][10]){
  int i,j,k;
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	house[i][j][k]=0;
      }
    }
  }
}

void print(int house[4][3][10]){
  int i,j,k;
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",house[i][j][k]);
      }
      printf("\n");
    }
    if(i<3){
      printf("####################\n");
    }
  }
}

int main(){
  int i,j,k,n;
  int b,f,r,v;
  int house[4][3][10];

  init(house);
 
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    house[b-1][f-1][r-1] += v;
  }

  print(house);
  
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  map<int,int> a;
  for(int i=1; i<=n; i++){
    int b;
    cin>>b;
    a[b]=i;
  }
  for(int i=1; i<=n; i++){
    cout<<a[i];
    if(i!=n){
      cout<<" ";
    }
  }
}

Measured memory_bytes: 5504
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    int x;
    cin>>x;
    if(x==0)cout<<1;
    else cout<<0;


    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int L;
	static String a0;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		a0 = sc.next();
		L = sc.nextInt();
		if(L == 0 && a0.equals("0"))return false;
		return true;
	}
	
	static void solve(){
		int posion = -1;
		int res = -1;
		int fromItoJ = -1;
		for(int i = a0.length(); i < L; i++){
			a0 += "0";
		}
		char[] array = a0.toCharArray();
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put(a0, 0);
		for(int index = 1; ; index++){
			Arrays.sort(array);
			String m = String.valueOf(array);
			int min = Integer.parseInt(m);
			StringBuffer sb = new StringBuffer(m);
			int max = Integer.parseInt(sb.reverse().toString());
			String diff = Integer.toString(max-min);
			for(int i = diff.length(); i < L; i++){
				diff = "0" + diff;
			}
			if(map.containsKey(diff)){
				posion = map.get(diff);
				fromItoJ = index - posion;
				res = max - min;
				break;
			}
			map.put(diff, index);
			array = diff.toCharArray();
		}
		System.out.println(posion + " " + res + " " + fromItoJ);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int maxn = 2e6+5;
int ans[maxn];

void solve(){
	string s;
	cin >> s;
	int n = s.length();
	for(int i = 0; i < n; i++){
		int l = i;
		while(i+1<n&&s[i]==s[i+1]){
			i++;
		}
		int len = i - l + 1;
		if(s[l]=='L') {
			ans[l] += (len+1)/2;
			ans[l-1]+= len/2;
		}else{
			ans[i] += (len+1)/2;
			ans[i+1] += len/2;
		}
	}
	for(int i = 0; i < n; i++){
		cout << ans[i] <<" ";
	}
  	cout << '\n';
}


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

Measured memory_bytes: 1104
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
input=lambda :sys.stdin.readline().rstrip()

H,W=map(int,input().split())
S=[input() for i in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w]=="#":
            for y,x in [[1,0],[-1,0],[0,1],[0,-1]]:
                Y=h+y;X=w+x
                if 0<=Y<H and 0<=X<W:
                    if S[Y][X]=="#":
                        break
            else:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];
    int ca = 0, cb = 0, cc = 0;
    rep(i, 0, n){
        if(p[i] <= a) ca++;
        else if(p[i] <= b) cb++;
        else cc++;
    }
    cout << min({ca, cb, cc}) << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

def dfs(x, y):
    C[y][x] = 0
    for dx,dy in zip([1,1,0,-1,-1,-1,0,1],[0,1,1,1,0,-1,-1,-1]):
        if 0 <= x+dx < w and 0 <= y+dy < h and C[y+dy][x+dx] == 1:
            dfs(x+dx, y+dy)

while 1:
    w,h = map(int,raw_input().split())
    if w == h == 0: break
    C = [map(int,raw_input().split()) for _ in xrange(h)]

    ans = 0
    for y in range(h):
        for x in range(w):
            if C[y][x] == 1:
                dfs(x, y)
                ans += 1
    print ans

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

int main()
{
	ll n, sum=0;
	cin >> n;
	rep(i, n){
		if(((i+1) %3==0 ) || ((i+1) % 5==0)){
			continue;
		}
		sum += i+1;
	}

	cout << sum << endl;
	
}



Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	double a=1,b=2;
	int X=0,MAX=0;

	scanf("%d",&X);

	if(X!=1){
	for(a=2;2*a<X;a++){
		for(b=2;pow(a,b)<=X;b++){
			if(pow(a,b)>MAX){
				MAX= (int)pow(a,b);
			}
		}
	}
	}
	else{
		MAX=X;
	}

	printf("%d",MAX);


	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

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

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

ll pow_mod(ll n, ll k, ll mod) {
    if(k == 0) {
        return 1;
    } else if(k % 2 == 1) {
        return pow_mod(n, k - 1, mod) * n % mod;
    } else {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
  ll n=s.size(),p=2019;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) {
        a[i] = (ll)(s[i] - '0');
    }
    reverse(ALL(a));
    vector<int> sum(n + 1, 0);
    for(ll i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + a[i] * pow_mod(10, i, p) % p;
        sum[i + 1] %= p;
    }
    map<ll, ll> mp;
    for(ll i = 0; i < n + 1; i++) {
        // cout << sum[i] << " ";
        mp[sum[i]]++;
    }
    // cout << endl;
    ll ans = 0;
    if(p == 2 || p == 5) {
        for(int i = 0; i < n; i++) {
            if(a[i] % p == 0) {
                ans += n - i;
            }
        }
        cout << ans << endl;
        return 0;
    }
    for(const auto &p : mp) {
        ans += (p.second - 1) * p.second / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5984
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();
		int[][] a = new int[n][m]; int[] b = new int[m]; int[] c = new int [n];
		
		//??????a?????????
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				a[i][j] = scan.nextInt();
			}
		}
		//??????b?????????
		for(int j=0; j<m; j++){
			b[j] = scan.nextInt();
		}
		
		//??????c????????????
		for(int i=0; i <n; i++){
			c[i] = 0;
		}
		
		//a??b???c???????´?
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				c[i] = c[i] + (a[i][j] * b[j]);
			}
			System.out.println(c[i]);
		}
	}
}

Measured memory_bytes: 40168
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c=0,d;
  cin>>a>>b;
  d=b;
  while(d!=0){
    d/=10;
    c++;
  }
  for(int i=0;i<c;i++){
    a*=10;
  }
  a=a+b;
  if(ceil(sqrt(a))*ceil(sqrt(a))==a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;



int main(){

    int n, x;
    cin >> n >> x;

    int l[n];
    for(int i=0;i<n;i++)cin >> l[i];

    unsigned long long ans = 0, d = 0;


    while(d<=x){
        d += l[ans];

        ans++;
    }

    cout << ans << endl;

}


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

using namespace std;

const int C[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

bool cs(string &a, string &b) {
    if (a.length() != b.length()) {
        return a.length() > b.length();
    }
    return a > b;
}

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

    string dp[n+1];
    dp[0] = "0";
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            if (i >= C[a[j]] && dp[i-C[a[j]]] != "") {
                string t = dp[i-C[a[j]]] + (char)(a[j] + '0');
                if (cs(t, dp[i])) {
                    dp[i] = t;
                }
            }
        }
    }

    cout << dp[n].substr(1, dp[n].length() - 1) << endl;

    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) cout << "Left" << endl;
  else if (a + b < c + d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    int n ;
    cin >> n;
    ll ans = 0;
    rep(i, n){
        if(i%3 != 0 && i%5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,A,T;
    cin >> N >> T >> A;
    int ans;
    double t = 1e9;
    REP(i,N) {
        int h;
        cin >> h;
        double tmp = (double)(abs(A - (T - h * 0.006)));
        //cout << tmp << endl;
        if(t >= tmp) {
            ans = i+1;
            t = tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] str = stdR.readLine().split(" ");
        int H = Integer.parseInt(str[0]);
        int W = Integer.parseInt(str[1]);
        String[] s = new String[H];
        int[] x = {-1,0,0,1};
        int[] y = {0,-1,1,0};
        for(int i = 0 ; i < H ; i++) {
            s[i] = stdR.readLine();
        }
        for(int i = 0 ; i < H ; i++) {
            for(int j = 0 ; j < W ; j++) {
                if(s[i].charAt(j) == '#') {
                    boolean isok = false;
                    for(int k = 0 ; k < x.length ; k++) {
                        if(j + x[k] >= 0 && j + x[k] < s[0].length() && i + y[k] >= 0 && i + y[k] < s.length && s[i + y[k]].charAt(j + x[k]) == '#') {
                            isok = true;
                            break;
                        }
                    }
                    if(!isok) {
                        System.out.println("No");
                        return;
                    }
                }
            }
        }
        System.out.println("Yes");
    }

}


Measured memory_bytes: 22612
N = int(input())
S = ""
Num = 0
Ans = []

for i in range(15):
  if not N:
    break
    
  r = (N-1) % 26 +1
  #print("r=", r)
  N = (N-1) // 26
  S += chr(ord("a")+r-1)
  
print(S[::-1])

Measured memory_bytes: 61720
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n,w;
		cin >> n >> w;
		int val[w+1]={};
		rep(i,0,w+1) val[i] = -1;
		val[0] = 0;
		rep(i,0,n){
			int t;
			cin >> t;
			int r;;
			cin >> r;
			for(int j=w; j>=0; j--){
				if(j+t<=w && val[j]!=-1){
					val[j+t] = max(val[j+t], val[j]+r);
				}
			}
		}
		int mx = -INF;
		rep(j,0,w+1) mx = max(mx, val[j]);
		cout<<mx;
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>

using namespace std;
const int maxn = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
typedef long long ll;

ll a, b, n;
int main(){
	scanf("%lld %lld %lld", &a, &b, &n);
	ll x = min(n, b - 1);
	ll ans = a * x / b + a * (x / b);
	printf("%lld\n", ans);
}

Measured memory_bytes: 3760
N=int(input())
S=list(input())
cnt=0
number=[str(i) for i in range(10)]
for i in range(10):
    try:
        first=S.index(number[i])
        if first>=N-2:
            continue
        for k in range(10):
            try:
                second=S[first+1:].index(number[k])
                if second>=len(S[first+1:])-1:
                    continue
                for l in range(10):
                    if number[l] in S[first+1:][second+1:]:
                        cnt+=1
            except:
                continue
    except:
        continue
print(cnt)
                

Measured memory_bytes: 3820
open Printf open Scanf
open Array

module UnionFind = struct
  let init n = Array.make n (-1)
  let is_root i a = a.(i) < 0
  let rec root_destructive x a =
    if a.(x) < 0 then x
    else (a.(x) <- root_destructive a.(x) a; a.(x))
  let size_destructive i a = let r = root_destructive i a in -a.(r)
  let same_destructive x y a = root_destructive x a = root_destructive y a
  let connect_destructive x y a =
    let p,q = root_destructive x a,root_destructive y a
    in if p = q then () else (
      let p,q = if a.(p) > a.(q) then q,p else p,q
      in
      a.(p) <- a.(p) + a.(q); a.(q) <- p)
end module UF = UnionFind
let rev a = a |> to_list |> List.rev |> of_list

let () = scanf " %d %d" @@ fun n m ->
  let uf = UF.init n in
  let q = rev @@
    init m (fun _ -> scanf " %d %d" @@ fun a b -> a-1,b-1)
  in
  let d = map (fun (a,b) ->
    if not @@ UF.same_destructive a b uf then (
      let p,q =
        UF.size_destructive a uf,
        UF.size_destructive b uf in
      UF.connect_destructive a b uf;
      p*q
    ) else 0
  ) q |> rev in
  ignore @@ fold_left (fun sum v ->
    let w = sum + v in
    printf "%d\n" w; w
  ) 0 d




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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, k;
string d[10];

bool ok() {
	string ns = to_string(n);
	rep(i,ns.length()) {
		rep(j,k) {
			if (ns[i]==d[j][0]) return false;
		}
	}
	return true;
}

int main() {
	cin >> n >> k;
	rep(i,k) cin >> d[i];
	
	while (true) {
		if (ok()) {
			cout << n << ln;
			return 0;
		}
		n++;
	}
}

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

int n, m;
int dp[100005];
vector <int> g[100005];

int dfs(int pos) {
	if(dp[pos]) return dp[pos];
	for(auto i:g[pos]) {
		dp[pos] = max(dp[pos], dfs(i)+1);
	}
	return dp[pos];
}

int main() {
	scanf("%d %d", &n, &m);
	int u, v;
	for(int i = 1;i <= m; i++) {
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
	}
	memset(dp, 0, sizeof(dp));
	int ans = 0;
	for(int i = 1;i <= n; i++) {
		//printf("i = %d sum = %d\n", i, dfs(i));
		ans = max(ans, dfs(i));
	} 
	//for(int i = 1;i <= n; i++) printf("%d ", dp[i]); puts("");
	printf("%d\n", ans);
}

Measured memory_bytes: 11604
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st s;
  ci(s);
  st a = "";
  for(int i = 0; i < sz(s); i += 2){
    a += s.at(i);
  }
  co(a);
}

Measured memory_bytes: 512
a,b = list(map(int, input().split()))
n = int(input())
sf = [list(map(int, input().split())) for _ in range(n)]

ans = 0
li = [True] * 1000
sf.sort()
for i in sf:
    for j in range(i[0], i[1]):
        li[j] = False
for i in range(a,b):
    if li[i] == False:
        ans = 1
        break


print(ans)


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

typedef long long ll;

ll INF = 1LL << 50;

int n;

vector<pair<ll, ll>> v(5010);

ll dp[5010][5010];

int main(){
    cin >> n;
    v.resize(n);

    for (int i = 0; i < n; i++){
        cin >> v[i].first >> v[i].second;
    }

    sort(v.begin(), v.end(), 
        [](pair<ll, ll> a, pair<ll, ll> b){
        return a.first + a.second < b.first + b.second;  
    });
/*
    for (auto a : v){
        cout << a.first << " " << a.second << endl;;
    }
    */

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

    int res = 0;

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if (dp[i-1][j-1] > v[i-1].first){
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-1] + v[i-1].second);
            }
        }
    }
    for (int j = 0; j <= n; j++){
        //cout << dp[n][j] << endl;
        if (dp[n][j] < INF) res = j;
    }
    cout << res << endl;
}

Measured memory_bytes: 196096
#include <iostream>
#include <string.h>
using namespace std;
int main(){
  int N,K,X,Y;
  cin>>N;
  cin>>K;
  cin>>X;
  cin>>Y;
  int ans=0;
  for(int i=0;i<N;i++){
    if(i<K){
    ans+=X;
  }else{
    ans+=Y;
  }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
int N;
  cin >> N;
  vector<int> kazu(N);
  int count = 0;
  for(int i = 0; i < N; i++){
  	cin >> kazu[i];
    count += kazu[i];
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
  	ans += kazu[i]*(count-kazu[i]);
  }
  cout << ans/2 << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<int> num(n+1,0); //n!の素因数はn以下の素数
  for(int i=2; i<=n; i++){ //n!を素因数分解
    int tmp=i;
    while(tmp!=1){
      for(int j=2; j<=i; j++){
        if(!(tmp%j)){
          num[j]++;
          tmp /= j;
          break;
        }
      }
    }
  }
  /*約数の数が75個である数は75=3*5^2より
  p^74, p^24*q^2, p^14+q^4, p^5*q^5*r^3の4パターン(p,q,rは任意の素数)
  n!の約数でこれを満たすものを数える*/
  int ans=0;
  for(int i=2; i<=n; i++){
    if(num[i]>=74)
      ans++;
  }
  for(int i=2; i<=n; i++){
    for(int j=2; j<=n; j++){
      if(i==j)
        continue;
      if(num[i]>=24 && num[j]>=2)
        ans++;
    }
  }
  for(int i=2; i<=n; i++){
    for(int j=2; j<=n; j++){
      if(i==j)
        continue;
      if(num[i]>=14 && num[j]>=4)
        ans++;
    }
  }
  for(int i=2; i<=n; i++){
    for(int j=i+1; j<=n; j++){
      for(int k=2; k<=n; k++){
        if(i==k || j==k)
          continue;
        if(num[i]>=4 && num[j]>=4 && num[k]>=2)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll mypow(ll a, ll p, ll MOD){
	if(MOD <= 0) return 0;
	if(p == 0) return 1;
	if(p == 1) return (a % MOD);
	if(p & 1) return ((a % MOD) * (mypow(a, p - 1, MOD) % MOD)) % MOD;
	ll x = mypow(a, p / 2, MOD) % MOD;
	return (x * x) % MOD;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll MOD = 0LL;
	rep(i, n) MOD += (s[i] == '1');
	ll MOD1 = MOD + 1, MOD2 = MOD - 1;
	ll cur3 = 0, cur4 = 0;
	reverse(all(s));
	rep(i, n) if(s[i] == '1') (cur3 += mypow(2, i, MOD1)) %= MOD1;
	if(MOD2 > 0) rep(i, n) if(s[i] == '1') (cur4 += mypow(2, i, MOD2)) %= MOD2;
	vi ans;
	rep(i, s.size()){
		if(MOD == 1 && s[i] == '1'){
			ans.pb(0);
			continue;
		}
		int num = 1;
		ll cur1 = cur3;
		ll MOD3 = MOD1;
		if(s[i] == '1') cur1 = cur4, MOD3 = MOD2;
		if(s[i] == '0') (cur1 += mypow(2, i, MOD3)) %= MOD3;
		else cur1 -= mypow(2, i, MOD3);
		while(cur1 < 0) cur1 += MOD3;
		//now we do the operation until we are done
		string nw = "";
		int ppcnt = 0;
		rep(j, 25){
			if(cur1 & (1LL << j)) nw += '1', ppcnt++;
			else nw += '0';
		}
		while(ppcnt){
			ll cur2 = 0;
			rep(j, nw.size()) if(nw[j] == '1') (cur2 += mypow(2, j, ppcnt)) %= ppcnt;
			string nw1 = "";
			ppcnt = 0;
			rep(j, 25){
				if(cur2 & (1LL << j)) nw1 += '1', ppcnt++;
				else nw1 += '0';
			}
			nw = nw1;
			num++;
		}
		ans.pb(num);
	}
	reverse(all(ans));
	rep(i, ans.size()) cout << ans[i] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 4496
h,w,d = map(int,input().split())

data = []

for i in range(h):
    l = list(map(int,input().split()))
    for j in range(w):
        data.append((l[j],i+1,j+1))

data.sort(key = lambda x:x[0])
#print(data)
dis = [0]*(h*w+1)

for i in range(h*w,0,-1):
    if i - d < 1:
        break
    x1,y1 = data[i-d-1][1],data[i-d-1][2]
    x2,y2 = data[i-1][1],data[i-1][2]
    '''
    if i - d == 4 and i == 6:
        print(str(x1)+str(y1))
        print(str(x2)+str(y2))
    '''
    dis[i-d] = dis[i] + abs(x1-x2)+abs(y1-y2)

#print(dis) 

q = int(input())

for _ in range(q):
    l,r = map(int,input().split())
    print(dis[l]-dis[r])


Measured memory_bytes: 18292
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - I hate Factorization
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

inline ll e5(int n) { return (ll)n * n * n * n * n; }
inline ll f(int n, int m) { return e5(n) - e5(m); }

/* main */

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

  for (int a = 1; f(a, a - 1) <= x; a++) {
    ll fb;
    for (int b = a - 1; (fb = f(a, b)) <= x; b--)
      if (fb == x) {
	printf("%d %d\n", a, b);
	return 0;
      }
  }

  for (int a = 0; f(a, a - 1) <= x; a--) {
    ll fb;
    for (int b = a - 1; (fb = f(a, b)) <= x; b--)
      if (fb == x) {
	printf("%d %d\n", a, b);
	return 0;
      }
  }
  return 0;
}


Measured memory_bytes: 3184
import sys
from itertools import product
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n, m = map(int, input().split())
    l = [tuple(map(int, input().split())) for _ in range(n)]
    ans = 0
    for i, j, k in product([-1, 1], repeat=3):
        l2 = sorted([x * i + y * j + z * k for x, y, z in l], reverse=True)
        ans = max(ans, sum(l2[:m]))
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    int d[n];
    for (int i = 0; i < n; ++i) cin >> d[i];
    sort(d, d + n);
    int ans = 0;
    for (int i = d[n / 2 - 1] + 1; i <= d[n / 2]; ++i) ++ans;
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }

int main(){
	ll n,a,b;cin>>a>>b>>n;
	if(b > n){
		cout << (a * n) / b - a * (n / b) << endl;
	}
	else{
		ll tmp = b - 1;
		cout << (a * tmp) / b - a * (tmp / b) << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
// Union Find 木
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func find(parent []int, i int) int {
	if parent[i] == -1 {
		return i
	}
	parent[i] = find(parent, parent[i])
	return parent[i]
}

func unite(parent []int, i, j int) {
	i = find(parent, i)
	j = find(parent, j)
	if i == j {
		return
	}
	parent[i] = j
}

func fill(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}

func main() {
	defer flush()

	n := readInt()
	k := readInt()
	l := readInt()

	roads := make([]int, n)
	fill(roads, -1)
	rails := make([]int, n)
	fill(rails, -1)

	for i := 0; i < k; i++ {
		p := readInt()
		q := readInt()
		unite(roads, p-1, q-1)
	}

	for i := 0; i < l; i++ {
		p := readInt()
		q := readInt()
		unite(rails, p-1, q-1)
	}

	d := map[int]int{}
	for i := 0; i < n; i++ {
		d[2000001*find(roads, i)+find(rails, i)]++
	}

	for i := 0; i < n; i++ {
		println(d[2000001*find(roads, i)+find(rails, i)])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 19252
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 510;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

// class ReconstructNumber {
// public:
//     string smallest(string);
// };

// string ReconstructNumber::smallest(string s) {
// }

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    int cnt = 0;
    FOR(i,2,n-1) {
        if (a[i-1] < a[i] && a[i] < a[i+1]) cnt++;
        else if (a[i-1] > a[i] && a[i] > a[i+1]) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint c(n), s(n), f(n);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    vint ans(n, 0);
    rep(i, n-1) {
        int t = 0;
        srep(j, n-1, i) {
            int t_tmp = s[j];
            if (s[j] > t) ans[i] = t_tmp;
            else {
                while (t > t_tmp) {
                    t_tmp += f[j];
                }
                ans[i] = t_tmp;
            }
            ans[i] += c[j];
            t = ans[i];
        }
    }

    rep(i, n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    vector<int> w(N);
    vector<int> v(N);

    int sumV = 0;
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
        sumV += v[i];
    }

    vector<LL> dp(sumV+1, W+1);
    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (LL val = sumV; 0 <= val - v[i]; --val) {
            dp[val] = min(dp[val], dp[val-v[i]] + w[i]);
        }
    }

    int ans = 0;
    for (int j = 0; j <= sumV; ++j) { 
        if (dp[j] <= W) {
            ans = max(ans, j);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順
//priority_queue<int> que; // 降順

using namespace std;

const int mod=1e9+7;

signed main()
{
    SPEED;
    string a,b;
    cin >> a >> b;
    int numA = stoi(a), numB = stoi(b);
    string tmpB = b;
    rep(i, numA - 1)
    {
        
        b += tmpB;
    }
    string tmpA = a;
    rep(i, numB - 1)
    {
        
        a += tmpA;
    }
    cout << min(a, b) << endl;
}


Measured memory_bytes: 256
S = input()
S2 = ""
S3 = ""
co1 = 0
co2 = 0
f = 1
for i in range(len(S)):
 if f == 1:
  S2 += "1"
  S3 += "0";f=0
 else:
  S2 += "0";S3 += "1";f=1
for i in range(0,len(S)):
  if S[i] != S2[i]:
   co1 += 1;print
for i in range(0,len(S)):
  if S[i] != S3[i]:
   co2 += 1
if co1 > co2:
 print(co2)
else:
 print(co1)

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

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            while (true)
            {
                input = Console.ReadLine();
                int H = int.Parse(input.Split(' ')[0]);
                int W = int.Parse(input.Split(' ')[1]);
                if (H != 0 & W != 0)
                {
                    for (int i = 0; i < H; i += 1)
                    {
                        Console.WriteLine(new String('#', W));
                    }
                }
                else
                {
                    break;
                }
                Console.Write("\n");

            }

        }
    }
}

Measured memory_bytes: 8892
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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 (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  ll n;
  while(cin>>n) {
    cout << n*(n-1)/2 << endl;
  }
}


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

int main()
{

  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()){
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
import math
n = int(raw_input())

for i in range(n):
    xa, ya, ra, xb, yb, rb = map(float, raw_input().split(' '))
    d = math.sqrt((xa-xb)**2 + (ya-yb)**2)
    if d+rb < ra:
        print 2
    elif d+ra < rb:
        print -2
    elif d > ra+rb:
        print 0
    else:
        print 1
    

Measured memory_bytes: 6468
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,df;
signed main(){
	cin>>n;
	for(int i=1,k;i<=n;i++) cin>>k,df+=!(k==i);
	if(df==2 || df==0)cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

#define maxn 10010

int n,a[maxn];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	ll money=1000;
	int i=1;while(i<=n)
	{
		int j=i;
		while(j<=n&&a[j+1]>=a[j])j++;
		if(j>i)money=money/a[i]*a[j]+money%a[i];
		i=j+1;
	}
	pr2(money); return 0;
}



Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;
vector<int> to[200005];
int ki[200005];

void dfs(int v, int j = -1){
  for(int u: to[v]){
    if(u==j) continue;
    ki[u] += ki[v];
    dfs(u, v);
  }
}
  

int main(){
  int N, Q;
  cin >> N >> Q;
  int a, b;
  rep(i, N-1){
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  int p, x;
  rep(i, Q){
    cin >> p >> x;
    p--;
    ki[p] += x;
  }
  dfs(0);
  rep(i, N){
    cout << ki[i] << endl;
  }
  
}

Measured memory_bytes: 23424