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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int d,contest_num=26;
vector<int> c(contest_num+1);
vector<vector<int>> s;
vector<set<int>> last(contest_num+1);

void input(){
    cin>>d;
    s.resize(d+1);
    rep(i,d+1){
        s[i].resize(contest_num+1);
    }
    // rep(i,contest_num+1)last[i].resize(d+1,0);
    rep(i,26)cin>>c[i+1];
    rep(i,d)rep(j,contest_num)cin>>s[i+1][j+1];
}

void output(vector<int> &ans){
    rep(i,d+1)cout<<ans[i]<<endl;
}

int max_lower_than_x(set<int> &st, int x){
    int res=0;
    for(auto tmp: st)if(tmp<=x)res=max(res,tmp);
    return res;
}

int min_upper_than_x(set<int> &st, int x){
    int res=d+1;
    for(auto tmp: st)if(tmp>=x)res=min(res,tmp);
    return res;
}

//b  AC
vector<int> calc_score(vector<int> &a){
    vector<int> score(d+1);
    int res=0;
    repi(day,1,d+1){
        int current_contest = a[day];
        last[current_contest].insert(day);

        res+=s[day][current_contest];
        rep(i,contest_num){
            res -= c[i+1] * (day-max_lower_than_x(last[i+1], day));
        }
        score[day] = res;
    }
    return score;
}

//c
int change_query(int score, int day, int before, int after){
    int res = score;

    int before_prev = max_lower_than_x(last[before], day-1);
    int before_next = min_upper_than_x(last[before],day+1);

    // cout<<"day = "<<day<<" before_prev = "<< before_prev<< " before_next = "<<before_next<<endl;

    int after_prev = max_lower_than_x(last[after], day-1);
    int after_next = min_upper_than_x(last[after], day+1);

    // cout<<"day = "<<day<<" after_prev = "<< after_prev<< " after_next = "<<after_next<<endl;

    // cout<<before_next-day<<endl;
    res -= (day-before_prev) * (before_next-day) * c[before];
    res -= s[day][before];

    res += (day-after_prev) * (after_next - day ) * c[after];
    res += s[day][after];

    last[before].erase(day);
    last[after].insert(day);

    return res;
}

int main()
{
    input();
    rep(i,contest_num+1)last[i].insert(0), last[i].insert(d+1);
    vector<int> v(d+1,0);
    rep(i,d)cin>>v[i+1];


    vector<int> tmp = calc_score(v);

    // rep(i,d)cout<<tmp[i+1]<<endl;
    // return 0;

    int score = tmp[d];

    //cout<<score<<endl;

    int m;
    cin>>m;
    rep(i,m){
        int dd,qq;
        cin>>dd>>qq;
        score = change_query(score, dd, v[dd], qq);
        v[dd]=qq;
        cout<<score<<endl;
    }

    // rep(i,d)cout<<tmp[i]<<endl;
	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll N, M, A, B, C[100001], ans=0;
	cin >> N >> M;
	vector<pair<ll, ll>> P(100000);
	for(int i=0; i<N; i++){
		cin >> A >> B;
		P[i]=make_pair(A, B);
	}
	sort(P.begin(), P.end());
	for(int i=0; i<100001; i++){
		if(M-P[i].second>=0){
			ans+=P[i].first*P[i].second;
			M-=P[i].second;
		} else {
			ans+=M*P[i].first;
			break;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <fstream>
using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
const int _MOD = 1000000009;
double EPS = 1e-10;
const int INF = INT_MAX / 2;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int N, M; cin >> N >> M;
	union_find uf(N * 2);
	while (M--) {
		int u, v; scanf("%d%d", &u, &v);
		u--; v--;
		uf.unite(u, N + v);
		uf.unite(N + u, v);
	}
	ll alone = 0, bi = 0, unko = 0;
	rep(u, N) if (uf.root(u) || uf.root(N + u)) {
		if (uf.size(u) == 1) alone++;
		else if (uf.same(u, N + u)) unko++;
		else bi++;
	}
	ll ans = 0;
	ans += alone * N;
	ans += N * alone;
	ans -= alone * alone;
	ans += bi * bi * 2;
	ans += bi * unko;
	ans += unko * bi;
	ans += unko * unko;
	cout << ans << endl;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lines = line.split(" ");
        int A = Integer.parseInt(lines[0]);
        int B = Integer.parseInt(lines[1]);
        int H = Integer.parseInt(lines[2]);
        int M = Integer.parseInt(lines[3]);

        double radianChoshin = 6 * M;
        double radianTanshin = 30 * H + 0.5 * M;
        double radian = Math.abs(radianChoshin - radianTanshin);

//        System.out.println(radianChoshin);
//        System.out.println(radianTanshin);
//        System.out.println(radian);
//        System.out.println(M);
        double ans = Math.sqrt(A*A + B*B-2*A*B*Math.cos(Math.toRadians(radian)));
        System.out.println(ans);
    }
}


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

using namespace std;


int main()
{
  int N, T[100001] = {}, X[100001] = {}, Y[100001] = {};

  cin >> N;
  for(int i = 1; i <= N; i++) {
    cin >> T[i] >> X[i] >> Y[i];
  }

  for(int i = 1; i <= N; i++) {
    int arong = T[i] - T[i - 1];
    int time = abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]);

    if(arong < time || (arong - time) % 2 == 1) {
      puts("No");
      return (0);
    }
  }

  puts("Yes");
}

