akhauriyash/Code-Regression huggingface dataset:
import heapq
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

# ans = []
# while len(A) > 2:
#     x = max(A)
#     y = min(A)
#     A = A[1:-1]
#     next_max = max(A)
#     next_min = min(A)
#     if abs(x - y - next_min) < abs(y - x - next_max):
#         x, y = y, x
#     bisect.insort_left(A, x - y)
#     ans.append((x, y))
# x, y = max(A), min(A)
# ans.append((x, y))
# print(x - y)
# for a in ans:
#     print(*a)


enable = [True] * N
mins = [(a, i) for i, a in enumerate(A)]
maxes = [(-a, i) for i, a in enumerate(A)]
heapq.heapify(mins)
heapq.heapify(maxes)

ans = []
for _ in range(N - 2):
    x, xi = heapq.heappop(maxes)
    x *= -1
    y, yi = heapq.heappop(mins)
    enable[xi] = False
    enable[yi] = False
    while not enable[maxes[0][1]]:
        heapq.heappop(maxes)
    while not enable[mins[0][1]]:
        heapq.heappop(mins)
    next_max = -maxes[0][0]
    next_min = mins[0][0]
    if abs(x - y - next_min) < abs(y - x - next_max):
        x, y = y, x
    enable.append(True)
    heapq.heappush(mins, (x - y, len(enable) - 1))
    heapq.heappush(maxes, (y - x, len(enable) - 1))
    ans.append((x, y))

x = -maxes[0][0]
y = mins[0][0]
ans.append((x, y))
print(x - y)
for a in ans:
    print(*a)


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

#define int long long

const int INF = 1e15;

struct Edge {
  int to, d, c;  
};

int s, g;
int n, m;
vector<Edge> G[31];

typedef pair<int, int> P;
typedef pair<double, int> E;
typedef pair<E, P> PE;

double dij() {
  double ret = INF;  
  bool used[n+1][n+1][101];
  fill_n(**used, (n+1)*(n+1)*101, false);
  priority_queue<PE, vector<PE>, greater<PE> > q;  
  q.push(PE(E(0, n), P(s, 1)));  
  while ( !q.empty() ) {
    PE e = q.top(); q.pop();    
    double c = e.first.first;
    int pre = e.first.second;    
    int u = e.second.first, v = e.second.second;
    // cout << u << " " << v << endl;
    if ( u == g && v == 1 ) {
      
    }

    if ( used[u][pre][v] ) continue;
    used[u][pre][v] = true;    
    for ( Edge &f : G[u] ) {
      if ( pre == f.to ) continue;      
      if ( f.c < v ) continue;
      if ( f.to == g && v == 1 ) {
	ret = min(ret, c+(double)f.d);	
      }
      q.push(PE(E(c+(double)f.d/v, u), P(f.to, v)));      
      q.push(PE(E(c+(double)f.d/v, u), P(f.to, v+1)));
      if ( v >= 2 ) q.push(PE(E(c+(double)f.d/v, u), P(f.to, v-1)));      
    }
  }

  return ret;
}

signed main() {  
  while ( cin >> n >> m, n ) {
    for ( int i = 0; i < 31; i++ ) G[i].clear();    
    cin >> s >> g;
    s--; g--;
    for ( int i = 0; i < m; i++ ) {
      int a, b, d, c;
      cin >> a >> b >> d >> c;
      a--; b--;
      G[a].emplace_back(Edge{b, d, c});
      G[b].emplace_back(Edge{a, d, c});
    }

    double ans = dij();
    if ( ans >= INF-100 ) cout << "unreachable" << endl;
    else printf("%.10lf\n", ans);    
  }
  
  return 0;
}



Measured memory_bytes: 29480
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 998244353;

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

vector<long long> inv,fact,invfact;

long long choose(long long n, long long k){
    if(k<0||k>n)return 0;
    long long res = fact[n];
    res *= invfact[k];
    res %= M;
    res *= invfact[n-k];
    res %= M;
    return res;
}

