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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 2e5 + 10;
int n;
string s;
int res[MAX];
int znaj(int a){
  while(1){
    a++;
    if(a == 2*n)a = 0;
    if(res[a] != 0)return a;
  }
}
int sumk[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> s;
  s+='1';
  int ost = 1;
  int ak = 1;
  int il = 2*n + 1;
  vector<int> spec;
  bool cz = 0;
  int ilx = 0;
  R(i,n*2){
    if(s[i] == '0'){
      cz = 0;
      if(ost == 0){
        res[i] = il / 2;
        il--;
      }else{
        res[i] = ak;
      }
      ost = 0;
    }else{
      if(ost == 0){
        res[i] = ak;
        ak++;
      }else{
        if(cz == 0){
          cz = 1;
          spec.PB(i);
        }
        ilx++;
      }
      ost = 1;
    }
  }
  if(ilx&1){
    cout << "No\n";
    return 0;
  }
  
  R(i,n*2){
    cerr << res[i] << " ";
  }
  cerr << "\n";
  debug(ilx);
  
  
    debug(spec);
  if(ilx % 4 == 2){
    debug(s[0],s[2 * n - 2]);
    if(s[0] == '1' && s[2 * n - 2] == '1'){
      spec.pop_back();
    }
    debug(spec);
    if(SZ(spec) <= 1){
      cout << "No\n";
      return 0;
    }
    res[spec[0]] = ak;
    res[spec[1]] = ak;
    ak++;
    int a = znaj(spec[0]);
    int b = znaj(spec[1]);
    swap(res[a],res[b]);
  }
  
  R(i,n*2){
    sumk[res[i]] += i;
  }
  cout << "Yes\n";
  
  R(i,n*2){
    cerr << res[i] << " ";
  }
  cerr << "\n";
  int x = 0;
  vector<int> pom;
  while(x != 2 * n){
    if(res[x] != 0){
      x = sumk[res[x]] - x;
    }
    if(res[x] == 0)
      pom.PB(x);
    x++;
  }
  debug(pom);
  for(int i = 0;i < SZ(pom);i+=4){
    res[pom[i]] = ak;
    res[pom[i+1]] = ak+1;
    res[pom[i+2]] = ak;
    res[pom[i+3]] = ak+1;
    ak+=2;
  }
  R(i,n*2){
    cout << res[i] << " ";
  }
  cout << "\n";
}


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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int h,w;
    
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        rep(i,0,h){
            rep(j,0,w){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    
    }
    
    
    return 0;
}


Measured memory_bytes: 3236
N,M=list(map(int,input().split()))
import sys
l=[list(map(int,_.rstrip().split())) for _ in sys.stdin.readlines()]
n=sorted(l,key=lambda x:x[1])
dic={}
mem=[0]*N
for i,j in n:
   mem[i-1]+=1
   dic[i,j]=str(i).zfill(6)+str(mem[i-1]).zfill(6)
for i,j in l:
   print(dic[i,j])

