akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;



int main() {

    ll n,y; cin >> n >> y;
    vector<ll> x(3,-1);
    y /= 1000;

    for(int i = 0; i <=n; i ++){
        for(int j = 0; j <= n-i; j ++){
            if(10*i + 5*j + 1*(n-j-i) == y){
                x[0] = i;
                x[1] = j;
                x[2] = n-j-i;
            }
        }
        if(x[0] != -1) break;
    }

    cout << x[0] << " " << x[1] << " " << x[2];

    return 0;
}











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

int main(){
    int N;
    cin >> N;
    if(N <= 111)
        cout << 111 << endl;
    else if(N <= 222)
        cout << 222 << endl;
    else if(N <= 333)
        cout << 333 << endl;
    else if(N <= 444)
        cout << 444 << endl;
    else if(N <= 555)
        cout << 555 << endl;
    else if(N <= 666)
        cout << 666 << endl;
    else if(N <= 777)
        cout << 777 << endl;
    else if(N <= 888)
        cout << 888 << endl;
    else
        cout << 999 << endl;
    return 0;
}

Measured memory_bytes: 256
# B - Tap Dance
S = input()
j = 1
flag = False
for i in S:
    if j % 2 != 0 :
        if(i == 'L'):
            flag = True
            break
    else:
        if(i == 'R'):
            flag = True
            break
    j= j+1

if(flag) :
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sc.useDelimiter("\n");
        char[] ch = new char[1200];
        ch = sc.next().toCharArray();
        
        for (int i = 0; i < ch.length; i++) {
            if (Character.isLowerCase(ch[i]))
                pw.print(Character.toUpperCase(ch[i]));
            else if (Character.isUpperCase(ch[i]))
                pw.print(Character.toLowerCase(ch[i]));
            else
                pw.print(ch[i]);
        }
        pw.println();
        
        pw.flush();
    }
}


Measured memory_bytes: 26244
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      k: usize,
      aa: [usize; n],
    }
    let mut ss = vec![0; n+1];
    for i in 0..n {
        ss[i+1] = aa[i] + ss[i];
    }

    let mut rs = vec![];
    for l in 0..n {
        for r in l..n {
            let v = ss[r+1] - ss[l];
            rs.push(v);
        }
    }
    rs.sort();
    rs.reverse();

    let max_v = rs[0];
    let mut d = 1;
    while (1 << d+1) < max_v { d += 1 };

    let mut ans = 0;
    loop {
        let mut tmp = vec![];
        let v = 1 << d;
        for &r in &rs {
            if r & v >= 1 {
                tmp.push(r);
            };
        }
        if tmp.len() >= k {
            rs = tmp;
            ans += v;
        }

        if d == 0 {
            break;
        }
        d -= 1;
    }
    println!("{}", ans);
}


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