int main(int argc, char const *argv[]) {
    long long n,a,b,k;cin>>n>>a>>b>>k;
    inv = vector<long long>(n+1);
    fact = vector<long long>(n+1);
    invfact = vector<long long>(n+1);
    inv[1]=1;
    fact[0]=1;
    invfact[0]=1;
    for(long long i=2;i<=n;++i){
        inv[i] = M - inv[M%i]*(M/i);
        inv[i] %= M;
        inv[i] += M;
        inv[i] %= M;
    }
    for(long long i=1;i<=n;++i){
        fact[i] = (fact[i-1]*i)%M;
        invfact[i] = (invfact[i-1]*inv[i])%M;
    }
    long long x,y;
    long long g = extGCD(a,b,x,y);
    if(k%g!=0){
        cout<<0<<endl;
        return 0;
    }
    x *= k/g;
    y *= k/g;
    long long s = x / (b/g);
    x -= s*b/g;
    y += s*a/g;
    long long res = 0,xx=x,yy=y;
    // ax + by = k
    while(xx>=0 && yy<=n){
        // cout<<xx<<" "<<yy<<endl;
        long long tmp = choose(n,xx)*choose(n,yy)%M;
        // cout<<choose(n,xx)<<" "<<choose(n,y)<<endl;
        res += tmp;
        res %= M;
        xx -= b / g;
        yy += a / g;
    }
    xx = x+b/g;
    yy = y-a/g;
    while(xx<=n && yy>=0){
        // cout<<xx<<" "<<yy<<endl;
        long long tmp = choose(n,xx)*choose(n,yy)%M;
        // cout<<choose(n,xx)<<" "<<choose(n,y)<<endl;
        res += tmp;
        res %= M;
        xx += b / g;
        yy -= a / g;
    }
    res += M;
    res %= M;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 7424
n = gets.to_i
b = gets.split.map(&:to_i)
ans = 0
pre = 0
ans += b[0]*2
pre = b[0]
for i in 1..n-2
  if pre > b[i]
    ans -= pre - b[i]
  end
    ans += b[i]
    pre = b[i]
end
puts ans


Measured memory_bytes: 1788
#include <cstdio>
#include <vector>

int** getarray(int w,int h){
	int** a = new int*[w];
	for(int i = 0;i < w;i++){
		a[i] = new int[h];
	}
	return a;
}

int remarray(int** a,int w,int h){
	for(int i=0;i<w;i++){
		delete[] a[i];
	}
	delete[] a;
}

int main(){
	int h,w,n;
	int self;
	int** d;
	int** m;
	
	while(1){
		scanf("%d %d %d",&h,&w,&n);
		if(!h && !w && !n){break;}
		d = getarray(w + 1,h + 1);
		m = getarray(w + 1,h + 1);
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				scanf("%d",&self);
				m[j][i] = self;
			}
		}
		
		d[0][0] = n - 1;
		for(int j=0;j<h;j++){
			for(int i=0;i<w;i++){
				if(i == 0 && j == 0){continue;}
				d[i][j] = 0;
				if(i != 0 && d[i-1][j] > 0){
					d[i][j] += (d[i-1][j]) / 2;
					if(m[i-1][j] == 1){
						d[i][j] += (d[i-1][j]) % 2;
					}
				}
				if(j != 0 && d[i][j - 1] > 0){
					d[i][j] += (d[i][j-1]) / 2;
					if(m[i][j-1] == 0){
						d[i][j] += (d[i][j-1]) % 2;
					}
				}
			}
		}
		for(int j=0;j<h;j++){
			for(int i=0;i<w;i++){
				m[i][j] = (m[i][j] + d[i][j]) % 2;
				//printf("%d ",m[i][j]);
			}
			//printf("\n");
		}
		int x,y;
		x = y = 0;
		while(x < w && y < h){
			if(m[x][y] == 1){
				//printf("ツ督圭n");
				x += 1;
			}else{
				//printf("ツ禿ャ\n");
				y += 1;
			}
		}
		printf("%d %d\n",y + 1,x + 1);
		remarray(m,w+1,h+1);
		remarray(d,w+1,h+1);
	}
}

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


int main(){
    while(true){
        int N;cin>>N;
        if(!N)break;
        vector<int>as(N);
        for(int i=0;i<N;++i){
            int a;cin>>as[i];
        }
        int sum=accumulate(as.begin(),as.end(),0);
        int ans=1e9;
        for(int i=0;i<(1<<N);++i){
            int asum=0;
            bitset<20>bs(i);
            for(int j=0;j<N;++j){
                if(bs[j]){
                    asum+=as[j];
                }
            }
            ans=min(ans,abs(sum-2*asum));
        }
        cout<<ans<<endl;
    }
    return 0;

}

Measured memory_bytes: 3000
H,W=map(int,input().split())
MAP=[input() for i in range(H)]
mod=10**9+7

DP=[[0]*W for i in range(H)]
DP[0][0]=1

for i in range(H):
    for j in range(W):
        if MAP[i][j]=="#":
            continue
        if i!=0 and j!=0:
            DP[i][j]=(DP[i-1][j]+DP[i][j-1])%mod

        if i==0 and j!=0:
            DP[i][j]=DP[i][j-1]

        if i!=0 and j==0:
            DP[i][j]=DP[i-1][j]

print(DP[H-1][W-1])


Measured memory_bytes: 43604
N = int(input())
A = list(map(int, input().split())) 
Ad = A.copy()
sum = 0

for i in range(N-1):
    if A[i] > A[i+1]:
        A[i+1] = A[i]

for j in range(N):
    sum += A[j]-Ad[j]

print(sum)

Measured memory_bytes: 32252
#include <iostream>

