akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : (^o^).cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a,b,t,m;
    t=0;
    m=0;
    while(1)
    {
    cin>>a>>b;
    if(a==0&&b==0){
    	return 0;
    }
    while (1){
    	cout<<"#";
    	m++;
    	if(m==b){
    		cout<<endl;
    		m=0;
    		break;
    	}
    }
    while(1){cout<<"#";
    while (1){
    	cout<<".";
    	m++;
    	if(m==b-2){
    		m=0;
    		break;
    	}}cout<<"#"<<endl;
        t++;
if(t==a-2){
	break;
t=0;
}


    	} while (1){
        	cout<<"#";
        	m++;
        	if(m==b){
        		cout<<endl;
        		m=0;
        		break;
        	}}
    m=0;t=0;
    cout<<endl;}
	return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////


int main(){fastio;
    ll n;cin>>n;
    ll a[n][2];
    vector<l_l>v;
    rep(i,0,n-1){
        rep(j,0,1)cin>>a[i][j];
        v.pb(l_l(a[i][0],i));
        v.pb(l_l(a[i][1],i+n));
    }
    sort(v.begin(),v.end());
    bool u[n][2];memset(u,false,sizeof(u));
    rep(i,0,n-1){
        ll k=v[i].second;
        if(k>=n)u[k-n][1]=true;
        else u[k][0]=true;
    }
    ll sum=0;rep(i,0,n-1)sum+=v[i].first;
    bool f1=true,f2=true;
    rep(i,0,n-1){
        if(u[i][0]&&u[i][1]){
            cout<<sum<<endl;return 0;
        }
        if(u[i][0])f1=false;
        if(u[i][1])f2=false;
    }
    if(f1||f2){
        cout<<sum<<endl;return 0;
    }
    ll ans=sum-v[n-1].first+v[n+1].first;
    if((v[n].second-v[n-1].second)%n!=0)Min(ans,sum-v[n-1].first+v[n].first);
    else Min(ans,sum-v[n-2].first+v[n].first);
    cout<<ans<<endl;
    
    
    
    
    
    return 0;
}







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