int main()
{
  string s,t;
  cin >> s >> t;
  
  int n = s.size();
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(s[i] != t[i]){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
#define Fi first
#define Se second
signed main(){
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a>=6)cout<<b/2<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
def f(B):
    if isinstance(B, float):
        if abs(B - int(B)) < 10**-6:
            return True
        else:
            return False
    return False


X = int(input())

for a in range(0, 10**5):
    bb = X + a**5
    B = bb**0.2
    if f(B):
        print(int(B), a)
        break

    a *= -1
    bb = X + a**5
    B = bb**0.2
    if f(B):
        print(int(B), a)
        break


Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=110000;
int N,M;
int A[MAXN];
unordered_map<int,int> cnt;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  cin>>N>>M;
  cnt[0]++;
  ll res=0;
  rep(i,0,N) {
    cin>>A[i];
    if (i>0) A[i]+=A[i-1];
    A[i]%=M;
    cnt[A[i]]++;
    res+=cnt[A[i]]-1;
  }

  cout<<res<<"\n";
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

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

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

    auto prime = [](int x){
        unordered_map<int,int> mp;
        int n = x;
        for(int i=2;i*i<=x;i++){
            while(n%i==0){
                mp[i]++;
                n /= i;
            }
        }
        if(n!=1) mp[n]++;
        return mp;
    };

    vec<unordered_map<int,int>> mps;
    vec<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        mps.push_back(prime(A[i]));
    }

    unordered_map<int,int> pmax;
    for(auto& mp:mps){
        for(auto& x:mp){
            if(!pmax.count(x.first)) pmax[x.first] = x.second;
            else pmax[x.first] = max(pmax[x.first],x.second);
        }
    }

    mint lcm = 1;
    for(auto& p:pmax){
        mint x = p.first;
        lcm *= x.pow(p.second);
    }

    mint ans = 0;
    for(int i=0;i<N;i++){
        ans += lcm/A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3416
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double total = 0.0;
        for(int i = 0; i < n; i++) {
            double amount = sc.nextDouble();
            String currency = sc.next();
            if(currency.equals("JPY")) {
                total += amount;
            } else {
                total += (amount * 380000.0);
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 24532
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

const int INF = 1000000000;

struct edge{int to,cap,rev;};

vector<edge> G[100];
bool used[100];

void add_edge(int from,int to,int cap){
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
	if(v==t) return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to]&&e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t,int V){
	int flow = 0;
	while(true){
		fill(used,used+V,false);
		int f = dfs(0,t,INF);
		if(f==0) return flow;
		flow += f;
	}
}

int main(){
	int V,E;
	scanf("%d %d",&V,&E);
	for(int i=0;i<E;i++){
		int u,v,c;
		scanf("%d %d %d",&u,&v,&c);
		add_edge(u,v,c);
	}
	printf("%d\n",max_flow(0,V-1,V));
	return 0;
}

Measured memory_bytes: 2804
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int[] s = nia(4);
        int dx = s[2] - s[0];
        int dy = s[3] - s[1];

        String ans = "";
        for (int i = 0; i < dx; i++) {
            ans += "R";
        }
        for (int i = 0; i < dy; i++) {
            ans += "U";
        }
        for (int i = 0; i < dx; i++) {
            ans += "L";
        }
        for (int i = 0; i < dy; i++) {
            ans += "D";
        }
        ans += "D";
        for (int i = 0; i < dx + 1; i++) {
            ans += "R";
        }
        for (int i = 0; i < dy + 1; i++) {
            ans += "U";
        }
        ans += "L";
        ans += "U";
        for (int i = 0; i < dx + 1; i++) {
            ans += "L";
        }
        for (int i = 0; i < dy + 1; i++) {
            ans += "D";
        }
        ans += "R";
        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    class INA {
        int[][] a;

        INA(int n, int m) throws IOException {
            this(n, m, -1);
        }

        INA(int n, int m, int t) throws IOException {
            a = new int[m][n];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[j][i] = ni() + t;
                }
            }
        }

        int[] get(int i) {
            return a[i - 1];
        }
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 205500
class Combination():
    def __init__(self, n, mod=10**9+7):
        self.mod = mod
        self.fac = [1]*(n+1)
        for i in range(1,n+1):
            self.fac[i] = self.fac[i-1] * i % self.mod
        self.invfac = [1]*(n+1)
        self.invfac[n] = pow(self.fac[n], self.mod - 2, self.mod)
        for i in range(n-1, 0, -1):
            self.invfac[i] = self.invfac[i+1] * (i+1) % self.mod

    def combination(self, n, r):
        return self.fac[n] * self.invfac[r] % self.mod * self.invfac[n-r] % self.mod

    def permutation(self, n, r):
        return self.factorial(n) * self.invfactorial(n-r) % self.mod

    def factorial(self, i):
        return self.fac[i]

    def invfactorial(self, i):
        return self.invfac[i]

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m = map(int, input().split())
    c = Combination(m)
    mod = 10**9 + 7
    ans = 0
    for i in range(n+1):
        tmp = c.combination(n,i)*pow(-1,i%2)*c.permutation(m, i)%mod
        tmp *= c.permutation(m-i, n-i)**2
        tmp %= mod
        ans += tmp
        ans %= mod
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 48164
//ITP1-10-B: Triangle
//2019.05.20

#include <stdio.h>
#include <math.h>

#define pi 3.14159265359

int main(void){
  double edge_a, edge_b, edge_c;
  double angle_c, height, surface, lap;
  double rad_c;

  scanf("%lf %lf %lf\n", &edge_a, &edge_b, &angle_c);

  rad_c = (pi/180)*angle_c;
  height = edge_b*sin(rad_c);
  surface = edge_a*height/2;
  edge_c = sqrt(pow(edge_a, 2) + pow(edge_b, 2) - 2*edge_a*edge_b*cos(rad_c));
  lap = edge_a + edge_b + edge_c;

  printf("%lf\n%lf\n%lf\n", surface, lap, height);

  return 0;
}



Measured memory_bytes: 2044
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define PI 3.14159265358979
#define MOD 1000000007
#define ERR 0.00000000000001
#define NUM 200010

int main(){
    int n, k, i, j;
    scanf("%d %d",&n,&k);
    int d[k], a[k][n], ans[n] = {}, c=0;
    for(i=0;i<k;i++){
        scanf("%d",&d[i]);
        for(j=0;j<d[i];j++){
            scanf("%d",&a[i][j]);
            ans[a[i][j]-1]++;
        }
    }
    for(i=0;i<n;i++){
        if(ans[i]==0){ c++; }
    }
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>

using namespace std;

typedef long long ll;

#define all(x) (x).begin(), (x).end()
#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(str) printf(#str "\n")

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  string s;
  cin >> s;
  REP(i, 2) {
    if (s[i] != s[i + 1]) {
      PRINT(Yes);
      return 0;
    }
  }
  PRINT(No);
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
/* AC check  copy */

#include<bits/stdc++.h>
#define MAX 200
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.9f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
 
int V,m,a;
vector<int> G[MAX];
vector<int> rG[MAX];
vector<int> vs;
bool used[MAX];
int cmp[MAX];
double p[MAX],ip[MAX];
 
void init(){
  FOR(i,0,MAX){
    G[i].clear();
    rG[i].clear();
    p[i]=1.0;
    ip[i]=0.0;
  }
}
 
void add_edge(int from, int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}
   
void dfs(int v){
  used[v] = true;
  for(int i = 0;i < G[v].size();i++){
    if(!used[G[v][i]])dfs(G[v][i]);
  }
  vs.push_back(v);
}
   
void rdfs(int v,int k){
  used[v] = true;
  cmp[v] = k;
  for(int i = 0;i < rG[v].size();i++){
    if(!used[rG[v][i]]) rdfs(rG[v][i],k);
  }
}
   
void scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v = 0;v < V;v++){
    if(!used[v]) dfs(v);
  }
  memset(used,0,sizeof(used));
  int k = 0;
  for(int i = vs.size() - 1;i >= 0;i--){
    if(!used[vs[i]])rdfs(vs[i],k++);
  }
  return;
}
 
void solve(){
  double res=1.0;
  map<int,vector<int> > mp;
  FOR(i,0,V)mp[cmp[i]].pb(i);
  FOR(i,0,V)FOR(j,0,V)if(cmp[i]==cmp[j])p[i]*=ip[j];
  FOR(i,0,V){
    vector<int> v=mp[i];
    if(v.size()==0)continue;
    bool flag=true;
    FOR(j,0,v.size()){
      int now=v[j];
      FOR(k,0,rG[now].size()){
        int next=rG[now][k];
        if(cmp[next]!=i)flag=false;
      }
    }
    if(flag)res*=(1.0-p[v[0]]);
  }
  pd(res);
}
 
int main()
{
  while(1){
    cin>>V;
    if(V==0)break;
    init();
    FOR(i,0,V){
      cin>>ip[i]>>m;
      FOR(j,0,m){
        cin>>a;
        add_edge(i,a-1);
      }
    }
    scc();
    solve();
  }
  return 0;
}

Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
struct Node{
  int key;
  Node *right,*left,*parent;
};
Node *root,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key = k;
  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);
  cout << " " << u->key;
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL)return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n,i,x;
  string com;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> com;
    if(com == "insert"){
      cin >> x;
      insert(x);
    }else if(com == "print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
  return 0;
}

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

