akhauriyash/Code-Regression huggingface dataset:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

l,r = iim()

if l//2019 != r//2019 or l%2019 == 0 or r%2019 == 0:
    print(0)
else:
    num = float('INF')
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            num = min((i*j)%2019,num)
    print(num)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int64_t A, B, C, D;

  cin >> A >> B >> C >> D;

  int64_t S1 = A * B, S2 = C * D;

  if(S1 > S2)
    cout << S1 << endl;
  else
    cout << S2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
  while(1){
    int a, b, c;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    if(op == '?')break;
    else if(op == '+')c=a+b;
    else if(op == '-')c=a-b;
    else if(op == '*')c=a*b;
    else c=a/b;
    printf("%d\n", c);
  }
  return 0;
}

Measured memory_bytes: 2732
#include <iostream>
#define ABS(n) (((n)>0)?(n):-(n))
using namespace std;
int main()
{
  int n,i,h,w,d,b,m;
  for(;;){
    cin >> n;
    if(n==0) break;
    d = 0x1fffffff;
    while(n--){
      cin >> i >> h >> w;
      b = w*10000000 / h / h;
      if(d > ABS(22000 - b)){
	d = ABS(22000 - b);
	m = i;
      }
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "algorithm"
#include "string"
#include "set"

using namespace std;

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

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

	cin >> N >> M >> K;
	set<int>s;
	for (int i = N; i <= min(M, N + K - 1); i++) {
		s.insert(i);
	}
	for (int i = M; i >= max(N, M - K + 1); i--) {
		s.insert(i);
	}
	for (auto i : s) {
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    
    int M1,D1,M2,D2;

    scanf("%d %d",&M1,&D1);
    scanf("%d %d",&M2,&D2);

    if(M1 == M2){
        printf("0\n");
    }else{
        printf("1\n");
    }

    return 0;
}

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

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

struct Edge{
	int a,b;
	Edge(int a,int b) : a(a), b(b) {}
};

typedef vector< vector<Edge> > Graph;

void addEdge(Graph &g,Graph &rg,Edge e){
	g[e.a].push_back(e);
	rg[e.b].push_back(Edge(e.b,e.a));
}

#define VAR(x) ((x)<<1)
#define NOT(x) ((x)^1)

int done[2000] = {};
int color[2000];
Graph gr;
vector<int> tpr;

void visit(int x){
	if( done[x]++ ) return;
	rep(i,gr[x].size()) visit(gr[x][i].b);
	tpr.push_back(x);
}
int sat2(int m,vector< pair<int,int> > info){
	Graph g(2*m),rg(2*m);
	rep(i,info.size()){
		int x = info[i].first;
		int y = info[i].second;
		addEdge(g,rg,Edge(NOT(x),y));
		addEdge(g,rg,Edge(NOT(y),x));
	}
	memset(done,0,sizeof(done));
	tpr.clear();
	gr = g;
	rep(i,g.size()) visit(i);
	reverse(tpr.begin(),tpr.end());
	gr = rg;
	memset(done,0,sizeof(done));
	memset(color,-1,sizeof(color));
	vector<int> mm = tpr;
	rep(i,mm.size()){
		tpr.clear();
		visit(mm[i]);
		rep(j,tpr.size())
			color[tpr[j]] = i;
	}
	rep(i,m){
		if( color[VAR(i)] == color[NOT(VAR(i))] ) return false;
	}
	return true;
}

struct NODE{
	int notflag;
	int a,b;
	int type;
	NODE(){
		notflag = a = b = 0;
		type = -1;
	}
};

NODE dem(NODE a){
	if( a.type == -1 ){
		a.a = NOT(a.a);
	}else{
		a.type ^= 1;
		a.notflag ^= 1;
		a.a ^= 1;
		a.b ^= 1;
	}
	return a;
}
NODE donot(NODE a){
	if( a.type == -1 ){
		a.a = NOT(a.a);
	}else{
		a.notflag ^= 1;
	}
	return a;
}

string ln;
int pos;
NODE Y();
NODE X(){
	NODE l = Y();
	NODE w;
	while( ln[pos] == '|' || ln[pos] == '&' ){
		char c = ln[pos];
		pos++;
		NODE r = Y();
		w.a = l.a;
		w.b = r.a; 
		w.type = c == '&';
		l = w;
	}
	return l;
}
int dic(string name){
	static map<string,int> memo;
	if( memo.count(name) ) return memo[name];
	else{
		int t = memo.size();
		return memo[name] = t;
	}
}
bool isalp(char c){
	return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') ;
}
NODE Y(){
	if( ln[pos] == '~' ){
		pos++;
		return donot(Y());
	}
	if( ln[pos] == '(' ){
		pos++;
		NODE r = X();
		pos++;
		return r;
	}
	string name = "";
	while( isalp(ln[pos]) ){
		name += ln[pos++];
	}
	NODE w;
	w.a = VAR(dic(name));
	return w;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector< pair<int,int> > info;
	rep(i,n){
		cin >> ln;
		pos = 0;
		NODE e = X();
		if( e.notflag ) e = dem(e);
		if( e.type == 0 ) info.push_back(make_pair(e.a,e.b));
		else if( e.type == 1 ){
			info.push_back(make_pair(e.a,e.a));
			info.push_back(make_pair(e.b,e.b));
		}else{
			info.push_back(make_pair(e.a,e.a));
		}
		//;cout << (e.a&1?"~":"") << (e.a>>1) << " " << (e.b&1?"~":"") << (e.b>>1) << " " << (e.type?'&':'|') << endl;
	}
	cout << (sat2(m,info)?"accept":"reject") << endl;
}

Measured memory_bytes: 1420
unittest
{
	assert( [ "BBBWW" ].parse.expand.solve == 1 );
	assert( [ "WWWWWW" ].parse.expand.solve == 0 );
	assert( [ "WBWBWBWBWB" ].parse.expand.solve == 9 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return s.group.walkLength - 1;
}


Measured memory_bytes: 2840
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;

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

    ll N;
    cin >> N;
    vector<double> T(N + 2, 0);
    vector<double> V(N + 2, 0);

    for (ll i = 1; i <= N; i++) {
        cin >> T[i];
    }
    for (ll i = 1; i <= N; i++) {
        cin >> V[i];
    }

    double total = 2 * accumulate(T.begin(), T.end(), 0.0);
    vector<vector<double> > f(N + 2, vector<double>(total + 1, 0));

    for (ll t = 1; t <= total; t++) {
        f[0][t] = f[0][t - 1] + 0.5;
        f[N + 1][total - t] = f[N + 1][total - t + 1] + 0.5;
    }

    double lt = 0;
    double rt = 0;
    for (ll i = 1; i <= N; i++) {
        lt += 2 * T[i - 1];
        rt += 2 * T[i];

        for (ll t = lt; t <= rt; t++) {
            f[i][t] = V[i];
        }
        for (ll t = lt - 1; t >= 0; t--) {
            f[i][t] += f[i][t + 1] + 0.5;
        }
        for (ll t = rt + 1; t <= total; t++) {
            f[i][t] += f[i][t - 1] + 0.5;
        }
    }

    vector<double> velocity(total + 1);
    for (ll t = 0; t <= total; t++) {
        velocity[t] = 1e18;
        for (ll i = 0; i < N + 2; i++) {
            velocity[t] = min(velocity[t], f[i][t]);
        }
    }

    double ans = 0;
    for (ll t = 0; t < total; t++) {
        double low  = min(velocity[t], velocity[t + 1]);
        double high = max(velocity[t], velocity[t + 1]);
        ans += (low + (high - low) / 2) / 2;
    }

    cout << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 32836
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
 
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
/*
 1≤N≤10^5
1≤L≤10^9
1≤T≤10^9
0≤X1<X2<…<XN≤L−1
1≤Wi≤2
Wi が 1 なら時計回りに、Wi が 2 なら反時計回りに動き始めます
v=1
 */
 
int main(){
    long long int N,L,T;
    scanf("%lld %lld %lld",&N,&L,&T);
    long long int X[100002],W[100002];
    vector<long long int> hit_one;
    rep(i,N){
        scanf("%lld %lld",&X[i],&W[i]);
        if(W[i]==1)W[i]=+1;
        if(W[i]==2)W[i]=-1;
        if(W[i]*W[0]<0)hit_one.push_back(i);
    }
    long long int list_ans[100002];
    rep(i,N){
        long long miniT=T%L;
        list_ans[i]=( ( (X[i]+W[i]*miniT)%L)+L)%L;
    }
    long long int zero_to_what=0;//0だと思われている座標は実際にはzero_to_what
    rep(i,hit_one.size()){
        long long int kyori;
        if(W[0]==1)kyori=abs(X[hit_one[i]]-X[0]);
        else kyori=X[0]+(L-X[hit_one[i]]);
        if(2*T>=kyori)zero_to_what+= ( ((2*T-kyori)/L)+1 );
    }
    zero_to_what=( (zero_to_what%N*W[0])+N)%N;
    long long int zero_to_what_x=list_ans[0];//0だと思われているが実際にはzero_to_whatであるものの座標
    sort(list_ans,list_ans+N);
    zero_to_what_x=lower_bound(list_ans,list_ans+N,zero_to_what_x)-list_ans;//zero_to_what_xのindex
if(zero_to_what_x<N&&list_ans[zero_to_what_x]==list_ans[(zero_to_what_x+1)%N]){
if(W[0]>0)zero_to_what_x=(zero_to_what_x+1)%N;
}
    //つまりzero_to_what+iの座標はlist_ans[zero_to_what_x+i]
    rep(i,N){
        printf("%lld\n",list_ans[(zero_to_what_x+i-zero_to_what+N)%N]);
    }
   
}


Measured memory_bytes: 4088
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    A.foldLeft(0) { (acc, num) =>
      gcd(acc, num)
    }
  }

  def gcd(x: Int, y: Int): Int =
    if(y == 0) x else gcd(y, x % y)

  println(solve())

}



Measured memory_bytes: 62664
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector< vector <int> >vee;
typedef vector<pair<int,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const int N=1e5+5;
bool f;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
    int n;
    cin>>n;
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9)
        cout<<"hon";
    else if(n==0||n==1||n==6||n==8)
        cout<<"pon";
    else
        cout<<"bon";
go;
}


