akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    vector<int64_t> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++){
        int b;
        cin >> b;
        A[i] -= b;
    }

    int64_t ans = 0;
    vector<int64_t> cost(N), P(N);

    auto dfs = [&](auto&& dfs, int i, int p)->void{
        cost[i] = 1;
        for(int j : edges[i]) if(j != p){
            dfs(dfs, j, i);
            P[i] = max(P[i], -A[j]);
            cost[i] += cost[j];
        }
        ans += P[i];
        for(int j : edges[i]) if(j != p){
            int64_t over = P[i] + A[j];
            ans += cost[j] * over;
            A[i] += A[j];
            A[j] = 0;
        }
        if(p >= 0){
            A[i] -= P[i];
            A[p] += P[i];
            if(A[i] > 0){
                ans += cost[i] * A[i];
                A[p] += A[i];
                A[i] = 0;
            }
        }
    };
    dfs(dfs, 0, -1);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 15112
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

int main(){
   int N[4];
   for(int i=0;i<4;i++)cin>>N[i];
   sort(N,N+4);
   if(N[0]==1 && N[1]==4 && N[2]==7 && N[3]==9)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;


}

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

#define ll long long
int main() {
  int N;
  cin >> N;
  
  ll ans = 0;
  
  for (int i = 1; i <= N; i++) {
    if (i % 3 && i % 5) ans += i;
  }
  
  cout << ans << endl;
  
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> graph(N);
  for(int i=0;i<M;i++){
    int u,v;
    cin >> u >> v;
    u--;
    v--;
    graph.at(u).push_back(v);
  }
  int S,T;
  cin >> S >> T;
  S--;
  T--;

  vector<vector<int>> dis(N,vector<int>(3,1e9));
  queue<pair<int,int>> que_cv;
  dis.at(S).at(0)=0;
  que_cv.push(make_pair(0,S));
  while(!que_cv.empty()){
    int c=que_cv.front().first;
    int v=que_cv.front().second;
    que_cv.pop();
    int nc=(c+1)%3;
    for(int i=0;i<graph.at(v).size();i++){
      int nv=graph.at(v).at(i);
      if(dis.at(nv).at(nc)!=1e9)  continue;
      dis.at(nv).at(nc)=dis.at(v).at(c)+1;
      que_cv.push(make_pair(nc,nv));
    }
  }
  if(dis.at(T).at(0)==1e9)  cout << -1 << endl;
  else  cout << dis.at(T).at(0)/3 << endl;

  return 0;
}

Measured memory_bytes: 11136
import copy
n = int(input())

def dfs(str_list, now):
    if len(str_list) == n:
        print(''.join(str_list))
    else:
        chr_a = ord('a')
        for c in range(chr_a, now + 2, 1):
            str_list_cp = copy.deepcopy(str_list)
            str_list_cp.append(chr(c))
            dfs(str_list_cp, max(c, now))

dfs([], ord('a') - 1)

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

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

  int N; cin >> N;
  int fx = 0;
  int temp = N;
  for (int i = 0; i < N; i++) {
    if (temp == 0) break;
    fx += (temp % 10);
    temp /= 10;
  }

  if (N % fx == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define FREE 0
#define NOT_FREE 1
int col[N],row[N],dpos[15],dneg[15],C[N][N];

void printBoard(){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(C[i][j]==1){
	if(row[i]!=j)
	  return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)
	printf("Q");
      else
	printf(".");
    }
    printf("\n");
  }

}
      
  

void putQueen(int i){
  int j;
  
  if (i==N){
    printBoard();
    return;
  } 
  for(j=0;j<=N-1;j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE){     
      continue;
    }     
    // put a queen at (i, j)
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    // try the next row   
    putQueen(i+1);    
    // remove the queen at (i, j) for backtracking
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    
  }
}
int main(){
  int i,j,k,r,c;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      C[i][j]=-1;
    } 
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    C[r][c]=1;
  }
  
  putQueen(0);

  return 0;
}

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

int main()
{
int a[101][101];
int b[101];
int n,m;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		scanf("%d",&a[i][j]);
	}
}
for(int i=0;i<m;i++){
	scanf("%d",&b[i]);
}
for(int i=0;i<n;i++){
	int ans=0;
	for(int j=0;j<m;j++){
		ans+=a[i][j]*b[j];
	}
	printf("%d\n",ans);
}
}


Measured memory_bytes: 2092
#include <stdio.h>