Measured memory_bytes: 1408
// ABC179C.cpp

#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
int main()
{
    int n;
    cin >> n;

    int ans = 0;
    // bの個数は(-1)/aなので、(n-1)/aを求める。
    for (int a = 1; a <= n; a++) {
        ans += (n - 1) / a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3184
from itertools import combinations
n,m,k = map(int,input().split())
mat = []
for _ in range(n):
    mat.append(list(input()))

def black(row,col):
    new = [mat[i] for i in range(n) if i not in row]
    if not new:return 0
    new = list(zip(*new))
    new = [new[i] for i in range(m) if i not in col]
    if not new:return 0
    return sum([i.count("#") for i in new])
ans = 0
rows = []
cols = []
for i in range(0,n+1):
    rows += list(combinations([i for i in range(n)],i))
for i in range(0,m+1):
    cols += list(combinations([i for i in range(m)],i))
#print(rows,cols)
for row in rows:
    for col in cols:
        if black(set(row),set(col))==k:
            #print(row,col)
            ans+=1
print(ans)



Measured memory_bytes: 9244
w, h, a, b = map(int, input().split())

# # y = (a - w / 2)(X - a) + b
# if a == w / 2:
#     ans = w * h / 2
# elif b == h / 2:
#     ans = w * h / 2
# elif a - w / 2 >= w / h or a - w / 2 >= -1 * (w / h):
#     key = (h + a * a - w / 2 * a - b) / (a - w / 2)
#     ans = key * (w - key) * h / 2
# else:
#     key = -a * a + w / 2 * a + b
#     ans = key * ( h - key) * w / 2
ans = w * h / 2
ans2 = 0
if a == w / 2 and b == h / 2:
    ans2 = 1
print(ans, ans2)


Measured memory_bytes: 38256
#include<stdio.h>
int main(void){
   int N;
   double X, Y, R, xa, xb, ya, yb, ra, rb;
   scanf("%d", &N);
   while ( N != 0 ) {
      scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
      X = xa - xb;
      Y = ya - yb;
      R = ra + rb;
      if ( rb < ra && X * X + Y * Y < ra * ra  - 2 * ra * rb + rb * rb ) {
         printf ("2\n");
      } else if ( ra < rb && X * X + Y * Y < ra * ra  - 2 * ra * rb + rb * rb  ) {
         printf ("-2\n");
      } else if ( X * X + Y * Y <= R * R ) {
         printf("1\n");
      } else if ( X * X + Y * Y > R * R ) {
         printf("0\n");
      }
      N--;
   }
   return 0;
}

Measured memory_bytes: 1744
# include <stdio.h>

int main(){
  int n,i = 0;    scanf("%d\n",&n);
  char arr[n] ,ch;

  while (i != n ){scanf("%c" , &arr[i]);i++;scanf("%c" , &ch);}

  //  int f = 0;
  for(i = 1 ; i < n ; i++){
    if (arr[i] == 'F' && arr[i-1] == 'T'){arr[i]= 'F';}
    else {arr[i]= 'T';}
  }
  /*
  if(f == 0){printf("F\n");}
  else if( (arr[n-1] == 'F') && (arr[n-2]== 'T' )){printf("F\n");}
  else{printf("T\n");}*/
  printf("%c\n",arr[n-1]);
  return 0;
}


Measured memory_bytes: 2064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e18+1;

int main()
{
    string s;
    cin >> s;
    ll n=s.length();
    ll ans=0;
    ll m=0;
    rep(i,n){
        if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){
            m++;
            if(ans<m){
                ans=m;
            }
        }
        else{
            m=0;
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
int main(){
	int N,S,i;
	scanf("%d%d",&S,&N);
	if(S<0)puts("0");
	else{
		std::vector<int>bag(S+1);
		bag[0]=1;
		for(int i=1;i<=N;i++)for(int j=i;j<=S;j++)bag[j]=(bag[j-i]+bag[j])%1000000007;
		printf("%d\n",bag[S]);
	}
}


Measured memory_bytes: 2772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  if(a + b == c + d)
    cout << "Balanced" << endl;
  if(a + b > c + d)
    cout << "Left" << endl;
  if(a + b < c + d)
    cout << "Right" << endl;
}

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

AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

AB.sort(key=lambda x:x[1])

time = 0
is_no = False
for i in range(N):
    time += AB[i][0]
    if time > AB[i][1]:
        is_no = True
        break

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

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

using namespace std;

#define N 500

int n, m, ans1[N + 5][N + 5], ans2[N + 5][N + 5];
char s[N + 5][N + 5];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);
	for (int i = 1; i <= n; ++i) {
		ans1[i][1] = ans2[i][m] = 1;
		if (i & 1)
			for (int j = 2; j <= m - 1; ++j)
				ans1[i][j] = 1;
		else
			for (int j = 2; j <= m - 1; ++j)
				ans2[i][j] = 1;
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			if (s[i][j] == '#')
				ans1[i][j] = ans2[i][j] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j)
			printf("%c", ans1[i][j] ? '#' : '.');
		printf("\n");
	}
	printf("\n");
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j)
			printf("%c", ans2[i][j] ? '#' : '.');
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,flag1=0,flag2=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	while(1)
	{
		c-=b;
		if(c<=0)
		{
			flag1=1;
			break;
		}
		a-=d;
		if(a<=0)
		{
			flag2=1;
			break;
		}
	}
	if(flag1)
	printf("Yes\n");
	else
	printf("No\n");
} 

