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

using namespace std;
string s[55],t[55],q[2505];
int main()
{
    int i,j,m,n,k,cnt=0,flag;
    cin >> m >> n;
    for(i=0;i<m;i++)
    {
        cin >> s[i];
    }
    for(i=0;i<n;i++)
    {
        cin >> t[i];
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<=m-n;j++)
        {
            for(k=0;k<n;k++)
            {
                q[cnt]+=s[i][j+k];
            }
            cnt++;
        }
    }
    for(i=0;i<(m-n+1)*(m-n+1);i++)
    {
        flag=1;
        for(j=0;j<n;j++)
        {
            if(q[i+j*(m-n+1)]!=t[j])
            {
                flag=0;
                break;
            }
        }
        if(flag==1)
        {
            cout << "Yes" << endl;
            break;
        }
    }
    if(flag==0)
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

vector<vector<pair<int, int> > > edge;//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<vector<int> >d(2, vector<int>(100010,INF));

void dijkstra(int start, int num){
    priority_queue<int, vector<int>, greater<int> > q;

    d[num][start] = 0;
    q.push(start);

    while(!q.empty()){
        int now = q.top();
        q.pop();
        for(int j = 0; j < edge[now].size(); j++){
            int next = edge[now][j].first;
            int nextd = d[num][now] + edge[now][j].second;
            if(nextd < d[num][next]){
                d[num][next] = nextd;
                q.push(next);
            }
        }
    }
}

int main()
{
    int n;
    cin >> n;
    edge.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(make_pair(b,1));
        edge[b].push_back(make_pair(a,1));
    }
    dijkstra(0,0);
    dijkstra(n-1,1);

    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > firstq, secondq;
    for(auto p : edge[0]) firstq.push(make_pair(d[1][p.first], p.first));
    for(auto p : edge[n-1]) secondq.push(make_pair(d[0][p.first], p.first));

    vector<bool> used(n,false);
    used[0] = true;
    used[n-1] = true;
    
    while(1){
        //先行
        int next = -1;
        while(true){
            if(firstq.empty()){
                cout << "Snuke" << endl;
                return 0;
            }
            auto p = firstq.top();
            firstq.pop();
            next = p.second;
            if(!used[next]){
                used[next] = true;
                break;
            }
        }
        for(auto s : edge[next]){
            firstq.push(make_pair(d[1][s.first], s.first));
        }

        //後攻
        while(true){
            if(secondq.empty()){
                cout << "Fennec" << endl;
                return 0;
            }
            auto p = secondq.top();
            secondq.pop();
            next = p.second;
            if(!used[next]){
                used[next] = true;
                break;
            }
        }
        for(auto s : edge[next]){
            secondq.push(make_pair(d[0][s.first], s.first));
        }
    }
}

Measured memory_bytes: 7800
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    
    int ans = 0;
    for(int i=0; i<N; i++) {
      if(scan.nextInt() >= K) ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 45632
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 200000
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    string S;
    cin >> S;
    int ans = 0;
    if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R'){
        ans = 3;
    }
    else if (S[0] == 'R' && S[1] == 'R'){
        ans = 2;
    }
    else if (S[1] == 'R' && S[2] == 'R'){
        ans = 2;
    }
    else if(S[0] == 'R' || S[1] == 'R' || S[2] == 'R'){
        ans = 1;
    }
    else {
        ans = 0;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3192
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, k] <- getInts
  print $ solve n k

solve :: Int -> Int -> Int
solve n k = sum $ map (countOverMod n k) [1 .. n]