int board[10][5];
int H;
int solve(){
    int point=0,cont;
    int i,j,k;
    int flag;
    while(1){
        flag=0;
        cont=0;
        for(i=0;i<H;i++){
            for(j=0;j<4;j++){
                if(board[i][j]==board[i][j+1]&&board[i][j]){
                    cont++;
                    if(j+1==4&&cont>1){
                        for(k=0;k<cont+1;k++){
                            point+=board[i][4-k];
                            board[i][4-k]=0;
                        }
                        cont=0;
                        flag=1;
                    }
                }else{
                    if(cont<2){
                        cont=0;
                    }else{
                        for(k=0;k<cont+1;k++){
                            point+=board[i][j-k];
                            board[i][j-k]=0;
                        }
                        cont=0;
                        flag=1;
                    }
                }
            }
            cont=0;
        }
        for(i=0;i<5;i++){
            for(j=H-1;j>=0;j--){
                if(board[j][i]==0){
                    cont=0;
                    while(board[j-cont][i]==0){
                        cont++;
                        if(j-cont<0) break;
                    }
                    if(j-cont<0) break;
                    board[j][i]=board[j-cont][i];
                    board[j-cont][i]=0;
                }
            }
        }
        /**
        for(i=0;i<H;i++){
            printf("%d %d %d %d %d\n",board[i][0], board[i][1], board[i][2], board[i][3], board[i][4]);
        }
        printf("\n");
        **/
        if(flag==0){
            break;
        }
    }
    return point;
}