Measured memory_bytes: 3764
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();

		Arrays.parallelSort(l);
		long ans = 0;
		for (int i = 0; i < n - 2; i++) {
			for (int j = i + 1; j < n - 1; j++) {
				int max = l[i] + l[j];
				if (l[j + 1] >= max) {
					continue;
				}
				int start = j + 1;
				int end = n;
				while (Math.abs(end - start) > 1) {
					int mid = (end + start) / 2;
					if (l[mid] >= max) {
						end = mid;
					} else {
						start = mid;
					}
				}
				int imax = start;

				int min = l[j] - l[i];
				if (l[j + 1] <= min) {
					continue;
				}
				start = j;
				end = n - 1;
				while (Math.abs(end - start) > 1) {
					int mid = (end + start) / 2;
					if (l[mid] > min) {
						end = mid;
					} else {
						start = mid;
					}
				}
				int imin = end;
				ans += Math.max(imax - imin + 1, 0);
			}
		}
		System.out.println(ans);
	}

	static int binarySearch1(int[] array, double val) {
		int start = -1;
		int end = array.length;

		while (Math.abs(end - start) > 1) {
			int mid = (end + start) / 2;
			if (array[mid] >= val) {
				end = mid;
			} else {
				start = mid;
			}
		}
		return end;
	}
}


