akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
bool isLike2017(int n) {
	for (int j = 0; j < 2; j++) {
		for (int i = 2; i <= (int)sqrt(n); i++) {
			if (n % i == 0) {
				return false;
			}
		}
		n = (n + 1) / 2;
	}
	return true;
}
int main() {
	int q, l, r, list[100000], num, sum[100000];
	scanf("%d", &q);
	for (int i = 0; i < 100000; i++) {
		if (i % 2 == 0 || i < 3) {
			list[i] = 0;
			continue;
		}
		if (isLike2017(i)) {
			list[i] = i;
			num++;
		} else {
			list[i] = 0;
		}
	}
	sum[0] = 0;
	for (int i = 1; i < 100000; i++) {
		sum[i] = sum[i - 1];
		if (list[i] != 0) {
			sum[i]++;
		}
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &l, &r);
		printf("%d\n", sum[r] - sum[l - 1]);
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  string s; cin>>s;
  if(s=="Sunny") cout<<"Cloudy";
  if(s=="Cloudy") cout<<"Rainy";
  if(s=="Rainy") cout<<"Sunny";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iterator>
#include<cmath>
#include<vector>
using namespace std;

int main()
{
    string S, T;
    getline(cin, S);
    getline(cin, T);
    T.pop_back();
    if(S==T)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i; i<N; i++){
    cin >> A[i];
  }

  int button = 1;
  int button_new;
  int count = 0;
  int flag = -1;
  while(button){
    button_new = A[button-1];
    A[button-1] = 0;
    button = button_new;
    count++;
    if (button == 2){
      flag = count;
      break;
    }
  }
  cout << flag << endl;

  return 0;
}


Measured memory_bytes: 640
def call(n)
  i = 1;

  loop do
      x = i;
      if  x % 3 == 0
        STDOUT << " " << i;
        i += 1
        break unless i <= n
        next
      end
    
      loop do
        if  x % 10 == 3 
          STDOUT << " " << i;
          break;
        end
        x /= 10;
        break unless  x != 0
      end
      i += 1
    break unless i <= n
  end

  STDOUT << "\n"
end

#include <stdio.h>
n = gets.to_i
call(n)




Measured memory_bytes: 6876
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define cond(a,b,c) ((a)?(b):(c))
#define int ll
using ll=long long;
using namespace std;


int A[2*100*1000+100];
int B[2*100*1000+100];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    rep(i, 1, N) cin >> A[i];
    int M=0;
    for(int i=N; i>=1; i--) {
        B[i] = B[i] ^ A[i];
        M+=B[i];
        for(int j=1; j*j <= i; j++) {
            if (i % j==0 and i != 1) { 
                B[j] = B[j] ^ B[i];
                int jj = i/j; if (jj!=j and jj!=i) B[jj] = B[jj] ^ B[i];
            }
        }
    }

    cout << M << endl;
    rep(i, 1, N) if (B[i]) cout << i << " ";
    cout << endl;
}



Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
using namespace std;
typedef long long int ll;
const int MOD = 1000000007;

int main(){
    int n;
    int a[n][26] = {};
    string ans;

    cin >> n;
    for(int i=0; i < n; i++){
        for(int j=0; j < 26; j++){
            a[i][j] = 0;
        }
    }
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        for(int j=0; j<=s.size(); j++){
            char c = s[j];
            a[i][c - 'a']++;
            // cout << c - 'a' << endl;
        }
        // cout << s.size() << endl;
    }
    for(int i = 0; i < 26; i++){
        int mn = 100;
        for(int j = 0; j < n; j++){
            if(a[j][i] < mn){
                mn = a[j][i];
            }
        }
        for(int k=0; k < mn; k++){
            ans += char(i + 'a');
        }
      }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main() {
  int a, b;
  while (true) {
    cin >> a >> b;
    if (a == 0 && b == 0) break;
    if (a < b) {
      cout << a << " " << b << endl;
    }
    else {
      cout << b << " " << a << endl;
    }
  }
  return 0;
}

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

int main() {

  int N = 0;
  double ans = 0;
  cin >> N;
  vector<double> MoneyMoneyMoneyMustBeFunnyInTheRichMansWorld(N);
  vector<string> str(N);
  for(int i = 0; i < N; i++)
  {
    cin >> MoneyMoneyMoneyMustBeFunnyInTheRichMansWorld.at(i) >> str.at(i);
  }
  
  for(int i = 0; i < N; i++)
  {
    if(str.at(i) == "BTC"){
      ans += MoneyMoneyMoneyMustBeFunnyInTheRichMansWorld.at(i) * 380000;
    }else{
      ans += MoneyMoneyMoneyMustBeFunnyInTheRichMansWorld.at(i);
    }
  }
  
  cout << ans << endl;
}

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

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

const int MAX_Y = 32+1;
const int MAX_X = 32+1;

#define MAX MAX_Y
#define INF (1<<28)

