akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
//const int mod=1000000007 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint i,ans=0,n;cin>>n;
	vector<string>a(n);
	vector<llint>b(n);
	REP(i,n){cin>>a[i]>>b[i];}
	string s;cin>>s;
	REP(i,n){ans+=b[i];if(s==a[i]){ans=0;}}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
using namespace std;
typedef long long ll;
int main() 
{
    fast;
    ll t;
    cin>>t;
    ll sm = 0;
    for(ll i=1;i<=t;i++)
    {
        if(i%3!=0&&i%5!=0)
            sm+=i;
    }
    cout<<sm;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  using D = double;
  int n;
  cin>>n;
  vector<D> as(n);
  for(int i=0;i<n;i++) cin>>as[i];

  const int MAX = 1e6;
  const D INF = 1e9;
  vector<D> dp(MAX,INF);
  for(int j=1;j<MAX;j++) dp[j]=abs(as[0]-j)/as[0];

  for(int i=0;i+1<n;i++){
    vector<D> nx(MAX,INF);
    for(int j=1;j<MAX;j++)
      for(int k=j;k<MAX;k+=j)
        chmin(nx[k],max(dp[j],abs(as[i+1]-k)/as[i+1]));
    swap(dp,nx);
  }

  cout<<*min_element(dp.begin(),dp.end())<<endl;
  return 0;
}



Measured memory_bytes: 18508
M,D = gets.split.map(&:to_i)

d1 = D % 10
d10 = (D-d1)%100/10

count = 0
4.upto(M) do |m|
  22.upto(D) do |d|
    d10 = d.to_s[0].to_i
    d1 = d.to_s[1].to_i
    if d1 < 2 || d10 < 2
      next
    end
    if d1 * d10 == m
      count += 1
    end
  end
end
puts count


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/abc077_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    a = input().strip()
    b = input().strip()

    if a == b[::-1]:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3060
x = int(input())
y = int(input())
if x==1 and y==2:
    print(3)
elif x==1 and y==3:
    print(2)
elif x==2 and y==3:
    print(1)
elif x==2 and y==1:
    print(3)
elif x==3 and y==1:
    print(2)
elif x==3 and y==2:
    print(1)

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

bool SortComp(pair<int, int> num1, pair<int, int> num2)
{
	if(num1.second > num2.second)
		return true;
	else if(num1.second < num2.second)
		return false;
	else if(num1.first < num2.first)
		return true;
	else
		return false;
}

int main(void)
{
	while(1)
	{
		int num, min;
		cin>>num>>min;
		if(num == 0 && min == 0)
			break;

		vector<pair<int, int> > arr(101);
		for(int i= 0; i < 101; i++)
			arr[i].first= i+1;

		for(int i= 0; i < num; i++)
		{
			int days;
			cin>>days;

			for(int j= 0; j < days; j++)
			{
				int input;
				cin>>input;
				arr[input-1].second++;
			}
		}

		sort(arr.begin(), arr.end(), SortComp);
		if(arr[0].second < min)
			cout<<0<<endl;
		else
			cout<<arr[0].first<<endl;
	}
}

Measured memory_bytes: 3020
using System;


namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int n = 1; n<3000; n++)
            {
                var A = Console.ReadLine().Split(' ');
               
                int a = int.Parse(A[0]);
                int aa = int.Parse(A[1]);
               
                if(a == 0 && aa ==0)
                {
                    break;
                }
                else if(a <= aa)
                {
                    Console.WriteLine("{0} {1}",a,aa);
                }
                else if(a >=aa)
                {
                    Console.WriteLine("{0} {1}", aa, a);
                }
            }

        }
    }
}

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

using namespace std;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<ll, ll> pii;

const int mn = 1005;
const int mod = 1e9 + 7;

int n, m;
int A, B;
char s[mn][mn];