Measured memory_bytes: 28356
#include <string>
#include <iostream>
#include <vector>

using namespace std;

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

	vector<char> ans;
	for (auto c: s) {
		if (c == 'B') {
			if (ans.size() > 0)
				ans.pop_back();
		} else {
			ans.push_back(c);
		}
	}

	if (ans.size() == 0)
		cout << "(empty)" << endl;
	else {
		for (int i = 0; i < ans.size(); i++) {
			cout << ans[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll a, b, c, K; cin >> a >> b >> c >> K;
    ll m = K%2;
    if(a-b==0) cout << 0 << endl;
    else if(m == 1) cout << b-a << endl;
    else cout << a-b << endl;
    return 0;
}


Measured memory_bytes: 256
require 'prime'
$mod = 1_000_000_007
io = STDIN
n=io.gets.chomp.to_i
hash={}
hash.default=0
(1..n).each  do |int|
  Prime.prime_division(int).each do |pr,i|
    hash[pr]+=i
  end
end
ans = 1
hash.values.each do |i|
  ans *= (i+1)
  ans %= $mod
end
p ans

Measured memory_bytes: 2300
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

int gcd(int a,int b) {
	if(a == 0 || b == 0) {
		return max(a,b);
	}
	else {
		if(a < b) {
			int tmp = a;
			a = b;
			b = tmp;
		}
		int r = a % b;
		while(r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}
}

signed main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	vector<int> A(N);
	vector<int> B(N);
	A.at(0) = 0;
	B.at(0) = 0;
	for(int i = 1;i < N;i++) {
		A.at(i) = gcd(A.at(i - 1),vec.at(i - 1));
	}
	for(int i = 1;i < N;i++) {
		B.at(i) = gcd(B.at(i - 1),vec.at(N - i));
	}
  	reverse(B.begin(),B.end());
	int ret = 0;
	for(int i = 0;i < N;i++) {
		ret = max(ret,gcd(A.at(i),B.at(i)));
	}
	cout << ret << endl;
}

Measured memory_bytes: 2560
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}
void solve()
{
      int a,b;
      cin>>a>>b;
      cout << a*b << endl;

}

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

	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b),0) << endl;
}


Measured memory_bytes: 3560
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int bil[4][3][10];
    Fill(bil, 0);
    int n;
    cin >> n;
    int b, f, r, v;
    for(int i=0; i<n; i++){
        cin >> b >> f >> r >> v;
        bil[b-1][f-1][r-1] += v;
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                cout << " " << bil[i][j][k];
            }
            cout << endl;
        }
        if(i<3) cout << "####################" << endl;
    }
}


Measured memory_bytes: 3096
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

string S;
ll N;
ll ans;