int main(){
	string s; cin>>s;
	int k=s.size();
	int sum=0;
	rep(i,k){
		sum+=s[i]-'0';
	}
	if(sum%9==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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


void solve(long long N, std::vector<long long> A, long long Q, std::vector<long long> B, std::vector<long long> C)
{
    map<int, int> D;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        if (D.find(A[i]) == D.end()) {
            D[A[i]] = 1;
        } else {
            D[A[i]]++;
        }
        sum += A[i];
    }
    for (int i = 0; i < Q; i++) {
        int count = 0;
        auto it = D.find(B[i]);
        if (it != D.end()) {
            count = D[B[i]];
            sum = sum - (B[i] * count) + (C[i] * count);
            D.erase(it);
            auto it2 = D.find(C[i]);
            if (it2 == D.end()) {
                D.insert(make_pair(C[i], count));
            } else {
                D[C[i]] += count;
            }
        }

        cout << sum << endl;
    }
            
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> B(Q);
    std::vector<long long> C(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), Q, std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 8412
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll dp[41][410][410];

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

  rep(i,0,41)rep(j,0,410)rep(k,0,410)dp[i][j][k]=MOD;

  ll n,ma,mb;
  std::cin>>n>>ma>>mb;

  dp[0][0][0]=0;

  rep(i,0,n){
    ll a,b,c;
    std::cin>>a>>b>>c;
    rep(j,0,410)rep(k,0,410)chmin(dp[i+1][j][k],dp[i][j][k]);
    rep(j,a,410)rep(k,b,410)chmin(dp[i+1][j][k],dp[i][j-a][k-b]+c);
  }

  ll ans=MOD;

  rep(i,1,400/std::max(ma,mb)+1){
    chmin(ans,dp[n][i*ma][i*mb]);
  }

  if(ans==MOD)std::cout<<-1;
  else std::cout<<ans;

  return 0;
}






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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



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

	vector<int> x;


	while (N != 0) {
		x.push_back(N % 26);
		N /= 26;
	}

	string s = "";

	rep(i, (int)x.size()-1) {
		if (x[i] <= 0) {
			x[i + 1] -= 1;
			x[i] += 26;
		}
		s += (char)('a'+x[i]-1);
	}
	if (x[x.size() - 1] != 0)s += (char)('a'+x[x.size() - 1]-1);

	for (int i = s.length() - 1; i >= 0; i--) {
		printf("%c", s[i]);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<stack>
#include<string>
using namespace std;
stack<string> stk;

void calc(string c) {
	if (c == "+") {
		string op1 = stk.top();
		stk.pop();
		string op2 = stk.top();
		stk.pop();
		int op3 = stoi(op2) + stoi(op1);
		//cout << "加算です." << op3 << "=" << op1 << "+" << op2 << "を計算しました" << endl;
		stk.push(to_string(op3));
	}
	else if (c == "-") {
		string op1 = stk.top();
		stk.pop();
		string op2 = stk.top();
		stk.pop();
		int op3 = stoi(op2) - stoi(op1);
		//cout << "減算です." << op3 << "=" << op1 << "-" << op2 << "を計算しました" << endl;
		stk.push(to_string(op3));
	}
	else if (c == "*") {
		string op1 = stk.top();
		stk.pop();
		string op2 = stk.top();
		stk.pop();
		int op3 = stoi(op2) * stoi(op1);
		//cout << "乗算です." << op3 << "*" << op1 << "+" << op2 << "を計算しました" << endl;

		stk.push(to_string(op3));
	}
	else {
		stk.push(c);
	}
}



int main()
{
	string buf;
	while (std::cin >> buf) {
		calc(buf);
	}
	string ans = stk.top();
	cout << ans << endl;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int h[3][2], m[3][2], s[3][2];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> h[i][j] >> m[i][j] >> s[i][j];
        }
    }
    for (int i = 0; i < 3; i++) {
        int t1 = 3600 * h[i][0] + 60 * m[i][0] + s[i][0];
        int t2 = 3600 * h[i][1] + 60 * m[i][1] + s[i][1];
        int e = t2 - t1;
        int H = e / 3600;
        int M = (e - H * 3600) / 60;
        int T = e - 3600 * H - 60 * M;
        printf("%d %d %d\n", H, M, T);
    }
    return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;
int N,A,B,C;
vector<int> l;
int dfs(int i,int a,int b,int c){
	if(i>=N){
		if(min({a,b,c})==0) return INF;
		return abs(a-A)+abs(b-B)+abs(c-C)-30;
	}
		
	int ret0,ret1,ret2,ret3;
	ret0 = dfs(i+1,a,b,c);
	ret1 = dfs(i+1,a+l[i],b,c)+10;
	ret2 = dfs(i+1,a,b+l[i],c)+10;
	ret3 = dfs(i+1,a,b,c+l[i])+10;
	
	return min({ret0,ret1,ret2,ret3});
}

int main(){
	cin >> N >> A >> B >> C;
	l.resize(N);
	for(int i=0;i<N;i++){
		cin >> l[i];
	}
	cout << dfs(0,0,0,0);
	
	return 0;
}

Measured memory_bytes: 256
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
    s <- getLine
    putStrLn $ if '9' `elem` s then "Yes" else "No"

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

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

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;
    vector<ll> x(N), y(N);
    rep(i, 0, N) cin >> x[i] >> y[i];
    map<PL, ll> mp;
    ll mx = 0;
    rep(i, 0, N-1){
        rep(j, i+1, N){
            ll dx = x[i] - x[j];
            ll dy = y[i] - y[j];
            if(dx < 0){
                dx = -dx;
                dy = -dy;
            }
            if(dx == 0){
                if(dy < 0) dy = -dy;
            }
            mp[{dx, dy}]++;
            mx = max(mx, mp[{dx, dy}]);
        }
    }
    ll ans = N - mx;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int a[3][3];
int n;
int b;

bool check(bool flag[3][3]) {
	int i, j;
	rep(i, 3) {
		rep(j, 3) if (!flag[i][j]) break;
		if (j == 3) return true;
	}
	rep(j, 3) {
		rep(i, 3) if (!flag[i][j]) break;
		if (i == 3) return true;
	}
	
	if (flag[0][0] && flag[1][1] && flag[2][2]) return true;
	if (flag[0][2] && flag[1][1] && flag[2][0]) return true;
	return false;
}

signed main() {
	int i, j, k;
	
	rep(i, 3) rep(j, 3) cin >> a[i][j];
	cin >> n;
	
	bool flag[3][3] = {false};
	rep(i, n) {
		cin >> b;
		rep(j, 3) rep(k, 3) if (a[j][k] == b) flag[j][k] = true;
	}
	
	if (check(flag)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;cin>>N;
  vector<int64_t>A(N+1);
  for(int i=0;i<=N;i++)
    cin>>A.at(i);
  if(A.at(0)!=0){
  if(N==0 && A.at(0)==1)cout<<1<<endl;
    else
      cout<<-1<<endl;
  }else{
vector<int64_t>B(N);B.at(N-1)=A.at(N);
    for(int i=N-2;0<=i;i--)
      B.at(i)=B.at(i+1)+A.at(i+1);
    vector<int64_t>C(N);C[0]=1;bool x=true;
    for(int i=1;i<N;i++){
    if(2*C[i-1]-A[i]<=B[i] && 1<=2*C[i-1]-A[i])
      C[i]=2*C[i-1]-A[i];
      else if(B[i]<2*C[i-1]-A[i])
        C[i]=B[i];
      else{x=false;break;}
    }
      if(!x)cout<<-1<<endl;
      else{
        if(2*C[N-1]<A[N])cout<<-1<<endl;
        else{
      int64_t ans=0;
        for(int i=0;i<N;i++){ans+=(A.at(i+1)+C.at(i));}
        cout<<ans<<endl;
        }
      }
    }
  return 0;
}

Measured memory_bytes: 5572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str, str_A, str_B;

    cin >> str;

    if (str[0]=='0') {
        str_A = str[1];
    }
    else {
        str_A = str.substr(0,2);
    }

    if (str[2]=='0') {
        str_B = str[3];
    }
    else {
        str_B = str.substr(2,2);
    }

    int a = atoi(str_A.c_str());
    int b = atoi(str_B.c_str());

    if (a >= 1 && a <= 12 && b >= 1 && b <= 12) {
        cout << "AMBIGUOUS" << endl;
    }
    else if (a >= 1 && a <= 12) {
        cout << "MMYY" << endl;
    }
    else if (b >= 1 && b <= 12) {
        cout << "YYMM" << endl;
    }
    else {
        cout << "NA" << endl;
    }

    return 0;
}

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

#define inf 0x3f3f3f3f
#define pi acos(-1)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()

int32_t main(){
	
	int n;
	scanf("%d",&n);
	vector<vector<int>> A(n+1);
	bool fl=false;
	for(auto &a:A){
		a = vector<int>(3,0);
		if(fl)
			scanf("%d%d%d",&a[0],&a[1],&a[2]);
		fl=true;
	}
	int dp[100002][3];
	for(int i=1;i<=n;i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2])+A[i][0];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2])+A[i][1];
		dp[i][2] = max(dp[i-1][1],dp[i-1][0])+A[i][2];
	}
	int ans =0;
	for(int i =0;i<3;i++)
		ans = max(ans,dp[n][i]);
	cout << ans << '\n';
	
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 6912
A, B, C = gets.chomp.split.map(&:to_i)