int main(void){
    int i;
    while(scanf("%d", &H),H){
        for(i=0;i<H;i++){
            scanf("%d %d %d %d %d", &board[i][0], &board[i][1], &board[i][2], &board[i][3], &board[i][4]);
        }
        printf("%d\n",solve());
    }
    return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
#define MAX_N 2000000
const long m = 1000000000 + 7;

long myPow(long x,long n,long m){
	if(n == 0) return 1;
	if( n % 2 == 0){
		return myPow(x*x % m, n / 2,m);
	}else{
		return x*myPow(x,n-1,m) % m;
	}
}

int main()
{
	long x,n;
	cin>>x>>n;
	cout<<myPow(x,n,m)<<endl;
	return 0;
}




Measured memory_bytes: 3116
#include<iostream>
#include<math.h>
#include<string>

using namespace std;

int main() {
   int n, k;
   cin >> n;
  
   std::string str;
   if (n == 0) str = '0';
   for (int i = 0; n != 0; i++) {
      str = std::to_string(int(abs(n)%2)) + str;
      if (abs(n)%2 == 0) n = n/2;
      else if (i%2 == 0) n = (n-1)/2;
      else n = (n+1)/2;
   }
   cout << str << endl;
   return 0;
}


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

using namespace std;
int main() {
	string str;
	cin >> str;
	int cnt = 1;
	if (str[0] != str[1]) {
		for (int i = 1; i < 3; i++) {
			if (str[i] != str[i + 1]) {
				cout << "No" << endl;
				return 0;
			}
				
		}
		cout << "Yes" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < 2; i++) {
			if (str[i] != str[i + 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
n,k = (int(i) for i in input().split())
s = input()
x,y,f,num,ans = [],[],1,0,0
for i in range(n):
    if f and s[i]=="1":
        f = 0
        x.append(i)
    elif 1-f and s[i]=="0":
        f,num = 1,num+1
        y.append(i-1)
if x and x[0]: num+=1
if int(s[-1]): y.append(n-1)
if num<=k: print(n)
else:
    if x[0]: ans = y[k-1]+1
    if s[-1]=="0": ans = max(ans,n-x[-k])
    for i in range(len(y)-k): ans = max(y[i+k]-x[i]+1,ans)
    print(ans)

Measured memory_bytes: 7200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;

  string T;
  cin >> T;

  int answer = 0;
  vector<string> player(N);

  for (int i = 0; i < N; i++) {
    if (T[i] == 'r') {
      player[i] = "p";
      answer += P;
    } else if (T[i] == 's') {
      player[i] = "r";
      answer += R;
    } else {
      player[i] = "s";
      answer += S;
    }
  }

  for (int i = 0; i < N; i++) {
    if (K <= i) {
      if (player[i - K] == player[i]) {
        player[i] = 'z';
        if (T[i] == 'r') {
          answer -= P;  
        } else if (T[i] == 's') {
          answer -= R; 
        } else {
          answer -= S; 
        }
      }
    }
  }

  cout << answer << endl;
 
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

		int[][] paper = new int[14][14];
		byte x, y, size;
		int whites = 0, blot = 0;

		StringTokenizer st;
		while ((line = br.readLine()) != null) {

			st = new StringTokenizer(line, ",");
			x = Byte.parseByte(st.nextToken());
			y = Byte.parseByte(st.nextToken());
			size = Byte.parseByte(st.nextToken());

			x += 2;
			y += 2;

			paper[x - 1][y]++;
			paper[x][y - 1]++;
			paper[x][y]++;
			paper[x][y + 1]++;
			paper[x + 1][y]++;
			if (size == 2) {
				paper[x - 1][y - 1]++;
				paper[x - 1][y + 1]++;
				paper[x + 1][y - 1]++;
				paper[x + 1][y + 1]++;
			} else if (size == 3) {
				paper[x - 2][y]++;
				paper[x - 1][y - 1]++;
				paper[x - 1][y + 1]++;
				paper[x][y - 2]++;
				paper[x][y + 2]++;
				paper[x + 1][y - 1]++;
				paper[x + 1][y + 1]++;
				paper[x + 2][y]++;
			}

		}
		for (int i = 2; i < 12; i++) {
			for (int j = 2; j < 12; j++) {
				if (paper[i][j] == 0)
					whites++;
				else if (paper[i][j] > blot)
					blot = paper[i][j];
			}
		}
		System.out.println(whites + "\n" + blot);
	}
}

Measured memory_bytes: 16872
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 100000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m, k, i, j;
    int a,b;

    cin >> k >> a >> b;
    for(i = a; i <= b; i++) {
        if (i % k == 0) { 
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	int N = getint(), M = getint();
	pair<int, int> P[100000];
	rep(i, N) {
		int a = getint();
		P[i] = mp(a, getint());
	}
	ll kotae = 0;
	sort(P, P + N);
	rep(j, N) {
		if (M) {
			int k = min(M, P[j].second);
			kotae += (ll)k * P[j].first;
			M -= k;
		}
	}
	co(kotae);

	Would you please return 0;
}

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

int main() {
	int n;
	while(cin>>n){
			long long int aux=0;
			while(n>=5){
				if(n>=500){
					aux+=1000;
					n-=500;
				}
				else {
					aux+=5;
					n-=5;
				}
		}
		cout<<aux<<endl;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define MAX_N 200000

int par[MAX_N];
int rnk[MAX_N];

void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
	}else{
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

bool same(int x, int y){
	return (find(x) == find(y));
}

int p[200000] = {};

int main(){
	
	int N, M;
	cin >> N >> M;
	
	for(int i = 1; i <= N; i++){
		cin >> p[i];
	}
	
	init(N);
	
	for(int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y;
		unite(x, y);
	}
	
	int ans = 0;
	
	for(int i = 1; i <= N; i++){
		if(same(i, p[i])){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
	ll n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << max(0LL, a+b-n) << endl;
  return 0;
}


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

using namespace std;

int main(){
    int a,b,c;
    int j = 0;
    cin >> a >> b >> c;
    for(int i = a;i <= b;i++){
        if(c % i == 0){
            j += 1;
    }
    else {
    }
    }
    cout << j << endl;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <random>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int> 
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)
const int  Inf = 2 * 1000 * 1000 * 1000;
ll LINF = (ll)4e18;
using namespace std;
#define M_PI       3.14159265358979323846   // pi

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<int>D(3, 0);

	vector<int>c(3);

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[j];
		}

		vector<int>newd(3, 0);

		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				newd[k] = max(newd[k], D[j] + c[k]);
			}
		}
		D = newd;
	}
	cout << max({ D[0], D[1], D[2] });
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

vector<ll> d;
vector<map<int,ll>> v;


void dfs(const int &cnt,const int &par) {
    for(auto to:v[cnt]) {
        if (to.first == par) continue;
        d[to.first] = d[cnt] + to.second;
        dfs(to.first,cnt);
    }
}

int main(void)
{
    IOS
    constexpr ll INF = 1LL << 50;
    int n; cin >> n;
    d.resize(n,INF);
    v.resize(n);
    REP(i,n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        v[a][b] = c;
        v[b][a] = c;
    }
    int q, k;
    cin >> q >> k;
    k--;
    vector<pii> xy;
    REP(i,q){
        int x,y; cin >> x >> y;
        x--;y--;
        xy.push_back(make_pair(x,y));
    }

    // ver dfs
    d[k] = 0;
    dfs(k,-1);

    REP(i,q) {
        cout << d[xy[i].first] + d[xy[i].second] << endl;
    }

    return 0;
}

Measured memory_bytes: 26996
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i, a, b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
 
using namespace std;
 
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long int LINF = 1LL<<56;

typedef long long int ll;
typedef pair<ll, ll> ii;



int main(){
	
		
	int N; cin >> N;
	
	int h[N];
	rep(i, 0, N) cin >> h[i];
	
	int dp[N];
	dp[0] = 0; dp[1] = abs(h[0]-h[1]);
	rep(i, 2, N){
		dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
	}
	
	cout << dp[N-1] << '\n';
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
string s,SS;

void dfs(int t,string S,int sum)
{
    if(t==4)
    {
        if(sum==7) SS=S;
        return ;
    }

    dfs(t+1,S+"-"+s[t],sum-(s[t]-'0'));
    dfs(t+1,S+"+"+s[t],sum+(s[t]-'0'));
}
int main()
{
    cin>>s;
    dfs(1,"",s[0]-'0');
    cout<<s[0]<<SS<<"=7"<<endl;
}


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

int main(){
  int N, K;
  double s = 0.0;
  cin >> N >> K;
  vector<double> p(N);
  for (int i = 0; i < N; i++){
    double P;
    cin >> P;
    p.at(i) = (P+1.0) / 2.0;
  }
  for (int i = 0; i < K; i++){
    s += p.at(i);
  }
  double ans = s;
  for (int i = 0; i < N-K; i++){
    s += p.at(K + i) - p.at(i);
    if (ans < s){
      ans = s;
    }
  }
  cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 4800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC164C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] si = new string[N];
            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();
                si[i] = s;
            }

            var ans = si.Distinct();

            Console.WriteLine(ans.Count());
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 40916
#include <bits/stdc++.h>
#define MAXN 207
#define MAXL 67
using namespace std;
long long b[MAXL],a[MAXN];
bool vi[MAXL];
void dodaj(long long x)
{
	for(long long i=59;i>=0;i--) if(x&(1LL<<i))
	{
		if(vi[i]) x^=b[i];
		else {vi[i]=true; b[i]=x; return;}
	}
}
bool proveri(long long x)
{
	for(long long i=59;i>=0;i--) if(x&(1LL<<i) && vi[i]) x^=b[i];
	return x!=0;
}
int main()
{
	int t; cin>>t;
	while(t--)
	{
		int n; cin>>n;
		string s;
		fill(vi,vi+MAXL,false);
		for(int i=0;i<n;i++) cin>>a[i];
		cin>>s;
		bool p1=false;
		for(int i=n-1;i>=0;i--)
		{
			if(s[i]=='0') dodaj(a[i]);
			else p1=p1||proveri(a[i]);
		}
		if(p1) printf("1\n");
		else printf("0\n");
	}
}

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a<b){
		cout << "a < b" << endl;
	}
	else if(a>b){
		cout << "a > b" << endl;
	}
	else if(a == b){
		cout << "a == b" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
#define ll long long
    

void test_case(){
    int n;
    cin >> n;
    bool previous = false;
    int continuous = 0;
    bool result = false;
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        if(x == y && previous == true){
            previous = true;
            continuous += 1;
        }else if(x == y && previous == false){
            previous = true;
            continuous += 1;
        }else{
            previous = false;
            continuous = 0;
        }
        
        if(continuous >= 3){
            result = true;
        }
    }
    if(result){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
} 


int main(){
    
    int t = 1;
    //cin >> t;
    for(int i = 0; i < t; i++)
        test_case();
    
    return 0;
} 


 


Measured memory_bytes: 3636
import sys

#+++++

def count_ab(a_s):
	ret=0
	is_a=False
	for c in a_s:
		if c == 'A':
			is_a=True
		elif is_a and c == 'B':
			ret+=1
			is_a=False
		else:
			is_a=False
	return ret
		
def main():
	n=int(input())
	sl=[]
	ret=0
	n_top_b=0
	n_buttom_a=0
	n_tb_ab=0
	
	for i in range(n):
		aa = input()
		ret+=count_ab(aa)
		if aa[0]=='B':
			n_top_b+=1
		if aa[-1]=='A':
			n_buttom_a+=1
		if aa[0]=='B' and aa[-1]=='A':
			n_tb_ab+=1
	
	min_n_ab=min(n_buttom_a, n_top_b)
	if min_n_ab == 0:
		return ret
	
	ret += min_n_ab
	if n_buttom_a==n_top_b and n_top_b==n_tb_ab:
		ret -= 1
	
	return ret
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
		


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
void topoSort(vector<vector<int>>& graph,int u,vector<bool>& visited,stack<int>& st) {
	visited[u] = true;
	for(int i=0;i<graph[u].size();i++) {
		if(!visited[graph[u][i]]) {
			topoSort(graph,graph[u][i],visited,st);
		}
	}
	st.push(u);
}
int main() {
	int n,m;
	cin>>n>>m;
	vector<vector<int>> graph(n,vector<int>(0));
	for(int i=0;i<m;i++) {
		int x,y;
		cin>>x>>y;
		graph[x-1].push_back(y-1);
	}
	stack<int> s;
	vector<bool> visited(n,false);
	for(int i=0;i<n;i++) {
		if(!visited[i]) {
			topoSort(graph,i,visited,s);
		}
	}
	vector<int> topo;
	while(!s.empty()) {
		topo.push_back(s.top());
		s.pop();
	}
	vector<int> dist(n,0);
	for(int i=0;i<n;i++) {
		int u = topo[i];
		for(int j=0;j<graph[u].size();j++) {
			if(dist[graph[u][j]] < (dist[u] + 1)) {
				dist[graph[u][j]] = dist[u] + 1;
			}
		}
	}
	int mxdist = 0;
	for(int i=0;i<n;i++) {
		mxdist = max(mxdist,dist[i]);
	}
	cout<<mxdist;
}

Measured memory_bytes: 13276
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	while (N--) {
		string st; cin >> st;
		int a = 0;
		int now = 26;
		int from = now;
		vector<int>anss(54,-1);
		while (1) {
			if (anss[now] == -1) {
				anss[now] = st[a] - 'a';
			}
			if (a == st.size() - 1)break;
			else {
				if (st[a + 1] == '-') {
					now++;
				}
				else {
					now--;
				}
				from = min(from, now);
			}
			a += 3;
		}
		for (int i = from; i < anss.size(); ++i) {
			if (anss[i] == -1)break;
			else {
				cout << char(anss[i] + 'a');
			}

		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll n,v;
ll f[1005][1005],w[1005],c[1005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>v;
	for(ll i=1;i<=n;i++)cin>>w[i]>>c[i];
	for(ll i=1;i<=n;i++)for(ll j=v;j>=0;j--)if(j>=w[i])f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+c[i]);else f[i][j]=f[i-1][j];
	ll maxx=-1;for(ll i=0;i<=v;i++)maxx=max(maxx,f[n][i]);
	cout<<maxx;
	return 0;
}


Measured memory_bytes: 1792
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

import bisect
from collections import deque


def main():
	n=int(input())
	A=[int(input()) for _ in range(n)]
	
	Q=deque([A[0]])
	
	for i in range(1,n):
		if A[i]<=Q[0]:
			Q.appendleft(A[i])

		else:
			ix=bisect.bisect_left(Q,A[i])
			Q[ix-1]=A[i]
	
	print(len(Q))
	
	
	
	
	



if __name__ == "__main__":
	main()


Measured memory_bytes: 8052
<?php

fscanf(STDIN, "%d", $n);

$red = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);
    $red[] = [$a, $b];
}

$blue = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);
    $blue[] = [$a, $b];
}

usort($blue, function ($a, $b) { return $a[0] > $b[0]; });
usort($red, function ($a, $b) { return $a[0] > $b[0]; });

$cnt = 0;
for ($i = 0; $i < $n; ++$i) {
    $bx = $blue[$i][0];
    $by = $blue[$i][1];

    $near_j = -1;
    $near_y = PHP_INT_MIN;
    for ($j = 0; $j < $n; ++$j) {
        if (!isset($red[$j])) continue;
        $rx = $red[$j][0];
        $ry = $red[$j][1];
        if ($rx > $bx) continue;
        if ($ry > $by) continue;

        if ($ry > $near_y) {
            $near_j = $j;
            $near_y = $ry;
        }
    }

    if ($near_j != -1) {
        ++$cnt;
        unset($red[$near_j]);
    }
}
echo $cnt, PHP_EOL;


Measured memory_bytes: 16264
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadLong;
            var Q = cin.ReadInt;
            var A = cin.ReadIntArray(Q);
            var count = new int[N];
            for (int i = 0; i < N; i++)
            {
                count[i] = 0;
            }
            for (int i = 0; i < Q; i++)
            {
                count[A[i] - 1]++;
            }
            var point = K - Q;
            for (int i = 0; i < N; i++)
            {
                if (point + count[i] > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 18256
#include <stdio.h>

int main() {
    int L, R, d, num = 0;
    scanf("%d %d %d", &L, &R, &d);
    
	for (int i = L; i <= R; i++) {
        if (i % d == 0) {
            num += 1;
        }
    }
    printf("%d", num);
    
	return 0;
}

Measured memory_bytes: 1712
public class Hello{
    public static void Main(){

        string[] num = System.Console.ReadLine().Split(' ');
        int[] group ={1,3,1,2,1,2,1,1,2,1,2,1};
        int x = int.Parse(num[0]);
        int y = int.Parse(num[1]);

        if(group[x - 1] == group[y - 1]){
            System.Console.WriteLine("Yes");
        }else{
            System.Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const ll INF = LONG_LONG_MAX / 4;

vector<ll> ss;
vector<ll> ts;

ll solve(const ll x) {
    auto p_s = lower_bound(ss.begin(), ss.end(), x);
    p_s--;
    ll cand_s_1 = *p_s;
    ll cand_s_2 = *(p_s + 1);

    auto p_t = lower_bound(ts.begin(), ts.end(), x);
    p_t--;
    ll cand_t_1 = *p_t;
    ll cand_t_2 = *(p_t + 1);

    auto f = [](const ll x, const ll _s, const ll _t) {
        ll s, t;
        s = min(_s, _t);
        t = max(_s, _t);
        // printf("calc for x: %lld, s: %lld, t: %lld -> ", x, s, t);

        ll ans;
        if (x <= s) {
            ans = t - x;
        } else if (x >= t) {
            ans = x - s;
        } else {
            ans = abs(s - t) + min(abs(x - s), abs(x - t));
        }
        // printf("%lld\n", t - x);
        return ans;
    };

    ll ans = INF;
    chmin(ans, f(x, cand_s_1, cand_t_1));
    chmin(ans, f(x, cand_s_1, cand_t_2));
    chmin(ans, f(x, cand_s_2, cand_t_1));
    chmin(ans, f(x, cand_s_2, cand_t_2));
    return ans;
}

int main(void) {
    int A, B, Q;
    cin >> A >> B >> Q;

    ss.resize(A + 2);
    ss[0] = -INF;
    for (int i = 1; i <= A; i++) {
        cin >> ss[i];
    }
    ss[A + 1] = INF;

    ts.resize(B + 2);
    ts[0] = -INF;
    for (int i = 1; i <= B; i++) {
        cin >> ts[i];
    }
    ts[B + 1] = INF;

    for (int i = 0; i < Q; i++) {
        ll x;
        cin >> x;
        cout << solve(x) << endl;
    }

    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int sides[4];
  for(int i=0; i<4; ++i) {
    scanf("%d", &sides[i]);
  }
  sort(sides, sides+4);
  if((sides[0] == sides[1]) && (sides[2] == sides[3])) cout << "yes" << endl;
  else cout << "no" << endl;
}




Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<iomanip>
#include<numeric>
using namespace std;

int main(){
  int N,M;cin>>N>>M;
  int ab[N][2];
  int cd[M][2];

  for(int i=0;i<N;i++)cin>>ab[i][0]>>ab[i][1];
  for(int i=0;i<M;i++)cin>>cd[i][0]>>cd[i][1];

  //各学生のマンハッタン距離算出
  for(int i=0;i<N;i++){//i番目の学生に対して
    int ans=1,deg=0,before=0;
    for(int j=0;j<M;j++){//j個の距離をチェックする
      deg=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]);
      if(j>0&&before>deg){
        ans=j+1;
        before=deg;
      }else if(j==0){
        before=deg;
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
  ll res=1;
  for(ll i=0;i<y;i++){
    res=res*x%mod;
  }
  return res;
}

main(){
  ll n;cin >> n;
  ll ans = powmod(10,n) -powmod(9,n)-powmod(9,n)+powmod(8,n);
  ans%=mod;
  ans=(ans+mod)%mod;
  cout << ans << endl;
  return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int n;
vector<int> to[200005];

mint ans;
int dfs(int v, int p=-1){
    int res = 1;
    vector<int> ts;
    for(int u : to[v]){
        if(u == p) continue;
        int t = dfs(u,v);
        res += t;
        ts.push_back(t);
    }
    if(p != -1){
        ts.push_back(n-res);
    }
    mint now = mint(2).pow(n-1)-1;
    for(int t : ts){
        now -= mint(2).pow(t)-1;
    }
    ans += now;
    return res;
}

int main(){
    cin >> n;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0);
    ans /= mint(2).pow(n);
    cout << ans.x << endl;
}

Measured memory_bytes: 32564
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,k) for (int i = 0; i < (int)(k); i++)
#define all(c) begin(c), end(c)

int solve(vector<int> a) {
    int n = a.size();
    assert(a.size() % 2 == 0);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += min(a[i], a[i] + 1);
        ++i;
    }
    return ans;
}

int main() {
    int n;
    while (cin >> n) {
        n += n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        cout << solve(a) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

    int N;
    int *d = new int(N);
    int total = 0;

    cin >> N;

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

    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            total += d[i] * d[j];
        }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 2019
#define pi 2*acos(0.0)
int main()
{
    int n,m,i,a,b,j;
    cin>>m>>n;
    vector<vector<int>> graph(m, vector<int>(0));
    for(i=1; i<=n; i++)
    {
        cin>>a>>b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue<int>q;
    vector<int>cost(m,-1);
    vector<int>res(m);
    int u;
    cost[0]=0;
    q.push(0);
    while(!q.empty())
    {
        u=q.front();
        q.pop();
        for(int y : graph[u])
        {
            if(cost[y]!=-1)
                continue;
            cost[y]=cost[u]+1;
            res[y]=u;
            q.push(y);

        }
    }
    cout<<"Yes\n";
    for(i=1; i<m; i++)
    {
        cout<<res[i]+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 10724
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
   fastio;
   int n;
   cin>>n;
   int ans=0,fans=0;
   while(n--)
   {
       int x,y;
       cin>>x>>y;
       if(x==y)
       {
           ans++;
           if(ans>=3)
           {
               fans=3;
           }
       }
       else
       {
           ans=0;
       }
   }
   cout<<(fans>=3?"Yes":"No")<<endl;
   return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int s = n % 100;
    n = n / 100;
    if ((n >= 1 && n <= 12) && (s >= 1 && s <= 12))
    {
        cout << "AMBIGUOUS";
    }
    else if (n >= 1 && n <= 12)
    {
        cout << "MMYY";
    }
    else if (s >= 1 && s <= 12)
    {
        cout << "YYMM";
    }
    else
    {
        cout << "NA";
    }
}

Measured memory_bytes: 256
a, b = map(int, input().split())

if a <= 0 and b >= 0:
  print("Zero")
elif a > 0 and b > 0:
  print("Positive")
elif a < 0 and b < 0:
  if a == b:
    print("Positive")
  elif abs(a-b) % 2 == 1:
    print("Positive")
  elif abs(a-b) % 2 == 0:
    print("Negative")

Measured memory_bytes: 3060
n = gets.to_i

ac=wa=tle=re=0

n.times do |i|
  s = gets.chomp
  ac +=1 if s=='AC'
  wa +=1 if s=='WA'
  tle +=1 if s=='TLE'
  re +=1 if s=='RE'
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"


Measured memory_bytes: 14240
import sys

l, r = map(int, input().split())

ans = 2019
for i in range(l, r):
    for j in range(i+1, r + 1):
        temp = i * j % 2019
        if temp < ans:
            ans = temp
        if ans == 0:
            print(0)
            sys.exit()
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#define N 200003
int main(void){
    int n,i,a[N],max=-222220,min;
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        scanf("%d",&a[i]);
    }
    max=a[1]-a[0];
    min=a[0];
    for(i=1;i<n;i++){
        if(min>a[i]){
            min=a[i];
            continue;
        }
        if(a[i]<=a[i+1])
            continue;
        if(a[i]-min>max)
            max=a[i]-min;
    }
    
    
    printf("%d\n",max);
    return 0;
}

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

const int maxn = 1005;
typedef pair<double, int> pid;
vector<pid> e[maxn];
typedef pair<double, double> pdd;
double dist[maxn];
double r[maxn];
pdd c[maxn];
int s = 0, t = 1001;
#define y second
#define x first

double sqr(double x) {return x * x;}

double _(pdd a, pdd b)
{
	return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}

int main()
{
	scanf("%lf%lf", &c[0].x, &c[0].y);
	scanf("%lf%lf", &c[t].x, &c[t].y);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= t; i++) dist[i] = 1e20;
	for (int i = 1; i <= n; i++)
		scanf("%lf%lf%lf", &c[i].x, &c[i].y, &r[i]);
	c[n + 1] = c[t];
	t = n + 1;
	for (int i = 0; i <= t; i++)
		for (int j = 0; j <= t; j++)
			if (i != j)
				e[i].push_back(pid(max(0., _(c[i], c[j]) - r[i] - r[j]), j));
	priority_queue<pid, vector<pid>, greater<pid> > pq;
	pq.push(pid(dist[0] = 0, 0));
	while (!pq.empty())
	{
		auto tp = pq.top();pq.pop();
		if (tp.x > dist[tp.y]) continue;
		for (pid v : e[tp.y])
		{
			if (v.x + dist[tp.y] < dist[v.y])
			{
				dist[v.y] = v.x + dist[tp.y];
				pq.push(pid(dist[v.y], v.y));
			}
		}
	}
	printf("%.10f\n", dist[t]);
	return 0;
}

Measured memory_bytes: 20592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

vector<ll> func(ll N){
    vector<ll> v;
    for(ll i = 1; i*i <= N; i++){
        if(N % i != 0) continue;
        v.push_back(i);
    }
    
    v.push_back(N);
    
    return v;
}

int main(){
    ll N,M;
    cin >> N >> M;
    auto v = func(M);
    ll L = v.size();
    ll ans = 1;
    rep(i,L){
        if(N*v[i] <= M){
            ans = max(ans, v[i]);
        }
        if(N*(M/v[i]) <= M){
            ans = max(ans, M/v[i]);
        }
    }
    cout << ans << endl;
}
    /*
    ll Q = M/N;
    ll R = M % N;
    ll q = Q;
    ll r = R;
    ll i = 2;
    while(r % q != 0){
        /*
        if(Q % i != 0){
            i++;
            continue;
        }*//*
        q = Q/i;
        r = M - (q*N);
        i++;
    }
    cout << q << endl;
    
}*/


Measured memory_bytes: 256
from math import atan2, degrees
A, B, X = map(int, input().split())
S = X / A


if S >= A * B / 2:
    h = (2 * (A * B - S)) / A
    print(degrees(atan2(h, A)))

else:
    w = (2 * S) / B
    print(degrees(atan2(B, w)))


Measured memory_bytes: 38256
#if WATCH_RUNTIME
	#include <ctime>
	clock_t startTime;
#endif
#include <algorithm>
	using std::sort;
#include <cstdio>

struct pNode
{
	int x,y;
	bool isRed;
	bool operator<(pNode const &b) const {return x<b.x;}
}*p;

int setsIndex=0,*setsList;
void push(int x)
{
	setsList[setsIndex++]=x;
}

bool pop(int target)
{
	//if q in sets,and q<target, pop the max of q and return true
	
	int i,maxIndex=-1,maxValue=-1;
	for(i=0;i<setsIndex;i++){
		if(setsList[i]<target)
		{
			if(setsList[i]>maxValue){
				maxValue=setsList[i];
				maxIndex=i;
			}
		}

	}
	if(maxIndex>=0){
		int tmp=setsList[setsIndex-1];
		setsList[setsIndex-1]=setsList[maxIndex];
		setsList[maxIndex]=tmp;
		setsIndex--;
		return true;
	}	
	else
		return false;
}


int main(void)
{
	#if DEBUG 
	freopen("_in","r",stdin);
	#endif
	#if WATCH_RUNTIME
	startTime=clock();
	#endif

	int i,N,counter=0;
	scanf("%d",&N);
	p=new pNode [2*N];
	setsList=new int [N];
	for(i=0;i<N;i++){
		scanf("%d%d",&p[i].x,&p[i].y);
		p[i].isRed=true;
	}

	for(i=0;i<N;i++){
		scanf("%d%d",&p[i+N].x,&p[i+N].y);
		p[i+N].isRed=false;
	}

	sort(p,p+2*N);

	for(i=0;i<2*N;i++)
	{
		if(p[i].isRed)
		{
			push(p[i].y);
		}
		else
		{
			if(pop(p[i].y))
				counter++;
		}

	}
	printf("%d\n",counter);


	#if WATCH_RUNTIME
	printf("----------\n");
	printf("\n+===============+\n");
	printf("|RUNTIME =%3dms.|\n",clock()-startTime);
	printf("+===============+\n");
	#endif

	return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
s=input()
if s.count('-')!=1:
	r='No'
else:
	t,u=s.split('-')
	if len(t)==a and len(u)==b and (t+u).isdecimal():
		r='Yes'
	else:
		r='No'
print(r)

Measured memory_bytes: 61396
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,K,x[101],res=0;
  cin >> N >> K;
  REP(i,N)cin >> x[i];
  REP(i,N){
    res += 2*min(abs(x[i]-K),x[i]);
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    counter = cl.Counter()
    for i in range(N):
        s = input()
        S = []

        for char in s:
            S.append(char)
        S.sort()
        
        s = "".join(S)
        counter.update({s:1})
    ans = 0

    for item, count in counter.items():
        ans += count * (count - 1) / 2
    print(int(ans))

main()


Measured memory_bytes: 104612
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    for (int i = 0;i<3;i++) a[i] = sc.nextInt();
    Arrays.sort(a);
    System.out.println(a[0]+" "+a[1]+" "+a[2]);
	}
}


Measured memory_bytes: 26332
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b;
	cin >> a >> b;
	if (b % a == 0) PRI(a + b);
	else PRI(b - a);
	return 0;
}

Measured memory_bytes: 3528