Measured memory_bytes: 3600
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,A; cin >> N >> A;
    cout << N*N-A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
 
int32_t main()
{
	unordered_map<int,int> m;
	int n,i;cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	int res=0;
	for(auto k:m)
	{
		res+=(k.second*(k.second-1))/2;
	}
	for(i=0;i<n;i++)
	{
		cout<<res-m[a[i]]+1<<endl;
	}
}

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  
  cout << s.at(0)<< n-2 <<s.at(n-1) <<endl ;

  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int a[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,x;
    cin>>n>>x;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<n;i++){
        if(a[i]>x){
            cout<<i-1;
            return 0;
        }
        x-=a[i];
    }
    if(a[n]==x){
        cout<<n;
    }
    else{
        cout<<n-1;
    }
    return  0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
#define endl '\n'

void solve() {
    int k, a, b;
    cin >> k;
    cin >> a >> b;

    int d1 = a/k;
    int d2 = b/k;

    // cout << d1 << " " << d2 << endl;
    if (d1 == d2) {
        if (a % k == 0 || b % k == 0) {
            cout << "OK";
        } else {
            cout << "NG";
        }
    } else {
        cout << "OK";
    }
    cout << endl;
 
}

int main() {
    FAST_IO;

    int t;
    // cin >> t;

    t = 1;
    while (t--) {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3616
from collections import Counter

mod = pow(10, 9)+7
n, k = map(int, input().split())
arr = list(map(int, input().split()))

BIT = [0]*(n+1)

def map_arr():
	dct = {}
	idx = 1
	lst = sorted(arr)
	for i in range(n):
		if lst[i] not in dct:
			dct[lst[i]] = idx 
			idx += 1
	return [dct[ele] for ele in arr]

arr = map_arr()
def get_add():
	counter = Counter(arr)
	lst = sorted(counter.items())
	add = lst[0][1]
	dp = [0]*len(lst)
	for i in range(1, len(lst)):
		dp[i] = lst[i-1][1] + dp[i - 1]
	return sum(dp[i]*lst[i][1] for i in range(len(lst)))

def read(idx):
	add = 0
	while idx > 0:
		add += BIT[idx]
		idx -= (-idx & idx)
	return add 

def update(idx):
	while idx <= n:
		BIT[idx] += 1
		idx += (-idx & idx)

inv_count = 0

for i in range(n-1, -1, -1):
	inv_count += read(arr[i]-1)
	update(arr[i])
ans = (k*inv_count)%mod

add = get_add()
multi = (k*(k-1)//2)%mod
ans = (ans + (multi*add)%mod)%mod
print(ans)

Measured memory_bytes: 41584
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
N, D, A = map(int, input().split())

ys = []
for _ in range(N):
    X, H = map(int, input().split())
    ys.append((2*X, -(-H//A)))
    ys.append((2*X+4*D+1, -(-H//A)))

ys = sorted(ys, key=lambda x : x[0])
d1 = dict()
d2 = dict()
ls = []
c = 0
hs = [0]
for i, (y, h) in enumerate(ys):
    if y%2:
        d1[y-1-4*D] = c
    else:
        c += 1
        d2[y] = c
        ls.append(y)
        hs.append(h)

lls = []
for i in range(N):
    lls.append(d1[ls[i]]-d2[ls[i]]+1)

X = Bit(N+1)

r = 0
for i in range(N):
    n = lls[i]
    x = hs[i+1] + X.sum(i+1)
    if x <=0:
        continue
    r += x
    X.add(i+1, -x)
    X.add(i+1+n, x)
print(r)


Measured memory_bytes: 130624
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) throws Exception {
        int[][] A = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        int N = sc.nextInt();
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextInt();
        }

        boolean[][] C = new boolean[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < N; k++) {
                    if (A[i][j] == B[k]) {
                        C[i][j] = true;
                    }
                }
            }
        }

        boolean bingo = false;

        for (int i = 0; i < 3; i++) {
            if (C[i][0] && C[i][1] && C[i][2]) {
                bingo = true;
            }
        }

        for (int i = 0; i < 3; i++) {
            if (C[0][i] && C[1][i] && C[2][i]) {
                bingo = true;
            }
        }

        if (C[0][0] && C[1][1] && C[2][2]) {
            bingo = true;
        }

        if (C[0][2] && C[1][1] && C[2][0]) {
            bingo = true;
        }

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

}


Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10**6)

a = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = a+a**2+a**3
print(ans)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
    ll N,M;
    SCLLD2(N,M);
    string S,T;
    cin >> S >> T;

    ll g; g = gcd(N,M);
    ll l = N*M / g;

    ll C = l / max(N,M);
    ll ans = l;
    //printf("C = %lld\n",C);

    REP(i,200000){
        ll sa = l / M;
        ll sb = l / N;
        if ((i*sa >= N) or (i * sb >= M)) break;
        if (S[i * sa] != T[i * sb]) ans = -1;
        //printf("S[%lld] = %c , T[%lld] = %c\n",i*sa,S[i*sa],i*sb,T[i*sb]);

    }

    PRINTLLD(ans);
}

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

int main() {
  int h, w; cin >> h >> w;
  vector<vector<char>> picture(h, vector<char>(w));
  for (int r = 0; r < h; r++) {
    for (int c = 0; c < w; c++) {
      cin >> picture[r][c];
    }
  }
  
  for (int r = 0; r < 2*h; r++) {
    for (int c = 0; c < w; c++) {
      cout << picture[r/2][c];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include<string>
#include <stdio.h>

using namespace std;

int main()
{
	int A, B, X;

	cin >> A >> B >> X;

	string ans = "NO";
	if (X >= A && A+B >= X)
	{
		ans = "YES";
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char t[1001]={};
    char h[1001]={};
    int j=0,n=0,t_score = 0,h_score = 0;

    scanf("%d", &n);
    while(n--){
        scanf("%s %s",t,h);
        while(t[j] != '\0' || h[j] != '\0'){
        if(t[j] - 'a' > h[j] - 'a'){
            t_score += 3;
            j=0;
            break;
        }
        else if(t[j] - 'a' < h[j] - 'a'){
            h_score += 3;
            j=0;
            break;
        }
        else j++;
        }
        if(j != 0){
            t_score += 1;
            h_score += 1;
            j=0;
        }
    }
    printf("%d %d\n", t_score,h_score);
    return(0);
}

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

typedef long long ll;
const ll MOD=1e9+7;

ll max_n=1000009;

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans;
}

int main(){
    ll N; cin >> N;
    ll a[N]; for(int i=0;i<N;i++) cin >> a[i];
    map<ll,ll> result;
    for(int i=0;i<N;i++){
        ll res=a[i];
        for(ll j=2;j*j<=res;j++){
            if(res%j!=0) continue;
            ll cnt=0;
            while(res%j==0){
                res/=j;
                cnt++;
            }
            result[j]=max(result[j],cnt);
        }
        if(res!=1){
            result[res]=max(result[res],1LL);
        }
    }
    ll ans=0;
    ll res=1;
    for(auto tmp:result){
        res*=mod_pow(tmp.first,tmp.second);
        res%=MOD;
    }
    for(int i=0;i<N;i++){
        ll now=res;
        now*=mod_pow(a[i],MOD-2);
        now%=MOD;
        ans+=now;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 896
char s[111][11],c;
i,j;
main(){
	for(gets(*s);gets(s[i]);i++)
	{
		if(c&&c!=s[i][0])return!puts("No");
		c=s[i][strlen(s[i])-1];
		for(j=0;j<i;j++)if(!strcmp(s[i],s[j]))return!puts("No");
	}
	puts("Yes");
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>

#define BIG 998244353
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

long gcd(long x,long y){
    while(x != 0){
        if(x < y){
            long k = x;
            x = y;
            y = k;
        }
        x %= y;
    }
    return y;
}

int main() {
    int n;
    cin >> n;
    vector<long> a(n,0);
    vector<long> b(n,0);
    vector<long> c(n,0);
    for(int i = 0;i < n;++i){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    b[0] = a[0];
    for(int i = 1;i < n;++i){
        b[i] = gcd(a[i],b[i - 1]);
    }
    c[n - 1] = a[n - 1];
    for(int i = n - 1;i >= 1;--i){
        c[i - 1] = gcd(a[i - 1],c[i]);
    }
    long max = c[1];
    for(int i = 0;i < n - 2;++i){
        long t = gcd(b[i],c[i + 2]);
        if(max < t)max = t;
    }
    if(max < b[n - 2])max = b[n- 2];
    cout << max << endl;
}





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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n,cnt=0;
    cin>>n;
    bool b[1000100];
    while(true){
        cnt++;
        if(b[n]==true)
        {
            break;
        }
        b[n]=true;
        if(n%2==0)
        {
            n/=2;
        }
        else
        {
            n=n*3+1;
        }
    }
    
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
function f(D,N)
	for k=1:N,i=1:N,j=1:N
		D[i,j]=min(D[i,j],D[i,k]+D[k,j])
	end
	D
end
const lines=readlines()
function main()
	N,M,L=map(x->parse(Int,x),split(shift!(lines)))
	D=(1-eye(Int,N))*1145141919810
	for i=1:M
		a,b,c=map(x->parse(Int,x),split(shift!(lines)))
		D[a,b]=D[b,a]=c
	end
	D=f(D,N)
	for i=1:N,j=1:N
		if i==j
			D[i,j]=0
		elseif D[i,j]<=L
			D[i,j]=1
		else
			D[i,j]=1145141919810
		end
	end
	D=f(D,N)
	shift!(lines)
	for s=lines
		u,v=map(x->parse(Int,x),split(s))
		ans=D[u,v]
		println(ans<1145141919810 ? ans-1 : -1)
	end
end
main()


Measured memory_bytes: 171672
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc163
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc163B();
			Console.Out.Flush();

        }

        public static void solve_abc163B()
        {
            int[] nm  = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = nm[0];
            int m = nm[1];
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            long sum = 0;
            for (int i = 0; i < m; i++)
            {
                sum += a[i];
            }
            Console.WriteLine(sum <= n ? n - sum : -1);
        }

        public static void solve_abc163A()
        {
            int r = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(2 * Math.PI * r);
        }
    }
}


Measured memory_bytes: 29288
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main(){

  int a, b;
  cin >> a >> b;
  if(a >= 10 || b >= 10){
    cout << "-1" <<endl;
    return 0;
  }
  cout << a * b << endl;

}


Measured memory_bytes: 256
from bisect import bisect_right

def eratosthenes(n):
    A = [i for i in range(2, n+1)]
    P = []
    i = 2
    while i**2 <= n:
        prime = min(A)
        P.append(prime)
        j = 0
        while j < len(A):
            if A[j] % prime == 0:
                A.pop(j)
                continue
            j += 1
        i += 1    
    for a in A:
        P.append(a)
    return P
    
x = int(input())
prime_table = eratosthenes(100003)
prime_set = set(prime_table)
if x in prime_set:
    print(x)
else:
    idx = bisect_right(prime_table, x)
    ans = prime_table[idx]
    print(ans)


Measured memory_bytes: 12952
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<queue>
#include<map>
#include<set>
#include<time.h>
#include<memory>
#include<algorithm>
#define M_PI 3.14159265358979323846
#define ll long long
#define int ll
#define E exp(1.0)
const int N = 1 << 22;
using namespace std;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
template<class T>
T MIN(const T& a, const T& b) {
	return a < b ? a : b;
}
template<class T>
T MAX(const T& a, const T& b) {
	return a > b ? a : b;
}
int bit[N + 1];
void update(int pos, int val) {
	while (pos <= N) {
		bit[pos] += val;
		pos += pos & (-pos);
	}
}
int bsearch(int x) {
	if (x == 0) return 0;
	int pos = 0;
	for (int i = N / 2; i >= 1; i >>= 1) {
		if (bit[i + pos] < x) {
			x -= bit[i + pos];
			pos += i;
		}
	}
	return  pos + 1;
}
int getsum(int pos) {
	int sum = 0;
	while (pos > 0) {
		sum += bit[pos];
		pos -= pos & (-pos);
	}
	return sum;
}
signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int a;
	long double b;
	cin >> a >> b;
	cout << (ll)(a * b) << endl;
	/*int n;
	cin >> n;
	int res = 1,limit=1e18;
	int f = 0,num=0;
	while (n--) {
		int a;
		cin >> a;
		if (a == 0) {
			f = -1;
		}
		if (f) continue;
		int b = a;
		int m = 0;
		while (b) {
			m++;
			b /= 10;
		}
		if (m + num > 20) f = 1;
		else {
			res *= a;
			b = res;
			if (res > limit) f = 1;
			num = 0;
			while (b) {
				num++;
				b /= 10;
			}
		}
	}
	if (f == -1) cout << 0 << endl;
	else if (!f&&res<=limit) cout << res << endl;
	else cout << -1 << endl;*/
	return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



int main(){
  int N; string S; cin >> N >> S; vector<ll> ato; ll cnt = 0, ans = 1;
  rep(i, 2*N-1){
    if(S[i]==S[i+1]) cnt++;
    if(cnt%2) ato.push_back(i+1);
  }
  if(ato.size()!=N || S[0]=='W' || S[2*N-1]=='W'){
    cout << 0 << endl; return 0;
  }
  cnt=0;
  rep(i, N){
    ato[i]-=cnt; if(ato[i]<0) ato[i]+=mod; ato[i]%=mod; ans*=ato[i]; ans%=mod; cnt+=2; cnt%=mod;
  }
  ll fact[N+100]; fact[0]=1;
  rep(i, N+50){
    fact[i+1]=fact[i]*(i+1)%mod;
  }
  ans*=fact[N]; ans%=mod;
  cout << ans << endl;  
}

Measured memory_bytes: 2168
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const ll MOD=998244353;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
int N,M,K;
const int MAXN=2e5+10;
ll factor[MAXN];
void init()
{
    factor[0]=1;
    for(int u=1;u<MAXN;u++){
        factor[u]=(factor[u-1]*u)%MOD;
    }
}
ll C(ll n,ll k)
{
    return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;
}
void solve()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M>>K;
    init();
    ll ans=0;
    for(int u=0;u<=K;u++){
        ans=(ans+M*C(N-1,u)%MOD*qpow(M-1,N-1-u)%MOD)%MOD;
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll K=1000000007;
ll Kuriage(ll a, ll b){
  	if(a%b){
      	return a/b+1;
    }
  	else{
      	return a/b;
    }
}
int main (){
    ll N, A, B, C, D, E;
    cin>>N>>A>>B>>C>>D>>E;
    ll O, P, Q, R, S, T;
    O=Kuriage(N, A);
    P=Kuriage(N, B);
    Q=Kuriage(N, C);
    R=Kuriage(N, D);
    S=Kuriage(N, E);
    ll MaxA=max(O, P);
  	ll MaxB=max(Q, R);
  	MaxA=max(MaxA, S);
  	MaxA=max(MaxA, MaxB);
  cout<<MaxA+4;
   
}

Measured memory_bytes: 256
# n^p mod m
def npmodm(n,p,m):
    if p == 0:
        return 1
    elif p % 2 == 0:
        a = npmodm(n,p//2,m) % m
        return (a*a) % m
    else:
        a = npmodm(n,p-1,m) % m
        return (a*n) % m

m = 10**9+7
n,p = map(int,input().split())
print(npmodm(n,p,m))



Measured memory_bytes: 5600
N,K = map(int,input().split())
A_list = list(map(int,input().split()))
counter = [0]*(N+1)

for i in A_list:
    counter[i] += 1

zeronashi = [i for i in counter if i != 0]
zeronashi.sort()

length = len(zeronashi)
x = length - K
y = 0
if x < 1:
    print(0)
else:
    for i in range(x):
        y += zeronashi[i]
    print(y)

Measured memory_bytes: 24836
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = o.a();
  var x = o.m(n);
  x.sort((a,b)=>a[0]-b[0]);
  var ans = 0;
  var dp = [-1e9,-1e9];
  for(var i = 0; i < n; i++){
    var y = x[i][0], l = x[i][1];
    if(dp[1] <= y-l){
      dp[1] = y+l;
      ans++;
    }else if(dp[0] < y-l && y+l < dp[1]){
      dp[1] = y+l;
    }
  }
  return ans;
}

Measured memory_bytes: 66692
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll N,X,T;
    cin>>N>>X>>T;
    if(N%X==0){
        cout<<T*(N/X)<<endl;
    }else{
        cout<<T*(N/X+1)<<endl;
    }
}


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

int main(){
  	int N;
  	cin>>N;
	long long a[90];
  	a[0]=2;a[1]=1;
	if(N>=2)for(int i=2;i<=N;++i)a[i]=a[i-1]+a[i-2];
  	cout<<a[N]<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

main()
{
    ll n;
    cin>>n;
    if(n%2==0 or n%5==0)
    {
        cout<<-1;
        return 0;
    }
    ll ans=-1,vag=7,cnt=1;
   while(1)
    {
        while(vag<n)
        {
            vag*=10;
            vag+=7;
            cnt+=1;
        }
        if(vag%n==0)
        {
            ans=cnt;
            break;
        }
        else
        {
            vag%=n;
        }
    }
    cout<<ans;
}



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

using namespace std;

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

  string s; cin>>s;
  string week[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  
  int res = 7;
  for (auto& day : week) {
    if (s == day)
      break;
    res--;
  }
  cout << res << endl;

  return 0;
}


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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007

void solve()
{
	ll a,b,c,d,flag=0;
	cin>>a>>b>>c>>d;
	while(a>0 && c>0)
	{
		if(flag==0)
		{
			c-=b;
			flag=1;
		}
		else
		{
			a-=d;
			flag=0;
		}
	}
	if(a<=0) cout<<"No";
	else cout<<"Yes";
}

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

Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
import sys

# 入力
H, W = map(int, input().split())

S = []
for i in range(H):
    S.append(input())

# 上下左右の座標
dx = [0,  -1, 1,  0]
dy = [1,  0, 0,  -1]

for i in range(H):
    for j in range(W):
        # ドットのマスはスキップ
        if S[i][j] == ".":
            continue

        # 塗りつぶせるかどうかのフラグ
        # 塗れるか否かはセルの上下左右のどこかに黒色のセルがいるかどうかで判断する
        can = False

        for k in range(4):
            ni = i + dx[k]
            nj = j + dy[k]

            if ni < 0 or H <= ni:
                continue
            if nj < 0 or W <= nj:
                continue

            if S[ni][nj] == "#":
                can = True
                break

        # 一つでも塗れないセルがあればNo
        if not can:
            print("No")
            sys.exit()

print("Yes")


Measured memory_bytes: 3064
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
   // cin >> TESTS;
    while (TESTS--)
    {
        ll a,b ,c ,d;
        cin >> a >> b >> c >> d;

        while(a>0 || c>0)
        {
            c=c-b;
          //  what_is(c);
            if(c<=0)
            {
                break;
            }
            else
            {
                 a=a-d;
            }

           // what_is(a);
//            if(c<=0 || a<=0)
//            {
//                break;
//            }
        }
        if(a!=0 && a>0)
        {
            cout<< "Yes"<<endl;
        }
        else
        {
            cout << "No"<< endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,k,p[1000];
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>p[i];
    sort(p,p+n);
    cout<<accumulate(p,p+k,0)<<endl;
}

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

nisi=[0]*n
for i in range(n):
    if(s[i]=="W"):
        nisi[i]=1

ruiseki=[0]
for i in range(n):
    ruiseki.append(ruiseki[i]+nisi[i])



ans=[]

for i in range(n):
    ans.append(ruiseki[i] + (n-i-1) - (ruiseki[-1] - ruiseki[i+1]) )

print(min(ans))

Measured memory_bytes: 29836
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=100000000000;

void display(long j,vector<long> x){
    cout<<"data"<<j<<endl;
    for(int i=0;i<x.size();i++){
        cout<<x.at(i)<<" ";
    }
    cout<<endl<<endl;
}

long root(long x,vector<long> &uni){//1<=x<=N;
  //  cout<<"#";
    if(x==uni.at(x)) return x;
    else {
        uni.at(x)=root(uni.at(x),uni);
        return uni.at(x);
    }
}

void unite(long x, long y,vector<long> &uni, vector<long> &weight){
   // cout<<"$";
    long X=root(x,uni),Y=root(y,uni);
    uni.at(X)=Y;
    if(X!=Y) weight.at(Y)+=weight.at(X);
}


//main
int main() {
    
    //入力
    long N,M;
    cin>>N>>M;
    vector<long> A(M),B(M);
    for(int i=0;i<M;i++){
        cin>>A.at(i)>>B.at(i);
    }
    
    
    //計算
    
    vector<long> ans(M+1), uni(N), weight(N,1);
    for(int i=0;i<N;i++){
        uni.at(i)=i;
    }
    ans.at(M)=(N*(N-1))/2;
    for(int m=M-1;m>=0;m--){
      //  display(1,uni);
        //display(0,weight);
        long x=root(A.at(m)-1,uni),y=root(B.at(m)-1,uni);
        ans.at(m)=ans.at(m+1)-(x!=y)*weight.at(x)*weight.at(y);
        unite(x,y,uni,weight);
        
    }
   // display(1,uni);
    //display(0,weight);
    
    
    //出力
    for(int i=1;i<=M;i++){
        cout<<ans.at(i)<<endl;
    }
}

Measured memory_bytes: 5248
import fractions
nm=raw_input()
nm=nm.split()
n=eval(nm[0])
m=eval(nm[1])
s=raw_input()
t=raw_input()

gg=fractions.gcd(n,m)
ll=n/gg*m
result = ll
for i in xrange(n):
    if not (i*m) % n :
            tmp=i*m/n
            if s[i] != t[tmp] :
                result= -1
print result


Measured memory_bytes: 4520
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
constexpr int MOD = 1000000007;

int main()
{
  std::ios::sync_with_stdio(false);
  long N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> sum(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> A[i];
    }
    for(ll i=N-2;i>=0;i--)
    {
        sum[i] = (sum[i+1] + A[i+1]) % MOD;
        //cerr << sum[i] << endl;
    }

    ll total = 0;
    for(size_t i=0;i<N-1; i++)
    {
        total += (A[i] * sum[i]) %MOD;
        total %= MOD;
    }
    cout << total << endl;
  return 0;
}


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

typedef long long ll;

ll mod=1e9+7;

ll modinv(ll a){
  ll b=mod,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=mod;
  if(u<0) u+=mod;
  return u;
}
 
ll fac[300010];
 
void modfac(){
  fac[0]=1;
  for(ll i=1;i<300010;i++){
    fac[i]=(fac[i-1]*i)%mod;
  }
}
 
ll modcomb(ll n,ll k){
  if(n<k) return 0;
  else return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}

int main(){
  ll n;
  cin >> n;
  ll a[n+1];
  for(ll i=0;i<n+1;i++) cin >> a[i];
  modfac();
  /*解法メモ（考察）
  基本的にはcomb(n+1,k)
  共通する部分文字列を考える
  一致する文字間の距離を取る
  これはO(nlogn)ぐらいで求めるべき
  comb(3,1)
  comb(3,2)あたりを引く
  modcomb実装するだけ
  一致する文字間の距離を取ることに帰着
  */
  for(ll i=0;i<n+1;i++){
    a[i]=i+a[i]*1e7;
  }
  sort(a,a+n+1);
  ll dis;
  for(ll i=0;i<n;i++){
    if(a[i+1]-a[i]<1e6){
      dis=a[i+1]-a[i];
    }
  }
  for(ll i=0;i<n+1;i++){
    ll ans=modcomb(n+1,i+1)-modcomb(n-dis,i);
    if(ans<0) ans+=mod;
    cout << ans << endl;
  }
}

Measured memory_bytes: 4352
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int n,d; cin >> n >> d;
  cout << ceil((double)n/(2*d+1));

  return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
 
int main(){
    int X, Y;
    cin >> X >> Y;

    cout << X+Y/2 << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Baumkuchen {
	class Baumkuchen {
		static void Main(string[] args) {
			/*
			System.IO.StreamReader sr = new System.IO.StreamReader("input.txt");
			int N = int.Parse(sr.ReadLine());
			long[] v_list = new long[N + 1];
			v_list[0] = 0;
			for (int n = 1; n < N+1; n++) {
				v_list[n] = v_list[n - 1] + long.Parse(sr.ReadLine());
			}
			sr.Close();
			/*/
			int N = int.Parse(Console.ReadLine());
			long[] v_list = new long[N + 1];
			v_list[0] = 0;
			for (int n = 1; n < N + 1; n++) {
				v_list[n] = v_list[n - 1] + long.Parse(Console.ReadLine());
			}
			//*/
			Baumkuchen baumkuchen = new Baumkuchen(v_list);
			Console.WriteLine(baumkuchen.GetAnwser());
		}

		readonly long[] v_list;
		readonly int N;
		readonly double tripartition;
		public Baumkuchen(long[] _v_list) {
			N = _v_list.Length - 1;
			v_list = _v_list;
			tripartition = v_list[N] / 3.0;
		}
		public long GetAnwser() {
			long interm_maxV = -1;
			int n0_max = findIndex(0, N, tripartition)[0];
			for (int n0 = 0; n0 <= n0_max; n0++){
				long tmp = searchOne(n0);
				if (tmp > interm_maxV) interm_maxV = tmp;
			}
			return interm_maxV;
		}

		private long searchOne(int n0) {
			int[] n1 = findIndex(n0, N, tripartition + v_list[n0]);
			int[] n2 = findIndex(n1[0], N, 2 * tripartition + v_list[n0]);
			return (from nn1 in n1 from nn2 in n2 select getMinV(n0, nn1, nn2)).Max();
		}

		private long getMinV(int n0, int n1, int n2) {
			if (n1 == -1 || n2 == -1) return long.MaxValue;
			else {
				long[] V0_V1_V2 = new long[] { 
					v_list[n1] - v_list[n0], 
					v_list[n2] - v_list[n1], 
					v_list[n0] - v_list[n2] + v_list[N] };
				return V0_V1_V2.Min();
			}
		}

		private int[] findIndex(int from_n, int to_n, double target) {
			int n_left = from_n;
			int n_right = to_n;
			while (n_right - n_left !=1) {
				int n_mid = (n_right + n_left) / 2;
				if (v_list[n_mid] <= target) n_left = n_mid;
				else n_right = n_mid;
			}
			return new int[] { n_left, n_right };
		}
	}
}

Measured memory_bytes: 16276
import math


def is_prime(x):
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    root = int(math.sqrt(x))
    for i in range(2, root):
        if x % i == 0:
          	return False
    return True
  
  
X = int(input())

while True:
    if is_prime(X):
        print(X)
        break
    X += 1

Measured memory_bytes: 38896