# A .. bad  / heal
# B .. good / heal
# C .. good / poison

# we can take all B
# we can take all C if (A + B) + 1 > C (

if A + B + 1 <= C
  p B + (A + B + 1)
else # A+B+1 > C
  p B + C
end


Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 5050;
const int MOD = 1e9+7;
int N, M;
string s;
ll dp[MAXN][MAXN];

ll dfs(int n, int m) {
    ll& ret = dp[n][m];
    if (ret >= 0) return ret;
    if (n == N) {
        if (m == 0) return ret = 1;
        else return ret = 0;
    }
    ret = 0;
    // Back
    if (m+1 < MAXN) {
        ret += 2*dfs(n+1, m+1);
    }
    if (m == 0) {
        ret += dfs(n+1, m);
    }
    // other
    if (m > 0) {
        ret += dfs(n+1, m-1);
    }
    ret %= MOD;
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    cin >> s;
    M = s.size();
    memset(dp, -1, sizeof(dp));
    cout << dfs(0, M) << endl;
    return 0;
}


Measured memory_bytes: 199680
x1,y1,x2,y2 = map(int,input().split())

dx = x2-x1
dy = y2-y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy

print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 9024
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		
		int ans=0;
		int n=sc.nextInt();
		int h=sc.nextInt();
		int w=sc.nextInt();
		int a[][]=new int[n][2];
		for(int i=0;i<n;i++) {
			a[i][0]=sc.nextInt();
			a[i][1]=sc.nextInt();
		}
		for (int j=0;j<n;j++) {
			if(a[j][0]>=h&&a[j][1]>=w) {
				ans++;
			}
		}
		System.out.println(ans);
	}
		
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 23380
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    int K;
    vector<ll> a;
    vector<ll> b;

    void input() {
        cin >> N >> K;
        a.resize(N);
        rep(i, 0, N) {
            cin >> a[i];
        }

        for (int i = 0; i < N; ++i) {
            ll tmp = 0;
            for (int j = i; j < N; ++j) {
                tmp += a[j];
                b.push_back(tmp);
            }
        }

        sort(all(b));
    }

    void solve() {
        input();

        vector<ll> survive;
        for (auto e : b) {
            survive.push_back(e);
        }
        //数字の下からpビット目
        ll ans = 0ll;
        for (int p = 50; p >= 0; --p) {
            vector<ll> next; //次の世代の生き残り
            for (auto e : survive) {
                if ((e >> p) & 1) {
                    next.push_back(e);
                }

            }
            if (next.size() >= K) {
                survive = next;
                ans |= 1ll << p;
            }
        }

        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 12268
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int maxtime(int x) { return (x + 9) / 10 * 10; }
int remtime(int x) { return maxtime(x) - x; }
int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
  sum -= max({remtime(A), remtime(B), remtime(C), remtime(D), remtime(E)});
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

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

ans = [0] * (N+1)

for a in A:
    ans[a] += 1

for i in ans[1:]:
    print(i)


Measured memory_bytes: 33492
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%d", $x);
fscanf(STDIN, "%d", $y);
if($n <= $k){
  echo $n * $x;
}else{
  echo $k * $x +($n - $k)*$y;
}
?>

Measured memory_bytes: 4604
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))