int main() {
  int a, e, k, tmp;
  std::cin >> a;
  std::cin >> tmp; std::cin >> tmp; std::cin >> tmp;
  std::cin >> e;
  std::cin >> k;
  if (e - a <= k) {
    std::cout << "Yay!" << std::endl;
  } else {
    std::cout << ":(" << std::endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int A, B;

int main(int argc, char *argv[])
{
    scanf("%d %d", &A, &B); 
    if (A > 9 || B > 9) {
        printf("-1\n");
    } else {
        printf("%d\n", A*B);
    }
    return 0;
}


Measured memory_bytes: 128
N = int(input())
S = []
for i in range(N):
    S.append(input())

count_AB = 0
lefter_B = 0
righter_A = 0
only_lefter_B = 0
only_righter_A = 0
for i in range(N):
    count_AB += S[i].count('AB')
    if S[i][0] == 'B':
        lefter_B += 1
    if S[i][len(S[i])-1] == 'A':
        righter_A += 1
    if (S[i][0] == 'B')and(S[i][len(S[i])-1] != 'A'):
        only_lefter_B += 1
    if (S[i][0] != 'B')and(S[i][len(S[i])-1] == 'A'):
        only_righter_A += 1
        
if (only_lefter_B==0) and (only_righter_A==0):
    Appearing_AB = max(min(lefter_B,righter_A) - 1 , 0)
else:
    Appearing_AB = min(lefter_B,righter_A)


print(count_AB + Appearing_AB)



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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

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

Measured memory_bytes: 3608
N,K=map(int,input().split())
X=list(map(int,input().split()))

ans=[]

for i in range(N-K+1):
  xl=X[i]
  xr=X[i+K-1]
  ans.append(min(abs(xl)+abs(xr-xl),abs(xr)+abs(xl-xr)))

print(min(ans))

Measured memory_bytes: 14228
#include <iostream>

using namespace std;

const char* cmp(int a, int b) {
  if (a == b)
    return "==";
  if (a < b)
    return "<";
  return ">";
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << "a " << cmp(a, b) << " b" << endl;
  return 0;
}

Measured memory_bytes: 3076
loop do
    n, r = gets.split.map(&:to_i)
    if n==0&&r==0
        break
    end
    cs = Array.new(n)
    n.times do |i|
        cs[i] = n-i
    end
    r.times do
        p, c = gets.split.map(&:to_i)
        out = cs.slice!(p-1,c)
        cs = out.concat cs
    end
    puts cs[0]
end

Measured memory_bytes: 6268
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int X,Y;
    int sum = 0;
    cin >> X >> Y;
    if(X == 3){
        sum += 100000;
    }else if(X == 2){
        sum += 200000;
    }else if(X == 1){
        sum += 300000;
    }
    if(Y == 3){
        sum += 100000;
    }else if(Y == 2){
        sum += 200000;
    }else if(Y == 1){
        sum += 300000;
    }
    if(X == 1&&Y == 1)sum += 400000;
    cout <<sum<< "\n";
}

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

int c[20],st[20];
int a[20][20];
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++) cin>>a[i][j];
    }
    int ans=0x3f3f3f3f;
    for(int i=0;i<=(1<<n)-1;i++){
        memset(st,0,sizeof st);
        int cnt=0;
        bool ok=1;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j)){
                    cnt+=c[j];
                    for(int k=0;k<m;k++) st[k]+=a[j][k];
            }
        }
        for(int j=0;j<m;j++) if(st[j]<x) ok=0;
        if(ok) ans=min(ans,cnt);
    }
    if(ans>1200000) cout<<"-1";
    else cout<<ans;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<time.h>
using namespace std;
int a[10000][1000], c[10000], n, k;
int main() {
	srand((unsigned)time(NULL));
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < n / 2; j++) {
			cin >> a[i][j];
		}
	}
	while (true) {
		for (int i = 0; i < n; i++) c[i] = (unsigned)(rand()) % 2;
		for (int i = 0; i < k; i++) {
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				cnt += c[a[i][j] - 1];
			}
			if (cnt < n / 8 || cnt>3 * n / 8) { goto E; }
		}
		for (int i = 0; i < n; i++) { cout << c[i]; }
		cout << endl; goto F;
	E:;
	}
F:;
	return 0;
}

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

int n, W;
int weight[110], value[110];

int dp[110][10010];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; i++) cin >> value[i] >> weight[i];

  for (int w = 0; w < W; w++) dp[0][w] = 0;

  for (int i = 0; i < n; i++) {
    for (int w = 0; w <= W; w++) {
      if (w >= weight[i])
        dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
      else
        dp[i + 1][w] = dp[i][w];
    }
  }

  cout << dp[n][W] << endl;
}


