akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


ll gcd(ll a, ll b){  if(b==0){  return a; }   return gcd(b , a%b); }


string toString(int n) 
{ 
    string str; 
    stringstream ss; 
    ss << n; 
    ss >> str; 
    return str; 
} 
  
// Method to convert n to base negBase 
string toNegativeBase(int n, int negBase) 
{ 
    //  If n is zero then in any base it will be 0 only 
    if (n == 0) 
        return "0"; 
  
    string converted = ""; 
    while (n != 0) 
    { 
        // Get remainder by negative base, it can be 
        // negative also 
        int remainder = n % negBase; 
        n /= negBase; 
  
        // if remainder is negative, add abs(base) to 
        // it and add 1 to n 
        if (remainder < 0) 
        { 
            remainder += (-negBase); 
            n += 1; 
        } 
  
        // convert remainder to string add into the result 
        converted = toString(remainder) + converted; 
    } 
  
    return converted; 
} 

int main() {


ll n;
cin>>n;



cout<<toNegativeBase(n,-2);
  
  return 0;
}


Measured memory_bytes: 3580
package main

import (
	"fmt"
)

func main(){
	var n int
	var p []int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		temp:=0
		fmt.Scan(&temp)
		p = append(p, temp)
	}

	res := 0
	for i := 1; i < len(p)-1; i++ {
		if p[i] > p[i-1] && p[i] < p[i+1] || p[i] < p[i-1] && p[i] > p[i+1] {
			res++
		}
	}

	fmt.Println(res)
}

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

using namespace std;

vector<int> Zalgorithm(auto S){
    vector<int> res(S.size());
    res[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k; j -= k;
    }
    return res;
}

int main(){
    int N;
    while(cin >> N){
        vector<int> a(N), b(N);
        for(auto& t : a) cin >> t;
        for(auto& t : b) cin >> t;
        vector<int> xa(N), xb(N);
        for(int i=0;i<N;i++){
            xa[i] = a[i]^a[(i+1)%N];
            xb[i] = b[i]^b[(i+1)%N];
        }
        vector<int> z = xb;
        z.insert(z.end(), xa.begin(), xa.end());
        z.insert(z.end(), xa.begin(), xa.end());
        auto len = Zalgorithm(z);
        for(int i=0;i<N;i++){
            if(len[N+i] >= N) cout << i << " " << (a[i]^b[0]) << endl;
        }
    }
}

Measured memory_bytes: 12076
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

//geometric library
//#include <complex>
typedef std::complex<double> Com;

//内積
double dot_product(const Com a, const Com b){
	return (conj(a)*b).real();
}

//外積
double cross_product(const Com a, const Com b){
	return (conj(a)*b).imag();
}

//点と直線の距離
double dist_dot_line(const Com st, const Com en, const Com dt){
    return std::abs(cross_product(dt-st, en-st) / std::abs(en-st));
}

//点と線分の距離
double dist_dot_seg(const Com st, const Com en, const Com dt){
	if(dot_product(en-st, dt-st) <= 0){
		return std::abs(dt-st);
	}else if(dot_product(st-en, dt-en) <= 0){
		return std::abs(dt-en);
	}else{
		return dist_dot_line(st, en, dt);
	}
}

//線分の交差判定
//平行・接触は含まない(接触を含みたいときはdist_seg==0を使う)
bool seg_crossing(const Com st1, const Com en1, const Com st2, const Com en2){
	double cross1 = cross_product(en1-st1, st2-st1) * cross_product(en1-st1, en2-st1);
	double cross2 = cross_product(en2-st2, st1-st2) * cross_product(en2-st2, en1-st2);
	return (cross1 < 0) && (cross2 < 0);
}

//線分と線分の距離
double dist_seg(const Com st1, const Com en1, const Com st2, const Com en2){
	if(seg_crossing(st1, en1, st2, en2)){
		return 0;
	}
	return std::min(std::min(dist_dot_seg(st1, en1, st2), dist_dot_seg(st1, en1, en2)), std::min(dist_dot_seg(st2, en2, st1), dist_dot_seg(st2, en2, en1)));
}

//線分と線分の垂直判定
bool is_vertical(const Com st1, const Com en1, const Com st2, const Com en2){
    if(dot_product(en1-st1, en2-st2) == 0){
        return true;
    }else{
        return false;
    }
}

//平行判定
bool is_parallel(const Com st1, const Com en1, const Com st2, const Com en2){
    if(cross_product(en1-st1, en2-st2) == 0){
        return true;
    }else{
        return false;
    }
}

//直線・線分の交点
Com cross_point(const Com st1, const Com en1, const Com st2, const Com en2){
    /* 線分の時はコメントを外した方が良さそう
    if(dist_seg(st1, en1, st2, en2) > 0 || is_parallel(st1, en1, st2, en2)){
        printf("Error! cross_point invalid input\n");
        std::exit(EXIT_FAILURE);
    }
    //*/
    double den = (real(st1)-real(en1)) * (imag(en2)-imag(st2)) - (real(en2)-real(st2)) * (imag(st1)-imag(en1));
    double mol = (real(en2)-real(en1)) * (imag(en2)-imag(st2)) - (real(en2)-real(st2)) * (imag(en2)-imag(en1));
    double s = mol/den;
    return st1 * s + en1 * (1-s);
}