s = ns()
k = ni()

check = set()

for left in range(0, len(s)):
    for right in range(left+1, left+k+1):
        check.add(s[left:right])

print(sorted(list(check))[k-1])



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

using namespace std;

const int N = 1e5+5;

const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    long long ans = 0 , lst = -1;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if(lst == -1){
            lst = x;
            continue;
        }
        if(lst > x){
            ans += lst - x;
            lst = lst;
        } else {
            lst = x;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

		int m = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());

		int count = 0;
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= d; j++) {
				int d1 = j % 10;
				int d10 = j / 10;
				if (d1 * d10 == i && d1 >= 2 && d10 >= 2) {
					count++;
				}
			}
		}

		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 21972
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


def main():
    """エントリーポイント"""
    A, B, C = input([int, 3])
    yesno(len({A, B, C}) == 2)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3436
#pragma region
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define f first
#define s second
#define szof(a) (int)a.size()
#define allof(a) a.begin(), a.end()

void pr(int x) { printf("%d", x); }
void pr(ll x) { printf("%lld", x); }
void pr(char x) { printf("%c", x); }
void pr(const string &x) { printf("%s", x.c_str()); }
void pr(bool x) { printf(x ? "true" : "false"); }
void pr(double x) { printf("%lf", x); }
void pr(const char *x) { printf("%s", x); }

template <typename S, typename T>
void pr(pair<T, S> x);

template <class T>
void pr(const T &x);

template <class T, class... Ts>
void pr(const T &t, const Ts &... ts) {
    pr(t);
    pr(ts...);
}
template <class T1, class T2>
void pr(const pair<T1, T2> &x) {
    pr("{", x.f, ", ", x.s, "}");
}
template <class T>
void pr(const T &x) {
    pr("{");
    bool fst = 1;
    for (const auto &a : x)
        pr(!fst ? ", " : "", a), fst = 0;
    pr("}");
}

void ps() { pr("\n"); }
template <class T, class... Ts>
void ps(const T &t, const Ts &... ts) {
    pr(t);
    if (sizeof...(ts)) pr(" ");
    ps(ts...);
}
void pc() { pr("]\n"); }
template <class T, class... Ts>
void pc(const T &t, const Ts &... ts) {
    pr(t);
    if (sizeof...(ts)) pr(", ");
    pc(ts...);
}
#define debug(x...) pr("[", #x, "] = ["), pc(x)
#ifndef LOCAL
#define debug(x...) 42
#endif
#pragma endregion

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int n, m, a, b;
    scanf("%d%d%d%d", &n, &m, &a, &b);
    if (2 * a > m || 2 * b > n) {
        puts("-1");
        return 0;
    }

    vi x(m, 0), y(m, 1);
    for (int i = 0; i < a; ++i)
        x[i] = 1, y[i] = 0;
    for (int i = 0; i < n; ++i) {
        const vi &v = (i < b) ? x : y;
        for (int j = 0; j < m; ++j)
            printf("%d", v[j]);
        printf("\n");
    }
}

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

bool has3(int x){ while(x){ if( x % 10 == 3 ) return true; x /= 10;} return false; }

void call(int n){ for( int x = 1; x <= n; x++ ){ if ( x % 3 == 0 || has3(x) ){ cout << " " << x; } } cout << endl; }