countOverMod :: Int -> Int -> Int -> Int
countOverMod n 0 _ = n
countOverMod n k b = s * p + t where
  (p, q) = divMod n b
  s = max (b - k) 0
  t = max (q - k + 1) 0

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    ll aa[100005];
    multiset<ll> a;
    for(int i = 0; i < n; i++){
        cin >> aa[i];
    }
    for(int i = n-1; i>=0; i--){
        auto itr = a.upper_bound(aa[i]);
        if(itr == a.end())a.insert(aa[i]);
        else{
            a.erase(itr);
            a.insert(aa[i]);
        }
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<string> w(N);
  set<string> exists;
  cin >> w[0];
  bool succ = true;
  exists.insert(w[0]);
  for (int i = 1; i < N; i++) {
    cin >> w[i];
    if (!exists.count(w[i]) && w[i - 1][w[i - 1].size() - 1] == w[i][0]) {
      exists.insert(w[i - 1]);
    } else {
      succ = false;
    }
  }
  if (succ)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3640
import java.util.HashMap;
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n+1];
		for(int i = 1;i <= n;i++){
			a[i] = sc.nextInt();
		}

		//		System.out.println();
		long[] sum = new long[n+1];
		for(int i = 1;i <= n;i++){
			sum[i] = a[i] + sum[i-1];
		}
		//		for(int i = 1; i<=n;i++){
		//			System.out.println(sum[i] + " " + sum[i]%m);
		//		}
		HashMap<Long, Integer> map = new HashMap<Long,Integer>();
		for(int i = 1; i<=n;i++){
			map.put(sum[i]%m, 0);
		}


		//		System.out.println();
		for(int i = 1; i<=n;i++){
			int x = map.get(sum[i]%m);
			map.put(sum[i]%m, x+1);
		}

		long ans = 0;
		if(map.containsKey(0l)){
			ans = map.get(0l);
		}
		for(long i:map.keySet()){
			if(map.get(i) >= 2){
				for(int j = map.get(i);j > 1;j--){
					ans += j-1;
				}
			}
		}
		System.out.println(ans);




	}


}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

#define int long long

signed main(){
    int n;
    cin >> n;

    set<int> st;

    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        if(st.find(a) != st.end()){
            cout << "NO" << endl;
            return 0;
        }
        st.insert(a);
    }
    cout << "YES" << endl;

    return 0;
}



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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)

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

const int MAXN = 3e5 + 5, mod = 998244353;

ll n, a, b, k, sol;
ll fakt[MAXN], inv[MAXN], povrh[MAXN], pref[MAXN];

ll add(int x, int y){
  x += y;
  if(x >= mod) return x - mod;
  return x;
}

ll mul(ll x, ll y){
  return x * y % mod;
}

ll sub(ll x, ll y){
  x -= y;
  if(x < 0) x += mod;
  return x;
}

ll pot(ll b, ll p){
    if (p % 2)
        return pot(b, p - 1) * b % mod;
    else{
        ll tmp = p ? pot(b, p / 2) % mod : 1;
        return tmp * tmp % mod;
    }
}

int main(){

  cin >> n >> a >> b >> k;
  fakt[1] = 1;
  FOR(i, 2, n + 1)
    fakt[i] = mul(fakt[i - 1], i);
  FOR(i, 1, n + 1)
    inv[i] = pot(fakt[i], mod - 2);
  FOR(i, 1, n + 1)
    povrh[i] = mul(fakt[n], mul(inv[i], inv[n - i]));
  povrh[0] = 1;
  povrh[n] = 1;

  REP(i, n + 1){
    ll x = i * a;
    ll tmp = k - x;
    if(tmp % b || x > k) continue;
    ll y = tmp / b;
    if(y > n) continue;
    sol = add( sol, mul(povrh[i], povrh[y]) );
  }
  cout << sol;
}


Measured memory_bytes: 7552
def f11():
    N, M=map(int, input().split())
    item=[0 for i in range(M)]
    for i in range(N):
        A = [int(j) for j in input().split()]
        for j in range(A[0]):
            item[A[j+1]-1] += 1
    print(sum([1 if item[i]==N else 0 for i in range(M)]))

def main():
    f11()

main()

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
int main()
{
  int N;
  scanf("%d",&N);
  
  int i,j;
  for (i=(int)sqrt(N); i>=1; i++) {
    j= N/i;
    if (i*j == N)  break;
  }
  printf("%s", (i<10 && j<10) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
#define F first
#define S second

constexpr int kN = int(2E5 + 10);

int p[kN], sz[kN], x[kN], y[kN], idx[kN];

int Find(int n) {return p[n] == n ? n : p[n] = Find(p[n]);}

void Merge(int a, int b) {
	a = Find(a), b = Find(b);
	if (a == b) return ;
	p[b] = a;
	sz[a] += sz[b];
	return ;
}

int main() {
	int n, mn;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 1; i <= n; i++) p[i] = i;
	for (int i = 1; i <= n; i++) sz[i] = 1;
	for (int i = 1; i <= n; i++) idx[x[i]] = y[i];
	for (int i = 1; i <= n; i++) {
		mn = idx[i];
		while (!pq.empty()) {
			if (pq.top().F < idx[i]) {
				mn = min(mn, pq.top().F);
				Merge(pq.top().S, i);
				pq.pop();
			}
			else break;
		}
		pq.push({mn, i});
	}
	for (int i = 1; i <= n; i++) printf("%d\n", sz[Find(x[i])]);
}


Measured memory_bytes: 7772
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <iomanip>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>, int> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int a, b;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b;
    if (a * b == 15) {
        cout << "*";
    } else if (a + b == 15) {
        cout << "+";
    } else {
        cout << "x";
    }
}