void solve(){
    double x[4], y[4];
    Com p[4];
    for(int i = 0; i < 4; i++){
        scanf("%lf%lf", &x[i], &y[i]);
        p[i] = Com(x[i], y[i]);
    }
    /*
    if(seg_crossing(p[0], p[1], p[2], p[3])){
        printf("crossing!\n");
    }
    //*/
    printf("%.10lf\n", dist_seg(p[0], p[1], p[2], p[3]));
}

long q;
int main(){
    scanf("%ld", &q);
    for(int i = 0; i < q; i++){
        solve();
    }
}



Measured memory_bytes: 3276
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a, b, w;
int main()
{
	scanf("%d%d%d", &w, &a, &b);
	int ant = a + w;
	int ans = b + w;
	if(a + w <= b)printf("%d\n", b - a - w);
	else if(b + w <= a)printf("%d\n", a - b - w);
	else printf("0\n");
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
using namespace std;

int main()
{
	cout << fixed << setprecision(6);
	int w, h, x, y;
	cin >> w >> h >> x >> y;

	auto halfS = 0.5 * w * h;
	bool isCenter = (x == w / 2 && w % 2 == 0) && (y == h / 2 && h % 2 == 0);

	cout << halfS << " " << (isCenter ? 1 : 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int rev = -1;

int main(){
    string s;
    int q;
    cin >> s >> q;
    string tail = "";
    string head = "";
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1) rev *= -1;
        if(t == 2){
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(rev == -1){
                    head.push_back(c);
                }else{
                    tail.push_back(c);
                }
            }else{
                if(rev == 1){
                    head.push_back(c);
                }else{
                    tail.push_back(c);
                }
            }
        }
    }
    if(rev == -1){
        reverse(all(head));
        cout << head + s + tail << endl;
    }else{
        reverse(all(tail));
        reverse(all(s));
        cout << tail + s + head << endl;
    }
}

Measured memory_bytes: 1348
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>

using namespace std;

int main(){
	long int A,B,X,out;
	scanf("%ld %ld",&A,&B);
	int temp = fmax(A,B);
	int temp2 = fmin(A,B);
	long int i=1;


	for(;;){
		X = i*temp;
//		printf("%ld\n",X);
		if(X%temp2==0){
			break;
		}
		i++;
	}
	printf("%ld",X);

	return 0;
}

Measured memory_bytes: 256
# A - Painting
import sys

debug = lambda message: print("DEBUG:", message, file=sys.stderr)