int main(){
	int n;
	cin >> n;
	call(n);
return 0;
}

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

//LIFE IS NOT A PROBLEM TO BE SOLVED

using namespace std;

#define rep(i,a,b) for(int i = int(a); i < int(b) ; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

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


int main(){
	
	int n, aux; cin >> n;
	set <int> st;
	rep(i, 0, n){
		cin >> aux;
		st.insert(aux);
	}
	
	cout << st.size() << "\n";
	
	return 0;
}

Measured memory_bytes: 256
n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }.sort
# n = a.size

m = a[-1] / 2

x = a[0,n-1].bsearch{ |t| t >= m }
y = a[0,n-1].reverse.bsearch{ |t| t <= m }

if (x && y && x-m <= m-y) || !y
  puts "#{a[-1]} #{x}"
else
  puts "#{a[-1]} #{y}"
end

Measured memory_bytes: 10104
<?php
list($n,$t)=explode(" ",trim(fgets(STDIN)));
$ans=20000;
$i=0;
while($i<$n){
  list($c,$x)=explode(" ",trim(fgets(STDIN)));
  if($x<=$t){
    $ans=min($ans,$c);
  }
  ++$i;
}
echo ($ans==20000)?"TLE":$ans;

Measured memory_bytes: 4728
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+:---test
3
2 3 1
---+/
/+---test
5
1 2 3 4 5
---+/
/+---test
8
8 2 7 3 4 5 6 1
---+/

void main(string[] args) {
  readln;
  auto nums = readln.split.map!(to!int).array;

  const ids = zip(nums.length.iota, nums).array.sort!"a[1] < b[1]".map!"a[0]".array;

  foreach (i, x; ids) {
    if (i != 0) " ".write;
    (x+1).write;
  }
  writeln;
}


Measured memory_bytes: 7100
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(void){
  long int N,R;
  cin >> N >> R;
  
  long int W;
  if(N<10) W=R+100*(10-N);
  else W=R;
  
  cout << W << endl;
  
  long int sum=0;
  
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
using namespace std;

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N) {
  vl ans;

  if (N == 3) {
    ans.push_back(2);
    ans.push_back(5);
    ans.push_back(63);
  } else if (N == 4) {
    ans.push_back(2);
    ans.push_back(5);
    ans.push_back(20);
    ans.push_back(63);
  } else if (N == 5) {
    ans.push_back(2);
    ans.push_back(5);
    ans.push_back(20);
    ans.push_back(30);
    ans.push_back(63);
  } else {
    ll cnt = 0;
    ll i = 0;
    ll m = 2;
    while (cnt < N) {
      ans.push_back(6 * i + m);
      cnt++;

      if (cnt == N) {
        break;
      }

      if (m == 0) {
        m = 2;
      } else if (m == 2) {
        m = 3;
      } else if (m == 3) {
        m = 4;
      } else if (m == 4) {
        i++;
        m = 0;
      }
    }

    ll sum = 0;
    rep(n, N) { sum += ans[n]; }
    ll rest = sum % 6;
    if (rest == 2) {
      ans[4] = ++i * 6;
    }
    if (rest == 3) {
      ans[5] = ++i * 6;
    }
    if (rest == 5) {
      if (m == 4) {
        ans[5] = ++i * 6 + 4;
      } else {
        ans[5] = i * 6 + 4;
      }
    }
  }

  rep(n, N) {
    cout << ans[n];
    if (n != N - 1) {
      cout << " ";
    }
  }
  cout << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n,m; cin >>n>>m;
    priority_queue<int> a;
    for (int i = 0; i < n; i++) {
        int p; cin >> p;
        a.push(p);
    }

    for (int i = 0; i < m; i++) {
        int q = a.top(); a.pop();
        q /= 2;
        a.push(q);
    }

    ll ans = 0;
    while (!a.empty()) {
        int t = a.top(); a.pop();
        ans += (ll)t;
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define pi pair<ll,ll>


int main(){
	
	ll n;
	cin>>n;
	
	cout<<(1000-n%1000)%1000;
		
	}



Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d[] = new int[n];
    int answer = 0;
    for(int i=0;i<n;i++){
      d[i]=sc.nextInt();
    }
    
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        answer = answer + d[i]*d[j];
      }
    }
    System.out.println(answer);
    
  }
  

  
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int a, b, c, d, e, f, wa, su;
double ma;
bool water[3005], sugar[3005];
signed main() {
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	for (int i = 0; i <= f; i += a) {
		for (int j = 0; i + j <= f; j += b) {
			water[i + j] = true;
		}
	}
	for (int i = 0; i <= f; i += c) {
		for (int j = 0; i + j <= f; j += d) {
			sugar[i + j] = true;
		}
	}
	for (int i = 0; i <= f; i++) {
		for (int j = 0; i + j <= f; j++) {
			if (!sugar[i] || !water[j])continue;
			if ((double)(e) / (double)(100. + e) >= (double)(i) / (double)(i + j)) {
				if (ma <= (double)(i) / (double)(i + j)) {
					ma = (double)(i) / (double)(i + j);
					wa = j + i;
					su = i;
				}
			}
		}
	}
	cout << wa << " " << su << endl;
	endre;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define MOD 998244353
#define db(a) cout << a << endl
#define adb(a) for(auto i:a) cout << i << " "
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

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

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

    int dp[n][3];
    dp[0][0] = m[0][0];
    dp[0][1] = m[0][1];
    dp[0][2] = m[0][2];

    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            if(j == 0) dp[i][j] = max(dp[i-1][j+1], dp[i-1][j+2]);
            else if(j == 1) dp[i][j] = max(dp[i-1][j-1], dp[i-1][j+1]);
            else dp[i][j] = max(dp[i-1][j-1], dp[i-1][j-2]);

            dp[i][j] += m[i][j];
        }
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}