int main() {
	int N, A; cin >> N >> A;
	int x[55], st=-1, en=-1;
	for(int i=0; i<N; ++i){
	    cin >> x[i];
	    x[i] -= A;
	}
	sort(x, x+N);
	for(int i=0; i<N; ++i){
	    if(st==-1 && x[i]>=0) st=i;
	    if(en==-1 && x[i]>0) en=i;
	}
	long long S;
	if(st==-1 || en==0) S=0;
	else if(en==-1) S=pow(2, N-st)-1;
	else if(st==0) S=pow(2, en)-1;
	else{
	    S=0;
	    int c[2][3000]; c[0][0]=1; c[1][0]=1;
	    for(int i=1; i<3000; ++i){
	        c[0][i]=0; c[1][i]=0;
	    }
	    for(int i=0; i<st; ++i){
	        for(int j=2999; j>=0; --j){
	            if(c[0][j]) c[0][j-x[i]] += c[0][j];
	        }
	    }
	    for(int i=en; i<N; ++i){
	        for(int j=2999; j>=0; --j){
	            if(c[1][j]) c[1][j+x[i]] += c[1][j];
	        }
	    }
	    for(int i=0; i<3000; ++i) S += (long) c[0][i]*c[1][i];
	    S=S*pow(2, en-st)-1;
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
N,D = (int(x) for x in input().split())
X = [None]*N
for i in range(N):
  X[i] = [float(x) for x in input().split()]
count = 0
for i in range(N-1):
  for j in range(i+1,N):
    sq = [(X[i][k]-X[j][k])**2 for k in range(D)]
    dist = sum(sq)**0.5
    if dist == int(dist):
      count += 1
print(count)

Measured memory_bytes: 9412
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<cmath>
#include<tuple>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define MMAX 7368795

int main()
{
	int m,n;
	while(cin >> m >> n,m|n)
	{
		int memo[MMAX] = {};
		int i,Mcount = 0;
		for(i = m;i < MMAX;i++)
		{
			if(memo[i] == 0)
			{
				if(Mcount == n)break;

				for(int j = i;j < MMAX;j += i)
				{
					memo[j] = 1;
				}
				Mcount++;			
			}
		}
		
		cout << i << endl;
		
		
	}
	return 0;
}

Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        arr[i]-=i;
    }
    sort(arr,arr+n);
    ll B=arr[n/2],ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(B-arr[i]);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 5148
#include <bits/stdc++.h>
using i64 = long long;
using B = std::bitset<2010>;

int main() {
    int n;
    std::cin >> n;

    std::vector<B> a(n), dpl(n), dpr(n);
    for (int i = 1; i < n; i++) {
        std::string in;
        std::cin >> in;
        for (int j = 0; j < i; j++) {
            if (in[j] == '1') a[i][j] = 1;
            else a[j][i] = 1;
        }
    }
    for (int i = 0; i < n; i++) dpl[i][i] = dpr[i][i] = 1;

    for (int d = 1; d < n; d++) {
        for (int i = 0; i + d < n; i++) {
            if ((dpl[i + d] & dpr[i + 1] & a[i]).any()) dpl[i + d][i] = 1;
            if ((dpl[i + d - 1] & dpr[i] & a[i + d]).any()) dpr[i][i + d] = 1;
        }
    }

    std::cout << (dpl.back() & dpr.front()).count() << std::endl;

    return 0;
}


Measured memory_bytes: 1792
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
flag = [[False]*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            flag[i][j] = True

# 判定していく
# 行
for row in flag:
    if all(row):
        print('Yes')
        exit()
# 列
for i in range(3):
    tmp = 0
    for j in range(3):
        if flag[j][i]:
            tmp += 1
    if tmp == 3:
        print('Yes')
        exit()

# 斜め
if flag[0][0] and flag[1][1] and flag[2][2]:
    print('Yes')
    exit()
if flag[0][2] and flag[1][1] and flag[2][0]:
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 3064
//int a = s - '0'; 文字から数字
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;

//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main() {
	string S;cin >> S;
	if(S[S.size()-1] == 's')cout << S + "es" << endl;
	else cout << S + 's' << endl;
}	

Measured memory_bytes: 11012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vvi g;
vvi lca;
vi v;
vi rui;
void dfs2(int i,int p){
    v.pb(i);
    for(ll x:g[i])if(x!=p)dfs2(x,i);
}
void dfs(int i,int p){
    v=vi(0);
    dfs2(i,p);
    ll n=v.size();
    rep(k,n)rep(j,n)lca[v[k]][v[j]]=i;
    for(ll x:g[i])if(x!=p)dfs(x,i);
}
ll d(int i,int p){
    for(ll x:g[i])if(x!=p)rui[i]+=d(x,i);
    return rui[i];
}
int main(){
    ll n;cin>>n;
    g=vvi(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    ll m;cin>>m;
    vector<P> query(m);
    rep(i,m)cin>>query[i].fi>>query[i].se;
    rep(i,m)query[i].fi--;
    rep(i,m)query[i].se--;
    lca=vvi(n,vi(n));
    dfs(0,-1);
    ll ans=0;
    rep(i,(1<<m)){
        ll num=1;
        rui=vi(n);
        rep(j,m)if(i>>j&1){
            num*=-1;
            ll a=query[j].fi,b=query[j].se,c=lca[a][b];
            rui[a]++;rui[b]++;rui[c]-=2;
        }
        ll s=0;
        d(0,-1);
        REP(k,1,n)if(rui[k]>0)s++;
        ans+=(1ll<<n-1-s)*num;
    }
    out(ans);
}



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

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

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

//  freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vec<char, 2> grid(n, m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> grid[i][j];
    }
  }

  vec<int, 1> g(m - 1);
  int ans = max(n, m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m - 1; ++j) {
      g[j] = 1 + (i && (grid[i - 1][j] == grid[i - 1][j + 1]) == (grid[i][j] == grid[i][j + 1]) ? g[j] : 0);
    }

    vec<int, 1> l(m - 1), r(m - 1);
    for (int j = 0; j < m - 1; ++j) {
      l[j] = j - 1;
      while (~l[j] && g[l[j]] > g[j]) {
        l[j] = l[l[j]];
      }
    }
    for (int j = m - 2; ~j; --j) {
      r[j] = j + 1;
      while (r[j] < m - 1 && g[r[j]] >= g[j]) {
        r[j] = r[r[j]];
      }
    }
    for (int j = 0; j < m - 1; ++j) {
      asMx(ans, g[j] * (r[j] - l[j]));
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 7176
n,a=map(int,input().split())
l=list(map(int,input().split()))
x=max(l)
x=max(x,a)
dp=[[[0 for _ in range(n*x+1)] for _ in range(n+1)] for _ in range(n+1)]

for j in range(n+1):
  for k in range(n+1):
    for s in range(n*x+1):
      if j==0 and k==0 and s==0:
        dp[j][k][s]=1
      elif j>=1 and s<l[j-1]:
        dp[j][k][s]=dp[j-1][k][s]
      elif j>=1 and k>=1 and s>=l[j-1]:
        dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-l[j-1]]
      else:
        dp[j][k][s]=0