bool judge() {
    for (int i = 1; i <= n; i++) {
        int c0 = 0, c1 = 0;
        for (int j = 1; j <= m; j++) {
            if (s[i][j] == '0') c0++;
            else c1++;
        }
        if (min(c0, c1) != A) return 0;
    }
    for (int j = 1; j <= m; j++) {
        int c0 = 0, c1 = 0;
        for (int i = 1; i <= n; i++) {
            if (s[i][j] == '0') c0++;
            else c1++;
        }
        if (min(c0, c1) != B) return 0;
    }
    return 1;
}

int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    cin >> n >> m >> A >> B;
    for (int j = 1; j <= m; j++) {
        if (j <= A) s[1][j] = '0';
        else s[1][j] = '1';
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (B * 2 >= i) {
                s[i][j] = '1' + '0' - s[i - 1][j];
            } else s[i][j] = s[i - 1][j];
        }
    }
    if (!judge()) puts("-1");
    else {
        for (int i = 1; i <= n; i++)
            printf("%s\n", s[i] + 1);
    }
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    string s;
    int k;
    int ans=0;
    cin >>k>>s;
    for(int i=0;i<s.size() and i<k;i++){
        cout<<s[i];
    }
    if(s.size() >k){
        cout<<"...";
    }
    cout<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define emp emplace
#define bit(mask, i) (((mask) >> (i))&1)
using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 16;
int a[N][N];
ll val[1 << 16];
ll dp[1 << 16];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			scanf("%d", &a[i][j]);
	}
	for (int mask = 1; mask < (1 << n); mask++)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = i+1; j < n; j++)
			{
				if (bit(mask, i) and bit(mask, j))
					val[mask] += a[i][j];
			}
		}
	}
	
	for (int mask = 1; mask < (1 << n); mask++)
	{
		dp[mask] = -1e18;
		for (int sub = mask; sub > 0; sub = (sub-1)&mask)
			dp[mask] = max(dp[mask], dp[mask^sub] + val[sub]);
	}
	printf("%lld\n", dp[(1 << n)-1]);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
 using namespace std;
#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; } 

 int main(){
   string s;
   cin>>s;
  int n=s.size(),p=2019;
   vector<int> d(n+1);
   int ten=1;
   for(int i=n-1;i>=0;i--){
   int a=(s[i]-'0')*ten % p;
     d[i]=(d[i+1]+a)%p;
     ten*=10;
     ten%=p;
   }
   vector<int> cnt(p);
   long long ans=0;
   for(int i=n;i>=0;i--){
   ans+=cnt[d[i]];
     cnt[d[i]]++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 4384
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
template <typename T>
using Vec3 = vector<Vec2<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repe(i, n) REPN(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define reper(i, n) REPNR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec2<ll> memo(401, Vec(401, -LINF));
Vec a, cs;

ll f(ll l, ll r){
	if(memo[l][r] != -LINF) return memo[l][r];
	if(r-l == 1) return memo[l][r] = 0;
	if(r-l == 2) return memo[l][r] = cs[r]-cs[l];
	ll res = LINF;
	REPN(i, l+1, r-1) chmin(res, f(l, i)+f(i, r));
	return memo[l][r] = res+cs[r]-cs[l];
}

int main(void){
	ll n;
	cin >> n;
	a.resize(n);
	rep(i, n) cin >> a[i];
	cs.resize(n+1);
	repn(i, n){
		cs[i] = a[i-1];
		cs[i] += cs[i-1];
	}

	ll ans = LINF;
	repn(i, n-1) chmin(ans, f(0, i)+f(i, n));
	co(ans+cs[n]);

	return 0;
}


Measured memory_bytes: 1536
package main

import (
        "fmt"
)

func main() {
        var A, B, C, X, Y, s int
        fmt.Scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y)
        if X > Y {
                s = X * 2
        } else {
                s = Y * 2
        }
        ans := 1<<63 - 1
        for i := s; i >= 0; i = i - 2 {
                tmp := i * C
                if i/2 < X {
                        tmp += A * (X - i/2)
                }
                if i/2 < Y {
                        tmp += B * (Y - i/2)
                }
                if tmp < ans {
                        ans = tmp
                }
        }
        fmt.Println(ans)
}

Measured memory_bytes: 512
import * as fs from 'fs'

//in
// 5
// 4 2 5 1 3
//out
// 3
const input: string[] = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
const n: number = parseInt(input[0]);
const p: number[] = input[1].split(' ').map(Number);
let result: number = 0;
let min :number = Infinity;
for (let i: number = 0; i < n; i++) {

    if (min > p[i]) {
        result++;
        min = p[i];
    }
}

console.log(result);


Measured memory_bytes: 22224
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N, 0);
  vector<int> arg_m(M, 0);
  vector<vector<int>> A(N, vector<int>(M, 0));
  ul ans_max = pow(10, 9);
  ul ans = ans_max;
  REP(ii, N) {
    cin >> C[ii];
    REP(jj, M) cin >> A[ii][jj];
    REP(jj, M) arg_m[jj] += A[ii][jj];
  }

  ul s_max = 1 << N;
  REP(s, s_max) {
    vector<ul> smart(M, 0);
    ul cost_sum = 0;
    REP(ii, N) {
      if (s >> ii & 1) continue;
      cost_sum += C[ii];
      REP(jj, M) smart[jj] += A[ii][jj];
    }
    bool ok = true;
    REP(ii, M) {
      if (smart[ii] < X) ok = false;
    }
    if (ok) {
      ans = min(ans, cost_sum);
    }
  }
  if (ans == ans_max) {
    cout << "-1" << endl;
    return 0;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
        
		int[] a=new int[5];
		int ans=0;
		
		for(int i=0;i<5;i++) {
			a[i] = sc.nextInt();
			if (a[i]== 0) {
				ans =i;
			}
		}
		System.out.println(ans+1);
	}
}

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