int bit[MAX_Y][MAX_X];

void update(int x, int y, int v)
{
	++x; ++y;
	int j = y;
	while (j <= MAX_Y) {
		int i = x;
		while (i <= MAX_X) {
			bit[j][i] += v;
			i += i & -i;
		}

		j += j & -j;
	}
}

int sum(int x, int y)
{
	int ans = 0;

	++x; ++y;
	int j = y;
	while (j > 0) {
		int i = x;
		while (i > 0) {
			ans += bit[j][i];
			i -= i & -i;
		}
		j -= j & -j;
	}

	return ans;
}

int range_sum(int x1, int y1, int x2, int y2)
{
	return sum(x2, y2) - sum(x2, y1-1) - sum(x1-1, y2) + sum(x1-1, y1-1);
}

int h, w, s;
int required;

int all;

bool memo[MAX][MAX][MAX][MAX];
pii ret[MAX][MAX][MAX][MAX];

bool ok(int x1, int y1, int x2, int y2)
{
	return range_sum(x1, y1, x2, y2) >= required;
}

pii dfs(int x1, int y1, int x2, int y2)
{
	if (memo[x1][y1][x2][y2])
		return ret[x1][y1][x2][y2];
	if (!ok(x1, y1, x2, y2)) {
		memo[x1][y1][x2][y2] = true;
		return ret[x1][y1][x2][y2] = pii(-INF, INF);
	}

	pii ans = pii(1, range_sum(x1, y1, x2, y2));
	REP(i, x1, x2) {
		pii r1, r2;
		r1 = dfs(x1, y1, i, y2);
		r2 = dfs(i+1, y1, x2, y2);
		ans = max(ans, pii(r1.first+r2.first, min(r1.second, r2.second)));
	}
	REP(j, y1, y2) {
		pii r1, r2;
		r1 = dfs(x1, y1, x2, j);
		r2 = dfs(x1, j+1, x2, y2);
		ans = max(ans, pii(r1.first+r2.first, min(r1.second, r2.second)));
	}

	memo[x1][y1][x2][y2] = true;
	return ret[x1][y1][x2][y2] = ans;
}

int main(void)
{
	while (cin >> h >> w >> s, h|w|s) {
		memset(memo, 0, sizeof(memo));
		memset(bit, 0, sizeof(bit));

		rep(j, h) {
			rep(i, w) {
				int uij;
				cin >> uij;
				update(i, j, uij);
			}
		}

		all = sum(w-1, h-1);
		required = all-s;
		pii ans = dfs(0, 0, w-1, h-1);
		printf("%d %d\n", ans.first, s-(all-ans.second));
	}

	return 0;
}

Measured memory_bytes: 11592
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

vector<vector<int>>G;
vector<int> visited;

void dfs(int i) {
    for(int next : G[i]) {
        if(visited[next]) continue;
        visited[next] = true;
        dfs(next);
    }
}