s=0
for k in range(1,n+1):
  s+=dp[n][k][k*a]

print(s)

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

int main() {
  string S;
  cin >> S;
  for (char c='a'; c<='z'; c++) {
    bool exist = false;
    for (int i=0; i<S.size(); i++) {
      if (c==S.at(i)) {
        exist = true;
        break;
      }
    }
    if (exist&&c<'z') continue;
    else if (exist&&c=='z') cout << "None" << endl;
    else {
      cout << c << endl;
      break;
    }
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



P func(int n){
  int a=n%10,b;
  while(n){
    b = n;
    n/=10;
  }
  return P(a,b);
}


int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;
  
  return 0;
}




Measured memory_bytes: 256
import sys
N = int(input())
a = int(N//1000)
N = N-1000*a
b = int(N//100)
N = N-100*b
c = int(N//10)
N = N-10*c
d = int(N)
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
  sys.exit()
if a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
  sys.exit()
if a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
  sys.exit()
if a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
  sys.exit()
if a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
  sys.exit()
if a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
  sys.exit()
if a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
  sys.exit()
if a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
  sys.exit()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <numeric>

using namespace std;

unsigned long long GCD(unsigned long long x, unsigned long long y)
{
    unsigned long long r;
    while((r = x % y) != 0){
        x=y;
        y=r;
    }
    return y;
}

unsigned long long LCM(unsigned long long x, unsigned long long y)
{
    return ((x*y) / GCD(x,y));
}

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    unsigned long long A,B,C,D;
    unsigned long long aC,aD,aCD;
    unsigned long long bC,bD,bCD;
    
    cin >> A >> B >> C >> D;
    
    aC = ( A - 1 ) / C;
    aD = ( A - 1 ) / D;
    aCD = ( A - 1 ) / LCM(C,D);
    
    bC = B / C;
    bD = B / D;
    bCD = B / LCM(C,D);
    
    cout << ( B - bC - bD + bCD ) - ( (A - 1) - aC - aD + aCD ) << endl;

    return 0;
}


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

using namespace std;


void solve() {
    char a, b; cin >> a >> b;

    string aa, bb;
    for (int i = 0; i < b - '0'; i++) {
        aa += a;
    }
    for (int i = 0; i < a - '0'; i++) {
        bb += b;
    }

    if (aa < bb) cout << aa << endl;
    else cout << bb << endl;
}


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

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

typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define int ll

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;


void solve() {
	int n, m;
	cin >> n >> m;
	int a[n];
	map<int, int, greater<int>> mp;
	F0R(i, n) cin >> a[i], mp[a[i]]++;

	F0R(i, m) {
		int x, y;
		cin >> x >> y;

		mp[y] += x;
	}
	int ans = 0;
	for (auto x : mp) {
		if (x.S <= n) ans += x.S * x.F;
		else ans += n * x.F;
		n -= x.S;
		if (n <= 0) break;
	}
	cout << ans;

}

int32_t main() {
	_

#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
	solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

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

int main() {
    
    string S;
    cin >> S;

   
    string T = "ATCG";

    int ans = 0; 
    int now = 0; 
    for (int i = 0; i < S.size(); i++)
    {
        bool isATCG = false;
        for (int j = 0; j < T.size(); j++)
        {
            if (S[i] == T[j]) isATCG = true;
        }

        if (!isATCG) {
           
            now = 0;
        }
        else {
         
            now++;
            
            ans = max(now, ans);
            
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;cin>>N;
  vector<int> arr(N+1,0);
  int a;cin>>a;
  int mx=0;
  if(a>0){
    print(0);
    re 0;
  }
  arr[0]=1;
  REP(i,0,N-1){
    cin>>a;
    arr[a]++;
  }
  int ans=1;
  if(arr[0]!=1){
    print(0);
    re 0;
  }
  while(arr[N]==0)N--;
  REP(i,0,N){
    REP(j,0,arr[i+1]){
      ans=ans*arr[i];
      ans%=998244353;
    }

  }
  print(ans);

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef vector<int> vi;
const int MX = 2e5 + 5;
#define f(i, x, n) for (int i = x; i < n; i++)
#define int long long
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define pb push_back
#define endl "\n"
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin>>n;
    int a[n+1],cnt{0};
    f(i,1,n+1)
    {
        cin>>a[i];
        if(i%2&&a[i]%2)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    
    
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}


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

long long const MOD = 1e9+7;

map<int, int> ans;

void f(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        while (n % i == 0) {
            n /= i;
            ans[i]++;
        }
    }
    if (n != 1) ans[n]++;
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) f(i);

    long long A = 1;
    for (int i = 1; i <= n; i++) {
        if (ans.count(i)) {
            (A *= (ans[i] + 1)) %= MOD;
        }
    }

    cout << A << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
    int sum=0;
    stack<int>S1;
    stack< pair<int,int> >S2;
    char ch[20000];
    scanf("%s", ch);
    for(int i=0;i<strlen(ch);i++){
        if(ch[i] == '\\'){
            S1.push(i);
        }else if(ch[i] == '/'&&S1.size()>0){
            int j=S1.top();S1.pop();
            int a =i-j;
            sum+=a;
            while(S2.size()>0&&S2.top().first>j){
                a+=S2.top().second;S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
    
    vector<int> A;
    printf("%d\n", sum);
    while(S2.size()>0){
        A.push_back(S2.top().second);
        S2.pop();
    }
    reverse(A.begin(),A.end());
    printf("%d", A.size());
    
    for(int i=0;i<A.size();i++){
        printf(" %d",A[i]);
    }
    printf("\n");
    
}


Measured memory_bytes: 2848
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

bool isEven(int64_t v) {
    return (v % 2) == 0;
}

int main()
{

    std::vector<int64_t> Q(3);
    //int64_t A, B, C;
    std::cin >> Q[0] >> Q[1] >> Q[2];

    std::sort(std::begin(Q), std::end(Q));

    size_t count = 0;
    while (isEven(Q[0]) && isEven(Q[1]) && isEven(Q[2])) {
        auto prev =  Q;
        Q[0] = (prev[1] + prev[2])/2;
        Q[1] = (prev[0] + prev[2])/2;
        Q[2] = (prev[0] + prev[1])/2;
        std::sort(std::begin(Q), std::end(Q));
        if (Q == prev) {
            std::cout << -1 << std::endl;
            return 0;
        }
        count++;
        prev = Q;
    }
    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 512
import itertools

def allCombination(n):
    switch = [i for i in range(1,n+1)] 
    slis = []
    for i in range(0,n+1):
        for pair in itertools.combinations(switch, i):
            slis.append(pair)
    return slis

n,m = map(int,input().split())
kS = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

slis = allCombination(n)

cnt = 0
for s in slis:
    flag = 1
    for i,eachs in enumerate(kS):
        same = set(eachs[1:]) & set(s)
        if len(same) % 2 != p[i]:
            flag = 0
    
    if flag:
        cnt += 1

print(cnt)

Measured memory_bytes: 9264
N, M = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(M)]

from collections import defaultdict
from collections import deque
from collections import Counter
g = defaultdict(set)

for x, y in XY:
  g[x].add(y)
  
  
def TSort(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    funin = Counter()
    
    for u in V:
        for v in g[u]:
            funin[v] += 1
    
    q = deque()
    for v in V:
        if funin[v] == 0:
            q.append(v)
    L = []
    while q:
        u = q.popleft()
        L.append(u)
        for v in g[u]:
            funin[v] -= 1
            if funin[v] == 0:
                q.append(v)
    return L

  
D = Counter()
ns = TSort(g)
for u in ns:
  for v in g[u]:
    D[v] = max(D[v], D[u] + 1)
print(D.most_common()[0][1])

Measured memory_bytes: 116876
import java.io.*;

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

		try {
			while (!(buf = br.readLine()).equals("0")) {
				int n = Integer.parseInt(buf);
				int m = Integer.parseInt(br.readLine());
				int atari = Integer.parseInt(br.readLine());
				int d = Integer.parseInt(br.readLine());
				int f[][] = new int[d][n-1];
				for (int i=0;i<d;i++) {
					buf = br.readLine();
					for (int j=0;j<n-1;j++) {
						f[i][j] = Character.getNumericValue(buf.charAt(j));
					}
				}
				if (atari==goal1(f,d,n-1,m)) System.out.println(0);
				else {
					//print_f(f,d,n-1);
					boolean clear = false;
					for (int i=0;i<d;i++) {
						for (int j=0;j<n-1;j++) {
							if (f[i][j]==2) {
								f[i][j] = 1;
								if (atari==goal2(f,d,n-1,m)) {
									System.out.println((i+1)+" "+(j+1));
									clear = true;
								}
								f[i][j] = 2;
							}
						}
						if (clear) break;
					}
					if (!clear) System.out.println(1);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static int goal1(int[][] f,int x,int y,int s) {
		int p = s;
		for (int i=0;i<x;i++) {
			if (p==1) {
				if (f[i][0]==1) p++;
				else if (y==1) {
					f[i][0] = 2;
				} else if (f[i][1]==0) {
					f[i][0] = 2;
				}
			} else if (p==y+1) {
				if (f[i][y-1]==1) p--;
				else if (y==1) {
					f[i][y-1] = 2;
				} else if (f[i][y-2]==0) {
					f[i][y-1] = 2;
				}
			} else if (f[i][p-2]==1) {
				p--;
			} else if (f[i][p-1]==1) {
				p++;
			} else {
				if (p==2) f[i][p-2] = 2;
				else if (f[i][p-3]==0) f[i][p-2] = 2;

				if (p==y) f[i][p-1] = 2;
				else if (f[i][p]==0) f[i][p-1] = 2;
			}
		}
		return p;
	}

	public static int goal2(int[][] f,int x,int y,int s) {
		int p = s;
		for (int i=0;i<x;i++) {
			if (p==1) {
				if (f[i][0]==1) p++;
			} else if (p==y+1) {
				if (f[i][y-1]==1) p--;
			} else if (f[i][p-2]==1) {
				p--;
			} else if (f[i][p-1]==1) {
				p++;
			}
		}
		return p;
	}

	public static void print_f(int[][] f,int x,int y) {
		for (int i=0;i<x;i++) {
			for (int j=0;j<y;j++) System.out.print(f[i][j]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 24332
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

#define MOD (1000000007)
const int MX = 777777 + 5;
int fac[MX+5],fac_inv[MX+5];
 
int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void init(){
  int n=MX+4;
	fac[0] = 1;
  for(int i=0;i<n;++i)fac[i+1]=fac[i]*(i+1)%MOD;
  fac_inv[n]=power(fac[n],MOD-2,MOD);
  for(int i=n-1;i>=0;--i)fac_inv[i]=fac_inv[i+1]*(i+1)%MOD;
}
int comb(int n,int r){return (fac[n]*fac_inv[r])%MOD*fac_inv[n-r]%MOD;}
int H(int n,int r){
  return comb(n+r-1,r)%MOD;
}

main() {
    init();
    int H,W,A,B; cin >> H >> W >> A >> B;
    H--; W--;
    ll ans=0;
    rep(i,W-B+1){
        ans=(ans+(comb(H-A+B+i,H-A)*comb(A-1+W-i-B,A-1))%MOD)%MOD;
    }
    cout << ans << endl;

}

Measured memory_bytes: 12544
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

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

	for (auto i = 0; i <= N / 4; ++i)
	{
		auto temp = N - i * 4;
		for (auto j = 0; j <= temp / 7; ++j)
		{
			if (temp - j * 7 == 0)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256