Measured memory_bytes: 50892
#include<stdio.h>
int main(){
    int H[10000], W[10000];
    int length;
    int i=0, j, k;
    do{
        scanf("%d %d", &H[i], &W[i]);
        i += 1;
    }while(H[i-1]!=0 || W[i-1]!=0);
    length = i;
    for(i=0; i<length-1; i++){
        for(j=0; j<H[i]; j++){
            for(k=0; k<W[i]; k++){
                if(j==0 || j==H[i]-1 || k==0 || k==W[i]-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2700
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val (n, k) = readListOfInt()
    println(if(n % k == 0) 0 else 1)

    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 35956
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a,b,t;
    cin>a>b>t;
    cout<t/a*b<endl;
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"log"
	"os"
)

var (
	Anser = []string{"Even", "Odd"}
)

func main() {
	fmt.Println(ABC086(nil))
}

func ABC086(in *os.File) string {
	if in == nil {
		in = os.Stdin
	}
	var a, b int
	fmt.Fscanf(in, "%d", &a)
	fmt.Fscanf(in, "%d", &b)
	c := (a * b) % 2
	log.Printf("input [%d, %d], anser = %s", a, b, Anser[c])
	return Anser[c]
}


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

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int n;
	cin >> n;
	vi a(n);
	map<int, int> mp;
	rep(i, n) {
		cin >> a.at(i);
		mp[a.at(i)]++;
	}
	int ans = 0;
	rep(i, n) {
		if (mp[a.at(i)] != 0) {
			if (mp[a.at(i)] > a.at(i)) {
				ans += mp[a.at(i)] - a.at(i);
			}
			else if (mp[a.at(i)] < a.at(i)) {
				ans += mp[a.at(i)];
			}
			mp[a.at(i)] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>

typedef long long ll;

int main(){
   int N, M, K;
   std::cin >> N >> M >> K;

   int A[N+1], B[M+1];
   ll sa[N+1], sb[M+1];
   sa[0] = 0;
   sb[0] = 0;
   for(int i=1; i<=N; ++i){
      std::cin >> A[i];
      sa[i] = sa[i-1] + A[i];
   }
   for(int i=1; i<=M; ++i) {
      std::cin >> B[i];
      sb[i] = sb[i-1] + B[i];
   }

   if(sa[N]+sb[M]<=K) {
      std::cout << N + M << std::endl;
      return 0;
   }

   int ans = 0;
   int bi = M;
   for(int i=0; i<=N; ++i){
      for(int j=bi; j>=0; --j){
	 if(sa[i]+sb[j]<=K) {
	    ans = std::max(ans, i + j);
	    break;
	 }else {
	    bi = j;
	 }
      }
   }


   std::cout << ans << std::endl;

   return 0;
}


Measured memory_bytes: 8312
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int maxn = 200010;

struct node {
	int s,m,e;
	int v;
	node *l, *r;
	node(int _s, int _e) {
		s = _s; e = _e; m = (s+e)/2;
		v = INT_MIN/2;
		if (s != e) {
			l = new node(s,m);
			r = new node(m+1, e);
		}
	}
	
	void up(int x, int newv) {
		if (s == e) {
			v = newv;
			return;
		}
		if (x > m) r -> up(x,newv);
		if (x <= m) l -> up(x,newv);
		v = max(l->v, r->v);
	}
	
	int rmq(int x, int y) {
		if (s == x and e==y) return v;
		if (x > m) return r -> rmq(x,y);
		if (y <= m) return l -> rmq(x,y);
		return max(l->rmq(x,m), r->rmq(m+1,y));
	}
}*root;

vector <int> disc(vector <int> V) {
	vector <int> dis = V;
	sort(dis.begin(),dis.end());
	dis.resize(unique(dis.begin(),dis.end()) - dis.begin());
	for (int i =0;i<(int)V.size();i++) {
		V[i] = lower_bound(dis.begin(),dis.end(),V[i]) - dis.begin() + 1;
	}
	return V;
}

vector <int> adjlist[maxn];
int n;
int ans[maxn];
int A[maxn];
vector <int> values[maxn];

void dfs(int x, int p) {
	
	for (auto i: adjlist[x]) {
		if (i == p) continue;
		int res = root -> rmq(0, A[i] - 1);
		if (res == INT_MIN/2) res = 0;
		root -> up(A[i], res + 1);
		values[A[i]].push_back(res+1);
		
		ans[i] = root -> rmq(0,n+1);
		
		dfs(i,x);
		
		values[A[i]].pop_back();
		int reset = (values[A[i]].empty() ? INT_MIN/2 : values[A[i]].back());
		root -> up(A[i], reset);
	}
	
}

int32_t main() {
	FAST
	cin >> n;
	vector <int> v(n);
	for (int i =0;i<n;i++) {
		cin >> v[i];
	}
	v = disc(v);
	for (int i =1;i<=n;i++) A[i] = v[i-1];
	root = new node(0,n+1);
	
	for (int i =0;i<n-1;i++) {
		int a,b; cin >> a >> b;
		adjlist[a].push_back(b);
		adjlist[b].push_back(a);
	}
	
	root -> up(A[1],1);
	ans[1] = 1;
	
	dfs(1,-1);
	for (int i =1;i<=n;i++) {
		cout << ans[i] << "\n";
	}
}





Measured memory_bytes: 88040
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

int main(void){
	int N;
	cin >> N;
	int a = N/100;
	int b = (N-a*100)/10;
	int c = N-a*100-b*10;
	if(N==c*100+b*10+a){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

int main() {
	cin.tie(NULL); cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<int> a(N + 1);
	for (int i = 1; i <= N; i++) cin >> a[i];
	
	for (int i = K + 1; i <= N; i++) {
		if (a[i - K] < a[i]) cout << "Yes\n";
		else cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3988
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) { return; }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) { return; }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        string command;
        cin >> command;
        if (command == "insert") {
            int key;
            scanf("%d", &key);
            insert(key);
        } else if (command == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 26680
//#define DEBUG
//#define USEPB_DS
#define USETR1
#define CPPELEVEN
#define GPP

/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

using namespace std;

#define mpr make_pair
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef pair <int, int> pii;



const int maxn = 255;
pii range[maxn * 2];
ll dp[maxn][maxn];
int to[maxn];
int n, mod;

int main() {
  //....................................................................
  ios_base::sync_with_stdio(0);
  #ifdef DEBUG //......................................................................................................
  freopen("input.txt", "r", stdin);
  #endif //...........................................................................................................

  cin >> n >> mod;
  for (int i = 0; i < 2 * n; i++) {
    for (int j = 0; j < 2 * n; j++) {
      if (j * j + i * i < n * n) range[i].first = j + 1;
      if (j * j + i * i <= 4 * n * n) range[i].second = j + 1;
    }
  }

  ll ans = 0;
  for (int cnt = 0; cnt <= n; cnt++) {
	  memset(dp, 0, sizeof(dp));
	  dp[n][0] = 1;
	  int l = 2 * n - 1;
	  for (int i = n - 1; i >= 0; i--) {
		  int rl = l;
		  for (int j = 0; j < min(n - i, cnt + 1); j++) {
			  ll rans = dp[i + 1][j];
			  if (!rans) continue;
			  l = rl;
			  while (l >= n && range[l].second <= range[i].first) {
				  rans = rans * (range[l].second - j - 2 * n + 1 + l) % mod;
				  l--;
			  }
			  dp[i][j + 1] += rans * max(0, (range[i].first - (j + 2 * n - 1 - l))) % mod;
			  if (dp[i][j + 1] >= mod) dp[i][j + 1] -= mod;
			  dp[i][j] += rans * max(0, range[i].second - (2 * n - 1 - i + cnt - j)) % mod;
			  if (dp[i][j] >= mod) dp[i][j] -= mod;
		  }
	  }
	  while (l >= n) {
		  dp[0][cnt] *= range[l].second - cnt - 2 * n + 1 + l;
		  dp[0][cnt] %= mod;
		  l--;
	  }
	  ans += dp[0][cnt] * ((1 - cnt % 2) * 2 - 1);
  }
  cout << (ans % mod + mod) % mod << endl;

  return 0;
}


Measured memory_bytes: 896
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

sum = 0
a_j = lines[0].first

lines[1].each {|a_i|
  sum += lines[2][a_i - 1]
  sum += lines[3][a_j - 1] if a_i == (a_j + 1)
  a_j = a_i
}

puts sum

Measured memory_bytes: 1788
A, B = map(int, input().split())

def xor(n):
    if n%4==0:
        return 1^(n+1)
    elif n%4==1:
        return 1
    elif n%4==2:
        return n+1
    else:
        return 0



print(xor(A-1)^xor(B))

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s, t, u;
int a,b;
void solve(){
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	
	if(s == u) a--;
	else b--;
	cout << a << " " << b << endl;
}

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

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static String solve() {

		int a = 0, b = 0;

		int[] x = new int[10];

		for (int i=0; i<10; i++) {
			x[i] = in.nextInt();
		}

		for (int i=0; i<10; i++) {
			if (x[i] < a && x[i] < b) return "NO";
			if (a < x[i] && b < x[i]) {
				if (a > b) a = x[i];
				else b = x[i];
			} else if (a < x[i]) {
				a = x[i];
			} else {
				b = x[i];
			}
		}

		return "YES";
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		int n = in.nextInt();

		while (n-- > 0) out.println(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

int main() {
  int n, m, f;
  while (cin >> n >> m >> f, n) {
    vector<int> x(n);
    rep (i, n) cin >> x[i];

    float sum = 0;
    rep (i, n) sum += 100.0*x[i];

    float ret = sum - ((float)f/100) * sum;

    int ans = ret / x[m-1];
    cout << (ans > 0 ? ans : 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 3020
cash = 1000
stock = 0
N = int(input())
l = list(map(int, input().split()))

downTrend = True

prev = l[0]
for i in range(1, N):
    A = l[i]
    if downTrend == True:
        if A < prev:
            prev = A
        else:
            stock, cash = divmod(cash, prev)
            prev = A
            downTrend = False
    else:
        if A > prev:
            prev = A
        else:
            cash += stock * prev
            stock = 0
            downTrend = True
            prev = A
cash += stock * prev

print(cash)


Measured memory_bytes: 61912
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		// sb.append("");// ??????????????\???????????????
		int h, w, c;
		c = 0;// ?????¶??§???????????°

		while (true) {
			h = scan.nextInt();// ????????????
			w = scan.nextInt();// ?¨??????????
			// h??¨w?????¨??????0????????£?????¨??????????????????????????????
			if ((h == 0) & (w == 0)) {
				break;
			}
			//????????????????????????
			for(int count = 0;count<h;count++){
				//?¨??????????????????????
				for(int count2 = 0;count2<w;count2++){
					if(c % 2 == 0){
						sb.append("#");
						c++;
					}else{
						sb.append(".");
						c++;
					}
				}
				sb.append("\n");
				c = count+1;
					
			}

			System.out.println(new String(sb));
			// StringBuilder????????????????????????
			sb.delete(0, sb.length());
			c = 0;// ?????¶??§???????????°????????????
		}

	}
}

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

int main(){
  ll L, R; cin>>L>>R;
  ll l=L%2019;
  ll r=R%2019;
  if(r<=l || (R-L)>=2018) cout<<0<<endl;
  else{
    ll min=2020;
    for(ll i=l; i<=r-1; i++){
      for(ll j=i+1; j<=r; j++){
        if((i*j)%2019<min) min=(i*j)%2019;
      }
    }
    cout<<min<<endl;
  } //else
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long h = scanner.nextLong();
    long w = scanner.nextLong();

    if (h == 1 || w == 1) {
      System.out.println(1);
    } else if (h % 2 == 0 || w % 2 == 0) {
      System.out.println((h * w) / 2);
    } else {
      System.out.println((h * w) / 2 + 1);
    }

  }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
    bool can = false;
    for (int i=1; i <= 9; i++) {
        for (int j=1; j <= 9; j++) {
            if (i*j == N) {
                can = true;
            }
        }
    }
    if (can) {
        printf("%s\n", "Yes");
    } else {
        printf("%s\n", "No");
    }
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String in = sc.next();
		if(s.equals(in)) {
			a--;
		} else if(t.equals(in)) {
			b--;
		}
		System.out.println(a + " " + b);
	}

}


Measured memory_bytes: 21844
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>

using namespace std;

int main(void)
{
	vector <int> A(3);

	for (int i = 0; i < 3; i++)
	{
		cin >> A[i];
	}
	
	sort(A.begin(), A.end());
	
	if (A[0] + A[1] == A[2])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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
















int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll t = n / (a + b);
    cout << t * a + min((n - t * (a + b)), a) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[1005];

int main(void)
{
	int i, j, cost[1005], n, m, b;
	int ans;
	
	scanf("%d %d", &n, &m);
	
	for (i = 0; i < n; i++){
		scanf("%d", &cost[i]);
	}
	
	for (i = 0; i < m; i++){
		scanf("%d", &b);
		for (j = 0; j < n; j++){
			if (cost[j] <= b){
				a[j]++;
				break;
			}
		}
	}
	ans = 0;
	for (i = 0; i < n; i++){
		if (a[ans] < a[i]) ans = i;
	}
	
	printf("%d\n", ans + 1);
	
	return (0);
}
		

Measured memory_bytes: 604
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		int n=scn.nextInt();
		int k=scn.nextInt();
	   int []arr =new int[n];
	   for(int i=0;i<n;i++){
		   arr[i]=scn.nextInt();
		   
	   }
Arrays.sort(arr);
             long sum=0;
             for(int i=0;i<k;i++){
            	 sum+=arr[i];
             }
             System.out.println(sum);
	}

}

Measured memory_bytes: 39048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>


using namespace std;

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

	vector<tuple<string, int, int>> rs(n);
	for (int i = 0; i < n; i++) {
		cin >> get<0>(rs[i]) >> get<1>(rs[i]);
		get<1>(rs[i]) *= -1;
		get<2>(rs[i]) = i + 1;

	}

	sort(rs.begin(), rs.end());
	for (int i = 0; i < n; i++) {
		cout <<  get<2>(rs[i]) << endl;
	}

}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <iomanip>

using namespace std;


int main(){
    int N;
    cin >> N;

    uint64_t Ai[200001]={};

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

    uint64_t divnum = (uint64_t) (1*pow(10,9)+7); 
    uint64_t outnum =0;
    for(int i=0; i< N-1;++i){
        uint64_t temp;
        sum -= Ai[i]; 
        temp = sum % divnum;

        temp = temp * Ai[i];
        temp = temp % divnum;
        outnum += temp;
        outnum = outnum % divnum;
    }

    cout<< outnum <<endl;
}



Measured memory_bytes: 5196
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	//https://qiita.com/tnoda_/items/b503a72eac82862d30c6

	//1行ずつ読み込む
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	s := sc.Text()
	x, _ := strconv.Atoi(s)

	happiness := 0

	happiness += x / 500 * 1000
	x = x % 500

	happiness += x / 5 * 5
	x = x % 5
	fmt.Println(happiness)

}


Measured memory_bytes: 640
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m,k;cin>>n>>m>>k;
  V<ll> a(n+1,0),b(m+1,0);
  rep(i,0,n)cin>>a[i+1];
  rep(i,0,m)cin>>b[i+1];

  rep(i,0,n)a[i+1]+=a[i];
  rep(i,0,m)b[i+1]+=b[i];
  b.pb(LINF);


  ll ans=0;
  rep(i,0,n+1){
    ll rem=k-a[i];
    if(rem<0)break;

    auto itr=ub(all(b),rem);
    
    chmax(ans,i+distance(b.begin(),--itr));
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 7952
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pii;
const ll base=1000000000;
const int n2=9;
const int n5=9;
int n;
ll ans;
int bucket[555][555];
pii get(ll x)
{
	int x2=-n2,x5=-n5;
	while(x%2==0)
		x/=2,++x2;
	while(x%5==0)
		x/=5,++x5;
	return pii(x2,x5);
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int e=1;e<=n;++e)
	{
		string s;
		cin>>s;
		ll x=0,G=base,f=0;
		for(int i=0;i<s.size();++i)
		{
			if(s[i]=='.')
			{
				f=1;
				continue;
			}
			x=x*10+s[i]-'0';
			if(f)
				G/=10;
		}
		x=x*G;
		pii g=get(x);
		int x2=g.first,x5=g.second;
		for(int j=-x2;j<=46;++j)
			for(int k=-x5;k<=21;++k)
				if(x2+j>=0&&x5+k>=0)
					ans+=bucket[j+50][k+50];
		++bucket[x2+50][x5+50];
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  vector<int> a(5),b(5),c(5);
  int count = 0, plus = 0;

  //入力
  for(int i = 0; i < 5; i++){
    cin >> a.at(i);
    b.at(i) = a.at(i) % 10;//10で割ったあまり
    c.at(i) = a.at(i) / 10;//10で割った商
  }
  //昇順ソート
  sort(b.begin(),b.end());

  //端数の考慮
  for(int i = 0; i < 5; i++){
    if(b.at(i) != 0){
      count++;
    }
  }
  //すべて10で割り切れた場合と区別して処理
  if(count != 0){
    count -= 1;
  }
  //0でない余りの最小値
  for(int i = 0; i < 5; i++){
    if(b.at(i) != 0){
      plus = b.at(i);
      break;
    }
  }
  //出力
  for(int i = 0; i < 5; i++){
    count += c.at(i);
  }
  cout << count * 10 + plus ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define BUG cout << "acdsfas" << endl
#define int long long

const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 16;
int n, a[N][N], dp[1 << N];

main() {
    cin >> n;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            cin >> a[i][j];
    for(int mask = 0; mask < (1 << n); ++mask)
        for(int i = 0; i < n; ++i)
            for(int j = i + 1; j < n; ++j)
                if((1 << i) & mask)
                    if((1 << j) & mask)
                        dp[mask] += a[i][j];
    for(int mask = 0; mask < (1 << n); ++mask)
        for(int s = mask; s; s = (s - 1) & mask)
            dp[mask] = max(dp[s] + dp[mask ^ s], dp[mask]);
    cout << *max_element(dp, dp + (1 << n)) << endl;
    return 0;
}

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

int main()
{
    int a;
    cin>>a;
    if (a==25){
        cout<< "Christmas" <<endl;
    } else if (a==24) {
        cout<< "Christmas Eve" <<endl;
    } else if (a==23) {
        cout<< "Christmas Eve Eve" <<endl;
    } else if (a==22) {
        cout<< "Christmas Eve Eve Eve" <<endl;
    }
}

Measured memory_bytes: 256
ans = 0

N = int(raw_input())

A = []

for i in range(N):
  A.append(int(raw_input()))

A.append(0)

for i in range(N):

  while True:

    if A[i] == 0:
      break

    elif A[i] == 1:

      if A[i + 1] >= 1:
        A[i + 1] -= 1
        ans += 1

      break

    ans += A[i] / 2

    A[i] = A[i] % 2

print ans

Measured memory_bytes: 8964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int count=0;
  cin >> N;
  int L[N];
  for (int i=0;i<N;i++) {
    cin >> L[i];
  }
  for (int i=0;i<N;i++) {
    for (int j=i+1;j<N;j++) {
      for (int k=j+1;k<N;k++) {
        if((L[i]!=L[j]&&L[i]!=L[k]&&L[j]!=L[k])&&(L[i]+L[j]>L[k]&&L[j]+L[k]>L[i]&&L[k]+L[i]>L[j])) count++;
      }
    }
  }
  cout << count;
}

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

int main(){
    int m, d, ans=0;
    cin >> m >> d;
    int d1, d2;
    for(int i=1; i<=m; ++i){
        for(int j=22; j<=d; ++j){
            d1 = j/10;
            d2 = j%10;
            if((d1*d2) == i && (d2>1)) {
                ++ans;
            }
            
        }
    }   
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define ll long long int 
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;

int main(){

	char s[200];
	scanf("%s", s + 1);
	rep(i, 1, 3) printf("%c", s[i]);
	return 0;
}



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

int main() {
  int r;

  cin >> r;
  cout << fixed << setprecision(10);
  cout << 2*r*3.14159265358979 << endl;
  return 0;
}

Measured memory_bytes: 3804
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q,W;
string s;
vi adj[N];
int dp[N];
pii a[N];

int Ans(int w)
{
	if( w <= 0 ) return  0;

	int& ans = dp[w];

	if( ~ans ) return ans;

	ans = inf;

	fo(i,0,n) ans = min( ans , a[i].sc + Ans( w - a[i].f ) );

	return ans;
}

void go()
{
	cin >> W >> n;

	fo(i,0,n) cin >> a[i].f >> a[i].sc;

	memset( dp , -1 , sizeof dp );

	cout << Ans(W) << endl;
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}



Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
// double startTime;
// double getCurrentTime()
// {
// 	return ((double)clock()-startTime)/CLOCKS_PER_SEC;
// }

// lli pwr(lli x,lli n)
// {
// 	lli res=1;
// 	for(; n!=0;n>>=1)
// 	{
// 		if(n&1)
// 			res=(res*x)%MOD;
// 		x=(x*x)%MOD;
// 	}
// 	return res;
// }
// lli inver(lli num)
// {
// 	return pwr(num,MOD-2);
// }
// lli findncr(lli n,lli r)
// {
// 	r=min(r,n-r);
// 	if(n==0||n==1||r==0)
// 		return 1;
// 	lli numer=1;
// 	for(lli i=n;i>=n-r+1;i--)
// 		numer=(numer*i)%MOD;
// 	lli den=1;
// 	for(lli i=2;i<=r;i++)
// 		den=(den*i)%MOD;
// 	den=inver(den);
// 	lli res=(numer*den)%MOD;
// 	return res;
// }
// lli gcd(lli a,lli b)
// {
// 	if(b==0)
// 		return a;
// 	else
// 		return gcd(b,a%b);
// }
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	lli n,w;
	cin>>n>>w;
	//cout<<n<<" ";
	lli vecw[n+1]={0};
	lli vecv[n+1]={0};
	//cout<<n<<w<<" ";
	for(lli i=1;i<=n;i++)
	cin>>vecw[i]>>vecv[i];
	vector<vector<lli> >dp(n+1,vector<lli>(w+1,0));
	//dp[n+1][w+1]={0}
	for(lli i=1;i<=n;i++)
	{
		for(lli  j=1;j<=w;j++)
		{
			if(j<vecw[i])
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],(vecv[i]+dp[i-1][j-vecw[i]]));
		}
	}
	cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 80256
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
signed main(void)
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
		puts("bust");
	else
		puts("win");
	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-8
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.12lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
int gcd(int i,int j)
{
    if(i%j==0)return j;
    return gcd(j,i%j);
}
int a[304][306];
vector<int>v[305];
int r[304],w[305],vis[305];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
        for(int j=m;j>=1;j--)v[i].pb(a[i][j]);
        r[i]=m-1;
    }
    int ans=n;
    bool b1=true;

    while(b1)
    {
        int ans1=1;
        for(int j=1;j<=m;j++)w[j]=0;
        for(int i=1;i<=n;i++)
        {
            int u=r[i];
            while(u>=0&&vis[v[i][u]]==1)
            {
                u--;
            }
            r[i]=u;
            if(u<0){b1=false;break;}
            int h=v[i][u];
            w[h]++;
            ans1=max(ans1,w[h]);
        }
      //  cout<<ans1<<endl;
        ans=min(ans,ans1);
        int q=0;
        for(int j=1;j<=m;j++)
        {
           // cout<<w[j]<<" ";
            if(w[j]==ans1)vis[j]=1;
            if(vis[j]==0)q++;

        }
        if(q==0)break;
       // cout<<endl;
    }
    cout<<ans<<endl;


}




Measured memory_bytes: 1280
import numpy as np

A = []
a = [int(x) for x in input().split()]
A.append(a)
A_len = len(a)
naname1 = 0
naname2 = 0

for s in range(A_len - 1):
    A.append([int(x) for x in input().split()])

A = np.array(A)

N = int(input())
B = []




for i in range(N):
    B.append(int(input()))

for i in range(N):
    A = np.where(A==B[i], 0, A)


for i in range(A_len):
    if (A[i].sum() == 0) or (A[:,i].sum() == 0):
        print('Yes')
        exit()

for i in range(A_len):
    naname1 += A[i,i]
    naname2 += A[i,A_len-i-1]


if naname1==0 or naname2==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21912
n, m, k = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

from itertools import accumulate
from bisect import bisect_right
aacc = list(accumulate(As))
bacc = list(accumulate(Bs))

# print(aacc)
ans = 0
for i in range(n):
    a = aacc[i]
    if k - a < 0:continue
    # print(a, k-a)
    n = bisect_right(bacc, k-a)
    # print("index a",i+1, "b",n)
    ans = max(i+1+n,ans)
# 逆も然り(めんどいので)
for i in range(m):
    a = bacc[i]
    if k - a < 0:continue
    n = bisect_right(aacc, k-a)
    ans = max(i+1+n,ans)


print(ans)

Measured memory_bytes: 132288
import java.util.Scanner;

public class Main {
  static int h, w;
  static char[][] tab;

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

    h = sc.nextInt(); w = sc.nextInt();
    tab = new char[h][w];
    for(int i = 0; i < h; i++){
      tab[i] = sc.next().toCharArray();
    }

    char[][] tab2 = new char[2 * h][w];
    for(int i = 0; i < 2 * h; i++){
      for(int j = 0; j < w; j++){
        tab2[i][j] = tab[i / 2][j];
      }
    }

    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < 2 * h; i++){
      sb.append(tab2[i]); sb.append(System.lineSeparator());
    }

    System.out.print(sb);
  }
}


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

//namespace _1_A
//{
    class Program
    {
        static void Main(string[] args)
        {
        int num = int.Parse(Console.ReadLine());
        Console.WriteLine(num * num * num);
    }
    }
//}

Measured memory_bytes: 9096
N = int(input())
P = list(map(int,input().split()))
x = 0
y = sum(P)
ans = 10 ** 15
if N == 2:
    ans = abs(P[0] - P[1])
else:
    for i in range(N-1):
        x += P[i]
        y -= P[i]
        ans = min(ans, abs(x-y))
print(ans)

Measured memory_bytes: 24832
from collections import deque
n,q = map(int,input().split())
ki = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
ans = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    p -= 1
    ans[p] +=x
visited = [0]*n
stack = deque()
stack.append(0)
visited[0] = 1
while stack:
    now = stack.popleft()
    for next in ki[now]:
        if visited[next]:continue
        ans[next] += ans[now]
        stack.append(next)
        visited[next] = 1

print(*ans)
    


Measured memory_bytes: 105876
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
ll longinf=1ll<<60;
int inf=1<<29;

string s;
ll K;

int main(){
    cin>>s;
    cin>>K;
    bool f=false;
    char ans;
    rep0(i,K){
        if(i>=s.size()) break;
        if(s[i]!='1'){
            f=true;
            ans=s[i];
            break;
        }
    }
    if(f) cout<<ans<<endl;
    else cout<<1<<endl;
      return 0;
}

Measured memory_bytes: 384
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i).sort

if n == 2
  puts a[1]
  exit
end

stack = []
2.times do |j|
  i = 1
  while i <= a[j] / i
    if a[j] % i == 0
      stack << i if !stack.include?(i)
      stack << a[j] / i if !stack.include?(a[j] / i)
    end
    i += 1
  end
end

stack.sort.reverse.each do |i|
  cnt = 0
  n.times do |j|
    cnt += 1 if a[j] % i != 0
  end
  if cnt <= 1
    puts i
    exit
  end
end


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S;
  cin >> S;
  if(S=="SUN") cout << 7 << endl;
  if(S=="SAT") cout << 1 << endl;
  if(S=="FRI") cout << 2 << endl;
  if(S=="THU") cout << 3 << endl;
  if(S=="WED") cout << 4 << endl;
  if(S=="TUE") cout << 5 << endl;
  if(S=="MON") cout << 6 << endl;
  
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
   //  String[] nyu=sc.nextLine().split("");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu);
     nyu=sc.nextLine();

int D=Integer.parseInt(nyu);


//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

int res=C%500;
if(res<=D){

System.out.println("Yes");
}else{
System.out.println("No");

}




	}
}

Measured memory_bytes: 23124
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	LL a,b;
	while(scanf("%lld %lld",&a,&b)!=EOF)
	{
		LL c=a+b;
		LL d=0;
		while(c>0)
		{
			c/=10;
			d++;
		}
		printf("%lld\n",d);
	}
	
	return 0;
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	map<int,bool> ison;
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if(!ison[x]) {
			ison[x] = true;
			cnt++;
		} else {
			ison[x] = false;
			cnt--;
		}
	}
	cout << cnt;
	return 0;
}



Measured memory_bytes: 4992