akhauriyash/Code-Regression huggingface dataset:
H, N = map(int, input().split())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
for i in range(N):
    A[i], B[i] = list(map(int, input().split()))

max_damage = max(A)
dp = [0 for _ in range(H + max_damage)]
for i in range(1, H + max_damage):
    dp[i] = min(dp[i - a] + b for a, b in zip(A, B))

print(min(dp[H:]))

Measured memory_bytes: 3536
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		int n = in.nextInt();
		
		int[][] ans = new int[h][w];
		//ArrayList<Integer> lst = new ArrayList<Integer>();
		
		int[] lst = new int[n];
		for(int i=0;i<n;i++)
			lst[i]=in.nextInt();
		int j =0;
		int cur = 1;
		int pos = 0;
		for(int i=0;i<h;i++){
			while(j>=0&&j<w){
				ans[i][j]=pos+1;
				j+=cur;
				if(lst[pos]==1)
					pos++;
				else
					lst[pos]--;
				
				
			}
			cur*=-1;
			j+=cur;
			
			
		}
		
		for(int i=0;i<h;i++){
			for( j=0;j<w;j++){
				System.out.print(ans[i][j]+ " " );

			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 32948
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	char str[201], tmp[201], work;
	int i, j, n, h, slen;
	while (1) {
		cin >> str;
		slen = strlen(str);
		if (slen == 1 && str[0] == '-')
			break;
		cin >> n;
		while (n--) {
			cin >> h;
			for (i = 0, j = h; i < slen; i++, ++j %= slen) {
				if (i < h)
					tmp[i] = str[j];
				else
					tmp[i] = str[j];
			}
			for (i = 0; i < slen; i++)
				str[i] = tmp[i];
			str[i] = '\0';
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, M;
  cin >> N >> M;
  priority_queue<ll> A;

  for (ll i = 0; i < N; i++) {
    ll x;
    cin >> x;
    A.push(x);
  }
  for (ll i = 0; i < M; i++) {
    auto value = A.top();
    A.pop();
    auto newValue = value / 2;
    A.push(newValue);
  }
  ll sum = 0;
  while(A.size() > 0) {
    sum += A.top();
    A.pop();
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1400
#include <iostream>

using namespace std;
const int NMAX=150;
int v[NMAX];

int main()
{
    long long x,i,n,mmin,mmax,bani=1000,st=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>v[i];
    }
    for(i=1;i<=n;i++){
        x=i;
        mmin=v[i];
        while(v[i]>v[i+1]&&i<n){
            i++;
            mmin=v[i];
        }
        mmax=v[i];
        while(v[i]<v[i+1]&&i<n){
            i++;
            mmax=v[i];
        }
        if(x!=i){
            st=bani/mmin;
            bani=st*mmax+bani%mmin;
            st=0;
            i--;
        }
    }
    if(st)
        bani=st*mmax+bani%mmin;
    cout<<bani;
    return 0;
}


Measured memory_bytes: 3632
def solve(N,S,A):
    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    mod = 998244353
    for i, a in enumerate(A, 1):
        for s in range(S+1):
            if s-a >= 0:
                dp[i][s] = (dp[i-1][s] * 2 + dp[i-1][s-a]) % mod
            else:
                dp[i][s] = dp[i-1][s] * 2 % mod
    print(dp[N][S])

N, S = map(int, input().split())
A = list(map(int, input().split()))
solve(N,S,A)


Measured memory_bytes: 132364
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a,b,c;
  cin >> a >> b >> c;
  string x = a.substr(0,1) + b.substr(0,1) + c.substr(0,1);
  transform(x.begin(),x.end(),x.begin(),::toupper);
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列以外を出力する
    void write(){

    }
    template<typename First, typename... Rest>
    void write(First first, Rest... rest){
        cout << first << " ";
        write(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    int N;
    io.read(N);
    vector<int> V(N);
    vector<int> C(N);
    for(int i = 0; i < N; i++){
        io.read(V[i]);
    }
    for(int i = 0; i < N; i++){
        io.read(C[i]);
    }
    vector<int> sub(N);
    for(int i = 0; i < N; i++){
        sub[i] = V[i] - C[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(sub[i] > 0) ans += sub[i];
    }
    io.write(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1001;
int matr[N][N],n,cur[N],sol,done,ok[N][N];
queue<pair<int,int> > q;
int main()
{
    scanf("%d",&n);
    fill(cur+1,cur+n+1,1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n-1;j++){
            scanf("%d",&matr[i][j]);
        }
    }
    for(int i=1;i<=n;i++){
        int u=matr[i][1];
        if(!ok[u][i] && matr[u][1]==i){
            q.push({i,u});
            ok[u][i]=1;
            ok[i][u]=1;
        }
    }
    while(!q.empty()){
        vector<int> tmp;
        while(!q.empty()){
            if(++cur[q.front().first]<n)    tmp.push_back(q.front().first);
            else
                done++;
            if(++cur[q.front().second]<n)   tmp.push_back(q.front().second);
            else
                done++;
            q.pop();
        }
        sol++;
        for(int i=0;i<tmp.size();i++){
            int l=tmp[i];
            int u=matr[l][cur[l]];
            if(matr[u][cur[u]]==l && !ok[u][l]){
                q.push({u,l});
                ok[l][u]=1;
                ok[u][l]=1;
            }
        }
    }
    if(done!=n){
        printf("-1");
    }
    else
        cout<<sol;
    return 0;
}


Measured memory_bytes: 8192
import copy
n = int(input())
x = list(map(int, input().split()))
y=x.copy()
x.sort()
for i in range(n):
    if y[i] <= x[n//2-1]:
        print(x[n//2])
        #print('↓')
        continue
    if y[i] >= x[n//2]:
        print(x[n//2-1])
        #print('↑')
        continue

Measured memory_bytes: 27156
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n,m;
int cost[MAXN];
int mask[MAXN];
int complete;
map <int,int> mp;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	complete = (1<<n) - 1;
	for (int i = 0; i < m; ++i)
	{
		int b;
		cin >> cost[i] >> b;
		int ms = 0;
		for (int j = 0; j < b; ++j)
		{
			int box; cin >> box;
			ms |= (1<<box-1);
		}
		mask[i] = ms;
	}

	for (int i = 0; i < m; ++i)
	{
		for (auto j : mp)
		{
			int newmask = j.first | mask[i];
			if(mp.count(newmask))
				mp[newmask] = min(mp[newmask], j.second + cost[i]);
			else
				mp[newmask] = j.second + cost[i]; 
		}
		if(mp.count(mask[i]))
			mp[mask[i]] = min(mp[mask[i]], cost[i]);
		else
			mp[mask[i]] = cost[i];
	}

	if(mp[complete])
		cout << mp[complete] << endl;
	else
		cout << -1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;



int main(){
    fast_io
    
    int x, y, z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if (((a % 2) == 1) && ((b % 2) == 1)) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3588
X_list =  [list(map(int, input().split())) for _ in range(list(map(int, input().split()))[0])]
print((sum([((sum([(x1 - x2) ** 2 for x1, x2 in zip(x_lis1, x_lis2)])) ** (0.5) % 1) == 0 for x_lis1 in X_list for x_lis2 in X_list]) - len(X_list)) // 2)

Measured memory_bytes: 38384
from collections import OrderedDict
while True:
    num = int(input())
    if not num: break
    result = OrderedDict()
    for _ in range(num):
        x, y, z = [int(el) for el in input().split(' ')]
        if x in result:
            result[x] += y*z
        else:
            result[x] = y*z
    res = [print(k) for k,v in result.items() if v >= 1e6]
    if not res: print('NA')

Measured memory_bytes: 8340
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<Integer,Integer> map = new TreeMap<>();

        String temp = sc.nextLine();

        String[] tempArr = temp.split(" ");

        int H = Integer.parseInt(tempArr[0]);
        int W = Integer.parseInt(tempArr[1]);

        temp = sc.nextLine();

        tempArr = temp.split(" ");

        int h = Integer.parseInt(tempArr[0]);
        int w = Integer.parseInt(tempArr[1]);

        System.out.println((H - h) * (W - w));




    }

}


Measured memory_bytes: 23252
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{

	public static void main(String[] args) {
		long mod = (long)(1e9+7);
		Scanner input = new Scanner(System.in);
		long A = input.nextLong();
		long B = input.nextLong();
		long N = input.nextLong();
		if (B==1) System.out.println(0);
		else {
			long max = A*N/B-N/B*A;
			for (long x = B-1; x <= N; x+=B) {
				long factor = x/B;
				long cur = A*x/B-factor*A;
				max = Math.max(max, cur);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 26984
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> P;
 
#define M 1005
#define MOD 1000000007
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//freopen("input.txt","rt",stdin);
	
	int r;
	cin>>r;
	
	double ans = (double)(2*(3.1415926535)*r);
	cout<<fixed<<setprecision(5)<<ans<<"\n";
}


Measured memory_bytes: 3792
# include "bits/stdc++.h"

using namespace std;

#define endl "\n"
typedef long long int ll;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

ll INF = 1e10;
int MOD = 1e9+7;

int main(){
	fastio();
	int n,m;
	cin>>n>>m;
	vector<string> s(n);
	for(int i=0;i<n;++i) cin>>s[i];
	int dp[n][m];
	dp[0][0] = (s[0][0] == '.') ? 1 : 0;
	for(int i=0; i<n; ++i){
		for(int j=0;j<m;++j){
			if(i == 0 && j == 0) continue;
			else if(s[i][j] == '#') dp[i][j] = 0;
			else if(i == 0) dp[0][j] = dp[0][j-1];
			else if(j == 0) dp[i][0] = dp[i-1][0];
			else{
				dp[i][j] = dp[i-1][j] + dp[i][j-1];
				if(dp[i][j] >= MOD) dp[i][j]-=MOD;
			}
		}
	}
	cout<<dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 8536
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pii pair<long long,long long>
#define reset(a,b) memset(a,b,sizeof a)
#define ll long long
#define MOD 1000000007
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define dalam fl<=l && r<=fr
#define kiwo 2*(idx),l,MID
#define tengen 2*idx+1,MID+1,r
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 200003
#define pc(x) putchar_unlocked(x);

int bit[mx],a[mx],n;
vector<int>ve;

void upd(int idx,int val){
	for(;idx<=n;idx+=idx&-idx)
		bit[idx]+=val;
}

int cari(int idx){
	int ret=0;
	for(;idx;idx-=idx&-idx)
		ret+=bit[idx];
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ve.pb(a[i]);
	}
	sort(ALL(ve));
	for(int i=1;i<=n;i++){
		int in=lower_bound(ALL(ve),a[i])-ve.begin()+1;
		upd(in,1);
	}
	for(int i=1;i<=n;i++){
		int in=lower_bound(ALL(ve),a[i])-ve.begin()+1;
		upd(in,-1);
		int lo=1,hi=n,tengah;
		while(lo<=hi){
			int mid=(lo+hi)/2;
			if(cari(mid-1)<=n/2-1){
				lo=mid+1;
				tengah=mid;
			}
			else hi=mid-1;
		}
		upd(in,1);
		cout<<ve[tengah-1]<<endl;
	}
}

Measured memory_bytes: 4724
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int k; cin>>k;
    string s; cin>>s;
    if(s.size()<=k) cout<<s<<endl;
    else{
        rep(i,k) cout<<s[i];
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
template <class T>
inline void Rd(T &res){
	char c;res=0;int k=1;
	while(c=getchar(),c<48&&c!='-');
	if(c=='-'){k=-1;c='0';}
	do{
		res=(res<<3)+(res<<1)+(c^48);
	}while(c=getchar(),c>=48);
	res*=k;
}
template <class T>
inline void Pt(T res){
	if(res<0){
		putchar('-');
		res=-res;
	}
	if(res>=10)Pt(res/10);
	putchar(res%10+48);
}
int n,a,b,c,d;
int main(){
	Rd(n);Rd(a);Rd(b);Rd(c);Rd(d);
	for(int i=1;i<=n;i++){
		ll l=1LL*(n-i)*c-1LL*(i-1)*d,r=1LL*(n-i)*d-1LL*(i-1)*c;
		if(abs(a-b)>=l&&abs(a-b)<=r){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a = [i for i in range(H)]

for i in range(H):
    a[i] = list(input())

row = []
column = []

for i in range(H):
    flag = True
    for j in range(W):
        if a[i][j] != '.':
            flag = False
            break
    if flag:
        row.append(i)

for j in range(W):
    flag = True
    for i in range(H):
        if a[i][j] != '.':
            flag = False
            break
    if flag:
        column.append(j)

for i in range(H):
    if i in row:
        continue
    for j in range(W):
        if j in column:
            continue
        print(a[i][j], end='')
    print('')

Measured memory_bytes: 4596
#include <stdio.h>
#include <stdlib.h>

#undef DEBUG

void
solver(int r)
{
    printf("%d\n", r*r);
    return;
}

int
main(int argc, char *argv[])
{
    int r;
#ifdef DEBUG
#else
    scanf("%d", &r);
#endif
    solver(r);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <tuple>
#define ll long long
using namespace std;


ll Solve(ll N,ll M) {
    if (N > M) {
        swap(N,M);
    }
    
    if (N == 1 && M == 1) {
        return 1;
    }

    if (N==1 && M>=2) {
        return M-2;
    }
    
    return (N-2)*(M-2);
    
    
    
    
}

int main() {
    ll N,M;
    cin>>N>>M;
    
    
    cout << Solve(N,M) << endl;
    
    
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    long m, v, p;
    cin >> n >> m >> v >> p;
    vector<long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

//    for (long x : a) cout << x << " ";
//    cout << "\n";

    long s = 0;
    int nn = n - p + 1;
    for (int i = 0; i < nn; i++) {
        s += a[i];
    }
    int res = p - 1;
    for (int i = 0; i < nn; i++) {
        long x =
                m * i +
                (a[i] + m) * (nn - i) - s +
                m * (p - 1);
//        cout << a[i] << " " << x << "\n";
        if (a[i] + m >= a[nn - 1] && x >= v * m) {
//            cout << "!!\n";
            res++;
        }

        s -= a[i];
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())

paper = []
numbers = sorted([int(input()) for _ in range(N)])

# for n in numbers:
for i in range(N - 1):
    if numbers[i] == numbers[i + 1]:
        numbers[i] = -1
        numbers[i + 1] = -1
    if numbers[i] != -1:
        paper.append(numbers[i])

if numbers[N - 1] != -1:
    paper.append(numbers[N - 1])
print(len(paper))

Measured memory_bytes: 8280
import math


# INPUT
n, k = map(int, input().split())

W = []

for _ in range(n):
    W.append(int(input()))


# CONSTRAINTS
P_min = max(max(W), math.ceil(sum(W) / k))
P_max = sum(W)


# PROCESS
while P_min < P_max:
    P_mid = (P_min + P_max) // 2

    cnt_track = 1
    sum_load = 0
    flag_success = True

    for w in W:
        sum_load += w
        if sum_load > P_mid:
            sum_load = w
            cnt_track += 1

        if cnt_track > k:
            flag_success = False
            break

    if flag_success:
        P_max = P_mid
    else:
        P_min = P_mid + 1


# OUTPUT
print(P_min)



Measured memory_bytes: 9616
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int max = Math.max(a, Math.max(b, c));
    if(max == a){
        System.out.println(max*10 + b + c);
    }else if(max == b){
        System.out.println(max*10 + a + c);
    }else{
        System.out.println(max*10 + a + b);
    }
    
    
	}
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int a, b;
    cin >> a >> b;
    cout << (a + b - 1) / b << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	L, R, D = getlist()
	ans = 0
	for i in range(L, R + 1):
		if i % D == 0:
			ans += 1

	print(ans)
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 64724
/**
 *    Author:   ElProfesor
 *	       
**/

#include<bits/stdc++.h>

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef vector <lli> vl;
typedef vector <string> vs;
typedef vector < pair <long, long> > vll;

// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(lli i=0; i<n; i++)
#define rep(i,k,n) for (lli i = k; i < n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

// Printing Data :
#define pvec(v) forz(i,v.si) cout<<v[i]<<" "; cout<<endl;
#define parr(arr, n) forz(i,n) cout<<arr[i]<<" "; cout<<endl;
#define p1(i) cout<<i<<endl;
#define p2(i, j) cout<<i<<" "<<j<<endl;
#define p3(i, j, k) cout<<i<<" "<<j<<" "<<k<<endl;
#define p4(i, j, k, l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
#define pc(b, s1, s2) cout << (b ? s1 : s2) << endl;

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

int main()
{
    kira; 

    string s1, s2; cin>>s1>>s2;

    s2.pop_back();

    pc(s1==s2, "Yes", "No");
    

    return 0;
}




















































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

template<class Z> bool is_prime(Z n) {
  if (n < 2 or (n > 2 and ~n & 1)) return false;
  for (Z i = 3; i * i <= n; i += 2) if (n % i == 0) return false;
  return true;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  for (int p = x; ; ++p) {
    if (is_prime(p)) {
      cout << p << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 256
# https://misteer.hatenablog.com/entry/ABC113

MOD = 10 ** 9 + 7

H, W, K = map(int, input().split())

K -= 1
# 以降縦棒の番号は0-indexedで扱う

dp = [[0 for _ in range(W)] for _ in range(H + 1)]
dp[0][0] = 1
# dp[h][k] = 横線h段からなるあみだくじで、0がkに来るものの数

for h in range(H):
    for b in range(1 << (W - 1)):
        if '11' in bin(b): continue

        perm = [i for i in range(W)]
        # 0-indexedの到達位置

        for i in range(W - 1):
            if (b >> i) & 1:
                perm[i], perm[i + 1] = perm[i + 1], perm[i]

        for i in range(W):
            dp[h + 1][perm[i]] += dp[h][i]
            dp[h + 1][perm[i]] %= MOD

print(dp[H][K])


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=110,MAX_V=220;

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

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

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

ll dfs(ll v,ll t,ll f)
{
	if (v==t)
		return f;
	used[v] = true;
	for (ll i=0; i<G[v].size(); ++i) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap>0) {
			ll 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;
}

ll max_flow(ll s,ll t)
{
	ll flow = 0;
	while(true){
		memset(used, 0, sizeof(used));
		ll f = dfs(s, t, inf);
		if (f==0) {
			return flow;
		}
		flow += f;
	}
}

ll N,M;
ll a[MAX_N],b[MAX_N],c[MAX_N],d[MAX_N];

int main(){
  cin>>N;
  ll s=2*N,t=s+1;

  for(ll i=0;i<N;i++){
    add_edge(s,i,1);
  }

  for(ll i=0;i<N;i++){
    add_edge(i+N,t,1);
  }

  ll tmpa,tmpb;
  for(ll i=0;i<N;i++){
    cin>>tmpa>>tmpb;
    a[i]=tmpa;
    b[i]=tmpb;
  }
  for(ll i=0;i<N;i++){
    cin>>tmpa>>tmpb;
    c[i]=tmpa;
    d[i]=tmpb;
  }

  for(ll i=0;i<N;i++){
    for(ll j=0;j<N;j++){
      if(a[i]<c[j]&&b[i]<d[j]){
        add_edge(i,N+j,1);
      }
    }
  }

  cout<<max_flow(s,t)<<endl;


  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
    string s;
    cin>>s;
    if(
    (s[0]==s[1] && s[1]==s[2])||
    (s[1]==s[2] && s[2]==s[3])
    ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  for(ll i=n;i;i++) {
    if(i%111==0||i%1111==0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3628
/**
 *    author:  Atreus
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 1000 + 10;
const int mod = 1e9 + 7;
int dp[maxn][maxn];
string s[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		cin >> s[i];
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			if (i + j == 2){
				dp[i][j] = 1;
				continue;
			}
			if (s[i - 1][j - 1] == '#')
				continue;
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	cout << dp[h][w] << endl;
}


Measured memory_bytes: 5248
using System;
using System.Collections.Generic;
class _0029
{
    public static void Main()
    {
        string sentence = Console.ReadLine();
        string[] words = sentence.Split();
        string maxLengthWord="",maxAppearedWord="";
        int cMax = 0, lMax = 0;
        Dictionary<string, int> count = new Dictionary<string, int>();
        Dictionary<string, int> length = new Dictionary<string, int>();
        for (int i = 0; i < words.Length; i++)
        {
            if (count.ContainsKey(words[i])) count[words[i]]++;
            else count[words[i]] = 1;
            if (!length.ContainsKey(words[i])) length[words[i]] = words[i].Length;
        }
        foreach (KeyValuePair<string, int> cDic in count) { if (cMax < cDic.Value) { maxAppearedWord = cDic.Key; cMax = cDic.Value; } }
        foreach (KeyValuePair<string, int> lDic in length) { if (lMax < lDic.Value) { maxLengthWord = lDic.Key; lMax = lDic.Value; } }
        Console.WriteLine(maxAppearedWord + " " + maxLengthWord);
    }
}

Measured memory_bytes: 5460
import math
n = list(map(int, input().split()))
s = [map(int, input().split()) for i in range(n[0])]
x,y = [list(i) for i in zip(*s)]
d=[]

for i in range(n[0]):
  d.append(math.sqrt(x[i] * x[i] + y[i] * y[i]))

c = 0
for i in range(n[0]):
  if d[i] <= n[1]:
    c += 1


print(c)

Measured memory_bytes: 121336
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}



Measured memory_bytes: 6384
N=int(input())
A=list(map(int, input().split()))

def kuriagari(n, m):
  if n+m == n^m:
    return 0
  else:
    return 1
  
num=0

zero_list = [0] * (N-1)
zero_list.append(N)
for i in range(N-1):
  if A[N-1-i] == 0:
    zero_list[N-2-i]=zero_list[N-1-i]
  else:
    zero_list[N-2-i]=N-1-i

for i in range(N):
  judge = 0
  num2 = 0
  j=0
  while judge == 0 and i+j<N:
    judge=kuriagari(num2, A[i+j])
    if judge==0:
      num2+=A[i+j]
      num+=zero_list[i+j]-(i+j)
    j+=zero_list[i+j]-(i+j)
      
print(num)
  

Measured memory_bytes: 78540
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long count = 0;
        while(n>1) {
            n = n / 2;
            count++;
        }
        long answer = 0;
        for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int w, h;
    cin >> h >> w;

    vector<string> s(h);
    vector<vector<pair<int, int> > > rn(h);
    for(int i=0; i<h; i++) {
        rn[i].resize(w);
        cin >> s[i];
        int l = 0, id = 0;
        for (int j=0; j<w; j++) {
            if (s[i][j] == '.') {
                l++;
            }
            if (s[i][j] == '#' || j==w-1) {
                for(int k=id; k<j; k++){
                    rn[i][k].first = l;
                }
                if (j==w-1) rn[i][j].first = l;
                l=0;
                id = j+1;
            }
        }
    }

    for (int i=0; i<w; i++) {
        int l = 0, id = 0;
        for(int j=0; j<h; j++) {
            if ( s[j][i] == '.') {
                l++;
            }
            if (s[j][i] == '#' || j==h-1) {
                for(int k=id; k<j; k++){
                    rn[k][i].second = l;
                }
                if (j==h-1) rn[j][i].second = l;
                l=0;
                id = j+1;
            }
        }
    }


    int m = 0;
    for(int r=0; r<h; r++){
        // cout << "--" << endl;
        for (int c=0; c<w; c++ ){
            // cout << rn[r][c].first << " " << rn[r][c].second << endl;
            m = max(m, rn[r][c].first + rn[r][c].second - 1);
        }
    }

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 35712
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 2005;

pll A[N];
ll dp[N][N];

void solve(){
	ll n;
	cin>>n;
	rep(i,1,n+1)	cin>>A[i].ft, A[i].sd=i;
	sort(A+1,A+n+1);reverse(A+1,A+n+1);
	rep(i,1,n+1){
		// err2(A[i].ft, A[i].sd);
		rep(j,0,i){
			ll l = j;
			ll r = i-j-1;
			dp[l+1][r] = max(dp[l+1][r], dp[l][r] + abs(l+1-A[i].sd)*A[i].ft);
			l = i-j-1;
			r = j;
			dp[l][r+1] = max(dp[l][r+1], dp[l][r] + abs(n-r-A[i].sd)*A[i].ft);
		}		
	}
	// rep(i,0,n+1)	{rep(j,0,n+1)	cout<<dp[i][j]<<" ";cout<<endl;}
	ll ans=0;
	rep(i,0,n+1)	ans=max(ans, dp[i][n-i]);
	cout<<ans<<endl;
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	// cin>>no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 26320
#include "iostream"
using namespace std;

int main(){

	int mplication, mplicand;

	for (int mplication = 1; mplication <= 9; ++mplication)
	{
		for (int mplicand = 1; mplicand <= 9; ++mplicand)
		{
			cout << mplication << "x" << mplicand << "=" << mplication * mplicand << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 1116
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
vector<pair<int,int> > test[15];

int check(int sset){
	vector<int> v;
	for(int i=0;i<n;i++){
		v.pb(sset%2);
		sset/=2;
	}
	//iterate through test
	for(int i=0;i<n;i++){
		if(v[i]){
			for(int j=0;j<test[i].size();j++){
				auto r = test[i][j];
				if(v[r.fi]!=r.se){
					return 0;
				}
			}
		}
	}

	return 1;
} 
 
int main()
{
	IOS;
	cin>>n;
	forn(i,n){
		cin>>m;
		forn(j,m){
			cin>>x>>y;
			x--;
			test[i].pb({x,y});
		}
	}
	int ans=0;
	for(int sset=0;sset<pow(2,n);sset++){
		if(check(sset)){
			int temp=0;
			for(int i=0;i<n;i++){
				if((sset & (1<<i)) > 0){
					temp++;
				}
			}
			ans=max(ans,temp);
		}
	}
	cout<<ans<<ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int a,b;
    cin>>a>>b;
    for(int i=0;i<2000;i++)
        if(floor(i*0.08)==a&&floor(i*0.1)==b)
            cout<<i<<endl,exit(0);
    cout<<-1<<endl;
}


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

using namespace std;
using LL = long long;
using VI = vector<int>;
using PI = pair<int, int>;

struct Dice {
	Dice() { d = new int[6]; }
	~Dice() { delete[] d; }

	void get() {
		for (int i = 0; i < 6; i++) {
			cin >> d[i];
		}
	}
	void roll(char c) {
		int t = d[0];
		int tmp = d[1];
		switch (c) {
		case 'N':
			d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = t;
			break;
		case 'S':
			d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = t;
			break;
		case 'W':
			d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = t;
			break;
		case 'E':
			d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = t;
			break;
		case 'r':
			d[1] = d[2]; d[2] = d[4]; d[4] = d[3]; d[3] = tmp;
			break;
		default:
			break;
		}
	}
	int top() { return d[0]; }
	int right() { return d[2]; }
	int front() { return d[1]; }
	int left() { return d[3]; }
	Dice & operator=(Dice & obj) { this->d = obj.d; }
	int* d;
};

int main() {
	Dice d;
	d.get();
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		if (d.left() == l) { d.roll('E'); }
		if (d.right() == l) { d.roll('W'); }
		while (d.top() != l) { d.roll('N'); }
		while (d.front() != r) { d.roll('r'); }
		cout << d.right() << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
int main(void)
{
    int i = 0, b = 0;
    char str[100];
    scanf("%s", str);
    
    while(str[i]){
        i++;
    }
    b = i-1;
    i = i-2;
    printf("%c%d%c\n", str[0], i, str[b]);
    
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <typename T> using order_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T1, typename T2> using order_map = tree <T1, T2, less <T1>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T> bool MIN(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool MAX(T &a, T b) { return a < b ? (a = b, true) : false; }

#define ll              long long int
#define endl            '\n'
#define pii             pair <int, int>
#define pll             pair <ll, ll>
#define mk              make_pair
#define ff              first
#define ss              second
#define all(a)          (a).begin(), (a).end()
#define rall(a)         (a).rbegin(), (a).rend()
#define eb              emplace_back
#define pb              push_back
#define LINE            __LINE__

static const int maxn = 1000 + 5;
static const int logn = 19;

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);


      auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
      mt19937 mt_rand(seed);

      function <ll(ll, ll)> Rand = [&](ll l, ll r) {
            ll rnd = uniform_int_distribution <ll> (l, r)(mt_rand);
            return rnd;
      };

      int n, m, need;
      cin >> n >> m >> need;
      vector <int> book_cost(n);
      vector < vector <int> > understanding_level(n, vector <int> (m));
      for (int i = 0; i < n; i++) {
            cin >> book_cost[i];
            for (int j = 0; j < m; j++) {
                  cin >> understanding_level[i][j];
            }
      }
      ll min_cost = numeric_limits <ll> :: max();
      bool found = false;
      for (int mask = 0; mask < (1 << n); mask++) {
            vector <int> increase(m);
            ll cost = 0;
            for (int i = 0; i < n; i++) {
                  bool bit = (bool)(mask >> i & 1);
                  if (bit) {
                        cost += book_cost[i];
                        for (int j = 0; j < m; j++) {
                              increase[j] += understanding_level[i][j];
                        }
                  }
            }
            int mini = numeric_limits <int> :: max();
            for (int i = 0; i < m; i++) {
                  MIN(mini, increase[i]);
            }
            if (mini >= need) {
                  found = true;
                  MIN(min_cost, cost);
            }
      }
      if (found == false) {
            min_cost = -1;
      }
      cout << min_cost;

      #ifndef ONLINE_JUDGE
            cerr << endl << "Time : " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
      #endif // ONLINE_JUDGE
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>
#include <iomanip>

using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()

bool dp[82][82][162*162];

int main(){
	int h,w;cin>>h>>w;
	vector<vector<int>> a(h,vector<int>(w)), c(h,vector<int>(w));
	rep(i,h)rep(j,w)cin>>a[i][j];
	rep(i,h)rep(j,w){
		int b;cin>>b;
		c[i][j]=a[i][j]-b;
	}
	int center = 81*161;
	rep(i,81)rep(j,81)rep(k,81*(i+j+2)){
		dp[i][j][center+k]=false;
		dp[i][j][center-k]=false;
	}
	dp[0][0][center+c[0][0]]=true;
	dp[0][0][center-c[0][0]]=true;
	rep(i,h)rep(j,w)rep(k,81*(i+j+2)){
		if(dp[i][j][center+k]){
			if(i+1<h){
				dp[i+1][j][center+k+c[i+1][j]]=true;
				dp[i+1][j][center+k-c[i+1][j]]=true;
			}
			if(j+1<w){
				dp[i][j+1][center+k+c[i][j+1]]=true;
				dp[i][j+1][center+k-c[i][j+1]]=true;
			}
		}
		if(dp[i][j][center-k]){
			if(i+1<h){
				dp[i+1][j][center-k+c[i+1][j]]=true;
				dp[i+1][j][center-k-c[i+1][j]]=true;
			}
			if(j+1<w){
				dp[i][j+1][center-k+c[i][j+1]]=true;
				dp[i][j+1][center-k-c[i][j+1]]=true;
			}
		}
	}
	int res=1e9;
	for(int i=0; ;++i){
		if(dp[h-1][w-1][center+i] || dp[h-1][w-1][center-i]){
			res=i;
			break;
		}
	}
	cout<<res<<endl;
}

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

using namespace std;


int main() {
    int x,y;
    cin >> x >> y;
    bool ok = false;
    for(int i = 0; i <= x; i++) {
        int rest = x - i;
        if(i * 2 + rest * 4 == y) {
            ok = true;
        }
    }
    if(ok) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4

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

    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    vector<bool> delh(h);
    vector<bool> delw(w);

    rep (i, h)
        init(a[i]);

    rep (i, h) {
        bool all = true;
        rep (j, w)
            if (a[i][j] == '#') {
                all = false;
                break;
            }
        delh[i] = all;
    }

    rep (j, w) {
        bool all = true;
        rep (i, h)
            if (a[i][j] == '#') {
                all = false;
                break;
            }
        delw[j] = all;
    }

    rep (i, h) {
        rep (j, w)
            if (!delh[i] and !delw[j]) cout << a[i][j];
        if (!delh[i]) cout << '\n';
    }

    return 0;
}

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

int main(){
  string n;
  int ans,l,i;
  cin >> n;
  ans = 0;
  l = (int)(n.length());
  // cout << l;
  for(i = 0;i< l;i++){
    ans += (int)n[i] - (int)'0';
  }
  // while(n != 0){
  //   ans += n % 10;
  //   n = n / 10;
  //   cout << n << endl;
  // }
  // cout << ans;
  if(ans % 9 == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++)
    cin >> a[i + 1];

  vector<int> a_checked(n + 1,0);
  int pos = 1;
  int cnt = 0;
  while ((pos != -1) && (pos != 2)) {
    if (a_checked[pos] == 1)
      pos = -1;
    else {
      a_checked[pos] = 1;
      pos = a[pos];
      cnt++;
    }
  }
  if (pos == -1)
    cout << pos << endl;
  else
    cout << cnt << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define MN(a,b,c)  min(a,min(b,c))
#define pr         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
ll dolog(ll n)
{
    int y=1,x=0;
    while(y<=n){y*=2;x++;}
  x--;
  return x;
}
ll pow2(ll x)
{
    ll y=1;
    while(x--){y*=2;}
    return y;
}
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  if(x==0)
  {
     if(k%2==0)
       cout<<0;
     else 
      cout<<d;
  }
  else if(x>0)
  {
    ll steps=x/d;
    if(k<steps)
      cout<<x-(k*d);
    else 
    {
      ll mnpx=x-(steps*d);
      ll mxnx=mnpx-d;
      if((k-steps)%2==0)
        cout<<mnpx;
      else 
        cout<<abs(mxnx);
    }
  }
 }

Measured memory_bytes: 3596
from math import gcd
def inv(n, p):
    """
    mod p の逆元
    """
    return pow(n, p-2, p)
def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += inv(a, mod)
    ans *= LCM % mod

    print(ans % mod)
main()

Measured memory_bytes: 73844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

const int N = 2e5 + 5;
char s[N], t[N];

int main()
{
	scanf("%s%s", s, t);	
	int len = strlen(s);
	int ans = 0;
	for (int i = 0; i < len; i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    unordered_set<int> st;
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            st.insert(a);
        }
    }
    int count = n;
    for(int i = 1; i <= n; i++){
        if(st.count(i)){
            count--;
        }
    }
    cout << count << '\n';
}

Measured memory_bytes: 3612