Measured memory_bytes: 7056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIZU {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			int[] Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		#endregion
		
		static void Main(string[] args) {
			Queue<string> Next = new Queue<string>();
			Stack<string> Prev= new Stack<string>();
			int n = cin();
			string[] A = Console.ReadLine().Split();
			for (int i = 0; i < n; i++) {
				if ((i&1)==0) Next.Enqueue(A[i]);
				else Prev.Push(A[i]);
			}
			string[] Res = new string[n];
			int pc = Prev.Count;
			for (int i = 0; i < pc; i++) {
				Res[i] = Prev.Pop();
			}
			for (int i = pc; i <n; i++) {
				Res[i] = Next.Dequeue();
			}
			if ((n & 1) == 1) Res = Res.Reverse().ToArray();
			print(string.Join(" ",Res));
		}
		
	}
}

Measured memory_bytes: 45248
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  int a,b,c; cin>>a>>b>>c;
  int d=a%b;
  for(int i=1;i<=b;i++){
    if((d*i)%b==c){
      puts("YES");
      return 0;
    }
  }
  puts("NO");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
LL read()
{
	LL x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int main()
{
	int q=read();
	while(q--)
	{
		LL a=read(),b=read(),m=a*b;
//		LL M=sqrt(m-1),ans=M*2LL;
		LL l=1,r=sqrt(m)+10;
		while(l<=r)
		{
			LL mid=l+r>>1;
			if(mid*mid<=m-1)l=mid+1;
			else r=mid-1;
		}
		LL M=l-1,ans=M*2LL;
//		printf("%lld\n",M);
		LL t;
		if(a!=b)
		{
			if(a<=M)ans--;
			if(b<=M)ans--;
			if(m%M==0)t=m/M-1;
			else t=m/M;
			if(t==M)
			{
				ans--;
				if(a==M&&b==M)ans++;
			}
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 256
import bisect
n, m = map(int, input().split())

fct = []
fct2 = []
sq = int(m**(1/2))
if sq + 1 ==m:
    sq += 1

for f in range(1, sq + 1):
    if m%f == 0:
        fct.append(f)
        fct2.append(m//f)
if fct2[-1] == fct[-1]:
    fct2.pop()

fct2.reverse()

fct += fct2

k = m//n
ind = bisect.bisect_left(fct,k)

print(fct[ind-1] if k<fct[ind] else fct[ind])

Measured memory_bytes: 38640
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var t = new int[3][];
        for (int i = 0; i < 3; i++) {
            t[i] = ToIntArray(input.ReadLine(), 3);
        }

        for(int a1=0; a1<=100; a1++) {
            var b1 = t[0][0] - a1;
            var b2 = t[0][1] - a1;
            var b3 = t[0][2] - a1;
            var a2 = t[1][0] - b1;
            var a3 = t[2][0] - b1;

            bool ok = true;
            ok &= t[0][0] == a1 + b1;
            ok &= t[0][1] == a1 + b2;
            ok &= t[0][2] == a1 + b3;
            ok &= t[1][0] == a2 + b1;
            ok &= t[1][1] == a2 + b2;
            ok &= t[1][2] == a2 + b3;
            ok &= t[2][0] == a3 + b1;
            ok &= t[2][1] == a3 + b2;
            ok &= t[2][2] == a3 + b3;
            if (ok) return Yes;
        }

        return No;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(void){
  int a, b, c, k, i, result = 0;

  scanf("%d%d%d%d", &a, &b, &c, &k);

  if(a < k){
    result += a;
    k -= a;
    if(b < k){
      k -= b;
      if(c = k){
        result -= c;
      }else{
        result -= k;
      }
    }
  }else{
    result += k;
  }

  printf("%d", result);

  return 0;
}


Measured memory_bytes: 1692
n, k = map(int, input().split())
a = list(map(int, input().split()))


def diff(now, d):
    return abs(a[now] - a[now - d])

dp = [0] * n
dp[1] = diff(1, 1)
for depth in range(2, n):
    # dp[depth] = min(dp[depth - 1] + diff(depth, 1), dp[depth - 2] + diff(depth, 2))
    dp[depth] = min(dp[depth - x] + diff(depth, x) for x in range(1, min(depth, k) + 1))
print(dp[-1])


Measured memory_bytes: 54496
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int64_t i = 0; i < n; ++i)
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i, h) cin >> v[i];
  rep(i, h) cout << v[i] << endl << v[i] << endl;
  return 0;
}

Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
if n>=m
  puts 0 
  exit
end
x.sort!
ary = []

(m-1).times do |i| 
  ary[i]= x[i+1] - x[i]
end
ary.sort!.reverse!
(n-1).times do |i|
  ary[i]= 0
end
puts ary.inject(&:+)

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

using namespace std;

int par[100], n, m;

void fc(int k){
	for(int i = 0; i < n-1; i++){
		if(par[i]%k > par[i+1]%k) swap(par[i], par[i+1]);
	}
	return;
}

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

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

	for(int i = 1; i <= m; i++) fc(i);

	for(int i = 0; i < n; i++){
		cout << par[i] << endl;
	}

	return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct Point {
  int x,y;
};

struct Segment {
  Point p1,p2;
};

int n;
int d[] = {1,0,-1};
vector<Segment> segs;
const int M = 500;
bool field[M][M],visited[M][M];

vector<int> compress(int type){
  vector<int> vec,buf;
  rep(i,(int)segs.size()) {
    if( type ) {
      vec.push_back(segs[i].p1.y*2);
      vec.push_back(segs[i].p2.y*2);
      vec.push_back(segs[i].p1.y+segs[i].p2.y);
    }
    else {
      vec.push_back(segs[i].p1.x*2);
      vec.push_back(segs[i].p2.x*2);
      vec.push_back(segs[i].p1.x+segs[i].p2.x);
    }
  }
  rep(i,(int)vec.size()) {
    rep(j,3) {
      int cp = vec[i] + d[j];
      buf.push_back(cp);
    }
  }
  vec = buf;
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  return vec;
}

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

void compute() {
  memset(field,false,sizeof(field));
  vector<int> xs = compress(0);  
  vector<int> ys = compress(1);

  //rep(i,(int)xs.size()) cout << xs[i] << " "; puts("");
  //rep(i,(int)ys.size()) cout << ys[i] << " "; puts("");

  rep(i,(int)segs.size()) {
    int p1,p2,base;
    if( segs[i].p1.x == segs[i].p2.x ) { // y
      p1 = lower_bound(ys.begin(),ys.end(),segs[i].p1.y*2) - ys.begin();
      p2 = lower_bound(ys.begin(),ys.end(),segs[i].p2.y*2) - ys.begin();
      base = lower_bound(xs.begin(),xs.end(),segs[i].p1.x*2) - xs.begin();
      if( p1 > p2 ) swap(p1,p2);
      //cout << "Y " << base << " : " << p1 << " => " << p2 << endl;
      REP(i,p1,p2+1) field[i][base] = true;
    } else { // x
      p1 = lower_bound(xs.begin(),xs.end(),segs[i].p1.x*2) - xs.begin();
      p2 = lower_bound(xs.begin(),xs.end(),segs[i].p2.x*2) - xs.begin();
      base = lower_bound(ys.begin(),ys.end(),segs[i].p1.y*2) - ys.begin();
      if( p1 > p2 ) swap(p1,p2);
      //cout << "X " << base << " : " << p1 << " => " << p2 << endl;
      REP(i,p1,p2+1) field[base][i] = true;
    }
  }

  /*
  rep(i,30) {
    rep(j,30) {
      cout << field[i][j];
    } puts("");
  }
  */
  rep(i,M) rep(j,M) visited[i][j] = field[i][j];
  int cnt = 0;
  rep(i,M) rep(j,M) if( !visited[i][j] ) {
    visited[i][j] = true;
    ++cnt;
    deque<int> deq;
    deq.push_back(j+i*M);
    while(!deq.empty()){
      int cur = deq.front(); deq.pop_front();
      rep(j,4){
	int nx = cur % M + dx[j], ny = cur / M + dy[j];
	if( !( 0 <= nx && nx < M && 0 <= ny && ny < M ) ) continue;
	if( visited[ny][nx] ) continue;
	visited[ny][nx] = true;
	deq.push_back(nx+ny*M);
      }
    }
  }
  cout << cnt << endl;
}

int main(){
  while( cin >> n, n ) {
    segs.clear();
    rep(_,n){
      int l,t,r,b;
      cin >> l >> t >> r >> b;
      segs.push_back((Segment){(Point){l,t},(Point){r,t}});
      segs.push_back((Segment){(Point){r,t},(Point){r,b}});
      segs.push_back((Segment){(Point){l,b},(Point){r,b}});
      segs.push_back((Segment){(Point){l,t},(Point){l,b}});
    }
    compute();
  }
  return 0;
}

Measured memory_bytes: 1744
n = int(input())
s = input()
arr = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 10, 'K': 11, 'L': 12, 'M': 13, 'N':14, 'O':15, 'P': 16, 'Q': 17, 'R': 18, 'S': 19, 'T': 20, 'U': 21, 'V': 22, 'W': 23, 'X': 24, 'Y': 25, 'Z':0}
arr2 = {1:'A', 2:'B', 3:'C', 4:'D', 5:'E', 6:'F', 7:'G', 8:'H', 9:'I', 10:'J', 11:'K', 12:'L', 13:'M', 14:'N', 15:'O', 16:'P', 17:'Q', 18:'R', 19:'S', 20:'T', 21:'U', 22:'V', 23:'W', 24:'X', 25:'Y', 0:'Z'}
ans = ''
for i in s:
    ans += arr2[(arr[i] + n) % 26]
print(ans)


Measured memory_bytes: 3064
s=int(input())
x1=int(s**0.5)
y1=0
x2=0
y2=int(s**0.5)
if x1*y2>s:
    x2=(x1*y2)-s
    y1=1
elif x1*y2<s:
    x1+=1
    x2=(x1*y2)-s
    if x2<0:
        y2+=1
        x2=(x1*y2)-s
    y1=1
print(0,0,x1,y1,x2,y2)

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

int number_of_buggage(vector<int> warray,int P,int k){
    int number_of_track = 0;
    int number_of_baggage = 0;
    int iniP = P;
    int i=0;
    while(number_of_track < k && i<warray.size()){
        if(warray.at(i) > P){
            P = iniP;
            number_of_track++;
            continue;
        }
        P -= warray.at(i);
        i++;
        number_of_baggage++;
    }
    return number_of_baggage;
}


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> warray(n);
    for(int i=0; i<n; i++) cin >> warray.at(i);
    int max_ = -1;
    int sum = 0;
    for(int i=0; i<n; i++){
        sum += warray.at(i);
        if(max_ < warray.at(i)){
            max_ = warray.at(i);
        }
    }
    int number_nimotsu = number_of_buggage(warray,max_,k);
    int left = max_,right = sum,half;
    while(true){
        half = (left + right) / 2;
        if(number_of_buggage(warray,half,k) == n && number_of_buggage(warray,half-1,k) < n){
            break;
        }else if(number_of_buggage(warray,half,k) == n && number_of_buggage(warray,half-1,k) == n){
            right = half;
        }else{
            left = half + 1;
        }
    }
    cout << half << endl;
}


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

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

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;