def main():
    H, W, N = map(int, open(0))
    debug(max(H, W))
    print((N + max(H, W) - 1) // max(H, W))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline


N = int(input())

a = int(input())
b = int(input())
ans = b-a
_min = min(a, b)

for i in range(2, N):
    tmp = int(input())
    ans = max(ans, tmp - _min)
    _min = min(_min, tmp)

print(ans)


Measured memory_bytes: 5616
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
int ds[205][205];
int hs[205][205];

int getr(int t,int f){
	int c=0;
	if(t>=4){
		c=1-c; t=7-t;
	}
	if(f>=4){
		c=1-c; f=7-f;
	}
	int res=t+f+1;
	if((t+1)%3==f%3)res=7-res;
	if(c==1)res=7-res;
	return res;
}

int main(void){
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		memset(hs,0,sizeof(hs));
		memset(ds,0,sizeof(ds));
		
		rep(qqq,n){
			int t,f;
			scanf("%d%d",&t,&f);
			int y=100,x=100;
			for(;;){
				bool rd=false;
				ireg(i,4,6){
					if(i==t || i==7-t)continue;
					int r=getr(t,f),dy,dx,tt,tf;
					if(i==f){
						dx=0; dy=1; tt=7-f; tf=t;
					}
					else if(i==7-f){
						dx=0; dy=-1; tt=f; tf=7-t;
					}
					else if(i==r){
						dy=0; dx=1; tt=7-r; tf=f;
					}
					else{
						dy=0; dx=-1; tt=r; tf=f;
					}
					
					int ty=y+dy,tx=x+dx;
					if(hs[ty][tx]<hs[y][x]){
						y = ty; x = tx;
						t = tt; f = tf;
						rd=true;
						break;
					}
				}
				if(!rd){
					hs[y][x]++;
					ds[y][x]=t;
					break;
				}
			}
		}
		int anss[7];
		rep(i,7)anss[i]=0;
		rep(i,205)rep(j,205){
			anss[ds[i][j]]++;
		}
		reg(i,1,6)printf("%d%c",anss[i],i==6?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1524
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int T=1;//fs.nextInt();
		for (int tt=0; tt<T; tt++) {
			int n=fs.nextInt();
			char[] colors=fs.next().toCharArray();
			ArrayList<Integer> ws=new ArrayList<>(), 
					rs=new ArrayList<>();
			for (int i=0; i<n; i++)
				if (colors[i]=='W')
					ws.add(i);
				else 
					rs.add(i);
			int wInd=0, rInd=rs.size()-1;
			int count=0;
			while (wInd<ws.size() && rInd>=0 && ws.get(wInd)<rs.get(rInd)) {
				count++;
				wInd++;
				rInd--;
			}
			System.out.println(count);
			
		}
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}

}


Measured memory_bytes: 42856
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

class disjoint_set {
	std::vector<std::int_fast32_t> tree;
public:
	disjoint_set(std::uint_fast32_t size) :tree(size, -1) {}
	std::uint_fast32_t find(std::uint_fast32_t x) {
		if (tree[x] < 0) return x;
		return tree[x] = (std::int_fast32_t)find((std::uint_fast32_t)tree[x]);
	}
	bool unite(std::uint_fast32_t x, std::uint_fast32_t y) {
		x = find(x);
		y = find(y);
		if (x == y) return false;
		if (tree[x] > tree[y]) {
			tree[y] += tree[x];
			tree[x] = y;
		}
		else {
			tree[x] += tree[y];
			tree[y] = x;
		}
		return true;
	}
	std::uint_fast32_t size(std::uint_fast32_t x) {
		return (std::uint_fast32_t)(-tree[find(x)]);
	}
	bool same(std::uint_fast32_t x, std::uint_fast32_t y) {
		return find(x) == find(y);
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	disjoint_set S(n);
	std::vector<std::pair<uint32, uint32>> x(n),y(n);
	std::vector<std::pair<uint64, std::pair<uint32, uint32>>> e;
	for (uint32 i = 0;i < n;++i) {
		std::cin >> x[i].first >> y[i].first;
		x[i].second = i;
		y[i].second = i;
	}
	std::sort(x.begin(), x.end());
	std::sort(y.begin(), y.end());
	for (uint32 i = 1;i < n;++i) {
		e.push_back({ x[i].first - x[i - 1].first,{x[i].second,x[i - 1].second} });
		e.push_back({ y[i].first - y[i - 1].first,{ y[i].second,y[i - 1].second } });
	}
	uint64 ans = 0;
	std::sort(e.begin(), e.end());
	for (uint32 i = 0;i < e.size();++i) {
		uint32 a = e[i].second.first, b = e[i].second.second;
		if (S.unite(a, b)) ans += e[i].first;
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 12528
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    int L = A + B;
    int R = C + D;

    if (L > R) {
        std::cout << "Left" << std::endl;
    } else if (L < R) {
        std::cout << "Right" << std::endl;
    } else {
        std::cout << "Balanced" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
    Only way to go is UP 
    H1s3nb3rg's Here !!
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h> 
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<int,int> pi;
typedef uint64_t i64;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vector<ll>> v2ll;
const int MOD = 1e9+7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAIN int main(){FAST_IO;ll tc;cin>>tc;while(tc--){solver();}ret0;}
#define MAIN1 int main(){FAST_IO;solver();ret0;}
#define rep(i,b,e) for(__typeof(e)i=(b)-((b)>(e));i!=(e)-((b)>(e));i+=1-2*((b)>(e)))
#define repa(i,x)  for(auto i:x)
#define vin(x) for(auto &i:x){cin>>i;}
#define vin1(x) for(ll i=1;i<x.size();i++){cin>>x[i];}
#define dbg(x) for(auto i:x){cout<<i<<" ";}cout<<ENDL;
#define ENDL "\n"
#define VALL(a) a.begin(),a.end()
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define MP(a,b) make_pair(a,b)
#define ff first
#define ss second
#define ret0 return 0;
#define ret return;
#define pb(x) push_back(x)
/*----------------------------*/

void solver(){
    ll n;
    cin>>n;
    cout<<n+(n*n)+(n*n*n)<<ENDL;
    ret;



}

MAIN1


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int h,w;
    cin>>h>>w;
    vector<string> s(h+2);
    
    REP(i,h) cin>>s[i+1];
    REP(i,h){
        for(int j=w-1;j>=0;j--){
            s[i+1][j+1]=s[i+1][j];
        }
        }
    
    REP(i,h+2){
        REP(j,w+2){
            if((i==0||j==0)||(i==h+1||j==w+1)){
                cout<<'#';
            }else{
                cout<<s[i][j];
            }
            }
            cout<<endl;
        }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll ;
char a[30]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main()
{
    ll n,x;
    string s;
    cin>>n;
    while(n)
    {
        x=n%26;
        if(x==0)x=26;
        s+=a[x-1];
        n=(n-1)/26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int l=s.size();
    s.push_back('2');
    int ans=0,id=0,b=0;
    vector<int> zero(n+k,0),one(n+k,0);
    while(id<l){
        while(s[id]=='0'){
            zero[b]++;
            id++;
        }
        while(s[id]=='1'){
            one[b]++;
            id++;
        }
        b++;
    }
    if(s[0]=='0'){
        for(int i=0; i<n; i++){
            int tmp=0;
            if(i!=0) tmp+=one[i-1];
            for(int j=0; j<k; j++){
                tmp+=zero[i+j]+one[i+j];
            }
            ans=max(ans,tmp);
            if(one[i]==0||zero[i]==0) break;
        }
    }
    else{
        for(int i=0; i<n; i++){
            int tmp=0;
            for(int j=0; j<k; j++){
                tmp+=one[i+j]+zero[i+j+1];
            }
            tmp+=one[i+k];
            ans=max(ans,tmp);
            if(one[i]==0||zero[i+1]==0) break;
        }
    }
    cout<<ans;

    return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string s;
    int x,y;
    cin >> s >> x >> y;

    int x_=0;
    rep(i,0,s.size()){
        if(s[i]=='T'){
            s=s.substr(i+1);
            break;
        }
        ++x_;
    }

    if(x_==s.size()){
        cout << (x_==x and 0==y?"Yes":"No") << endl;
        return;
    }

    vector<int> dx,dy;
    bool f=true;
    int k=0;
    rep(i,0,s.size()){
        if(s[i]=='T'){
            if(f) dy.push_back(k);
            else dx.push_back(k);
            k=0;
            f^=true;
            continue;
        }
        ++k;
    }

    if(k){
        if(f) dy.push_back(k);
        else dx.push_back(k);
    }

    vector<vector<bool>> dpx(dx.size(),vector<bool>(20000)),dpy(dy.size(),vector<bool>(20000));
    int offset=10000;
    if(dx.size()) dpx[0][x_+dx[0]+offset]=dpx[0][x_-dx[0]+offset]=true;
    rep(i,0,int(dx.size())-1){
        rep(j,0,20000){
            if(!dpx[i][j]) continue;
            dpx[i+1][j+dx[i+1]]=dpx[i+1][j-dx[i+1]]=true;
        }
    }
    if(dy.size()) dpy[0][dy[0]+offset]=dpy[0][-dy[0]+offset]=true;
    rep(i,0,int(dy.size())-1){
        rep(j,0,20000){
            if(!dpy[i][j]) continue;
            dpy[i+1][j+dy[i+1]]=dpy[i+1][j-dy[i+1]]=true;
        }
    }

    if(!dx.size() and !dy.size()){
        cout << (x_==x and 0==y?"Yes":"No") << endl;
        return;
    }

    if(!dx.size()){
        cout << (dpy[dy.size()-1][y+offset]?"Yes":"No") << endl;
        return;
    }

    if(!dy.size()){
        cout << (dpx[dx.size()-1][x+offset]?"Yes":"No") << endl;
        return;
    }

    cout << ((dpx[dx.size()-1][x+offset] and dpy[dy.size()-1][y+offset])?"Yes":"No") << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 20096
gets
a = gets.split.map &:to_i
max = 0
min = a[0]
count = 0
a[1..-1].each.with_index(1) do |e,i|
    t = e-min
    if t > max
        count = 1
        max = t
    elsif t == max
        count += 1
    end
    min = e if min > e
end
p count

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define p(d_type1, d_type2) pair<d_type1, d_type2>
#define F first
#define S second
#define loop(i, s, n) for(int i = s; i < n; i++)
#define nl "\n"
#define fat 1000000007

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

    v(int) l(n);
    loop(i, 0, n)
    {
        cin >> l[i];
    }

    sort(l.begin(), l.end());
    ll ans = 0;

    for(int i = 0; i < l.size(); i++)
    {
        for(int j = i + 1; j < l.size(); j++)
        {
            int len = l[j] + l[i];
            auto it = lower_bound(l.begin() + j + 1, l.end(), len);
            ans += it - (l.begin() + j) - 1;
        }   
    }

    cout << ans << nl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        boolean bre = false;
        for (int i = 0; i < a; i++) {
            if (s.charAt(i) < '0' || s.charAt(i) > '9') {
                bre = true;
                break;
            }
        }
        if (s.charAt(a) != '-') {
            bre = true;
        }
        for (int i = a + 1; i < a + b + 1; i++) {
            if (s.charAt(i) < '0' || s.charAt(i) > '9') {
                bre = true;
                break;
            }
        }
        if (bre) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


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

using namespace std;

#define int long long

const int N = (int)3e5, MOD = (int)1e9 + 7, INF = (int)3e18;

vector <int> g[N];

main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        int x;
        cin >> x;
        g[x].push_back(i);
    }
    for (int i = 1; i <= n; ++i) {
        cout << g[i].size() << '\n';
    }
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i >= 1 && i < 10) ans++;
        else if (i >= 100 && i < 1000) ans++;
        else if (i >= 10000 && i < 100000) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=LINF,sum=0;

    ll h,w;
    cin >>h>>w;
    
    if(h%3==0 || w%3==0){
        cout<<0<<endl;
        return 0;
    }

    ans = min(h,w);

    rep1(ii,1,h){
        ll i = ii;
        ll a = w/2;
        ll mx=max(max((h-i)*a , (h-i)*(w-a)),w*i);
        ll mn=min(min((h-i)*a , (h-i)*(w-a)),w*i);

        //db(mx-mn);ln;

        chmin(ans,mx-mn);
    }

    rep1(ii,1,w){
        ll i = ii;
        ll a = h/2;
        ll mx=max(max((w-i)*a , (w-i)*(h-a)),h*i);
        ll mn=min(min((w-i)*a , (w-i)*(h-a)),h*i);
        
        //db(mx-mn);ln;
        
        chmin(ans,mx-mn);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
ll n ;
ll solve(int x)
{
	ll temp = 2 ;
	for(int i = 1 ; i <= x ; i ++)
	  temp *= 5 ;
	if(temp > n)  return 0ll ;
	ll ans1 = n / temp ;
	ll ans2 = n / (temp * 5) ;
	return (ans1 - ans2) * ll(x) ;
}
int main()
{
	ll ans = 0 ;
	scanf("%lld" , &n) ;
	if(n % 2 == 1 || n < 10)  
	{
		printf("0\n") ;
		return 0 ;
	}
	for(int i = 1 ; ; i ++)
	{
		ll sum = solve(i) ;
		if(sum == 0)  break ;
		ans += sum ;
	}
	printf("%lld\n" , ans) ;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b && b<c && a<c){
		printf("%d %d %d\n",a,b,c);
	}
	if(a<b && c<b && a<c){
		printf("%d %d %d\n",a,c,b);
	}
	if(b<a && c<b && a<c){
		printf("%d %d %d\n",b,a,c);
	}
	if(b<a && b<c && c<a){
		printf("%d %d %d\n",b,c,a);
	}
	if(a<b && c<b && c<a){
		printf("%d %d %d\n",c,a,b);
	}
	if(b<a && c<b && c<a){
		printf("%d %d %d\n",c,b,a);
	}


	if(a==b && b==c && a==c){
		printf("%d %d %d\n",a,b,c);
	}
	if(a==b && b<c && a<c){
		printf("%d %d %d\n",a,b,c);
	}
	if(a==b && c<b && c<a){
		printf("%d %d %d\n",c,a,b);
	}
	if(b<a && b<c && a==c){
		printf("%d %d %d\n",b,a,c);
	}
	if(a<b && c<b && a==c){
		printf("%d %d %d\n",a,c,b);
	}
	if(a<b && b==c && a<c){
		printf("%d %d %d\n",a,b,c);
	}
	if(b<a && b==c && c<a){
		printf("%d %d %d\n",b,c,a);
	}

	return 0;
}


Measured memory_bytes: 2104
function frac(){
    readonly mul=1000000
    readonly mullen=${#mul}
    local a=$1
    local b=$2
    local tmp=`printf "%0${mullen}d" $((a*mul/b))`
    local tmplen=${#tmp}
    local ilen=$((tmplen-(mullen-1)))
    local flen=$((mullen-1))
    echo ${tmp:0:$ilen}"."${tmp: -$flen}
    }
read l
frac $((l*l*l)) 27

Measured memory_bytes: 3796
import java.util.*;

public class Main{
    public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
        long goal_depo = sc.nextLong();
      	long now_deposit = 100; 
      	long year = 0;
      
      	while(now_deposit < goal_depo)
        {
        	now_deposit += now_deposit / 100;
            year++;
        }
        System.out.println(year);
    }
}

Measured memory_bytes: 35724
a = list(map(int,input().split()))
b = []

if a[1]-a[0]>=2019:
  print(0)
else:
  for i in range(a[0],a[1]+1):
    for j in range(a[0],i):
      c = (i*j)%2019
      b.append(c)
  else:
    print(min(b))

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

using namespace std;
typedef long long int ll;

void solve()
{
	ll x, k, d;
	cin >> x >> k >> d;
	if(x < 0) x = -x;
	if(x == 0)
	{
		if(k % 2ll == 0ll) cout << 0;
		else cout << d;
	}
	else if(x > 0)
	{
		
		ll p = x / d;
		if(p == k)
		{
			cout << x - p * d;
		}
		else if(k < p)
		{
			cout << x - k * d;
		}		
		else
		{
			ll po = x - p * d;
			if(d - po < po)
			{
				p++;
				if((k - p) % 2ll == 0ll) cout << d - po;
				else cout << po;
			}
			else
			{
				if((k- p) % 2ll == 0ll) cout << po;
				else cout << d - po;
			}
		}
	}
	
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

int main() {

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

    if (a == b && a != c){
        cout << "Yes" << endl;//かわいそう、ふたつが等しい 
    } else if(b == c && a != c ){
        cout << "Yes" << endl;//そうでない
    }else if(a == c && b != c ){
        cout << "Yes" << endl;//そうでない
    }
    else{
         cout << "No" << endl;//そうでない

    }

}

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

int main(){
  int n = 0,ma=0,x=0;
  string s;
  cin >> n >>s;
  rep(i,n){
    if(s.at(i) == 'I') x++;
    else x--;
    ma = max(x,ma);
  }
  cout << ma << endl;
} 


Measured memory_bytes: 256
pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

fn main(){
    let mut scan = Scanner::new();
    let n: i32 = scan.next();
    let m: usize = scan.next();
    let v: Vec<i32> = scan.next_vec(m);

    let sum = v.iter().fold(0, |sum, x| sum + x);

    if sum <= n{
        println!("{}", n - sum);
    }else{
        println!("-1");
    }
}


Measured memory_bytes: 2664
h = [[[0]*10 for i in range(3)] for j in range(4)]
n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    h[b-1][f-1][r-1] += v

s = ""
for i in range(4):
    for j in range(3):
        for k in range(10):
            s += " " + str(h[i][j][k])
        s += "\n"
    if i < 3:
        s += "####################\n"

print(s,end="")

Measured memory_bytes: 7620
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

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

    if(a > x){
        cout << "NO" << endl;
        return 0;
    }

    cout << (x-a <= b ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
int main(){
  ll X, Y;
  cin >> X >> Y;

  int ans = 0;
  ll r = X;
  while(r <= Y){
    r*=2;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)

using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
	int n,ans = 0;
	cin >> n;
	int d[n+1];
	rep(i,n) cin >> d[i];
	rep(i,n){
		for(int j = i+1; j < n ;j++){
			ans += d[i]*d[j];
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#8:47
MOD=10**9+7
INT_MAX=10**18+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
def power(a,x):
    res=1
    while(x>0):
        if x&1:
            res=(res*a)%MOD
        a=(a*a)%MOD
        x//=2
    return res%MOD
def NCR_MOD(n,r):
    num=1
    for i in range(n,n-r,-1):num=(num*i)%MOD
    for j in range(1,r+1):num=(num*power(j,MOD-2))%MOD
    return num
#################################################################################
k=int(input())
s=input()
if len(s)<=k:
    print(s)
else:
    print(s[0:k],end="...")


Measured memory_bytes: 61892
s=input()
t=input()

ans=len(s)
for i in range(len(s)-len(t)+1):
    res=len(t)
    s_slice=s[i:i+len(t)]
    for j in range(len(t)):
        if s_slice[j]==t[j]:
            res-=1
    ans=min(res,ans)
print(ans)



Measured memory_bytes: 9008
#include<stdio.h>
int main(void)
{
	int n,e,p,q,x[4001],X[1001],cnt,i;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		cnt=0;
		for(i=0;i<=4000;i++) x[i]=0;
		for(i=0;i<n;i++){
			scanf("%d%d%d",&e,&p,&q);
			if(x[e]>=1000000) x[e]=-1;
			if(x[e]!=-1){
				x[e]+=p*q;
			}
			if(x[e]>=1000000){
				cnt++;
				X[cnt]=e;
			}
		}
		if(cnt>0){
			for(i=1;i<=cnt;i++){
				printf("%d\n",X[i]);
			}
		}
		else printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 2596
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n;
string s;
int dp[300005][3][3][2];
inline void add(int &x,int y){
	x+=y;if(x>=mod)x-=mod;
}
int calc(int cur,int st,int pos){
	if(cur==0){
		if(st==0&&pos==1)return st+1;
		if(st==1&&pos==0)return st+1;
	}
	return st;
}
int main(){
	cin>>s;n=s.size();
	dp[0][0][0][1]=1;
	for(int i=0;i<n;i++){
		for(int cur=0;cur<3;cur++){
			for(int st=0;st<3;st++){
				for(int pos=0;pos<2;pos++){
					if(s[i]=='0'||s[i]=='?'){
						add(dp[i+1][cur==2?1:cur+1][st][pos],dp[i][cur][st][pos]);
					}
					if(s[i]=='1'||s[i]=='?'){
						add(dp[i+1][0][calc(cur,st,pos)][pos^(cur!=1)],dp[i][cur][st][pos]);
					}
				}
			}
		}
	}
	int ans=0;
	for(int cur=0;cur<3;cur++){
		for(int st=0;st<3;st++){
			for(int pos=0;pos<2;pos++){
				if(calc(cur,st,pos)==2){
//					cerr<<cur<<" "<<st<<" "<<pos<<" "<<dp[n][cur][st][pos]<<endl;
					add(ans,dp[n][cur][st][pos]);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 21764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define ff first
#define ss second
#define pb push_back
#define all(s) (s).begin(), (s).end()
const ll mod = 1e9 + 7;

ll h, w, x;
vector<pair<ll,ll>> arr;
vi ans, fact;

ll binexp(ll a)
{
    ll res = 1, y = mod - 2;
    while (y > 0)
    {
        if (y & 1)
            res = (res * a) % mod;
        y >>= 1;
        a = (a * a) % mod;
    }
    return res;
}

ll num(ll x1, ll y1, ll x2, ll y2)
{
    ll x = fact[x2 - x1 + y2 - y1];
    ll y = binexp((fact[x2 - x1] * fact[y2 - y1]) % mod);
    return (x * y) % mod;
}

void solve()
{
    for (int i = 2; i <= h + w; i++)
        fact[i] = (fact[i - 1] * i) % mod;

    for (int i = 0; i <= x; i++)
    {
        ll ans_i = num(1, 1, arr[i].ff, arr[i].ss);
        ll ans_t = 0;
        for (int j = 0; j < i ; j++)
        {
            if (arr[j].ff <= arr[i].ff && arr[j].ss <= arr[i].ss)
            {
                ans_t += (ans[j] * num(arr[j].ff, arr[j].ss, arr[i].ff, arr[i].ss)) % mod;
                ans_t %= mod;
            }
        }
        ans[i] = ((ans_i - ans_t) % mod + mod) % mod;
    }    
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> h >> w >> x;
    arr.resize(x);
    ans.resize(x + 1);
    fact.resize(h + w + 1);
    fact[0] = fact[1] = 1;
    for (int i = 0; i < x; i++)
    {
        ll a, b;
        cin >> a >> b;
        arr[i] = make_pair(a, b);
    }
    sort(all(arr));
    arr.pb({h, w});
    solve();
    cout << ans[x] << endl;
    return 0;
}

Measured memory_bytes: 1920
lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i
U = array[1].split(" ").map(&:to_i)
D = array[2].split(" ").map(&:to_i)
SUM_D = D.inject(&:+)

arr = Array.new(5,0)

for i in 0...N
  if i == 0
    arr[i] = U[i] + SUM_D
  else
    arr[i] = arr[i-1] - D[i-1] + U[i]
  end
end

puts arr.max

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    for (int i = 1; i + 1 < n; i++) {
        vector<int> q{p[i - 1], p[i], p[i + 1]};
        sort(q.begin(), q.end());
        if (q[1] == p[i]) ans++;
    }
    cout << ans;
    return 0;
}


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

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

    int n;
    cin >> n;
    map<string, long long> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    long long ans = 0;
    for(auto x : mp){
        ans += x.second * (x.second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11264
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var h1 = int.Parse(line[0]);
        var w1 = int.Parse(line[1]);
        Console.WriteLine(h * w - h * w1 - w * h1 + h1 * w1);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
cin.tie(0);
ios::sync_with_stdio(false);
}
signed main(){
  int n,k;
  cin >> n >> k;
  VV<vi> dp(n+1,vvi(3,vi(3,0)));
  vi b(n+1,0);
  REP(i,k){
    int a;
    cin >> a;
    a--;
    cin >> b[a];
  }
  if(b[0]) dp[1][b[0]-1][b[0]%3] = 1;
  else REP(i,3) dp[1][i][(i+1)%3] = 1;
  const int mod = 1e4;
  FOR(i,1,n){
    if(b[i]){
      REP(j,3)REP(k,3){
        if(j==k&&j==b[i]-1) continue;
        dp[i+1][b[i]-1][k] += dp[i][k][j];
        dp[i+1][b[i]-1][k] %= mod;
      }
      continue;
    }
    REP(j,3)REP(k,3){
      if(dp[i][k][j]==0) continue;
      REP(l,3){
        if(j==k&&k==l) continue;
        dp[i+1][l][k] += dp[i][k][j];
        dp[i+1][l][k] %= mod;
      }
    }
  }
  ll ans = 0;
  REP(i,3)REP(j,3){
    ans += dp[n][i][j];
    //cout << dp[3][i][j] << endl;
  }
  ans %= mod;
  cout << ans << endl;
}



Measured memory_bytes: 3184
k = int(input())
a,b = k//50, k%50

base = 49+(a if not b else a+1) 
print(50)
if b==0:
    print(" ".join(map(str, [base]*50)))
else:
    i = 50 - b
    print(" ".join(map(str, [base-50+i-1]*i + [base+i]*(50-i))))

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

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] t = new long[n];
        for(int i = 0; i < n; i++){
            t[i] = in.nextLong();
        }
        long ans = t[0];
        for(int i = 1; i < n; i++){
            ans = lcm(ans, t[i]);
        }
        System.out.println(ans);
    }

   public static long gcd(long a, long b){
       return b == 0 ? a : gcd(b, a % b);
   }

   public static long lcm(long a, long b){
       return a / gcd(a, b) * b;
   }
}

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

int main(){
	int a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a < b){
		if (b < c){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#累積和を求めてbisect
# 初期入力
from itertools import accumulate
import bisect
import sys
input = sys.stdin.readline
N,M,K = (int(i) for i in input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
acuum_A =list(accumulate(A))
acuum_B =list(accumulate(B))

#Aを優先に読む場合、Bは何冊読めるか
ans =[]
a =bisect.bisect_right(acuum_A,K)
remainder =K -acuum_A[a-1]
b =bisect.bisect_right(acuum_B,remainder)
ans.append(a+b)

#⇒Aを減らしたらBが何冊読めるか
for i in range(1,N+M):
    ai =a -i
    if ai -1 >=0:
        remainder =K -acuum_A[ai-1]
    else:
        remainder =K
    b =bisect.bisect_right(acuum_B,remainder)
    ans.append(ai+b)
    if b==M:
        break
    #print(ai,b,end=" ")
#print()
print(max(ans))

Measured memory_bytes: 64980
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

	int N;
	cin >> N;
	vector<int> H(N);
	rep(i, N) cin >> H.at(i);
	vector<int> score(1, 0);
	int cnt = 0;
	
	while(1) {
		int num = 0;
		for (int j = cnt; j < N - 1; j++) {
			if (H.at(j) >= H.at(j + 1)) {
				cnt++;
				num++;
				if ((j + 1) >= (N - 1)) {
					score.push_back(num);
				}
			}
			else if(H.at(j) < H.at(j + 1)) {
				cnt++;
				score.push_back(num);
				break;
			}
		}
		if (cnt == (N - 1)) break;
	}
	sort(score.begin(), score.end());
	reverse(score.begin(), score.end());

	cout << score.front() << endl;
	
	return 0;
}

Measured memory_bytes: 1276
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<iterator>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k,i,j,v;
	cin>>n>>k;
	vector<int>vec;
	for(i=0; i<n; i++)
	{
		cin>>v;
		vec.push_back(v);
	}
	int dp[k+1];
	memset(dp,0,sizeof(dp));
	dp[0]=0;
	for(i=1; i<=k; i++)
	{
		int flag=0;
		for(j=0; j<n; j++)
		{
			if(vec[j]<=i)
			{
				if(dp[i-vec[j]]==0)
				{
					flag=1;	
				}	
			}
			if(flag==1)
			{
				break;
			}
		}
		if(flag==1)
		{
			dp[i]=1;
		}
		else
		{
			dp[i]=0;
		}
	}
	if(dp[k]==0)
	{
		cout<<"Second"<<"\n";
	}
	else
	{
		cout<<"First"<<"\n";
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;
    string ans = "Yes";

    if (s.size() != (a + b + 1)) ans = "No";
    if (s[a] != '-') ans = "No";
    for (int i = 0; i < (a + b + 1); ++i) {
        if (i == a) continue;
        if (s[i] > '9' || s[i] < '0') {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef pair<int,int> pii;

int main(){
	int n, m;
	vector<pii> v;
	cin >> n >> m;
	rep(i,m){
		int x, y;
		cin >> x >> y;
		y--;
		v.emplace_back(x, y);
	}
	sort(v.begin(), v.end());

	vector<pii> ans(n);
	rep(i,n) ans[i] = pii(i,i+1);
	for(auto p: v){
		int y = p.second;
		ans[y+0].second = ans[y+1].second;
		ans[y+1].first  = ans[y+0].first;
	}

	rep(i,n){
		cout << ans[i].second-ans[i].first;
		if( i < n-1 ) cout << " ";
	}
	cout << endl;

	return 0;
}

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

using namespace std;

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

    int v, e;
    cin >> v >> e;
    vector<int> g[v];
    int h[v + 1];
    memset(h, 0, sizeof(h));
    int a, b;
    for (int i = 0; i < e; ++i) {
        cin >> a >> b;
        g[a].push_back(b);
        h[b]++;
    }

    queue<int> que;
    for (int i = 0; i < v; ++i) {
        if (h[i] == 0) {
            que.push(i);
        }
    }

    vector <int> ans;
    while (!que.empty()) {
        int p = que.front();
        que.pop();
        ans.push_back(p);
        for (auto c: g[p]) {
            h[c]--;
            if(h[c] == 0) {
                que.push(c);
            }
        }
    }

    for (int i = 0; i < v; ++i) {
        cout << ans[i] << '\n';
    }

    return 0;
}



Measured memory_bytes: 3920
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
#define dump(x)  cout << " "<< #x << " = " << (x) << endl;
typedef long long ll;
typedef complex<int> P;
const double EPS = 1e-10;
const double PI  = acos(-1.0);



struct st{
	vector<P> vp;
	vector<P> rvp;
};


P d[] = { P(1,0), P(0,1), P(-1,0), P(0,-1) };

void f(vector<P> &vp){
	P a = vp[0], b = vp[1];
	int num = 0;
	if(a.real() == b.real()){
		if(a.imag() < b.imag()) num = 3;
		else num = 1;
	}else if(a.imag() == b.imag()){
		if(a.real() < b.real()) num = 0;
		else num = 2;
	}
	for(int i=0;i<vp.size();i++){
		vp[i] -= a;
		vp[i] *= d[num];
	}
	return;
}

bool eq(vector<P> &a, vector<P> &b){
	for(int i=0;i<a.size();i++){
		if(a[i] != b[i]) return false;
	}
	return true;
}

bool solve(int n){
	vector<st> vst(n+1);
	
	int m; cin>> m;
	vector<P> tmp;
	for(int i=0;i<m;i++){
		P in; cin>> in.real()>> in.imag();
		tmp.pb(in);
	}
	f(tmp);
	vst[0].vp = tmp;
	reverse(tmp.begin(), tmp.end());
	f(tmp);
	vst[0].rvp = tmp;
	
	for(int i=1;i<n+1;i++){
		int m2; cin>> m2;
		vector<P> tmp;
		for(int j=0;j<m2;j++){
			P in; cin>> in.real()>> in.imag();
			tmp.pb(in);
		}
		f(tmp);
		vst[i].vp = tmp;
	}
	
	for(int i=1;i<n+1;i++){
		if(vst[0].vp.size() != vst[i].vp.size()) continue;	//
		if(eq(vst[i].vp, vst[0].vp) || eq(vst[i].vp, vst[0].rvp)) cout<< i<< endl;
	}
	cout<< "+++++"<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	while(cin>>n, n) solve(n);
	return 0;
}

 

Measured memory_bytes: 1200