Measured memory_bytes: 2560
/* vo0_28.cpp */
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

inline int MAX(int a, int b) { return (a < b) ? b : a; }

int main()
{
	vector<int> d;
	int count[100];
	
	for (int i = 0; i < 100; ++i) { count[i] = 0; }

	int n;
	while (cin >> n) { d.push_back(n); }

	sort(d.begin(), d.end());

	for (int i = 0; i < d.size(); ++i) { count[d[i] - 1]++; }

	int max = 0;
	for (int i = 0; i < d.size(); ++i) { max = MAX(max, count[i]); }
	for (int i = 0; i < d.size(); ++i) {
		if (max == count[i])
			cout << i + 1 << '\n';
	}

	return 0;
}

Measured memory_bytes: 1220
from collections import defaultdict


def dfs(N, tree, v):
    s = []
    done = [False for _ in range(N)]
    dist = [0 for _ in range(N)]

    done[v] = True
    dist[v] = 0
    s.append(v)

    while 0 < len(s):
        v = s.pop()

        # process
        # print(v, tree[v], dist[v])

        for i in tree[v]:
            if not done[i]:
                done[i] = True
                dist[i] = dist[v] + 1
                s.append(i)

    return dist


def main():
    N, u, v = map(int, input().split())
    u -= 1
    v -= 1

    tree = defaultdict(list)

    for _ in range(N - 1):
        A, B = map(int, input().split())
        A -= 1
        B -= 1

        tree[A].append(B)
        tree[B].append(A)

    u_dist = dfs(N, tree, u)
    v_dist = dfs(N, tree, v)
    # print(u_dist)
    # print(v_dist)

    ans = 0
    for u1, v1 in zip(u_dist, v_dist):
        if u1 < v1:
            ans = max(ans, v1 - 1)

    print(ans)


main()


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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)


using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int K,T;
    cin>>K>>T;
    VI v;

    rep(i,T){
        int a;
        cin>>a;
        v.PB(a);
    }
    int m = *max_element(v.begin(),v.end());

    cout<<max(m-1-(K-m),0)<<endl;;
    return 0;
}


Measured memory_bytes: 256
//abc061.cpp
//Sat Oct 20 22:03:58 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b,c;
	cin >> a >> b >> c;

	if (c >= a && c <= b){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import math
a,b,h,m=map(int,input().split())
h=h*30+m*0.5
m=m*6
r=h-m
r=abs(r)
result=(a**2)+(b**2)-(2*a*b*(math.cos(math.radians(r))))
print(pow(result,0.5))

Measured memory_bytes: 9512
#C
N,W = map(int,input().split())
VW = [list(map(int,input().split())) for i in range(N)]

dp = [0 for j in range(W+1)]
for i in range(N):
    v,w = VW[i]
    for j in range(W+1):
        if j+w <= W:
            dp[j+w] = max(dp[j+w],dp[j]+v)

print(max(dp))



Measured memory_bytes: 5924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    int a,b;
    cin >> a >> b;
    COUT(a*b);
}