bool check(string s)
{
   int k = s.size()/2;
   for(int i = 0; i <k; i++)
   {
      if(s[i] != s[i+k])
         return false;
   }
   return true;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int x, t;
   cin >> x >> t;
   x >= t? cout << x - t : cout << 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 15;

struct edg{
	int s, e, x;
};

vector<edg> v;
int cyc[1 << MAXN];
int dp[1 << MAXN][MAXN];
int adj[MAXN][MAXN];
int n, m;

int main(){
	scanf("%d %d",&n,&m);
	for(int i=0; i<MAXN; i++){
		for(int j=0; j<MAXN; j++){
			adj[i][j] = -1e9;
		}
	}
	int ans = 0;
	for(int i=0; i<m; i++){
		int s, e, x;
		scanf("%d %d %d",&s,&e,&x);
		adj[s-1][e-1] = x;
		adj[e-1][s-1] = x;
		v.push_back({s-1, e-1, x});
	}
	for(int i=0; i<(1<<n); i++){
		for(auto &j : v){
			if((i >> j.s) % 2 == 1 & (i >> j.e) % 2 == 1){
				cyc[i] += j.x;
			}
		}
	}
	for(int i=0; i<(1<<n); i++){
		for(int j=0; j<n; j++){
			dp[i][j] = -1e9;
			if((i >> j) % 2 == 0){
				continue;
			}
			if(j == 0){
				dp[i][j] = cyc[i];
			}
			for(int k=i; k; k=(k-1)&i){
				if((k >> j) % 2 == 0) continue;
				for(int l=0; l<n; l++){
					dp[i][j] = max(dp[i][j], dp[i^k][l] + adj[l][j] + cyc[k]);
				}
			}
		}
	}
	int ret = dp[(1<<n)-1][n-1];
	for(auto &i : v) ret -= i.x;
	cout << -ret << endl;
}


Measured memory_bytes: 2304
A, B, C ,D  = map(int, input().split())
count = 0
while 1:
    count = count + 1
    if count % 2 == 1:
        C = C - B
    else:
        A = A - D
    if A <= 0:
        print("No")
        break
    if C <= 0:
        print("Yes")
        break


Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>

using namespace std;

#define M_INF (-1)<<30

int dp[2010][2010][2];

int main(void){
    int m,n,i,j,ans=0,p,q,x,y;
    char s[2010],t[2010];
    cin >> m >> n;
    for(i=0; i<=m; i++){
        for(j=0; j<=n; j++){
            dp[i][j][0] = 0;
            dp[i][j][1] = M_INF;
        }
    }
    cin >> s;
    cin >> t;
    s[m] = 'O';
    t[n] = 'O';
    for(i=0; i<=m; i++){
        for(j=0; j<=n; j++){
            if(s[i]=='O' && i<m){
                dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][1]+1);
            }else if(s[i]=='I' && i<m){
                dp[i+1][j][1] = max(dp[i+1][j][1],dp[i][j][0]+1);
            }
            if(t[j]=='O' && j<n){
                dp[i][j+1][0] = max(dp[i][j+1][0],dp[i][j][1]+1);
            }else if(t[j]=='I' && j<n){
                dp[i][j+1][1] = max(dp[i][j+1][1],dp[i][j][0]+1);
            }
        }
    }
    for(i=0; i<=m; i++){
        for(j=0; j<=n; j++){
            ans = max(dp[i][j][1],ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Console.WriteLine(S * T >= D ? "Yes" : "No");
		
		
	}
	long D,T,S;
	public Sol(){
		var d = rla();
		D = d[0]; T = d[1]; S = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27476
#include <iostream>
using namespace std;
int main(void){
    int x, y, s;
    while (cin >> x >> y >> s && s) {
        int res = 0;
        for (int i = 1; i < s; ++i) {
            for (int j = 1; j < s; ++j) {
                if (i + j > s) break;
                int ax = (i * (100 + x))/100;
                int bx = (j * (100 + x))/100;
                if (ax + bx == s) {
                    int ay = (i * (100 + y))/100;
                    int by = (j * (100 + y))/100;
                    if (res < ay + by) {
                        res = ay + by;
                    }
                }
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int dfs(vector<vector<int>>& adj,vector<int>& height, vector<int>& stree,
        vector<int>& parent,int a=0){
  static int h=0;
  height[a]=h;
  int cnt=1;
  h++;
  for(int x:adj[a]){
    if(x==parent[a]) continue;
    parent[x]=a;
    cnt+=dfs(adj,height,stree,parent,x);
  }
  h--;
  return stree[a]=cnt;
}

int main(){
  int n; cin >>n;
  vector<vector<int>> adj(n);
  rep(i,n-1){
    int a,b; cin >>a >>b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<int> height(n,-1),stree(n,-1),parent(n,-1);
  height[0]=0;
  int fenn=dfs(adj,height,stree,parent);
  if(df){
    print("h:",height);
    print("n:",stree);
    print("p:",parent);
  }
  int a=n-1;
  int h=height[a];
  rep(i,(h-1)/2) a=parent[a];
  int sunk=stree[a]; fenn-=sunk;
  if(df)print(fenn,sunk);
  print(fenn>sunk?"Fennec":"Snuke");
}


Measured memory_bytes: 16256
#include <cstdio>
#include <utility>
#include <vector>
#include <string>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
bool scan(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

typedef vector<string> vs;

bool wark(int x, int y, vs &v) {
	static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
	if (v[y][x] == '0')
		return false;
	v[y][x] = '0';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx >= 0 && nx < 12 && ny >= 0 && ny < 12)
			wark(nx, ny, v);
	}
	return true;
}

int main() {
	do {
		vs v(12);
		int c = 0;
		for (auto &i: v)
			scan(i);
		for (int i = 0; i < 12; i++)
			for (int j = 0; j < 12; j++)
				c += wark(j, i, v);
		out(c, '\n');

	} while (gcu() != EOF);
}


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

int main()
{
   
    long long int n,k;
    cin>>n>>k;
    vector<long long int> v;
    for(long long int i=0;i<n;i++)
    {
        long long int x;
        cin>>x;
        v.push_back(x);
    }
    long long int dp[n];
    for(int i=0;i<n;i++)
    dp[i]=1000000005;

    dp[0]=0;
    
    for(long long int i=0;i<n;++i)
    {
        for(long long int j=1;j<=k;++j)
        {
            if(i+j<n)
            {
                dp[i+j]=min(dp[i+j],dp[i]+abs(v[i]-v[i+j]));
            }
        }
    }
    
    cout<<dp[n-1];
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 100007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q, t, indx, l, r;
    char ch;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> cache(26);
    for (int i = 0; i < n; i++) {
        cache[s[i] - 'a'].insert(i);
    }
    while (q--) {
        cin >> t;
        if (t == 1) {
            cin >> indx >> ch;
            indx--;
            if (s[indx] == ch) continue;
            cache[s[indx] - 'a'].erase(indx);
            s[indx] = ch;
            cache[ch - 'a'].insert(indx);
        } else {
            cin >> l >> r;
            l--, r--;
            int res = 0;
            for (int c = 0; c < 26; c++) {
                auto iter = cache[c].lower_bound(l);
                if (iter == cache[c].end()) continue;
                if (*iter <= r) res++;
            }
            cout << res << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 24220
/*input
codefestival
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	string s;
	cin>>s;
	string t="CODEFESTIVAL2016";
	int ans=0;
	REP(i,SZ(t)) if(s[i]!=t[i]) ans++;
	cout<<ans;	
	return 0;
}


Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 178 A - Not
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/09/13
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

uint32_t x;

void solve() {

    printf("%d\n", x^1);
}

int main() {

    scanf("%d", &x);

    solve();

}

Measured memory_bytes: 3236
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, h, w) = get!(i32, i32, i32);
    let mut v = Vec::new();
    for _ in 0..n {
        v.push(get!(i32, i32));
    }
    let mut ans = 0;
    for i in v.iter() {
        if h <= i.0 && w <= i.1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N;
        int R;

        int temp1;
        int temp2;

        N = sc.nextInt();
        R = sc.nextInt();

        temp1 = 100 * (10-N) + R;
        temp2 = R;

        if( N < 10) {
            System.out.println(temp1);
        }
        else if( N >= 10) {
            System.out.println(R);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
 
int main(){
	int L, R;
    cin >> L >> R;
    int r = L / 2019;
    L -= r * 2019;
    R -= r * 2019;
    if (R - L >= 2019) {
        R = L + 2019;
    }
    int min_mod = 2019;
    for (int i = L; i < R; i++) {
        for (int j = i + 1; j <= R; j++) {
            int mod = (i * j) % 2019;
            min_mod = min(min_mod, mod);
        }
    }
//    int ans = min_mod(L, R);
 
    cout << min_mod << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




void solve(){
	string s ;cin >> s ; 
	if(s[2]==s[3] and s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 1000000000
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int N,K,h[110000];
  ll dp[110000];
  cin>>N>>K;
  for(int i=0;i<N;i++) cin>>h[i];

  for(int i=0;i<N;i++) dp[i]=INF;
  dp[0]=0;
  for(int i=0;i<N-1;i++){
    for(int j=1;j<=K;j++){
      if(i+j<N) dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int H = Integer.parseInt(str[0]);
		int W = Integer.parseInt(str[1]);

		str = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);

		System.out.println((H - h) * (W - w));
	}
}


Measured memory_bytes: 32780
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int n; cin >> n;
    vector<int> X(n); rep(i, n) cin >> X.at(i);

    int cost = 2147483647;
    rep2(p, 1, 100) {
        int tmp = accumulate(all(X), 0, [p](int sum, int val){return sum + (val - p) * (val - p);});
        chmin(cost, tmp);
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    int sz[3];
    sz[0] = a.size();
    sz[1] = b.size();
    sz[2] = c.size();
    if(a[sz[0]-1] == b[0] && b[sz[1]-1] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	ll x;
	cin >> x;
	ll curr = 100;
	int cnt = 0;
	while(1) {
		if(curr >= x) {
			cout << cnt;
			return 0;
		}
		ll s = curr / 100;
		curr += s;
		cnt++;
	}
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
	using namespace std;
	int main(){
		string w;
		bool b=true;
		int x[25] = {};
		cin >> w;
		for (int i = 0; i < w.size(); i++){
			if (w[i] == 'a'){ x[0] = x[0] + 1; }
			if (w[i] == 'b'){ x[1] = x[1] + 1; }
			if (w[i] == 'c'){ x[2] = x[2] + 1; }
			if (w[i] == 'd'){ x[3] = x[3] + 1; }
			if (w[i] == 'e'){ x[4] = x[4] + 1; }
			if (w[i] == 'f'){ x[5] = x[5] + 1; }
			if (w[i] == 'g'){ x[6] = x[6] + 1; }
			if (w[i] == 'h'){ x[7] = x[7] + 1; }
			if (w[i] == 'i'){ x[8] = x[8] + 1; }
			if (w[i] == 'j'){ x[9] = x[9] + 1; }
			if (w[i] == 'k'){ x[10] = x[10] + 1; }
			if (w[i] == 'l'){ x[11] = x[11] + 1; }
			if (w[i] == 'm'){ x[12] = x[12] + 1; }
			if (w[i] == 'n'){ x[13] = x[13] + 1; }
			if (w[i] == 'o'){ x[14] = x[14] + 1; }
			if (w[i] == 'p'){ x[15] = x[15] + 1; }
			if (w[i] == 'q'){ x[16] = x[16] + 1; }
			if (w[i] == 'r'){ x[17] = x[17] + 1; }
			if (w[i] == 's'){ x[18] = x[18] + 1; }
			if (w[i] == 't'){ x[19] = x[19] + 1; }
			if (w[i] == 'u'){ x[20] = x[20] + 1; }
			if (w[i] == 'v'){ x[21] = x[21] + 1; }
			if (w[i] == 'w'){ x[22] = x[22] + 1; }
			if (w[i] == 'x'){ x[23] = x[23] + 1; }
			if (w[i] == 'y'){ x[24] = x[24] + 1; }
			if (w[i] == 'z'){ x[25] = x[25] + 1; }
		}
		for (int j = 0; j < 26; j++){
			if (x[j] % 2 == 1){ b = false; }
		}
		if (b == false){ cout << "No" << endl; }
		if (b == true){ cout << "Yes" << endl; }
		return 0;
	}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

long long modpow(long long a,long long p){
    if(p==0)return 1;
    if(p%2==0){
      long long halfP=p/2;
      long long half=modpow(a,halfP);
      return half*half%mod;
    }else{
      return a*modpow(a,p-1)%mod;
    }
}

signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  vector<int> rui(n+1);
  rui[0]=0;
  for(int i=1;i<=n;i++){
    rui[i]=rui[i-1]+modpow(i,mod-2);
    if(rui[i]>=mod)rui[i]-=mod;
  }

  int ans=0;
  for(int i=1;i<=n;i++){
    int x=(rui[i]+rui[n-i+1]-1)%mod;
    ans+=x*a[i-1];
    ans%=mod;
  }
  for(int i=1;i<=n;i++){
    ans*=i;
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792