def main():
    n, m, k = map(int, input().split())

    for i in range(n + 1):
        for j in range(m + 1):
            if i * (m - j) + j * (n - i) == k:
                print('Yes')
                exit()

    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var lrs = new (long l, long r)[N];
            for (var i = 0; i < N; ++i)
            {
                var S = ReadLine();
                var l = 0L;
                var r = 0L;
                foreach (var s in S)
                {
                    if (s == '(') ++l;
                    else
                    {
                        if (l == 0) ++r;
                        else --l;
                    }
                }
                lrs[i] = (l, r);
            }
            //(だけで最長のものを作る
            var ln = 0L;
            foreach (var lr in lrs.Where(lr => 0 < lr.l - lr.r).OrderBy(lr => lr.r))
            {
                if (lr.r <= ln) ln += lr.l - lr.r;
                else
                {
                    WriteLine("No");
                    return;
                }
            }
            //)だけで最長のものを作る
            var rn = 0L;
            foreach (var lr in lrs.Where(lr => lr.l - lr.r < 0).OrderBy(lr => lr.l))
            {
                if (lr.l <= rn) rn += lr.r - lr.l;
                else
                {
                    WriteLine("No");
                    return;
                }
            }
            var eqM = 0L;
            var eqMs = lrs.Where(lr => lr.l == lr.r);
            if (eqMs.Any()) eqM = eqMs.Max(lr => lr.l);

            if (rn == ln && eqM <= rn) WriteLine("Yes");
            else WriteLine("No");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 105344
#include<stdio.h>
#define N 100000
#define INF 1000000000
 
struct C{
  char s;
  int v;
};
 
struct C L[N], R[N];
 