Measured memory_bytes: 256
/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

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

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
map<ll, pll> mp;
ll A[MAXN], cnt[MAXN], n;

int main() {
    scanf("%lld", &n);
    for (ll i = 1; i <= n; i++) {
        scanf("%lld", &A[i]);
        if (mp.find(A[i]) == mp.end()) {
            mp[A[i]] = {1, i};
            continue;
        }
        mp[A[i]].F++;
    }
    while (1) {
        ll cur = mp.rbegin()->F; ll ind = (mp[cur].S);
        if (sz(mp) == 1) {
            cnt[ind] += mp[cur].F * cur;
            break;
        }
        pll X = mp[cur];
        mp.erase(cur);
        ll lst = mp.rbegin()->F;
        cnt[ind] += X.F * (cur - lst);
        mp[lst].F += X.F, mp[lst].S = min(mp[lst].S, X.S);
    }
    for (ll i = 1; i <= n; i++) printf("%lld\n", cnt[i]);
    return 0;
}



Measured memory_bytes: 12160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int n=in(),a=in(),b=in(),i,t,x,s=0;
	for(i=1;i<=n;i++){
		t=i;
		x=0;
		while(t){
			x+=t%10;
			t/=10;
		}
		if(a<=x&&x<=b)s+=i;
	}
	print(s);
	return 0;
}

Measured memory_bytes: 128
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,k = map(int, stdin.readline().rstrip().split())
Hs = list(map(int, stdin.readline().rstrip().split()))
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

Hs.sort()
ans = 0
for i in range(n-k):
    ans += Hs[i]
print(ans)