int main() {
    cin >> S;
    N = S.size();
    if (N % 2){
        ll mid = (N-1)/2;
        char m = S[mid];
        ans = N/2 + 1;
        ll d = 1;
        while(mid-d >= 0 && (S[mid-d] == m && S[mid+d] == m)){
            ans++;
            d++;
        }
    }
    else{
        ll mid = N/2;
        char m = S[mid];
        char n = S[mid-1];
        ans = N/2;
        ll d = 0;
        while((mid+d < N) && (S[mid+d] == m && S[mid-1-d] == m)){
            ans++;
            d++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define ROF(i,a,b) for(int i=(a),i##end=(b);i>=i##end;i--)
#define temT template<typename T>
using namespace std;
typedef long long ll;
const int N=int(2e5)+10;

int n,Q; ll res;
int tre[2][N*4];

#define RT 1,1,n
#define LS p<<1,l,mid
#define RS p<<1|1,mid+1,r

void build(int *tr,int p,int l,int r){
	tr[p]=1; if(l==r) return ; int mid=(l+r)>>1;
	build(tr,LS); build(tr,RS);
}

void upd(int *tr,int p,int l,int r,int el,int er,int v){
	if(el>er) return ;
	if(el<=l && r<=er) return tr[p]=max(tr[p],v),void();
	int mid=(l+r)>>1;
	if(el<=mid) 	upd(tr,LS,el,er,v);
	if(er>=mid+1)	upd(tr,RS,el,er,v);
}
int ask(int *tr,int p,int l,int r,int ep,int v=0){
	v=max(v,tr[p]); if(l==r) return v; int mid=(l+r)>>1;
	if(ep<=mid) 	return ask(tr,LS,ep,v);
	if(ep>=mid+1)	return ask(tr,RS,ep,v);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>Q; build(tre[0],RT); build(tre[1],RT); res=1ll*(n-2)*(n-2);
	for(int r=1,t,x,v;r<=Q;r++){
		cin>>t>>x; t--; x=n-x+1;
		v=ask(tre[t],RT,x); res-=(n-v-1);
		upd(tre[t^1],RT,v+1,n-1,x);
	}
	return cout<<res,0;
}

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

int main(){
  string sa;
  cin >> sa;
  int chain = 0;
  int ma = 0;
  for (char j : sa){
    if (j == 'R'){
      chain ++;
    }else chain = 0;
    ma = max(ma,chain);
  }
  cout << ma << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi   = vec<int>;
using vvi  = vec<vi>;
using vvvi = vec<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  ll n; cin >> n;
  cout << n * (n-1)  / 2 << endl;
  return 0;
}


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

long long n, ans = 0;
int e = 0;

int main() {
	cin >> n;
	for (int p = 2; (long long) p * p <= n; p++) {
		e = 0;
		while (!(n % p)) {
			n /= p;
			e++;
		}
		if (e) {
			int t = 1;
			while (e >= (t + 1) * (t + 2) / 2)
				t++;
			ans += t;
		}
	}
	if (n > 1)
		ans++;
	cout << ans << endl;

}


Measured memory_bytes: 3636
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif



int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	string s; cin >> s;

	if(s[s.size()-1] == 's'){
		s += "es";
	}
	else{
		s.push_back('s');
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 3632
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    long long int n, k;
    cin >> n >> k;
    
    cout << min(n%k, k-(n%k)) << endl;
}

Measured memory_bytes: 256
let inputs = require('fs').readFileSync('/dev/stdin', 'UTF-8').split('\n');
let str = '';
for (let i=0; i<inputs.length; i++) {
  const input = inputs[i].split(' ').map(Number);
  const h = input[0]
  const w = input[1]

  if (h === 0 && w === 0) break;

  // 横幅分ループ
  let wTmp = '';
  for (let j=0; j<w; j++) {
    if (j % 2 === 0) {
      wTmp += '#';
    } else {
      wTmp += '.';
    }
  }

  if (i !== 0) str += '\n';

  // 縦幅分ループ
  for (let jj=0; jj<h; jj++) {
    if (jj % 2 === 0) {
      str += wTmp + '\n';
    } else {
      // str += wTmp.split('').reverse().join('') + '\n';
      str += wTmp.replace(/#/g, 'a').replace(/\./g, '#').replace(/a/g, '.') + '\n';
    }
  }
}
console.log(str);


Measured memory_bytes: 16156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pair<int,int>>



int main(){
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    map<string,int> mp;
    for (int i = 0 ; i < n ; ++i){
        string str;
        cin >> str;
        ++mp[str];
    }
    vector<string> ans;
    int t = 0;
    for (auto &p : mp)
        t = max(t, p.second);
    for (auto &p : mp){
        if (t == p.second)
            cout << p.first << endl;
    }
    return 0;
}


Measured memory_bytes: 23808
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    REP(i, n) cin >> w[i];

    int ans;
    int is_min = 10000;
    REP(i, n - 1){
        int a = 0;
        int b = 0;
        for(int j = 0; j <= i; j++) a += w[j];
        for(int k = i + 1; k < n; k++) b += w[k];
        int sa = abs(a - b);
        is_min = min(is_min, sa);
        if (is_min == sa) ans = sa;   
    }
    cout << ans << "\n";
}


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

int main(){
  int N,K;
  string S;

  cin>>N>>K;
  cin>>S;

  vector<int> a;

  int i,count,now;

  now=1;
  count=0;
  for(i=0;i<N;i++){
    if(S.at(i)==(char)('0'+now))
    count++;
    else{
      a.push_back(count);
      now=1-now;
      count=1;
    }
  }
  if(count!=0)
  a.push_back(count);

  int maxsum=0;
  int left=0;
  int right=left;
  int sum=a.at(0);


  for(left=0;left<a.size();left+=2){
    int res=0;

    // cout<<"aaa"<<endl;
    while(res<=2*K-1){
      right+=2;
      res=right-left;
      if(right<a.size()){
        sum+=a.at(right-1);
        sum+=a.at(right);
      }
    }
    if(right>=a.size()){
      sum=0;
      for(i=left;i<a.size();i++)
      sum+=a.at(i);
      if(maxsum<sum)
      maxsum=sum;
      break;
    }
    if(left!=0){
      sum-=a.at(left-2);
      sum-=a.at(left-1);
    }

    if(maxsum<sum)
    maxsum=sum;

    // cout<<maxsum<<endl;
  }

  cout<<maxsum<<endl;


}


Measured memory_bytes: 1020
import Data.List

main = do
  s <- getLine

  let
    a = filter (/= 'x') s
    b = countX s

  if isPalindrome a then
    print $ aux b
    else
    print $ -1

  where
    isPalindrome xs = xs == (reverse xs)

    countX xs = length a : (if null b then [] else countX $ tail b)
      where (a,b) = span (=='x') xs

    aux xs
      | even len  = sum $ (\(x,y) -> zipWith (\a b -> abs $ a - b) (reverse x) y) $ splitAt (len`div`2) xs
      | otherwise = sum $ (\(x,y) -> zipWith (\a b -> abs $ a - b) (reverse x) (tail y)) $ splitAt (len`div`2) xs 
        where len = length xs

Measured memory_bytes: 20860
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

struct UnionFind {
    vector<int> par, cnt;

    UnionFind(int n): par(n, -1), cnt(n) {}
    int find(int x) {
        if (par[x]<0) return x;
        return par[x] = find(par[x]);
    }
    bool same(int i, int j) {
        // iとjが同じグループかどうかを判別する
        return find(i) == find(j);
    }
    int size(int x) {
        return -par[find(x)];
    }

    bool unite(int x, int y) {
        // iとjを併合する
        x = find(x);
        y = find(y);
        bool ok = (-par[x]>cnt[x] || -par[y]>cnt[y]);
        if (x == y) {
            cnt[x]++;
        } else if (par[x] > par[y]) {
            par[y] += par[x];
            par[x] = y;
            cnt[y] += cnt[x]+1;
        } else {
            par[x] += par[y];
            par[y] = x;
            cnt[x] += cnt[y]+1;
        }
        return ok;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    UnionFind uni(n);
    int com, x, y;
    for (int i=0; i<q; i++) {
        cin >> com >> x >> y;
        if (com == 0) uni.unite(x, y);
        else cout << (uni.same(x, y)?1:0) << '\n';
    }
    return 0;
}



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

def main():
    n = int(input())

    ans = []

    if n == 0:
        print(0)
        exit()
    
    while True:
        if n % (-2) == -1:
            ans.append(1)
            n = (n // -2) + 1
        elif n % -2 == 0:
            ans.append(0)
            n //= -2
        if n == 1:
            ans.append(1)
            break
    ans.reverse()
    print(''.join(list(map(str, ans))))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from copy import deepcopy
from collections import deque

h,w=nii()
s=[list(input()) for i in range(h)]

def dfs(cs,i,j):
  que=deque()
  que.append([i,j])

  cs[i][j]='#'

  dist=[[-1 for a in range(w)] for b in range(h)]
  dist[i][j]=0

  while que:
    y,x=que.popleft()
    for dy,dx in [[1,0],[-1,0],[0,1],[0,-1]]:
      ny=y+dy
      nx=x+dx
      if 0<=ny<h and 0<=nx<w and cs[ny][nx]=='.':
        que.append([ny,nx])
        cs[ny][nx]='#'
        dist[ny][nx]=dist[y][x]+1

  t_ans=0
  for a in dist:
    t_ans=max(t_ans,max(a))

  return t_ans

ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      cs=deepcopy(s)
      dist=dfs(cs,i,j)
      ans=max(ans,dist)

print(ans)

Measured memory_bytes: 9668
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vector<string> grid(n);
    cin>>grid;

    ll ans = 0;
    rep(i, n) {
        bool f = true;
        rep(j, n) rep(k, n) {
            if (grid[(j + i) % n][k] != grid[(k + i) % n][j]) f = false;
        }
        if (f) ans += n;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
n,W=map(int,input().split())
v=[]
w=[]
for i in range(n):
    vv,ww=map(int,input().split())
    v.append(vv)
    w.append(ww)
dp=[[-1]*(W+1) for i in range(n+1)]
for i in range(W+1):
    dp[0][i]=0
for i in range(n):
    for j in range(W+1):
        if j-w[i]>=0:
            dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i])
        else:
            dp[i+1][j]=dp[i][j]
print(dp[n][W])


Measured memory_bytes: 15684
#include <stdio.h>

int main()
{
    int i,j;
    char c[3][4];
    
    for(i=0;i<3;i++){
        for(j=0;j<4;j++){
            scanf("%c",&c[i][j]);
        }
    }
    
    printf("%c%c%c\n",c[0][0],c[1][1],c[2][2]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
int n, m;

vector <int> g[323456]; 
int cnt[323456];
int ans;
int d[323456];
vector <int> ord;
bool used[323456];

void dfs(int v) {
	used[v] = true;
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (!used[to])
			dfs (to);
	}
	ord.push_back (v);
}

void bfs() {
	queue <int> q;

	for(int i = 0; i < ord.size(); i++) q.push(ord[i]);
	while(q.size()) {
		int x = q.front();
		q.pop();
		for(int i = 0; i < g[x].size(); i++) {
			int y = g[x][i];
			if(d[x] + 1 > d[y]) d[y] = d[x] + 1, q.push(y), ans = max(ans, d[y]);
		}
	}
	cout << ans;
	exit(0);
}
int main() {
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		cnt[y]++;
		//g[y].push_back(x);
	}
	for(int i = 1; i <= n; i++) if(used[i] == 0) dfs(i);
	reverse(ord.begin(), ord.end());
	bfs();
	cout << ans;
}


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

int main() {
    int r, g, b, temp;
    cin >> r >> g >> b;
    temp = 100 * r + 10 * g + b;
    if(temp % 4) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n;
	vector<int>list;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	int index = -1;

	for (int i = 0; i < n - 1; i++) {
		if (list[i] > list[i + 1]) {
			index = i;
			break;
		}
	}

	vector<int>list2 = list;
	vector<bool>flag2(1000, false);
	bool flag3 = false;
	int cnt = 0;

	if (index != -1) {

		while (true)
		{

			list = list2;

			for (int i = index + 1; i < n; i++) {
				if (list[index] > list[i] ) {
					if (flag2[i] == true)continue;

					swap(list[index], list[i]);
					flag2[i] = true;
					break;
				}
			}

			bool flag = false;

			for (int i = 0; i < n - 1; i++) {
				if (list[i] > list[i + 1]) {
					flag = true;
					break;
				}
			}

			if (flag == false) {
				flag3 = true;
				break;
			}

			cnt++;
			if (cnt >= n)break;

		}

			if (flag3 == true) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}
		
	}
	else {
		cout << "YES" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int N, M;
    cin >> N >> M;

    map<ll, ll> S;
    REP(i, N) {
        ll a, b;
        cin >> a >> b;
        S[a] += b;
    }

    ll ans = 0;
    ll cnt = 0;
    for (auto p: S) {
        if (cnt + p.se < M) {
            ans += p.fi * p.se;
            cnt += p.se;
        } else {
            ll c = M - cnt;
            ans += p.fi * c;
            break;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

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

		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int ans = a * b;
		int ans2 = (2 * a) + (2 * b);
		System.out.println(ans + " " + ans2);
	}

}



Measured memory_bytes: 26004
import java.util.*;

/**
 * A
 */
public class Main {

    void run() {
        
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[][] G = new int[n+1][n+1];
        int[] d = new int[n+1];

        d[1] = 1;

        for(int i=1; i<=n; i++) {
            for (int j=1; j<=n; j++) {
                G[i][j] = sc.nextInt();
            }
        }

        sc.close();

        int sum=0;
        int dis;
        int min;

        for(int p=0; p<n; p++) {

            min = 2000;
            dis = -1;

            for(int i=1; i<=n; i++) {

                if(d[i] == 1) {
                    for(int j=1; j<=n; j++) {

                        if(d[j]==0 && G[i][j]>-1 && G[i][j]<min) {
                            min = G[i][j];
                            dis = j;
                        }

                    }
                }

            }

            if(dis != -1) {
            d[dis] = 1;
            sum += min;
            }

            if(n==n-1) {
                break;
            }

        }

        System.out.println(sum);

    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 40716
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var n = parseInt(input[0], 10);
    var str = input[1];
    var suu = str.split(" ");
    for(var i=0; i<n; i++){
      suu[i] = parseInt(suu[i], 10);
    }
    var count = 0;
    var min = 200001;
  	for(var i=0; i<n; i++){
      if(suu[i] < min){
        count++;
        min = suu[i];
      }
    }
  console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int a, b, c, d, e, f, g, h = 0;
	cin >> a >> b;
	for (int i = a;i <= b;i++)
	{
		c = i % 10;
		d = (i % 100)/10;
		e = (i % 1000) / 100;
		f = (i % 10000) / 1000;
		g = i / 10000;
		if ((c == g) && (d == f))
			h++;

	}



	cout << h << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main()
{
	long long int n;
	cin >> n;
	long long int i,a ,b ,c;
	cin >> a >> b >> c;
	long long int dp[n][3];
	dp[0][0] = a;dp[0][1] = b;dp[0][2] = c;
	for(i=1;i<n;i++)
	{
		cin >> a >> b >> c;
		dp[i][0] = a;dp[i][1] = b; dp[i][2] = c;
		
		dp[i][0]+= max(dp[i-1][1], dp[i-1][2]);
		dp[i][1]+= max(dp[i-1][0], dp[i-1][2]);
		dp[i][2]+= max(dp[i-1][1], dp[i-1][0]);
		
	}
	cout << max(max(dp[n-1][0], dp[n-1][1]),dp[n-1][2]);
	
	return 0;
}

Measured memory_bytes: 2560
#オンオフについてのimos法
W,H,N=map(int,input().split())
L,R = 0,W
D,T = 0,H
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        if R <= x:
            L,R = 0,0
        elif L <= x:
            L = x
    elif a == 2:
        if x <= L:
            L,R = 0,0
        elif x <= R:
            R = x
    elif a == 3:
        if T <= y:
            D,T = 0,0
        elif D <= y:
            D = y
    else:
        if y <= D:
            D,T = 0,0
        elif y <= T:
            T = y
print( ( R - L ) * ( T - D ) )

Measured memory_bytes: 3064
A,B = map(int,input().split())
ans = 0
while 1:
    C = int(ans*0.08)
    D = int(ans*0.1)
    if C == A and D == B:
        print(ans)
        break
    if C > A or D > B:
        print(-1)
        break
    ans += 1

Measured memory_bytes: 3060
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba-064a5016a 

#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
signed main()
{
	fast_io
	int n, k;
	cin >> n >> k;
	vector < int > h(n);
	for(int i = 0; i < n; i++)
		cin >> h[i];
	vector < int > dp(n + 1, 0);
	dp[1] = 0;
	dp[2] = abs(h[1] - h[0]);
	for(int i = 3; i <= n; i++)
	{
		dp[i] = 1e9; // inf
		for(int j = i - 1; j >= max(1LL, i - k); j--)
		{
			dp[i] = min(dp[i], dp[j] + abs(h[i - 1] - h[j - 1]));
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    int n;
    cin  >> n;
    int l = 1e9, r = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        l = min(l, a);
        r = max(a, r);
    }
    cout << r - l << "\n";
}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256