void merge(struct C[], int , int , int );
void mergeSort(struct C[], int , int ); 
int partition(struct C[], int , int );
void quickSort(struct C[], int , int );
 
 
int main(){
   
  int n, i, v;
  struct C A[N], B[N];
  char S[10];
  int stable = 1;
   
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].s = S[0];
    B[i].s = S[0];
    A[i].v = v;
    B[i].v = v;
  }
 
  mergeSort(A,0,n);
  quickSort(B,0,n-1);
 
  for(i=0;i<n;i++ ){
    if(A[i].s!=B[i].s){
      stable=0;
    }
  }
 
  if(stable==1){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  for(i=0;i<n;i++){
    printf("%c %d\n", B[i].s, B[i].v);
  }
  return 0;
}
 
void merge(struct C A[],int left,int mid,int right){
   
  int i,j,k,n1,n2;
   
  n1=mid-left;
  n2=right-mid;
   
  for(i=0;i<n1;i++){
    L[i] = A[left + i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid + i];
  }
 
  L[n1].v=INF;
  R[n2].v=INF;
  i=0;
  j=0;
   
  for (k=left;k<right;k++ ){
    if (L[i].v<=R[j].v){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}
 
void mergeSort(struct C A[], int left, int right ){
   
  int mid;
   
  if (left+1<right){
    mid=(left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
 
int partition(struct C A[],int p,int r){
 
  int i,j;
  struct C t,x;
 
  x = A[r];
  i = p - 1;
  for (j=p;j<=r-1;j++ ){
    if ( A[j].v <= x.v){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
   
  return i+1;
}
 
void quickSort(struct C A[],int p,int r){
 
  int q;
   
  if (p<r){
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

Measured memory_bytes: 4924
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
 
using namespace std;
 
int main(){
    int a=0,b=0,in;
     
    for(int i=0;i<4;i++){
        scanf("%d",&in);
        a+=in;
    }
    for(int i=0;i<4;i++){
        scanf("%d",&in);
        b+=in;
    }
     
    if(a>b)
        printf("%d\n",a);
    else
        printf("%d\n",b);
     
    return 0;
}

Measured memory_bytes: 3172
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s,t;
  cin>>s>>t;
  ll dp[s.size()+1][t.size()+1];
  memset(dp,0,sizeof(dp));
  rep(i,s.size()) rep(j,t.size()){
    if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
    else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
  }
  ll i=s.size(),j=t.size();
  string ans="";
  while(i>0 && j>0){
    if(dp[i][j]==dp[i-1][j]){
      i--;
    }else if(dp[i][j]==dp[i][j-1]){
      j--;
    }else{
      ans=t[j-1]+ans;
      i--;j--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 70656
#include <stdio.h>

// target以外の候補者の石の数がすべて0の場合にtrueを返す
bool otherkouho(int *kouho, int target, int total)	{
	
	for (int i = 0; i <= total - 1; i++)	{
		
		if (i == target)	{
			continue;
		}
		
		if (kouho[i] > 0)	{
			return false;
		}
	}
	
	return true;
}

int main(void)	{
	
	int n, p, wan, turn;
	int kouho[50];
	
	while (true)	{
		
		scanf("%d %d", &n, &p);
		
		if (n == 0)	{ break; }

		// 諸々の初期化
		turn = 0;
		wan = p;
		for (int i = 0; i <= 49; i++)	{
			kouho[i] = 0;
		}
		
		while (true)	{
			
			if (wan > 0)	{
				
				kouho[turn]++;
				wan--;
				
				if (wan == 0)	{
					if (otherkouho(kouho, turn, n))	{
						break;
					}
				}
			} else	{
				if (kouho[turn] > 0)	{
					wan = kouho[turn];
					kouho[turn] = 0;
				}
			}
			
			turn++;
			
			if (turn >= n)	{
				turn = 0;
			}
		}
		
		printf("%d\n", turn);
	}
	
	return 0;
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// using cd = complex<double>;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 

typedef long long int ll;
typedef long double ld;
const ll N = 1e6 + 9;
const ll mod = 1e9 + 7;
const ll inf= 1e14;

const double PI = acos(-1);
#define x first
#define y second
#define pb push_back
#define mp make_pair    
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b,ll mod) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
std::vector <int> prime;
bool is_composite[N];
ll ct[N];
void sieve (int n) {
    std::fill (is_composite, is_composite + n, false);
    for (int i = 2; i < n; ++i) {
        if (!is_composite[i]) prime.push_back (i);
        for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
            is_composite[i * prime[j]] = true;
            if (i % prime[j] == 0) break;
        }
    }
}
int main() {    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    ll T = 1;
    // cin>>t;

    sieve(N);
    memset(ct,0,sizeof(ct));
    while(T--){
        ll n;cin>>n;
        ll a[n];
        for(int i = 0;i<n;i++){
            cin>>a[i];
            ct[a[i]]++;
        }
        bool pa = 1,se = 1;
        for(auto i:prime){
            ll div = 0;
            for(int j = i;j<N;j+=i){
                div+=ct[j];
            }
            if(div>1){
                pa = 0;
            }
            if(div==n){
                se = 0;
            }
        }
        if(pa){
            cout<<"pairwise coprime\n";
        }
        else if(se){
            cout<<"setwise coprime\n";
        }
        else{
            cout<<"not coprime\n";
        }

    }
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;
const ll mod = 1000000007;

ll modinv(ll a, ll m)
{
  ll b=m, x=1, y=0;
  while (b) {
    ll t = a/b;
    a -= t*b; swap(a, b);
    x -= t*y; swap(x, y);
  }
  x %= m;
  if (x<0) x += m;
  return x;
}

ll choose(ll n, ll r, ll p)
{
  ll ret = 1;
  while(true) {
    if (r==0) break;
    ll N = n%p;
    ll R = r%p;
    if (N<R) return 0;
    for (ll i=0; i<R; i++) {
      ret = ret * (N-i) % p;
    }
    ll imul = 1;
    for (ll i=0; i<R; i++) {
      imul = imul * (i+1) % p;
    }
    ret = ret * modinv(imul, p) % p;
    n /= p;
    r /= p;
  }
  return ret;
}

ll modpow(ll a, ll n)
{
  ll res=1;
  while (n>0) {
    if (n&1) res = res*a % mod;
    a = a*a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll ans = modpow(2, n);
  ans = (ans + mod - 1) % mod;

  ans = (ans + mod - choose(n, a, mod)) % mod;
  ans = (ans + mod - choose(n, b, mod)) % mod;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <sstream>
#include <cstring>
#include <set>
#include <cctype>
#include <bitset>
#define IO                       \
    ios::sync_with_stdio(false); \
    // cin.tie(0);                  \
    // cout.tie(0);
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 1e6 + 100;
const int maxm = 1e6 + 10;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
// int dis[8][2] = {0, 1, 1, 0, 0, -1, -1, 0, 1, -1, 1, 1, -1, 1, -1, -1};

int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    IO;
    string s;
    cin >> s;
    int len = s.size();
    if (s[len - 1] == 's')
        cout << s + "es";
    else
        cout << s + "s";
    return 0;
}


Measured memory_bytes: 3056
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    res = accumulate(a.begin(),a.end(),0LL) - N;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    
    ll N;
    while(cin >> N,N){
        ll W,H; cin >> W >> H;
        auto masu = make_v<int>(W+1,H+1);
        for(int i = 0; i < N;i++){
            int x,y; cin >> x >> y;
            masu[x][y]++;
        }
        for(int i = 1; i <= W; i++){
            for(int j = 1; j <= H;j++){
                masu[i][j] += masu[i-1][j] + masu[i][j-1] - masu[i-1][j-1];
            }
        }
        int ans = 0;
        int S,T; cin >> S >> T;
        for(int i = S; i <= W; i++){
            for(int j = T; j <= H; j++){
                ans = max(ans,masu[i][j]-masu[i-S][j]-masu[i][j-T]+masu[i-S][j-T]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3172
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()

mat = []
for i in range(3):
    mat.append(get_array())

n = int(input())
for i in range(n):
    x = int(input())
    for j in range(3):
        for k in range(3):
            if mat[j][k]==x:
                mat[j][k]=-1

flag = 0
if mat[0][0]==mat[0][1]==mat[0][2]==-1:
    flag = 1
elif mat[1][0]==mat[1][1]==mat[1][2]==-1:
    flag = 1
elif mat[2][0]==mat[2][1]==mat[2][2]==-1:
    flag = 1
elif mat[0][0]==mat[1][0]==mat[2][0]==-1:
    flag = 1
elif mat[0][1]==mat[1][1]==mat[2][1]==-1:
    flag = 1
elif mat[0][2]==mat[1][2]==mat[2][2]==-1:
    flag = 1
elif mat[0][0]==mat[1][1]==mat[2][2]==-1:
    flag = 1
elif mat[0][2]==mat[1][1]==mat[2][0]==-1:
    flag = 1
if flag==0:
    print('No')
else:
    print('Yes')

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

int main()
{
  int64_t X,Y ;
  cin>>X>>Y ;
  
  int64_t ans=(X>Y?X-Y:Y-X) ;
  if(ans<=1) cout<<"Brown"<<endl ;
  else cout<<"Alice"<<endl ;
  
  return 0 ;
}


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

int main()
{
  uint64_t x, c = 100;
  cin >> x;

  for (uint64_t i = 1; true; i++)
  {
    c *= 1.01;
    if (c >= x)
    {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3636
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    d=Dict{String,Char}("A"=>'T',"T"=>'A',"C"=>'G',"G"=>'C')
    println(d[chomp(readline())])
end
main()

Measured memory_bytes: 165628
/**
 *    Author: "Robin Singh" !!
 *    BrainyIsTheNewSexy    (CodeForces, CodeJam)
 *    rob_in_1              (All Other OJs)
**/

#include <bits/stdc++.h>
using namespace std;

#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ff first
#define ss second
#define MP make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr, val)  memset(ptr, val, sizeof ptr)
#define sbit(n)  __builtin_popcount(n)
#define nl "\n"

typedef long double ld;
typedef pair<int, int> pii;
typedef vector <int> vi;
typedef vector < pair<int,int> > vpii;
const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//*****************************************!Template Ends Here!******************************************//

const int nn = 2e5+5;

void solve(){
    int n;
    cin >> n;
    int k = -1;
    for(int i=1; i<=1000; i++){
        if(i * (i - 1)/2 == n){
            k = i;
            break;
        }
    }
    // k subsets of size (k-1)  [for one set one common from each k-1 set]
    // tot elements = k * (k-1)/2  [ /2  as all elements appear twice]
    if(k == -1){
        cout << "No";
        return;
    }
    cout << "Yes\n" << k << nl;

    int cur = 1;
    vector <int> s[k];

    for(int i = 0; i < k; i++){
        for(int j = i+1; j < k; j++){
            s[i].push_back(cur);
            s[j].push_back(cur++);
        }
    }
    for(int i=0; i<k; i++){
        cout << szz(s[i]) << ' ';
        for(int x : s[i]) cout << x << ' ';
        cout << nl;
    }
}

int32_t main(){
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 1e5+10;
const int MAXM = 3e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<pii> que;
int A[MAXM][MAXM];
char S[MAXN];

int gx[] = {-1,0,0,1};
int gy[] = {0,-1,1,0};
int n,m;

bool chk(int x,int y)
{
    if(x<=0)return false;
    if(y<=0)return false;
    if(x>n)return false;
    if(y>m)return false;
    return true;
}

void bfs(){

    int hx,hy;
    int nx,ny;
    while(!que.empty()){

        hx = que.front().first;
        hy = que.front().second;
        que.pop();

        for(int i=0;i<4;i++){

            nx = hx+gx[i];
            ny = hy+gy[i];

            if(!chk(nx,ny))continue;
            if(A[nx][ny])continue;

            A[nx][ny] = A[hx][hy]+1;
            que.push(pii(nx,ny));
        }

    }
    return;
}


int main()
{
    int k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;

    scanf("%d%d",&n,&m);

    char c;

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            scanf(" %c",&c);
            if(c=='#')A[i][j] = 1;
    }

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(A[i][j])que.push(pii(i,j));

   bfs();

   for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
        mx = max(mx,A[i][j]);

    printf("%d\n",mx-1);

    return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define pb push_back
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define MOD 1000000007

ll factorial(ll n) { if(n == 0 || n == 1) return 1; ll res = 1;for(ll i=2;i<=n;i++) res = (res*n)%MOD;return res;}
ll mpow(ll a, ll n) { ll ret=1; ll b=a; while(n) { if(n&1) {ret=(ret*b)%MOD;} b=(b*b)%MOD; n>>=1; } return (ll)ret; }
int toint(const string &s) { stringstream ss(s); int x; ss >> x; return x; }
ll xGCD(ll a, ll b, ll &x, ll &y) { if (b == 0) {x = 1;y = 0;return a;} ll x1, y1, gcd = xGCD(b, a % b, x1, y1); x = y1; y = x1 - (a / b) * y1; return gcd; }
ll inverse(ll a) {ll x, y;ll gcd = xGCD(a, MOD, x, y);return (x%MOD+MOD)%MOD;}
ll bc(ll n, ll k) { if(n == k || k == 0) return 1; if(k == 1 || k == n-1) return n;ll a = factorial(n);ll b = inverse(factorial(k));ll c = inverse(factorial(n - k));return ((a%MOD*b%MOD)*c%MOD)%MOD;}
void fastscan(ll &x) { bool neg=false; register int c; x =0;c=getchar();if(c=='-') {neg = true;c=getchar();}for(;(c>47 && c<58);c=getchar())x = (x<<1) + (x<<3) +c -48;if(neg) x *=-1;}


int main() {
//     fstream fin,fout;
//     fin.open("sample.txt");
//     fout.open("res.txt");
    const ll N = 1e5+5;
    ll m[N]={0};
    
    ll n;
    cin>>n;
    
    vi v(n);
    ll sum = 0;
    for(ll i=0;i<n;i++) {
        cin>>v[i];
        sum+=v[i];
        m[v[i]]++;
    }
    
    ll q;
    cin>>q;
    
    while(q--){
        
        ll b,c;
        cin>>b>>c;
        
        ll b1 = m[b];
        sum -= b1*b;
        sum += b1*c;
        m[c] += b1;
        m[b] = 0;
        
        cout<<sum<<endl;
    }
//     cout << duration.count() << endl;
//     fin.close();
//     fout.close();
    return 0;
}



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

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c > 21 ? "bust" : "win");

  return 0;
}

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

void repl(char *s, int l, int r, char *tt) {
    for (int i = l; i <= r; i++)
        *(s + i) = *(tt + i - l);
}

void revse(char *s, int l, int r) {
    char tt[1005];
    for (int i = l; i <= r; i++)
        tt[i] = *(s + i);
    for (int i = l; i <= r; i++)
        *(s + i) = tt[r - i + l];
}

void prnt(char *s, int l, int r) {
    for (int i = l; i <= r; i++)
        putchar(*(s + i));
    putchar('\n');
}

int main() {
    char rp[] = "replace", rv[] = "reverse", pt[] = "print";
    char s[1005], t1[15], t4[1005]; scanf("%s", s);
    int n, t2, t3; scanf("%d", &n);
    while (n--) {
        scanf("%s %d %d", t1, &t2, &t3);
        if (strcmp(t1, rp) == 0) {
            scanf("%s", t4);
            repl(s, t2, t3, t4);
        }
        if (strcmp(t1, rv) == 0) revse(s, t2, t3);
        if (strcmp(t1, pt) == 0) prnt(s, t2, t3);
    }
}


Measured memory_bytes: 2112
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, a[220000], b[220000],dp[200000][2];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL dfs(int cur,int par) {
	LL num = 0;
	if (dp[cur][0] != -1)return dp[cur][0] + dp[cur][1];
	dp[cur][0] = 1, dp[cur][1] = 1;
	rep(i, vec[cur].size()) {
		LL v = vec[cur][i].to;
		if (v == par)continue;
		num++;
		dfs(v, cur);
		dp[cur][0] *= (dp[v][0] + dp[v][1]);
		dp[cur][1] *= dp[v][0];
		dp[cur][0] %= MOD;
		dp[cur][1] %= MOD;
	}
	if (num==0) {
		dp[cur][0] = 1, dp[cur][1] = 1;
	}
	return dp[cur][0] + dp[cur][1];
}
int main() {
	cin >> n;
	vec.resize(n);
	rep(i, n - 1) {
		LL x, y;
		cin >> x >> y;
		x--, y--;
		vec[x].push_back(Edge{ y,1 });
		vec[y].push_back(Edge{ x,1 });
	}
	rep(i, n)dp[i][0] = -1, dp[i][1] = -1;
	cout << dfs(0, -1)%MOD << endl;
	return 0;
}


Measured memory_bytes: 18944
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();
        int prev = -1;
        int ren = 1;
        int ans = 0;
        for (int i = 0; i<n; i++) {
            //System.out.println(prev+","+ren+","+ans);
            if (prev==a[i]) ren++;
            else {
                ans += (ren/2);
                ren = 1;
            }
            prev = a[i];
        }
        ans += (ren/2);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define debug(x) cout<<#x<<": "<<x<<endl

typedef long long ll;

typedef complex<ll> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

namespace std {
    bool operator<(const Point a, const Point b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

bool compy(const Point a, const Point b) {
    return a.Y < b.Y;
}

int main(void){
    int N,K;
    cin>>N>>K;
    VP p(N);
    rep(i,N){
        ll x,y;
        cin>>x>>y;
        p[i] = Point(x,y);
    }
    sort(all(p));
    ll res = LLONG_MAX;
    rep(r,N)rep(l,r){
        ll w = p[r].X-p[l].X;
        if(r-l+1<K)continue;
        VP pp;
        for(int i=l;i<=r;i++){
            pp.push_back(p[i]);
        }
        int n = pp.size();
        sort(all(pp),compy);
        int idxS,idxT;
        rep(i,pp.size()){
            if(pp[i]==p[l])idxS=i;
            if(pp[i]==p[r])idxT=i;
        }

        if(idxS>idxT)swap(idxS,idxT);
        for(int i=idxT-K+1;i<=idxS;i++){
            if(i<0 || i+K-1>=n)continue;
            ll h = pp[i+K-1].Y-pp[i].Y;
            res = min(res,w*h);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M  = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a = a.drop(1)
a.sort!
(N-1).times {
  b = gets.split.map(&:to_i) 
  b = b.drop(1)
  b.sort!
 a = a & b
}
 
puts a.length

Measured memory_bytes: 1788
//  Suraj Saste

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define mkp make_pair
#define nl cout<<"\n"
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)//prec(x)<<ans;
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}


int main()
{
	fast;
	ll n;cin>>n;
	vector<double> dp(n+1);
	dp[0]=1.0;
	double a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		for(ll j=i+1;j>=0;j--)
		{
			double x,y;
			if(j==0)x=0.0;
			else x=dp[j-1]*a[i]*1.0;
			y=dp[j]*1.0*(1-a[i]);
			dp[j]=x+y;
		}
	}
	double ans=0.0;
	for(ll i=0;i<=n;i++)
	{
		ll j=n-i;
		if(i>j)ans+=dp[i];
	}
	prec(10)<<ans;
	return 0;
}


Measured memory_bytes: 3828
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-15

constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  using ld = long double;
  ld a, b, c;
  cin >> a >> b >> c;
  if (a + b + 2 * sqrt(a * b) - c + EPS < 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256