Measured memory_bytes: 3608
def solve():
  n, m = map(int,input().split())
  plst = list(map(int,input().split()))
  pare_inds = [i for i in range(n)]
  belongs = [[] for i in range(n)]
  
  def get_root(x):
    p = pare_inds[x]
    if p == x:
      return x
    a = get_root(p)
    pare_inds[x] = a
    return a
  
  for i in range(m):
    x, y = map(int,input().split())
    x, y = x - 1, y - 1
    r_x, r_y  = get_root(x), get_root(y)
    if r_x < r_y:
      pare_inds[y] = r_x
      pare_inds[r_y] = r_x
    else:
      pare_inds[x] = r_y
      pare_inds[r_x] = r_y
  
  for i in range(n):
    belongs[get_root(i)].append(i)
  #print(belongs)
  #print(plst)
  ans = 0
  for lst in belongs:
    lst2 = [plst[i] - 1 for i in lst]
    lst.sort()
    lst2.sort()
    ind1 = 0
    ind2 = 0
    end = len(lst)
    while ind1 < end and ind2 < end:
      if lst[ind1] == lst2[ind2]:
        ans += 1
        ind1 += 1
        ind2 += 1
      elif lst[ind1] < lst2[ind2]:
        ind1 += 1
      else:
        ind2 += 1
  
  print(ans)
solve()

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    
  cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define Rep(i , a , b) for(int i = (a) , i##MAX = (b) ; i <= i##MAX ; inc(i))
#define rep(i , b , a) for(int i = (b) , i##MIN = (a) ; i >= i##MIN ; dec(i))
using namespace std;

const int N = 200000 + 7 , MMAX = 4000 + 7 , MAX = 2000 + 1 , Mod = 1000000000 + 7;
int n , Dp[MMAX][MMAX] , Inv[MMAX << 1] , Fac[MMAX << 1] , Ans , X[N] , Y[N];
inline void Inc(int& A , int B) {
	A += B; if(A >= Mod) A -= Mod;
}
inline int IInc(int A , int B) {
	A += B; if(A >= Mod) A -= Mod; return A;
}
inline void Dec(int& A , int B) {
	A -= B; if(A < 0) A += Mod;
}
inline int C(int n , int m) {
	return 1ll * Fac[n] * Inv[m] % Mod * Inv[n - m] % Mod;
}
inline int KSM(int x , int q) {
	int Ret = 1;
	while(q) {
		if(q & 1) Ret = 1ll * Ret * x % Mod;
		x = 1ll * x * x % Mod , q >>= 1;
	}
	return Ret;
}

int main() {
	scanf("%d" , &n);
	int x , y;
	Rep(i , 1 , n) scanf("%d%d" , &x , &y) , inc(Dp[MAX - (X[i] = x)][MAX - (Y[i] = y)]);
	Fac[0] = 1; Rep(i , 1 , MAX << 2) Fac[i] = 1ll * Fac[i - 1] * i % Mod;
	Inv[MAX << 2] = KSM(Fac[MAX << 2] , Mod - 2); rep(i , (MAX << 2) - 1 , 0) Inv[i] = 1ll * Inv[i + 1] * (i + 1) % Mod;
	Rep(i , 1 , MAX << 1) Rep(j , 1 , MAX << 1)
		Inc(Dp[i][j] , Dp[i][j - 1]) , Inc(Dp[i][j] , Dp[i - 1][j]);
	int Ans = 0;
	Rep(i , 1 , n) Inc(Ans , Dp[X[i] + MAX][Y[i] + MAX]);
	Rep(i , 1 , n) Dec(Ans , C((X[i] + Y[i]) << 1 , Y[i] << 1));
	printf("%lld" , 1ll * Ans * KSM(2 , Mod - 2) % Mod);
	return 0;
}

Measured memory_bytes: 64512
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			Data now = new Data();
			String in = sc.next();
			for(int j = 0; j < in.length(); j++) {
				if(in.charAt(j) == '[') {
					Data tmp = new Data();
					tmp.p = now;
					now.list.add(tmp);
					now = tmp;
				}
				else if(in.charAt(j) == ']') {
					now = now.p;
				}
				else {
					int k = j;
					for(; k < in.length(); k++) {
						if(in.charAt(k) == ']') {
							break;
						}
					}
					int s = Integer.parseInt(in.substring(j,k));
					
					now.sum = s;
					j = k-1;	
				}
			}
			int ans = solv(now);
			System.out.println(ans);
		}
		
		
		
	}
	
	static class Data {
		Data p;
		ArrayList<Data> list = new ArrayList<Data>();
		int sum = 0;
	}
	
	static int solv(Data a) {
		if(a.list.isEmpty()) {
			return a.sum/2+1;
		}
		
		int ret = 0;
		
		int[] list = new int[a.list.size()];
		
		
		for(int i = 0; i < a.list.size(); i++) {
			list[i] = solv(a.list.get(i));
		}
		
		Arrays.sort(list);
	
		for(int i = 0; i < list.length / 2 + 1; i++) {
			ret += list[i];
		}
		
		return ret;
	}
	
}
			