int main() {
    int N, M; cin >> N >> M;
    int X[M], Y[M], Z[M];
    G.resize(N);
    visited.resize(N, false);
    rep(i, M) {
        cin >> X[i] >> Y[i] >> Z[i];
        --X[i], --Y[i];
        G[X[i]].pb(Y[i]);
        G[Y[i]].pb(X[i]);
    }
    int ans = 0;
    rep(i, N) {
        if(visited[i])continue;
        ++ans;
        visited[i] = true;
        dfs(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 10368
#include <iostream>

using namespace std;

int main(){
	int X, Y;
	cin >> X >> Y;

	for (int i = 0; i <= X; i++){
		if (i * 4 + (X - i) * 2 == Y) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
	char s[100005];
	
	int dist[30][100005];
	int alpha[30];

int main(void) {
	

	
	scanf("%s", s);
	
	int i, j;
	
	int len=strlen(s);
	
	for(i=0;i<len;i++){
		dist[s[i]-'a'][alpha[s[i]-'a']]=i+1;
		alpha[s[i]-'a']++;
	}
	
	int a=-1;
	int b=-1;
	
	for(i=0;i<26;i++){
		for(j=0;j<len;j++){
			if(dist[i][j]==0 || dist[i][j+1]==0)
			break;
			if(dist[i][j+1]-dist[i][j]<=2){
				a=dist[i][j];
				b=dist[i][j+1];
			}
		}
		if(a!=-1 && b!=-1)
		break;
			
		
	}
	printf("%d %d", a, b);
	return 0;
}


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

char grid[10][10];

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  rep(i,h)rep(j,w){
    cin>>grid[i][j];
  }
  int ans=0;
  rep(i,1<<h){
    rep(j,1<<w){
      int now=0;
      rep(hi,h)rep(wi,w){
        if(i>>hi&1 || j>>wi&1)continue;
        if(grid[hi][wi]=='#') now++;
      }
      if(now==k)ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3612
l = ['R', 'Y', 'G', 'B']
h, w, d = map(int, input().split())
res = [[None] * 1000 for _ in range(1000)]
for i in range(1000):
    if (i // d) % 2 == 0:
        for j in range(1000):
            res[i][j] = l[(j // d + 2) % 4]
    else:
        for j in range(1000):
            res[i][j] = l[j // d % 4]
ans = [[None] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        ans[i][j] = res[i + j][h - i - 1 + j]
for row in ans:
    print(''.join(row))


Measured memory_bytes: 114860
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_snake_toy(void) {
	int n, k;
	int l[50];
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> l[i];

	sort(l, l + n);
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += l[n - i - 1];
	}
	cout << sum << endl;
}

int main()
{
	b_snake_toy();
    return 0;
}

Measured memory_bytes: 3580
N, M, X, Y = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.append(X)
y_list = list(map(int, input().split()))
y_list.append(Y)

if max(x_list) < min(y_list):
  print('No War')
else:
  print('War')

Measured memory_bytes: 3060
function main()
  
  S = chomp(readline())
  T = chomp(readline())
  
  ans = true
  
  for i in 1:length(S)
    if S[i] != T[i]
      ans = false
    end
  end
  
  if ans
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 154972
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<cstring> 
#include<climits>  
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define INF 1000000000000000
#define MAXN 100000
#define LL long long
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
struct node{
	int a,b;
	node(){}
	node(int A,int B){a=A,b=B;}
}line[MAXN+5];
bool cmp(node a,node b){return a.b==b.b?a.a<b.a:a.b<b.b;}
int main(){
	int n=read(),m=read(),ans=1,R=0;
	for(int i=1;i<=m;i++)
		line[i].a=read(),line[i].b=read();
	sort(line+1,line+m+1,cmp);
	R=line[1].b;
	for(int i=2;i<=m;i++){
		if(line[i].a<R) continue;
		ans++,R=line[i].b;
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int>> generate(int n){
    if(n == 0) return vector<vector<int>>(1, vector<int>(1, 0));
    auto pre = generate(n-1);
    const int N = (1<<n);
    const int h = N/2;
    vector<vector<int>> res(N, vector<int>(N, 0));
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            int c = pre[i%h][j%h];
            res[i][j] = (i >= h && j >= h ? 1 - c : c);
        }
    }
    return res;
}

int main(){
    int N, M;
    while(cin >> N >> M){
        auto sum = generate(min(N, M));
        vector<vector<int>> res((1<<N)-1, vector<int>((1<<M)-1, 0));
        const int c = 1 << (min(N, M));
        for(int i=0;i<res.size();i++){
            for(int j=0;j<res[i].size();j++){
                for(int di=0;di<2;di++){
                    for(int dj=0;dj<2;dj++){
                        res[i][j] += sum[(i+di)%c][(j+dj)%c];
                    }
                }
                res[i][j] %= 2;
            }
        }
        for(auto& v : res){
            for(auto& t : v) cout << t;
            cout << endl;
        }
    }
}

Measured memory_bytes: 9600
#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>;

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;

    rep(i,S.size()) {
        if (S.at(i) != T.at(i)) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3928
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()

f = [0] * 1000001
for v in a:
    f[v] += 1
for i in range(2, 500001):
    for j in range(i*2, 1000001, i):
        f[i] += f[j]

def gcd(a, b):
    while b > 0:
        c = a % b
        a = b
        b = c
    return a

if max(f[2:]) <= 1:
    print("pairwise coprime")
else:
    x = 0
    for v in a:
        x = gcd(x, v)
    if x == 1:
        print("setwise coprime")
    else:
        print("not coprime")


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

using namespace std;

const int mxn = 506;

int n;
char a[mxn][mxn];

bool allwhite() {
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			if (a[i][j] == '#')
				return false;
	return true;
}

int ans = 0x3f3f3f3f;

bool allblack(int x) {
	for (int i = 0; i < n; ++i)
		if (a[x][i] != '#')
			return false;
	return true;
}

bool anyblack() {
	for (int i = 0; i < n; ++i)
		if (allblack(i))
			return true;
	return false;
}

bool canywhite(int x) {
	for (int i = 0; i < n; ++i)
		if (a[i][x] == '.')
			return true;
	return false;
}

bool canyblack(int x) {
	for (int i = 0; i < n; ++i)
		if (a[i][x] == '#')
			return true;
	return false;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		scanf("%s", a[i]);
	
	if (allwhite()) {
		puts("-1");
		return 0;
	}
	
	if (anyblack()) {
		ans = 0;
		for (int i = 0; i < n; ++i)
			ans += canywhite(i);
		cout << ans << endl;
		return 0;
	}
	
	for (int i = 0; i < n; ++i) {
		if (canyblack(i)) {
			int cnt = 0;
			for (int j = 0; j < n; ++j) {
				if (a[i][j] == '.')
					++cnt;
				if (canywhite(j))
					++cnt;
			}
			ans = min(ans, cnt);
		} else {
			int cnt = 1;
			for (int j = 0; j < n; ++j) {
				if (a[i][j] == '.')
					++cnt;
				if (canywhite(j))
					++cnt;
			}
			ans = min(ans, cnt);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
    FASTIO
//     ///*
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
// //*/
    int T;
    //scanf("%d", &T);
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n, k;
        cin >> n >> k;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int x;
            cin >> x;
            ans += (k <= x);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
w1 = 0
w2 = w
h1 = 0
h2 = h
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        w1 = max(w1, x)
    elif a == 2:
        w2 = min(w2, x)
    elif a == 3:
        h1 = max(h1, y)
    elif a == 4:
        h2 = min(h2, y)
print(max(0, w2 - w1) * max(0, h2 - h1))

Measured memory_bytes: 3064
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()

imos_l=[0]*(N+1)

for i in range(K):    
    imos_l=[0]*(N+1)
    for j in range(len(A)): 
        imos_l[max(j-A[j],0)]+=1
        imos_l[min(j+A[j]+1,N)]-=1
    for j in range(len(imos_l)-1):
        imos_l[j+1]=imos_l[j]+imos_l[j+1]
    for j in range(len(A)):
        A[j]=imos_l[j]
    flag=True
    for j in range(len(A)):
        if(A[j]<N):
            flag=False
    if(flag):
        print(*A)
        sys.exit(0)

print(*A)
            
        



Measured memory_bytes: 168244
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  double t,x;
  cin >> t >> x;
  pd(t/x);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,k;
    char s;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>s;
        cout<<(i+1==k?(char)(s+'a'-'A'):s);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a < b:
        return gcd(b, a)
    r = a % b
    return b if r == 0 else gcd(b, r)


n = int(input())
a = [int(i) for i in input().split()]

l = [0 for i in range(n)]
for i in range(1, n):
    l[i] = gcd(a[i-1], l[i-1])

r = [0 for i in range(n)]
for i in range(n-1)[::-1]:
    r[i] = gcd(a[i+1], r[i+1])

m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))

Measured memory_bytes: 14400
#include<bits/stdc++.h>
using namespace std;
int main()
 {
long long int n;
int m;
cin>>n>>m;
int a[m];
for(int i=0;i<m;i++)
{
	cin>>a[i];
}
int sum=0;
for(int i=0;i<m;i++)
{
	sum=sum+a[i];
}
if(n<sum)
{
	cout<<"-1"<<endl;
}
if(n==sum)
{
	cout<<"0"<<endl;
}
if(n>sum)
{
	int b=n-sum;
	cout<<b<<endl;
}
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int par[MAX_N];
int nrank[MAX_N];
int weight[MAX_N];

void initial(int n){		//?????????
	for(int i=0;i<n;i++){
		par[i] = i;
		nrank[i] = 0;
        weight[i] = 0;
	}
}

P find(int x){		//??¨??????????±???????
	if(par[x] == x){
		return P(x,0);
	}else{
		P p = find(par[x]);
		par[x] = p.fi;
		weight[x] = p.se + weight[x];
		return P(par[x],weight[x]);
	}
}

void unite(int x,int y,int w){
	int bx = x;
	int by = y;
	x = (find(x)).fi;
	y = (find(y)).fi;
	if(x == y) return;
	if(nrank[x] < nrank[y]){
		par[x] = y;
		weight[x] = -weight[bx] - w + weight[by];
	}else{
		par[y] = x;
        weight[y] = weight[bx] + w - weight[by];
		if(nrank[x] == nrank[y])
			nrank[x]++;
	}
}

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

int main()
{
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0){
            break;
        }
        initial(n+1);
        rep(i,m){
            int a,b,w;
            char hoge,c;
            scanf("%c%c",&hoge,&c);
            if(c == '!'){
                scanf("%d%d%d",&a,&b,&w);
                unite(a,b,w);
            }else{
                scanf("%d%d",&a,&b);
                if(same(a,b)){
                    printf("%d\n",weight[b]-weight[a]);
                }else{
                    printf("UNKNOWN\n");
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4316
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

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

  int n;
  cin >> n;
  map<int, int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  int res = 0;
  for(auto p : mp) {
    int x = p.se;
    if(x % 2 == 1) res++;
  }
  cout << res << endl;
  return 0;
}

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

int main(void)
{
  int n,k;
  char s[20];
  scanf("%d %s %d",&n,s,&k);
  char tmp=s[k-1];
  int len=strlen(s);
  for(int i=0;i<len;i++){
    if(s[i]!=tmp){
      s[i]='*';
    }
  }

  printf("%s\n",s);
  return 0;
}


Measured memory_bytes: 1632
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    float D, T, S;
    cin >> D >> T >> S;

    if(D / S  <= T){cout << "Yes" << endl;}
    else{cout << "No" << endl;}

    return 0;
}


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


int digits_sum(int num){
    int ret = 0;

    while(num > 0){
        ret += num % 10;
        num /= 10;
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    int res = 1e9;

    for(int a = 1; a < N; ++a){
        int b = N - a;
        int tmp = digits_sum(a) + digits_sum(b);
        if(tmp < res) res = tmp;
    }

    cout << res << endl;
}

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

const ll MOD = 1e9+7;

ll powmod(ll x, ll n){
  ll ret = 1;

  for (ll i=0; i<n; i++){
    ret = ret * x % MOD;
  }

  return ret;
}

int main(void){
  ll n, ans;
  cin >> n;

  ans = powmod(10,n);
  ans -= powmod(9,n);
  ans -= powmod(9,n);
  ans += powmod(8,n);
  ans %= MOD;
  ans = (ans+MOD)%MOD;

  cout << ans;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
	unsigned long a,u;
	cin >> a;
	while(a >= 5){
		if(a >= 500){
			u += 1000;
			a -= 500;
		}else{
			u += 5;
			a -= 5;
		}
	}
	cout << u;
}

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

using namespace std;

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

const int N = 3e2 + 5;

int n,m,a[N][N],l[N],cnt[N];
bool used[N];

inline void relax() {
  for (int i = 1 ; i <= n ; i++)
    while(l[i] <= m && used[a[i][l[i]]])
      l[i]++;
}

inline bool is_gg() {
  for (int i = 1 ; i <= n ; i++)
    if (l[i] > m)
      return true;
  return false;
}

bool check(int x) {
  memset(used,0,sizeof used);
  for (int i = 1 ; i <= n ; i++)
    l[i] = 1;
  int adim = 0;
  while(true) {
    relax();
    if (is_gg())
      break;
    memset(cnt,0,sizeof cnt);
    for (int i = 1 ; i <= n ; i++)
      cnt[a[i][l[i]]]++;
    bool ok = true;
    for (int i = 1 ; i <= m ; i++)
      if (cnt[i] > x) {
        ok = false;
        used[i] = true;
        break;
      }
    if (ok == true)
      return true;
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1 ; i <= n ; i++)
    for (int j = 1 ; j <= m ; j++)
      cin >> a[i][j];
  int l = 0,r = n;
  while(l < r) {
    int mid = (l + r - 1);
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << r << endl;;
}

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

int main()
{
    int n;
    cin >> n;
    long a[n], ans = 0;
    size_t j = 0;

    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (j = 0;; j++)
    {
        if (a[j] % 2 == 0)
        {
            a[j] /= 2;
        }
        else
        {
            break;
        }
        if (j == n - 1)
        {
            ans++;
            j = 0;
        }
    }

    cout << ans << endl;
}


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

int main() {
    int d, g, p[10], c[10];
    cin >> d >> g;
    for (int i = 0; i < d; i++) cin >> p[i] >> c[i];

    int solve_num = 10 * 100;

    for (int combination = 0b0; combination < (1 << d); combination++) {
        int const_score = 0, const_num = 0, not_used_max = -1;
        for (int i = 0; i < d; i++) {
            if ((combination >> i) & 1) {
                const_score += (i + 1) * 100 * p[i] + c[i];
                const_num += p[i];
            } else {
                not_used_max = i;
            }
        }

        int adjust_unit, adjust_score, adjust_num = 0;
        if (const_score < g) {
            adjust_unit = (not_used_max + 1) * 100;
            adjust_score = g - const_score;
            adjust_num = (adjust_score / adjust_unit) + (adjust_score % adjust_unit > 0 ? 1 : 0);
            if (adjust_num >= p[not_used_max]) continue;
        }

        solve_num = min(solve_num, const_num + adjust_num);
    }

    cout << solve_num << endl;
}

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


int main(void) {
	
	char ch[5000];
	int i;
	
	for(i=0;i<5000;i++){
		scanf("%c", &ch[i]);
		if( ch[i] == '\n' ){
			break;
		}
	}
	
	for(i=0;i<5000;i++){
		if ( ch[i] >= 'A' && ch[i] <= 'Z' ){
			printf("%c",ch[i] + 'a' - 'A');
		} else if (ch[i] >= 'a' && ch[i] <= 'z') {
			printf("%c",ch[i] - 'a' + 'A');
		} else {
			printf("%c",ch[i]);
		}
		if( ch[i] == '\n' ){
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 524
# include <iostream>
# include <string>
# include <algorithm>
# include <map>
using namespace std;
map<int,int> mp;
int n;
int ans;
int main()
{
	cin>>n;
	int a[n+10];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	for(int i=0;i<n;i++)
	{
		if(mp[a[i]]!=a[i])
		{
			if(mp[a[i]]<a[i])
			{
				ans+=mp[a[i]];
				mp[a[i]]=0;
			}
			else
			{
				ans+=mp[a[i]]-a[i];
				mp[a[i]]=0;
			}
		}
	}
	cout<<ans;
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    
    vector<vector<int> > vvs;
    vector<int> vp;
    vector<int> vc;
    for (int i = 1; i <= m; i++) {
        vector<int> vs;
        for (int j = 0; j < n; j++) {
            vs.push_back(0);
        }
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            vs[s-1] = 1;
        }
        vvs.push_back(vs);
    }
    for (int i = 1; i <= m; i++) {
        int p;
        cin >> p;
        vp.push_back(p);
        vc.push_back(0);
    }
    
    int s = 0;
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < m; j++) {
            vc[j] = 0;
        }
        int idx = 0;
        int tmpI = i;
        while (idx < n) {
            if (tmpI & 1) {
                for (int j = 0; j < m; j++) {
                    if (vvs[j][idx]) {
                        vc[j] += 1;
                    }
                }
            }
            tmpI >>= 1;
            idx++;
        }
        bool isOn = true;
        for (int j = 0; j < m; j++) {
            isOn = isOn && (vp[j] == (vc[j] % 2));
        }
        if (isOn) {
            s++;
        }
    }
    
    cout << s << endl;
    return 0;
}


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

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    if (K == 0) {
        cout << 1 << endl;
        return 0;
    }

    constexpr ll MOD = 1e9 + 7;

    vector<ll> dp(K + 1, 0);
    for (ll i = 0; i <= a[0]; i++) {
        dp[i] = 1;
    }
    for (ll i = 1; i <= K; i++) {
        dp[i] += dp[i - 1];
    }

    for (ll i = 1; i < N; i++) {
        for (ll j = K; j >= 0; j--) {
            dp[j] = (dp[j] - (j - a[i] - 1 < 0 ? 0 : dp[j - a[i] - 1]) + MOD) % MOD;
        }

        for (ll j = 1; j <= K; j++) {
            (dp[j] += dp[j - 1]) %= MOD;
        }
    }

    cout << (dp[K] - dp[K - 1] + MOD) % MOD << endl;
}

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

int main(){
    using namespace std;
    unsigned long N, D, A;
    cin >> N >> D >> A;
    vector<pair<unsigned long, unsigned long>> enemies(N);
    for(auto& i : enemies){
        cin >> i.first >> i.second;
        (i.second += A - 1) /= A;
    }
    sort(enemies.begin(), enemies.end(), greater<>());
    unsigned long ans{0}, now{0};
    priority_queue<pair<unsigned long, unsigned long>> pq;
    pq.emplace(0, 0);
    for(const auto& i : enemies){
        while(pq.top().first > i.first && (now += pq.top().second))pq.pop();
        auto k = i.second - min(i.second, ans - now);
        if(k)pq.emplace(i.first - min(i.first, D * 2), k);
        ans += k;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int n,d;
	cin >> n >> d;
	vector<vector<int>> X(n,vector<int>(d));
	for(int i = 0;i<n;i++)
	for(int j =0;j<d;j++)cin >> X[i][j];

	int cnt = 0;
	for(int i = 0;i<n;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			if(i==j)continue;
			int sum  = 0;
			for(int k= 0;k<d;k++)
			{
				sum += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			}
			for(int k = 1;k*k<=sum;k++)
			{
				if(k*k==sum)
				{
					cnt++;
					break;
				}
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long

signed main(){
	ios_base::sync_with_stdio(false);
	lli l, r;
	cin >> l >> r;

	if(2019 <= r-l){
		cout << 0;
		return 0;
	}

	int res = INT_MAX;
	for(int i=l; i<=r; i++){
		for(int j=i+1; j<=r; j++){
			res = min(res, (i*j) % 2019);
		}
	}
	cout << res;

	return 0;
}

Measured memory_bytes: 256
n;a[9][9];v[9];i;x,y;d(c,u,s,i){v[c]=1;for(i=0;i++<n;)s+=a[c][i]&!v[i]?d(i,u+1,0):0;v[c]=0;return u==n?:s;}main(m){for(scanf("%d%d",&n,&m);i++<m;)scanf("%d%d",&x,&y),a[x][y]=a[y][x]=1;printf("%d",d(1,1,0));}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
int A[111];


signed main(){
    cin>>N>>M;
    rep(i,M)cin>>A[i];

    vint o,e;
    rep(i,M){
        if(A[i]%2)o.pb(A[i]);
        else e.pb(A[i]);
    }

    if(o.size()>2){
        cout<<"Impossible"<<endl;
        return 0;
    }

    if(o.size()==0){
        rep(i,e.size()){
            if(i)cout<<" ";
            cout<<e[i];
        }
        cout<<endl;
        cout<<e.size()+1<<endl;
        rep(i,e.size()){
            if(i)cout<<" ";
            if(i==0)cout<<e[i]-1;
            else cout<<e[i];
        }
        cout<<" "<<1<<endl;

    }
    else if(o.size()==1){
        cout<<o[0];
        rep(i,e.size()){
            cout<<" "<<e[i];
        }cout<<endl;

        vint ans;
        if(o[0]>1)ans.pb(o[0]-1);
        rep(i,e.size())ans.pb(e[i]);
        ans.pb(1);

        cout<<ans.size()<<endl;
        rep(i,ans.size()){
            if(i)cout<<" ";
            cout<<ans[i];
        }
        cout<<endl;
    }
    else{
        cout<<o[0]<<" ";
        rep(i,e.size())cout<<e[i]<<" ";
        cout<<o[1]<<endl;

        vint ans;
        if(o[0]>1)ans.pb(o[0]-1);
        rep(i,e.size())ans.pb(e[i]);
        ans.pb(o[1]+1);

        cout<<ans.size()<<endl;
        rep(i,ans.size()){
            if(i)cout<<" ";
            cout<<ans[i];
        }cout<<endl;
    }
    return 0;
}


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

int n, k;
vector<int> books[11];
int dp[11][2001];
int main()
{
  //chap1
  for(int i = 1; i <= 10; i++)
    books[i].push_back(0);
  
  //chap2
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    int c, g;
    cin >> c >> g;
    books[g].push_back(c);
  }

  //chap3
  for(int i = 1; i <= 10; i++)
    sort(books[i].begin() + 1, books[i].begin() + books[i].size(), greater<int>());  
  
  //chap4
  for(int i = 1; i <= 10; i++)
    for(int j = 2; j < books[i].size(); j++)
      books[i][j] += books[i][j - 1] + 2 * (j - 1);

  //chap5
  for(int i = 1; i <= 10; i++)
    for(int j = 0; j <= k; j++)
      for(int sell = 0; sell + j <= k && sell < books[i].size(); sell++)
	dp[i][j + sell] = max(dp[i][j + sell], dp[i - 1][j] + books[i][sell]);

  cout << dp[10][k] << endl;
  return 0;
}

Measured memory_bytes: 1316
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>

using Input = std::vector<std::string>;
using Num = std::vector<int>;

Input input(void) {
	Input result;
	{
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				result.push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		result.push_back(row);
	}
	return result;
}

Num replaceToInteger(Input original = {""}) {
	Num result;
	for (unsigned int i = 0; i < original.size(); i++) {
		result.push_back(atoi(original[i].c_str()));
	}
	return result;
}

int main(void) {

	Num s = replaceToInteger(input());

	int a = 0, b = 0;

	a = s[0];
	b = s[1];

	if (0 == (a * b) % 2) {
		printf("Even\n");
	} else {
		printf("Odd\n");
	}

	return NULL;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> M >> N;
	M += 100;
	vector<int>v(301,1);
	for (int i = 0; i < N; i++) {
		cin >> K;
		v[K + 100] = 0;
	}
	int ans = 0;
	for (int i = 0; i <= 300; i++) {
		if (!v[i])continue;
		if (abs(ans - M) > abs(M - i))ans = i;
	}
	cout << ans - 100 << endl;
	return 0;
}

Measured memory_bytes: 3648
n = int(input())
s = input()

temp = s[1:].count('E')
ans = temp
for i in range(1, n):
    if s[i] == 'E':
        temp -= 1
    if s[i - 1] == 'W':
        temp += 1
    ans = min(ans, temp)
print(ans)


Measured memory_bytes: 3672
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int h,w;
    cin>>h>>w;
    queue<pair<int,int>> que;
    vector<vector<int>> field(h,vector<int>(w,-1));
    for(int i=0;i<h;i++){
        string a;
        cin>>a;
        for(int j=0;j<w;j++){
            if(a[j]=='#'){
                field[i][j]=0;
                que.push({i,j});
            }
        }
    }
    auto isRange=[&](int x,int y){
        return 0<=x && x<h && 0<=y && y<w;
    };
    int res=0;
    while(!que.empty()){
        auto tmp=que.front(); que.pop();
        int x=tmp.first,y=tmp.second;
        for(int i=0;i<4;i++){
            int tox=x+dx[i],toy=y+dy[i];
            if(isRange(tox,toy) && field[tox][toy]==-1){
                res=field[tox][toy]=field[x][y]+1;
                que.push({tox,toy});
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	long long x, y, z;
	cin >> x >> y >> z;
	for (int i = 100000; i >= 0; i--) {
		if (x >= y * i + z * i + z) {
			cout << i << "\n";
			return;
		}
	}
}

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


Measured memory_bytes: 256
s=int(input())
a=s//100
b=s%100

if 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
elif 1<=a<=12 and not 1<=b<=12:
    print('MMYY')
elif not 1<=a<=12 and 1<=b<=12:
    print('YYMM')
else:
    print('NA')

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

template < typename Monoid >
struct Segtree{
    using FM = function < Monoid(Monoid, Monoid) >;
    using FA = function < void(Monoid&, Monoid) >;
    int N;
    vector<Monoid> dat;
    
    const FM fm;
    const FA fa;
    const Monoid M1;

    Segtree(int n,const FM fm, const FA fa, const Monoid &M1): fm(fm), fa(fa), M1(M1){
        N = 1;
        while(N < n) N *= 2;
        dat.assign(2*N,M1);
    }

    void set(int idx, const Monoid &x){
        dat[idx+N-1] = x;
    }

    void build(){
        for(int i=N-2; i>=0; i--){
            dat[i] = fm(dat[2*i+1], dat[2*i+2]);
        }
    }

    void update(int idx, const Monoid &x){
        idx += N-1;
        fa(dat[idx],x);
        while(idx > 0){
            idx = (idx-1)/2;
            dat[idx] = fm(dat[idx*2 + 1], dat[idx*2+2]);
        }
    }

    Monoid get(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return M1;
        if(a<=l && r<=b) return dat[k];
        else{
            Monoid vl = get(a,b,k*2+1,l,(l+r)/2);
            Monoid vr = get(a,b,k*2+2,(l+r)/2,r);
            return fm(vl,vr);
        }
    }
    Monoid get(int a,int b){ return get(a,b,0,0,N); }

    Monoid at(int k) {return dat[k+N-1];}

    void debug(){
        for(int i=N-1;i<dat.size();i++){
            cerr << dat[i] << ", ";
        }
        cerr << "\n";
    }
};

// RMQ
// auto fm = [](ll a,ll b){ return min(a,b); };
// auto fa = [](ll& a, ll b){ min(a,b); };
// Segtree<ll> seg(n, fm, fa, INF);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,q;
    cin>>n>>q;
    auto fm = [](ll a,ll b){ return min(a,b); };
    auto fa = [](ll& a, ll b){ a=b; };
    Segtree<ll> seg(n, fm, fa, (1LL<<31)-1);

    while(q--){
        int c;
        cin>>c;
        if(c == 0){
            ll i,a;
            cin>>i>>a;
            seg.update(i,a);
        }
        else{
            int l,r; cin>>l>>r;
            cout << seg.get(l,r+1) << "\n";
        }
    }
    

}


Measured memory_bytes: 4892
import java.util.Scanner;

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

      for (int i = 0; i < num; i++) {
          array[i] = sc.nextInt();
      }

      print(array);
      for (int i = 1; i < array.length; i++) {
          int key = array[i];
          int j = i - 1;
          while (j >= 0 && array[j] > key) {
              array[j+1] = array[j];
              j--;
          }
          array[j+1] = key;
          print(array);
      }

  }

  public static void print(int[] array) {
      for (int i = 0 ; i < array.length - 1; i++) {
          System.out.print(array[i] + " ");
      }
      System.out.println(array[array.length-1]);
  }
}


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

int main() {
	int x;
	cin >> x;
	int ans = 0;
	if(x>=1800){
	     ans=1;
	}else if(x>=1600){
	     ans=2;
	}else if(x>=1400){
	     ans=3;
	}else if(x>=1200){
	     ans=4;
	}else if(x>=1000){
	     ans=5;
	}else if(x>=800){
	     ans=6;
	}else if(x>=600){
	     ans=7;
	}else if(x>=400){
	     ans=8;
	}
	cout << ans;
	return 0;
}


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

int main(int argc, char const *argv[])
{
  unsigned long long power = 1;
  int N;
  cin >> N;
  for(int i = 1; i <= N; ++i)
    power = i * power % 1000000007;
  cout << power << flush;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};



//#define int ll
signed main(){
    string s;
    cin>>s;
    if(s.size()==1){
        cout<<s<<endl;
        return 0;
    }
    int k;
    cin>>k;
    k--;
        int cnt=0;
        rep(i,0,s.size()){
            if(s[i]=='1')cnt++;
            else {
                if(cnt<=k)cout<<s[i]<<endl;
                return 0;
            }
            if(cnt>k){
                cout<<'1'<<endl;
                return 0;
            }
        }
    
    cout<<s[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
function main(input: string) {
  const inputNumbers: string[] = input.split(' ')
  const A: number = parseInt(inputNumbers[0], 10)
  const B: number = parseInt(inputNumbers[1], 10)

  A * B % 2 === 0 ? console.log('Even') : console.log('Odd')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
l, r = input().split()
l = int(l)
r = int(r)

l_q = l // 2019
r_q = r // 2019
l_mod = l % 2019
r_mod = r % 2019

mod_min = 2019

if l_q < r_q:
    print(0)
else:
    for i in range(l_mod, r_mod):
        for j in range(i+1, r_mod+1):
            mod = (i * j) % 2019
            if mod < mod_min:
                mod_min = mod
    
    print(mod_min)


Measured memory_bytes: 3064