Measured memory_bytes: 26764
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let N: i64 = read().unwrap();
    if N == 0 {
        println!("0 0 0");
    }
    for n in 1..3501 as i64 {
        for w in 1..3501 as i64 {
            let t = 4 * n * w - N * (w + n);
            if 4 * n * w - N * (w + n) > 0 {
                if (N * n * w) % t == 0 {
                    let u = ((N * n * w) / t) as i64;
                    println!("{} {} {}", u, n, w);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 4352
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ds = list(mapint())
if Ds[0]!=0:
    print(0)
    exit(0)
Ds.sort()
mod = 998244353

from collections import Counter
c = Counter(Ds)
dmax = Ds[-1]


if c[0]>1:
    print(0)
else:
    ans = 1
    for i in range(1, dmax+1):
        ans *= pow(c[i-1], c[i], mod)
        ans %= mod
    print(ans)

Measured memory_bytes: 98712
import sys
a,b=input().split()
a,b=int(a),int(b)
s=input().rstrip()
if len(s)!=a+b+1:
    print("No")
    sys.exit()
elif s[a]!="-":
    print("No")
    sys.exit()
k=0
list=["0","1","2","3","4","5","6","7","8","9"]
while k<a:
    if s[k] in list:
        pass
    else:
        print("No")
        sys.exit()
    k+=1
k+=1
while k<=a+b:
    if s[k] in list:
        pass
    else:
        print("No")
        sys.exit()
    k+=1
print("Yes")

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

int main(void){
	string s;
	cin >> s;
	if(s[0]==s[1] && s[1]==s[2]){
		cout << "Yes" << endl;
		return 0;
	}
	else if(s[1]==s[2] && s[2]==s[3]){
		cout << "Yes" << endl;
		return 0;
	}
	else{
		cout << "No" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        String[] array = line.split(" ");
        int hp = Integer.parseInt(array[0]);
        int attack = Integer.parseInt(array[1]);
        
        int result = 0;
        result = hp / attack;
        if(hp % attack != 0)
        {
            result++;
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] = A[i] % 4
        if A[i] == 3:
            A[i] = 1
    if A.count(2):
        if A.count(1) + 1 - A.count(0) <= 1:
            print('Yes')
        else:
            print('No')
    else:
        if A.count(1) - A.count(0) <= 1:
            print('Yes')
        else:
            print('No')


resolve()

Measured memory_bytes: 62576
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int ans=1<<30;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        int p=0;
        while(a%2==0){
            a/=2;
            p++;
        }
        ans=min(ans,p);
    }
    cout<<ans<<endl;
}


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

int abs(int n) {
    if (n < 0) return -n;
    else return n;
}

int main() {
    int N;
    cin >> N;
    vector<int> t(N + 1), x(N + 1), y(N + 1);
    t[0] = 0, x[0] = 0, y[0] = 0;

    for (int i = 1; i <= N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    bool ispossible = true;

    for (int i = 0; i < t.size() - 1; i++) {
        /*if (t[i + 1] - t[i] == 1) {
            if (abs(x[i + 1] - x[i]) == 0) {
                if (abs(y[i + 1] - y[i]) == 1) continue;
            } else if (abs(x[i + 1] - x[i]) == 1) {
                if (abs(y[i + 1] - y[i]) == 0) continue;
            }
            ispossible = false;
            break;
        } else {*/
            int time = t[i + 1] - t[i], xnow = x[i], ynow = y[i];
            while (time > 0) {
                if (xnow < x[i + 1]) xnow++;
                else if (xnow > x[i + 1]) xnow--;
                else if (ynow < y[i + 1]) ynow++;
                else if (ynow > y[i + 1]) ynow--;
                else xnow++;
                //cout << '(' << xnow << ", " << ynow << ')' << endl;
                time--;
            }
            if (xnow == x[i + 1] && ynow == y[i + 1]) continue;
            else {
                ispossible = false;
                break;
            }
        //}
    }

    if (ispossible) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4496
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int n;
  cin >> n;
  int a[n];
  int mpo[100000]={};
  int mpe[100000]={};
  int count=0;
  REP(i, n) {
    cin >> a[i];
    if(i && a[i] == a[i-1]) ++count;
    if(i%2) ++mpo[a[i]];
    else ++mpe[a[i]];
  }
  if(count == n-1){
    cout << n/2 << endl;
    return 0;
  }

  int maxo=0, maxe=0, oi, ei, ans;
  REP(i, n){
    if(maxo < mpo[i]){
    maxo=max(maxo, mpo[i]);
      oi = i;
    }
    if(maxe < mpe[i]){
    maxe=max(maxe, mpe[i]);
      ei = i;
    }
  }
  sort(mpo, mpo + 100000, greater<int>());
  sort(mpe, mpe + 100000, greater<int>());
  if(oi != ei) {
    ans = n - mpo[0] - mpe[0];
  }
  else {
    ans = n - max(mpo[0] + mpe[1], mpe[0] + mpo[1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x,c=0,p=0,q=0,y=0;
cin>>x>>n;
p=x;
q=x;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
	for(int i=0;i<=101;i++)
	{
		int k=0;
	for(int j=0;j<n;j++)
	{
if(x+i==a[j])
{
k=1;
break;
}
}
if(k==0)
{
p=x+i;
break;
}
}
for(int i=0;i<=101;i++)
	{
		int y=0;
	for(int j=0;j<n;j++)
	{
if(x-i==a[j])
{
y=1;
break;
}
}
if(y==0)
{
q=x-i;
break;
}
}
if(abs(x-q)>abs(x-p))
cout<<p<<endl;
else
cout<<q<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll N, M;
ll a[MAX];

ll ans() {
	ll x = a[1] / 2;

	for (int i = 2; i <= N; i++) {
		x = lcm(x, a[i] / 2);
		if (x > M) { return 0; }
	}

	for (int i = 1; i <= N; i++) {
		if (x / (a[i] / 2) % 2 == 0) { return 0; }
	}


	return (M / x + 1) / 2;

}


int main() {

	cin >> N >> M;
	repn(i, N) cin >> a[i];

	cout << ans();

	system("PAUSE");


}


Measured memory_bytes: 1272
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=1000005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,a[max_n];
int p[max_n];
void work(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i)continue;
        int c=0;
        while(n%i==0)n/=i,c++;
        p[i]=max(p[i],c);
    }
    if(n!=1)p[n]=max(p[n],1);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    for(int i=1;i<=n;i++){
        int x=a[i];
        work(x);
    }
    int ans=1;
    for(int i=1;i<max_n;i++)ans=Mul(ans,Pow(i,p[i]));
    int res=0;
    for(int i=1;i<=n;i++)res=Add(res,Pow(a[i],mod-2));
    ans=Mul(ans,res);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <iostream>

#include <string>
using namespace std;
int a,b,c,d;
int main(){
  scanf("%d %d %d %d",&a,&b,&c,&d);
  int x=c-a,y=d-b;
  string str=string(x,'R')+string(y,'U')
  +string(x,'L')+string(y,'D')
  +string(1,'D')+string(x+1,'R')+string(y+1,'U')+string(1,'L')
  +string(1,'U')+string(x+1,'L')+string(y+1,'D')+string(1,'R');
  //printf("%c\n",str);
  cout <<str<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
L = input()
def func1(N):
  if len(str(N)) == 5:
    if str(N)[0] in L or str(N)[1] in L or str(N)[2] in L or str(N)[3] in L or str(N)[4] in L:
      return False
  elif len(str(N)) == 4:
    if str(N)[0] in L or str(N)[1] in L or str(N)[2] in L or str(N)[3] in L:
      return False
  elif len(str(N)) == 3:
    if str(N)[0] in L or str(N)[1] in L or str(N)[2] in L:
      return False
  elif len(str(N)) == 2:
    if str(N)[0] in L or str(N)[1] in L:
      return False
  elif len(str(N)) == 1:
    if str(N)[0] in L:
      return False
  else:
    return True
while func1(N) == False:
  N += 1
print(N)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#define NUM 200

int main()
{
   static long i,j,k,l;
   static char p[102];
   static char s[102];
   static char ch;
   static int sum[26];
   char ok;

   fgets(p,1005,stdin);
   fgets(s,1005,stdin);
   for(i=0;p[i] != '\n';i++) {
      if(p[i] == s[0]) {
         ok = 1;
         k = i;
         for(j=0;s[j] != '\n';j++) {
            if(p[k+j] == '\n')
               k -= k+j;
            if(p[k+j] != s[j]) {
               ok=0;break;
            }
         }
         if(ok)
            break;
      }
   }
   if(ok)
      cout << "Yes";
   else
      cout << "No";
   cout << endl;



    
   return 0;
}

Measured memory_bytes: 1124
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        a = [len(S()) for _ in range(n)]

        def f(i):
            t = [5,7,5,7,7]
            ti = 0
            for c in a[i:]:
                if c > t[ti]:
                    return False
                if t[ti] == c:
                    ti += 1
                    if ti == 5:
                        return True
                else:
                    t[ti] -= c
            return False

        r = 0
        for i in range(n):
            if f(i):
                r = i+1
                break

        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9040
#include<stdio.h>
int main()
{
	long long n,i,sum;
	char a[100005];
	while(~scanf("%lld",&n))
	{getchar();
	 for(i=0;i<n;i++)
	 scanf("%c",&a[i]);
	 sum=1;
	 for(i=1;i<n;i++)
	 {if(a[i]!=a[i-1])sum++;
	 }
	printf("%lld\n",sum);
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

L, R = map(int, input().split())

mod = 2019

if R - L > mod:
    print(0)
    exit()

if R % mod > L % mod:
    L_mod = L % mod
    R_mod = R % mod
else:
    L_mod = R % mod
    R_mod = L % mod

lowest = mod
for i in range(L_mod, R_mod):
    for j in range(i + 1, R_mod + 1):
        r = i * j % mod
        lowest = min(r, lowest)

print(lowest)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>

//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//// 任意長整数型
//using Bint = mp::cpp_int;
//// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
//
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;

const int MOD = 1000000007;

ll N;
vector<bool> cand;
ll sum = 0;
vector<vector<P>> A;

void dfs(vector<bool> A_candidate){
    if(A_candidate.size()>=N){
//        for(ll k=0;k<N;k++){
//            if(A_candidate[k]) cout << 1 << " ";
//            else{
//                cout << 0 << " ";
//            }
//        }
//        cout << endl;
        
        bool flag = true;
        for(ll i=0;i<N;i++){
            if(!A_candidate[i]) continue;
//            cout << "A[i].size : " << A[i].size() << endl;
            for(ll j=0;j<A[i].size();j++){
                if((A[i][j].second == 0 && A_candidate[A[i][j].first] == true)){
                    flag=false;
                }
                else if((A[i][j].second == 1 && A_candidate[A[i][j].first] == false)){
                    flag = false;
                }
            }
        }
//        cout << "flag = " << flag << endl;
        if(flag){
            ll t_num = 0;
            for(ll i=0;i<N;i++){
                if(A_candidate[i]) t_num++;
            }
            sum = max(sum, t_num);
        }
        return;
    }
    A_candidate.push_back(true);
    dfs(A_candidate);
    A_candidate.pop_back();
    A_candidate.push_back(false);
    dfs(A_candidate);
    
}


int main(int argc, const char * argv[]) {
    cin >> N;
    vector<bool> A_candidate;
    
    for(ll i=0;i<N;i++){
        ll A_num; cin >> A_num;
        vector<P> A_pair(A_num);
        for(ll j=0;j<A_num;j++){
            
            cin >> A_pair[j].first >> A_pair[j].second;
            A_pair[j].first--;
        }
        A.push_back(A_pair);
    }
    
////    入力チェック
//    for(ll i=0;i<N;i++){
//        cout << "i  =  " << i << endl;
//        for(ll j=0;j<A[i].size();j++){
//            cout << A[i][j].first << "  " <<A[i][j].second << endl;
//        }
//    }
//
    dfs(vector<bool>());
    cout << sum << endl;
    
    
    
}



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

void solve(long long H, long long W, long long N, vector<long long> X, vector<long long> Y){
	vector<set<long long>> O(W + 2);
	for(int i = 0; i <= W; ++i) {
		O[i].insert(H + 1);
	}
	for(int i = 0; i < N; ++i) {
		O[Y[i]].insert(X[i]);
	}

	long long res = H;
	long long r = 1, c = 1;
	for(; c <= W; ++c) {
		//cerr << r << "," << *O[c].upper_bound(r) << endl;
		res = min(res, *O[c].upper_bound(r) - 1);
		if(r < H && c < W) {
			do {
				++r;
			} while(O[c + 1].find(r) != O[c + 1].end());
		}
		if(r > H) break;
	}
	cout << res << endl;
}

int main(){	
	long long N;
	long long H;
	long long W;
	scanf("%lld",&H);
	scanf("%lld",&W);
	scanf("%lld",&N);
	vector<long long> X(N-1+1);
	vector<long long> Y(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&X[i]);
		scanf("%lld",&Y[i]);
	}
	solve(H, W, N, X, Y);
	return 0;
}



Measured memory_bytes: 34688
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int k;
  string str;
  cin>>k>>str;
  if(str.size()<=k)cout<<str;
  else
  {
    for(int i=0;i<k;i++)
    {
      cout<<str[i];
    }
    cout<<"...";
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<atcoder/all>
#define a(x,y)if(std::gcd(x,y)==1)A=x*atcoder::inv_mod(x,y),m=std::min(m,(A>1?A:A+N)-1);
int main(){long long m,N,A,i=1;std::cin>>N;N*=2;m=N*9;for(;i*i<N;i++)if(N%i==0){a(i,N/i)a(N/i,i)}std::cout<<m;}

Measured memory_bytes: 3636
from itertools import accumulate
n,m = map(int,input().split())
a = list(map(int,input().split()))
ls_0 = [0 for i in range(m*2+2)]
ans_0 = 0
for i in range(1,n):
  if a[i-1] < a[i]:
    l = a[i-1]+2
    r = a[i]+1
  else:
    l = a[i-1]+2
    r = a[i]+m+1
  ls_0[l] += 1
  ls_0[r] -= (r-l+1)
  ls_0[r+1] += r-l
  ans_0 += r-l+1

ls_1 = list(accumulate(ls_0))
ls_2 = list(accumulate(ls_1))
ls_3 = [0]+[ls_2[i]+ls_2[i+m] for i in range(1,m+1)]
print(ans_0-max(ls_3))

Measured memory_bytes: 33056
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    for a in A:
        if a == cnt + 1:
            cnt += 1
    if cnt == 0:
        print(-1)
    else:
        print(N-cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 77516
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        int xmin,xmax,ymin,ymax;
        xmin = xmax = ymin = ymax = 0;
        vector<pair<int,int> > sq(n);
        sq[0] = make_pair(0,0);

        for(int i=1; i<n; i++){
            int n,d,x,y;
            cin >> n >> d;
            x = sq[n].first + dx[d];
            y = sq[n].second + dy[d];
            sq[i] = make_pair(x,y);
            xmin = min(x, xmin);
            ymin = min(y, ymin);
            xmax = max(x, xmax);
            ymax = max(y, ymax);
        }
        cout << xmax-xmin+1 << " " << ymax-ymin+1 << endl;   
    }
    return 0;
}

Measured memory_bytes: 3104
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    d, x = map(int, input().split())
    a = 0
    for i in range(n):
        a = int(input())
        ans += 1 + (d-1)//a
    print(ans+x)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int N; string S; cin >>N >>S;
  vi left(N+1);
  vi right(N+1);
  rep(i,0,N) {
    if (S[i]=='#') {
      left[i+1]=left[i]+1;
    } else {
      left[i+1]=left[i];
    }
    if (S[N-i-1]=='.') {
      right[N-i-1]=right[N-i]+1;
    } else {
      right[N-i-1]=right[N-i];
    }
  }

  int ans=INT_MAX;
  rep(i,0,N+1) {
    chmin(ans,left[i]+right[i]);
  }

  cout <<ans <<'\n';
  return 0;
}


Measured memory_bytes: 5172
n = int(input())
now, bef = 0, 0
ans = 0
for i in range(n):
  now = int(input())
  if now == 0 and bef == 1:
    bef = 0
  if (now+bef)%2 == 0:
    if bef == 0:
      ans += now//2
      bef = 0
    else:
      ans += (now+bef)//2
      bef = 0
  else:
    if bef == 0:
      ans += now//2
      bef = 1
    else:
      ans += (now+bef)//2
      bef = 1

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iterator>
#include <queue>
#include <stack>
#include <vector>
#include <utility>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
template<class T> using vv=vector< vector<T> >;
typedef deque<int> di;
typedef deque< deque<int> > ddi;


int main() {
    int x, y;
    while(cin >> x >> y){
    int out;
    if(x <= 0 && y <= 0) {
        if(abs(x) > abs(y)) {
            out = y-x;
            if(y == 0) out = -x;
        } else {
            out = 2+x-y;
            if(x == 0) out = -y+1;
        }
    } else if(x > 0 && y <= 0) {
        if(abs(x) > abs(y)) {
            out = 1+x+y;
        } else {
            out = 1+abs(y)-x;
        }
    } else if(x < 0 && y >= 0) {
        if(abs(x) > abs(y)) {
            out = 1-x-y;
        } else {
            out = 1+abs(y+x);
        }
    } else {
        if(abs(x) > abs(y)) {
            out = 2+abs(x-y);
        } else {
            out = y-x;
        }
    }
    cout << out << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main() {
 int a, b;
  cin >> a >> b;
  int c = (a + b) / 2;
  if (abs(a-c) == abs(b-c)) {
   cout << c << endl; 
  }
  else {
   cout << "IMPOSSIBLE" << endl; 
  }
}

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

int main() {
  int a, b, c, d, x;
  cin >> a >> b;
  c = b - a;

  int i = 0;
  while (i <= c) {
    d = d + i;
    i++; 
  }
  
  x = d - b;
  cout << x << endl;
}

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

signed main()
{
    int N; cin>>N;
    vector<int> h(N);
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    
    vector<int> dp(N);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i=2;i<N;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[N-1]<<endl;
}


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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      for (; x > 0; x /= 10) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
      }
    }
  }
  cout << endl;
}

Measured memory_bytes: 3076
def d_banned_k():
    from collections import Counter
    N = int(input())
    A = [int(i) for i in input().split()]

    count = Counter(A)
    total = sum(c * (c - 1) // 2 for c in count.values())

    ans = [total - (count[a] - 1) for a in A]
    return ' '.join(map(str, ans))

print(d_banned_k())

Measured memory_bytes: 39300
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int n;
    vector<int> high;
     
    for(int i=0 ; i<10 ; i++){
        cin >> n;
        high.push_back( n );
    }
     
    sort( high.begin() , high.end() );
 
    for(int i=9 ; i>=7 ; i--){
        cout << high.at( i ) << endl;
    }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 200005
ll fact[MAX_P];
ll extgcd(ll a,ll b,ll& x,ll& y){
  ll d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
ll mod_inverse(ll a,ll m){
  ll x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

ll euler_phi(ll n){
  ll res=n;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0){
      res=res/i*(i-1);
      for(;n%i==0;n/=i);
    }
  }
  if(n!=1) res=res/n*(n-1);
  return res;
}

ll euler[MAX_N];

void euler_phi2(){
  for(ll i=0;i<MAX_N;i++) euler[i]=i;
  for(ll i=2;i<MAX_N;i++){
    if(euler[i]==i){
      for(int j=i;j<MAX_N;j+=i) euler[j]=euler[j]/i*(i-1);
    }
  }
}

ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  ll res=mod_fact(n/p,p,e);
  e+=n/p;
  if(n/p%2!=0)return res*(p-fact[n%p]) %p;
  return res*fact[n%p]%p;
} 
ll mod_comb(ll n,ll k,ll p){
  if(n==k||k==0) return 1;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%p,p)%p;
}

int main(){
  ll a,b,c,d;
  cin >> a >> b;
  extgcd(a,b,c,d);
  cout << c << " " << d << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

ll a, n;
ll arr[55], dp[55][2500][55];
ll gen(int i, int sum, int num){
    if(i==n && num && ((double)sum/(double)num) == sum/num && sum/num==a) return 1;
    if(i==n) return 0;

    ll &ret = dp[i][sum][num];
    if(~ret) return ret;

    return ret = gen(i+1, sum, num) + gen(i+1, sum+arr[i], num+1);
}

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

    cin >> n >> a;
    for(int i=0; i<n; i++) cin >> arr[i];

    memset(dp, -1, sizeof dp);
    cout << gen(0, 0, 0);
    return 0;
}


Measured memory_bytes: 59392
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<(i32, i32)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();
    let mut b: Vec<(i32, i32)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();
    a.sort();
    b.sort();

    let mut used = vec![false; n];
    let mut ans = 0;
    for i in 0..n {
        let x = b[i].0;
        let y = b[i].1;
        let mut maxy = 0;
        let mut pair = n;
        for j in 0..n {
            if used[j] {
                continue;
            }
            if a[j].0 < x && a[j].1 < y && maxy <= a[j].1 {
                maxy = a[j].1;
                pair = j;
            }
        }
        if pair == n {
            continue;
        } else {
            ans += 1;
            used[pair] = true;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	queue<pair<string, int>> que;
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; ++i) {
		string s;
		int t;
		cin >> s >> t;
		que.push(make_pair(s, t));
	}

	int time = 0;
	do {
		if (que.front().second <= q) {
			time += que.front().second;
			cout << que.front().first << " " << time << endl;
			que.pop();
		}
		else {
			que.push(make_pair(que.front().first, que.front().second - q));
			que.pop();
			time += q;
		}
	} while (que.size() != 0);
	
	return 0;
}


Measured memory_bytes: 6336
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        char[] input = next().toCharArray();
        int last = input.length - 1;
        int change = 0;
        for (int i = 0; i < input.length; i++) {
            if (i > last) break;
            if (input[i] != input[last]) change++;
            last--;
        }
        System.out.println(change);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 22484
#include"bits/stdc++.h"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using ll=long long; 
using ld=long double; 
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int mod1=1e9+7; 
int main()
{
    #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  string s; cin>>s; int n=s.size(); 
  if(s[n-1]=='s') s+="es"; else s+="s"; 
  cout<<s; 
}

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

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  char c; cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel\n";
  else cout << "consonant\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;
typedef unsigned int uint;

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

    if (A == B) {
        cout << A << endl;
        return 0;
    }
    
    ll ret = 0;
    rep(k,40) {
        //cout << "bit:" << k << endl;
        ll a_bit = (A >> k) & 1;
        ll b_bit = (B >> k) & 1;

        //cout << "a_bit:" << a_bit << endl;
        //cout << "b_bit:" << b_bit << endl;

        ll a_sub = A;
        ll b_sub = B;
        for(int n=k; n<=40;n++){
            a_sub &= ~((ll)1<<n);
            b_sub &= ~((ll)1<<n);
        }

        //cout << "a_sub:" << a_sub << endl;
        //cout << "b_sub:" << b_sub << endl;

        ll bit_num = 0;
        ll A_temp, B_temp;
        if (a_bit == 1) {
            A_temp = A + (pow(2,k) - a_sub);
            bit_num += (pow(2,k) - a_sub);
        } else {
            A_temp = A;
        }
        if (b_bit == 1) {
            B_temp = B - (b_sub+1);
            bit_num += b_sub+1;
        } else {
            B_temp = B;
        }

        if (k == 0) {
            if (A%2 == 1) A_temp = A-1;
            if (B%2 == 1) B_temp = B+1;
            if ((B_temp - A_temp) % 4 != 0) {
                bit_num = 1;
            } else {
                bit_num = 0;
            };
        }

        //cout << "A_temp:" << A_temp << endl;
        //cout << "B_temp:" << B_temp << endl;

        if (B_temp < A_temp) {
            bit_num = B - A + 1;
        }

        

        //cout << "bit_num:" << bit_num << endl;

        if (bit_num % 2 == 1) {
            ret += pow(2,k);
        }

        //cout << ret << endl;
        //cout << "------------" << endl;

    }

    cout << ret << endl;
    
    return 0;
}


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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



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

const int N = 200005;


void solve()
{
	int n;
	cin >> n;
	cout << (n + n * n + n * n * n) << endl;

	return;
}

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



	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int r;
	cin >> r;
	r = r * r * 3;
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 256