Measured memory_bytes: 30308
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define M 998244353

int main(){
	int n;
	cin>>n;
	vector<pair<int, P>> ps;
	rep(i, n){
		int x, d;
		cin>>x>>d;
		ps.push_back(make_pair(x, make_pair(d, i)));
	}

	sort(ps.rbegin(), ps.rend());
	vector<P> ac;
	vector<int> e(n, -1);
	for(auto p : ps){
		int x=p.first, d=p.second.first, ind=p.second.second;
		for(int i=ac.size()-1; i>=0; i--){
			int xa=ac[i].first, ia=ac[i].second;
			if(xa<x+d){
				// e[ind].push_back(ia);
				e[ia]=ind;
				ac.pop_back();
			}
			else break;
		}
		ac.push_back(make_pair(x, ind));
	}

	queue<int> q;
	vector<int> req(n);
	vector<bool> deta(n, false);
	vector<int> cnt(n, 1);
	rep(i, n) if(e[i]!= -1){
		deta[e[i]]=true;
		req[e[i]]++;
	}
	rep(i, n) if(!deta[i]) q.push(i);

	int tcnt=1;
	while(!q.empty()){
		int v=q.front(); q.pop();
		cnt[v]=(cnt[v]+1)%M;
		if(e[v] == -1) tcnt=((ll)tcnt*cnt[v])%M;
		else{
			cnt[e[v]]=((ll)cnt[e[v]]*cnt[v])%M;
			req[e[v]]--;
			if(req[e[v]]==0) q.push(e[v]);
		}
	}

	cout<<tcnt<<endl;

	return 0;
}


Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int high=1e6;
vector <int> adj[high];
int visited[high];
int cnt;


void dfs(int s){
    visited[s]=1;
    cnt++;
    for(auto u: adj[s]){
        if(visited[u]==0) {
            visited[u]=1;
            dfs(u);
        }
    }
}
int main(){
    int n,m;cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int max=0;

    for(int i=1;i<=n;i++){
        if(visited[i]==0){
            cnt=0;
            dfs(i);
        }
        if(cnt>=max) max=cnt;

    }
    cout<<max<<endl;

    
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const int MAX_C = 60;
long long Com[MAX_C][MAX_C];

void calc_com() {
    //https://drken1215.hatenablog.com/entry/2018/06/08/210000
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i) {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j) {
            Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]);
        }
    }
}

void solve(long long N, long long K, long long S, long long T, std::vector<long long> A){
    i64 L = 0;
    vector<i64> rule(18);
    calc_com();
    rep(i, 18){
        i64 s = (S & (1<<i)) != 0, t = ((T & (1<<i))) != 0;
        if(s == 1 && t == 1) rule[i] = 1;
        else if(s == 0 && t == 0) rule[i] = 0;
        else if(s == 0 && t == 1){rule[i] = 2; L++;}
        else{
            cout << 0 << endl;
            return;
        }
    }
    vector<i64> B;
    rep(i, N){
        i64 flag = true;
        i64 nw = 0;
        for(int j = 17; j >= 0; --j){
            i64 bit = (A[i] & (1<<j)) != 0;
            if(rule[j] == 1 && bit == 0) flag = false;
            if(rule[j] == 0 && bit == 1) flag = false;
            if(rule[j] == 2) nw = nw * 2 + bit;
        }
        if(flag) B.emplace_back(nw);
    }
    N = B.size();
    i64 bar = 0;
    rep(i, N){
        rep(j, 1, 1<<L){
            i64 a = B[i] & j, b = (~B[i]) & j, cnt = 0;
            rep(k, i + 1, N) if(((a & B[k]) == a) && ((b & (~B[k])) == b)) ++cnt;
            if(__builtin_popcount(j) % 2 == 1) rep(k, min(cnt + 1, K)) bar += Com[cnt][k];
            else rep(k, min(cnt + 1, K)) bar -= Com[cnt][k];
        }
    }
    i64 ans = 0;
    rep(i, 1, min(N, K) + 1) ans += Com[N][i];
    cout << ans - bar << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, S, T, std::move(A));
    return 0;
}


Measured memory_bytes: 3736