akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int num = Integer.parseInt(sc.nextLine());

        String[] line = sc.nextLine().split(" ");
        
        int[] array = new int[num];

        for (int i = 0;i < num;i++){
            array[i] = Integer.parseInt(line[i]);
        }

        int ans = 1;
        boolean isCanLook = true;
        for (int i = 1;i < num; i++){
            for (int k = 0;k < i;k++){
                if(array[k] > array[i]){
                    isCanLook = false;
                    break;
                }
            }

            if(isCanLook){
                ans++;
            }

            isCanLook = true;
        }


        System.out.println(ans);
    }
}


Measured memory_bytes: 22228
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10
/*
int c[100001];
int go[100001];

int main() {
	int n;
	while (cin >> n && n != 0) {
		int cnt = 0;
		for (int i = 0; i < n; ++i) {
			cin >> c[i];
		}
		go[0] = c[0];
		for (int i = 1; i < n; ++i) {
			if ((i + 1) % 2 == 0 && go[i - 1] != c[i]) {
				go[i - 1] = 1 - go[i - 1];
				int i2 = i - 2;
				while (i2 >= 0 && go[i - 1] == go[i2]) {
					go[i2] = 1 - go[i2];
					--i2;
				}
			}
			go[i] = c[i];
		}
		cout << endl << "****************" << endl;
		for (int i = 0; i < n; ++i) {
			cout << go[i];
			if (go[i] == 0) { ++cnt; }
		}
		cout << endl << "****************" << endl;
		cout << cnt << endl;
	}
*/
int c[100001];
int go[100001];
int main(){
	int n;
	while (cin >> n && n != 0) {
		for (int i = 1; i <= n; ++i) {
			cin >> c[i];
		}
		int right = 0;
		go[right] = 1;
		int left = c[1], prev = c[1];
		for (int i = 2; i <= n; ++i) {
			if (prev == c[i]) { ++go[right]; }
			else if (i % 2 == 0) {
				if (right == 0) {
					++go[right];
					left = c[i];
				}
				else {
					go[right - 1] += go[right] + 1;
					--right;
				}
			}
			else {
				++right;
				go[right] = 1;
			}
			prev = c[i];
		}
		int sum = 0;
		int num = 0;
		for (int i = 0; i <= n && num < n && sum < n; ++i) {
			num += go[i];
			if (left == 0) {
				if (i % 2 == 0) {
					sum += go[i];
				}
			}
			else {
				if (i % 2 == 1) {
					sum += go[i];
				}
			}
		}
		cout << sum << endl;
	}

	return 0;
}

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

int main() {
  long long h,w;

  cin >> h >> w;

  long long val = h*w;

  if(h==1 || w==1)
  cout << 1;

  else if(val %2 == 0)
  cout << val/2;
  else
  {
    cout << val/2+1;
  }
  


}

Measured memory_bytes: 3588
#![allow(unused_imports)]
extern crate proconio;
use proconio::{input,marker::Chars};
use std::cmp::Reverse;

pub fn main() {
    input! {
        s: Chars,
        t: Chars,
        //h: [i64; n],
    }
    let mut count:i32 = 0;
    for i in 0..s.len(){
        if s[i] != t[i]{
            count += 1;
        }
    }
    

    println!("{}", count);
}


Measured memory_bytes: 3984
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static private enum House {
		Building(4),
		Floor(3),
		Room(10);

		private int number;
		public int getnumber() {
			return this.number;
		}

		private House(int number) {
			this.number = number;
		}
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		int lists = Integer.parseInt(input.readLine());
		String[] inputListStr = null;
		int[][][] listData = new int[House.Building.getnumber()][House.Floor.getnumber()][House.Room.getnumber()];

		for (int i = 0; i < lists; i++) {
			inputListStr = (input.readLine()).split("\\s");
			int b = Integer.parseInt(inputListStr[0]);
			int f = Integer.parseInt(inputListStr[1]);
			int r = Integer.parseInt(inputListStr[2]);
			int v = Integer.parseInt(inputListStr[3]);

			listData[b -1][f -1][r -1] += v;
		}

		for (int i = 0; i < House.Building.getnumber(); i++) {
			for (int j = 0; j < House.Floor.getnumber(); j++) {
				for (int k = 0; k < House.Room.getnumber(); k++) {
					System.out.print(" " + listData[i][j][k]);
				}
				System.out.println();
			}
			if (i != 3) {
				System.out.println("####################");
			}
		}

	}

}



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

int main() {
  int n;cin>>n;
  ll ans=1,x=1e18;
  bool ng=false;
  rep(i,n){
    ll a;cin>>a;
    if(a==0){
      cout<<0<<endl;
      return 0;
    }
    if(ng||x/ans<a)ng=true;
    ans*=a;
  }
  if(ng)cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 3540
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

void chmin(int& t, int f) { if (f < t) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int D[1024], C[1024], dp[1024][1024];

int main() {
    int N = in();
    int M = in();
    
    for (int i = 0; i < N; ++i) {
        D[i] = in();
    }
    for (int j = 0; j < M; ++j) {
        C[j] = in();
    }
    
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            chmin(dp[i][j + 1], dp[i][j]);
            chmin(dp[i + 1][j + 1], dp[i][j] + D[i] * C[j]);
            /*cout << "dp[" << i << "][" << j << "] = " << dp[i][j]
            << endl;*/
        }
    }
    //cout << endl;
    
    int res = 1001001001;
    for (int j = 1; j <= M; ++j) {
        //cout << "dp[" << N << "][" << j << "] = " << dp[N][j] << endl;
        chmin(res, dp[N][j]);
    }
    printf("%d\n", res);
    
    return 0;
}

Measured memory_bytes: 7308
n, t = gets.split().map{|num| num.to_i}
ct = []
n.times do
  cn, tn = gets.split().map{|num| num.to_i}
  if t >= tn then
    ct.push([cn, tn])
  end
end

ct.sort!
if ct == [] then
  puts "TLE"
else
  puts ct[0][0]
end


Measured memory_bytes: 1788
N = int(input())
*A, = map(int, input().split())
operations = []
pos = []; zero = []; neg = [];
for a in A:
    if a > 0: pos.append(a)
    elif a == 0: zero.append(a)
    else: neg.append(a)
pos.sort(); neg.sort()
if N == 2:
    a, b = max(A), min(A)
    ans = a - b
    operations.append((a, b))
else:
    if len(neg) == 0:
        pos = zero + pos
        operations.append((pos[0], pos[-1]))
        neg = [pos[0] - pos[-1]]
        pos = pos[1:-1]
    elif len(pos) == 0:
        neg = neg + zero
        operations.append((neg[-1], neg[0]))
        pos = [neg[-1] - neg[0]]
        neg = neg[1:-1]
    else:
        neg = neg + zero
    neg = neg[::-1]
    while len(pos) > 1 and len(neg) > 1:
        n, p = neg.pop(), pos.pop()
        operations.append((p, n))
        pos.append(p-n)
    if len(neg) == 1:
        while len(pos) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((n, p))
            neg.append(n-p)
    else:
        while len(neg) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((p, n))
            pos.append(p-n)
    operations.append((pos[0], neg[0]))
    ans = pos[0] - neg[0]
print(ans)
for x, y in operations:
    print(x, y)

Measured memory_bytes: 20696
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define It iterator
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;


int main() {
    //freopen("test.in","r",stdin);
    ll x,p;
    cin>>x>>p;
    double xx=x/2+x%2;
    printf("%.6f",xx/p*100);
    return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int ddx[8]={0,0,-1,1,1,1,-1,-1};
int ddy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
	int N,M;
	cin>>N>>M;
	int ans=0;
	vector<int> a,b;
	for(int i=0;i<M;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		a.pb(x),b.pb(y);
	}
	for(int i=0;i<M;i++){
		UnionFind U(N+1);
		for(int j=0;j<M;j++){
			if(i!=j){
				U.unionSet(a[j],b[j]);
			}
		}
		bool flag=0;
		for(int j=0;j<N;j++){
			if(U.findSet(0,j)==0)
				flag=1;
		}
		if(flag)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[222222];
long long ans,n,cnt;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for (int i=0;i<n;i++)
	{
		if (s[i]=='B') cnt++;
		else ans+=cnt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define N 500000

int data[N+1], n;

void swap(int* a, int* b){
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void maxHeapify(i){
    int l = 2*i;
    int r = 2*i+1;
    int valM;
    if(l <= n && data[l] > data[i]) valM = l;
    else valM = i;
    if(r<=n && data[r] > data[valM]) valM = r;
    if(valM != i){
        swap(&data[i], &data[valM]);
        maxHeapify(valM);
    }
}

void buildMaxHeap(){
    int i;
    for(i=n/2; i>0; i--)maxHeapify(i);
}

int main(){
    int i;
    scanf("%d", &n);
    for(i=1; i<=n; i++) scanf("%d", &data[i]);
    buildMaxHeap();
    for(i=1; i<=n; i++) printf(" %d", data[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define vsort(v) sort(v.begin(),v.end)
using namespace std;
int n, h, w, a, b, cnt;
signed main() {
	cin >> n >> h >> w;
	rep(i, n) {
		cin >> a >> b;
		if (h <= a && w <= b)cnt++;
	}
	cout << cnt << endl;
	system("PAUSE");
}

Measured memory_bytes: 504
a, b, c, x, y = map(int, input().split())
a1 = a * x + b * y
a2 = min(x, y) * c * 2 + ((x - y) * a if x > y else (y - x) * b)
a3 = max(x, y) * c * 2
print(min(a1, a2, a3))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		if(N%10 ==2 ||N%10 == 4 || N%10 == 5|| N%10 ==7 || N%10 == 9 ) {
			System.out.println("hon");
		}else if(N%10 == 0|| N%10 == 1|| N%10 == 6|| N%10 == 8){
			System.out.println("pon");
		}else if(N%10 == 3) {
			System.out.println("bon");
		}

	}

}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int[] ans = new int[3];
		ans[0] = sc1.nextInt();
		ans[1] = sc1.nextInt();
		ans[2] = sc1.nextInt();

		Arrays.sort(ans);

		System.out.println(ans[0] + " " + ans[1] + " " + ans[2]);

		sc1.close();

	}

}


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

int main() {
  string O, E;
  cin >> O >> E;

  for (int i = 1; i <= O.length() + E.length(); i++) {
    if (i % 2 == 0)
      cout << E[(i - 1) / 2];
    else
      cout << O[(i - 1) / 2];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1050
#define M 200
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
#define MOD mod
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
  	int n; cin>>n;
  	n%=1000;
  	n = 1000 - n;
  	cout<<n%1000;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string a,b;
  cin>>a>>b;
  pair<string,int> s;
  pair<string,int> t;
  sort(all(a));
  sort(all(b),greater<char>());
  s=make_pair(a,a.size());
  t=make_pair(b,b.size());
  if(s<t){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    string ans;
    for(int i=0; i<S.size(); i++){
        if(!ans.size()){
            if(S[i] == 'A'){
                ans += S[i];
            }
            continue;
        }
        if(S[i] == 'Z' and ans.back() == 'A'){
            ans += S[i];
            continue;
        }
        if(S[i] == 'A' and ans.back() == 'Z'){
            ans += S[i];
            continue;
        }
    }    
    if(ans.size() and ans.back()=='A') ans.pop_back();
    if(ans.size()){
        cout << ans << "\n";
    }else{
        cout << "-1\n";
    }
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    ll a,b; cin>>a>>b;
    bool ok=1;
    for(ll i=1;i<=1000000;i++){

        if(a<=i*0.08 && i*0.08<a+1 && b<=i*0.1 && i*0.1<b+1){
            cout<<i;
            ok=0;
            break;
        }
    }
    if(ok) cout<<-1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[50005];
int A[25];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)	cin>>A[i];
	for(int i=1;i<=n;i++)	dp[i]=0x3f3f3f3f;
	for(int i=1;i<=m;i++){
		for(int j=A[i];j<=n;j++){
				dp[j]=min(dp[j],dp[j-A[i]]+1);
		}
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 3292
#include <iostream>

int main() {
    int n;
    std::cin >> n;
    for (int a = 0; a <= n; ++a) {
        int b = a * 108 / 100;
        if (b == n) {
            std::cout << a << std::endl;
            return 0;
        }
    }

    std::cout << ":(" << std::endl;
    return 0;
}


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

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N, M;
    read(N, M);
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        read(A[i]);
    }
    priority_queue<int> q;
    for(int i = 0; i < N; i++){
        q.push(A[i]);
    }
    for(int i = 0; i < M; i++){
        int cur = q.top();
        q.pop();
        q.push(cur / 2);
    }
    ll ans = 0;
    while(!q.empty()){
        ans += q.top();
        q.pop();
    }
    write(ans);
    return 0;
}

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

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

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

Measured memory_bytes: 1276
import math
n, d = map(int, input().split())
x = [[int(e) for e in input().split()] for _ in range(n)]
result = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    t = math.sqrt(sum((x[i][k] - x[j][k]) * (x[i][k] - x[j][k]) for k in range(d)))
    if t == math.ceil(t):
      result += 1
print(result)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

    rep(i,8){
        int tmp=s[0]-'0';
        rep(j,3){
            int a=s[j+1]-'0';
            if(i>>j&1)tmp+=a;
            else tmp-=a;
        }
        if(tmp!=7)continue;
        cout<<s[0];
        rep(j,3){
            if(i>>j&1)cout<<"+";
            else cout<<"-";
            cout<<s[j+1];
        }
        cout<<"=7"<<endl;
        return 0;
    }

    return 0;
}


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

int main(){
  string S,T="";
  cin>>S;
  for(char c:S){
    if(c=='B'){
      if(T.size()!=0){
        string U="";
        for(int i=0;i+1<T.size();i++)
          U+=T.at(i);
        T=U;
      }
    }else
      T+=c;
  }
  cout<<T<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  for (int i = n;;++i) {
    int d = i/100;
    int e = (i/10)%10;
    int f = i%10;
    if (d == e && e == f) {
      cout << d*100 + e*10 + f << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt(), b = sc.nextInt();
		
		int cnt = 0;
		
		for (int i = a; i <= b; i++) {
			
			String tmp = String.valueOf(i);
			
			String rev = new StringBuilder(tmp).reverse().toString();
			
			if (tmp.equals(rev)) cnt++;
			
		}
		
		System.out.println(cnt);
		
	}

}

Measured memory_bytes: 36948
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
//#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	int a, b, c;
	cin >> a >> b >> c;
	if(a+b+c >= 22){
		cout << "bust" << endl;
	}
	else{
		cout << "win" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
import math
ans = 0
mod = 10**9+7
a = 0
ans = 0
for i in range(N-1):
  a += pow(i+1,mod-2,mod)
  ans += ((X[i+1]-X[i])%mod)*(a%mod)
  ans %= mod
  
ans *= math.factorial(N-1)%mod

print(ans%mod)

Measured memory_bytes: 14228
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF 2147483647
#define INFLL LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    bool ans = true;

    int n;
    cin >> n;
    rep(i, n){
        int in;
        cin >> in;
        if(in%2 == 0){
            if(in%3 != 0 && in%5 != 0) ans = false;
        }
    }

    if(ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
 
  for (int i = 0; i < N+1; i++) {
    int A;
    cin>>A;
    if (A%2==0 && A%6!=0 && A%10!=0){
      cout << "DENIED" << endl ;
      break ;
    }
    else if (i==N) {
      cout << "APPROVED" << endl ;
    }
    else if(A%2!=0) {
    }
    else if(A%2==0 && A%6 ==0){
    }
    else if (A%2==0 && A%10 == 0){
    }
    
  }
}


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

int main(){
	int height,width;
	cin >> height >> width;
	string image[height];
	for(int i=0; i<height; i++){
		cin >> image[i];
	}
	for(int i=0; i<width+2; i++)cout<<"#";
	cout<<endl;
	for(int i=0; i<height; i++)cout<<"#"<<image[i]<<"#\n";
	for(int i=0; i<width+2; i++)cout<<"#";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef pair<ll,ll>pll;
const  ll MAX=100000000;
int main()
{


ll n;

cin>>n;


ll l=n/1000;

if(n%1000)l++;

l=l*1000;


cout<<l-n<<endl;





}



Measured memory_bytes: 3556
import sys
readline = sys.stdin.readline

N, K = map(int, readline().split())
A = list(map(int, readline().split()))

K = min(100, K)
while K:
    K -= 1
    table = [0]*(N+1)
    for i in range(N):
        a = A[i]
        table[max(0, i-a)] += 1
        table[min(N, i+a+1)] -= 1
    
    for i in range(1, N):
        table[i] += table[i-1]
    
    A = table[:-1]

print(*A)

Measured memory_bytes: 168952
// Implementation practice (Have seen the editorial)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define loop(i, a) for (int i = 0; i < a; i++)
#define revloop(i, a) for (int i = a-1; i > -1; i--)
#define show(a) cout << a << "\n"
#define showloop(a, len) for (int i = 0; i < len; i++) cout << a[i] << "\n"
#define debug(a) cout << #a << ": " << a << "\n"
#define MOD 1000000007
#define V vector
#define S set
#define P pair
#define M map;
#define PQ priority_queue

int main() {
//    freopen("inputs.txt", "w", stdout);
//    int n = maxN;
//    loop(i, n) cout << i+1 << " ";
    //freopen("inputs.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int a[n];
    loop(i, n) cin >> a[i];
    sort(a, a+n);
    int c = a[0], count = 1;
    int m1 = 0, m2 = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] == c) {
            count++;
            if (count == 2) {
                m1 = m2;
                m2 = c;
            }
            else if (count == 4) {
                m1 = c;
            }
        }
        else {
            count = 1;
            c = a[i];
        }
    }
    show((ull)m1*m2);

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
  
// Returns the value of maximum profit 
ll knapSackRec(ll W, ll wt[], ll val[], 
                ll i, ll** dp) 
{ 
    // base condition 
    if (i < 0) 
        return 0; 
    if (dp[i][W] != -1) 
        return dp[i][W]; 
  
    if (wt[i] > W) { 
  
        // Store the value of function call  
        // stack in table before return 
        dp[i][W] = knapSackRec( 
W, wt, val, i - 1, dp); 
        return dp[i][W]; 
    } 
    else { 
  
        // Store value in a table before return 
        dp[i][W] = max( 
            val[i] + knapSackRec( 
                         W - wt[i], wt, val, i - 1, dp), 
            knapSackRec(W, wt, val, i - 1, dp)); 
  
        // Return value of table after storing 
        return dp[i][W]; 
    } 
} 
  
ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
    // double poller to declare the  
// table dynamically 
    ll** dp; 
    dp = new ll*[n]; 
  
    // loop to create the table dynamically 
    for (ll i = 0; i < n; i++) 
        dp[i] = new ll[W + 1]; 
  
    // loop to initially filled the  
// table with -1 
    for (ll i = 0; i < n; i++) 
        for (ll j = 0; j < W + 1; j++) 
            dp[i][j] = -1; 
    return knapSackRec(W, wt, val, n - 1, dp); 
}

int main()
{
  ll n,W;
  cin>>n>>W;
  ll val[n],wt[n];
  for (ll i = 0; i < n; ++i)
  {
    cin>>wt[i]>>val[i];
    /* code */
  }
  cout<<knapSack(W,wt,val,n)<<endl;
  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, D;
    cin >> N >> D;

    vector<vector<double>> vv(N, vector<double>(D, 0));
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < D; j++) {
            cin >> vv[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            if (i == j) {
                continue;
            }
            double tmp = 0;
            for (int k = 0; k < D; k++) {
                tmp += pow(abs(vv[i][k]-vv[j][k]), 2);
            }
            tmp = pow(tmp, 0.5);
            if (ceil(tmp) == floor(tmp)) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 512
function Main(input) {
  const nameArr = input.split("\n");
  
  const name1letArr = nameArr[0].split('');
  const name1letNum = name1letArr.length;
  
  const name2letArr = nameArr[1].split('');
  const name2letNum = name2letArr.length;
  
  let matchLetNum = 0;
  
  if (name2letNum === name1letNum + 1) {
    for (let i = 0; i < name1letNum; i++) {
      if (name2letArr[i] === name1letArr[i]) {
        matchLetNum += 1;
      }
    }
  }
  
  if (matchLetNum === name1letNum) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29628
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int e[N+1],o[N+1];
	rep(i,N+1) e[i]=o[i]=0;
	int n;cin>>n;
	rep(i,n){
		int v;cin>>v;
		if(i%2==0) o[v]++;
		else e[v]++;
	}
	int ie[2]={0,0},io[2]={0,0};
	rep1(i,N){
		if(e[i]>e[ie[0]]) ie[0]=i;
		if(o[i]>o[io[0]]) io[0]=i;
	}
	rep1(i,N){
		if(e[i]>e[ie[1]]&&i!=ie[0]) ie[1]=i;
		if(o[i]>o[io[1]]&&i!=io[0]) io[1]=i;
	}
	int ans;
	if(ie[0]!=io[0]) ans=n-e[ie[0]]-o[io[0]];
	else{
		ans=n-e[ie[1]]-o[io[0]];
		ans=min(ans,n-e[ie[0]]-o[io[1]]);
	}
	cout<<ans<<endl;
}


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

N = int(input().strip())
x_u = [[j for j in input().split()] for i in range(N)]

amou=float(0)
for x_str,u in x_u:
    if u == "JPY":
        amou += float(x_str)
    else:
        amou += float(x_str) * 380000

print(amou)


Measured memory_bytes: 2940
// AOJ ALDS1_10_D Optimal Binary Search Tree
// 2019.3.29 bal4u

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

#define INF  1e20
#define MAX  503
int N;
double p[MAX], q[MAX];
double sp[MAX][MAX], sq[MAX][MAX];
double dp[MAX][MAX];

int main()
{
	int i, j, k;
	double t;
	
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%lf", p + i);
	for (i = 0; i <= N; i++) scanf("%lf", q + i);

	for (i = 0; i < N; i++) {
		sp[i][i] = p[i];
		for (j = i + 1; j < N; j++) sp[i][j] = sp[i][j - 1] + p[j];
	}

	for (i = 0; i <= N; i++) {
		dp[i][i] = sq[i][i] = q[i];
		for (j = i + 1; j <= N; j++) sq[i][j] = sq[i][j - 1] + q[j];
	}

	for (i = 1; i <= N; i++) {
		for (j = 0; j + i <= N; j++) {
			dp[j][j + i] = INF;
			for (k = 0; k < i; k++) {
				t = dp[j][j + k] + dp[j + k + 1][j + i] + sp[j][j + i - 1] + sq[j][j + i];
				if (t < dp[j][j + i]) dp[j][j + i] = t;
			}
		}
	}
	printf("%.12lf\n", dp[0][N]);
	return 0;
}


Measured memory_bytes: 7632
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  public static void main(String argus[]) {

    Scanner sc = new Scanner(System.in);
    String[] number = sc.next().split("");
   
    for (int i = 0; i < number.length - 1; i++) {
      if (number[i].equals(number[i + 1])) {
        System.out.println("Bad");
        return;
      }
    }
    
    System.out.println("Good");
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define R register
const int MN = 2e5 + 5;
int n, a[MN], nxt[MN];
long long ans;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin >> n;
	for (R int i = 1, pre = 1; i <= n; ++i) {
		std::cin >> a[i];
		if (a[i]) {
			for (; pre < i; ++pre)
				nxt[pre] = i;
			pre = i;
		}
	}

	for (R int i = 1; i <= n; ++i) {
		R int res = 0;
		for (R int j = i; j <= n; j = nxt[j]) {
			if (!j) {
				ans += n - i + 1;
				break;
			}
			if (res & a[j]) {
				ans += j - i;
				break;
			}
			res |= a[j];
		}
	}

	std::cout << ans << std::endl;	
}

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

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> all_nums = {{1,2},{2,5},{3,5},{4,4},{5,5},{6,6},{7,3},{8,7},{9,6}};
  map<int, int> nums;
  
  for(int i=0; i<M; i++) {
    int tmp;
    cin >> tmp;
    nums[tmp] = all_nums[tmp];
  }
  
  /* マッチN本でM個の数から数を作っていく */
  /* dp[n] : n本のマッチでつくることのできる、最大桁数*/
  
  vector<int> dp(N+2,-10000);
  int i = 0;  
  dp[0] = 0;
  dp[1] = 0;
  while(i<=N+1) {
    for(auto num:nums) {
      if(i-num.second<=0) {
        continue;
      }
      int tmp = dp[i-num.second] + 1;
      if(tmp>dp[i]) {
        dp[i] = tmp;
      }
    }  
    i++;
  }
  
  int len = dp[N+1];
  dp.erase(dp.begin());
  
  for(int i=0; i<len; i++) {
    for(auto itr=nums.rbegin(); itr!=nums.rend(); itr++) {
      if(i==len-1) {
        if(N==itr->second) {
          cout << itr->first << endl;
          break;
        }
      } else {
        if(dp[N-itr->second] == dp[N]-1) {
          cout << itr->first;
          N -= itr->second;
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val (d, x) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val aList = (0 until n).map {
        readLine()?.toInt()!!
    }

    var result = 0
    for (i in 0 until n) {
        var count = 1
        while (count <= d) {
            result++
            count += aList[i]
        }
    }

    result += x
    println(result)
}

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

int main() {
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int x3, y3, x4, y4;

	int dx = x2 - x1;
	int dy = y2 - y1;

	x3 = x2 - dy;
	y3 = y2 + dx;
	x4 = x3 - dx;
	y4 = y3 - dy;

	cout << x3 << " " << y3 << " " << x4 << " " <<  y4 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var swr = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(swr);
            int ans = 0;
            int[] a = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
            if (a[0] + a[1] + a[2] >= 22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }

            Console.Out.Flush();
        }
    }
}

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

#define F first
#define S second 
#define pb push_back
#define ll long long
#define int long long

using namespace std ;

const int MAXN = 101 * 1001 ;

int32_t main()
{
    ios::sync_with_stdio(0) ;
    cin.tie(0) ;
    string s ;
    cin >> s ;
    int n = s.size() ;
    int ans = 0 ;
    for(int i = 0 ; i < n ; i ++ )
        ans -= s[i]=='p' ;
    cout << ans + n / 2 <<'\n';
 
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;


// ============union_find_tree===============
long long MAX_N = 100000;
vector<long long> par(MAX_N);//MAX_N == num of node
vector<long long> tree_rank(MAX_N);

void init(long long n)
{
  for (long long i = 0; i < n; ++i)
  {
    par.at(i) = i;
    tree_rank.at(i) = 0;
  }
}

long long find(long long x)
{
  if (par.at(x) == x)
  {
    return x;
  }
  else
  {
    return par.at(x) = find(par.at(x));
  }
}

void unite(long long x, long long y)
{
  x = find(x);
  y = find(y);
  if (x == y)
  {
    return;
  }
  if (tree_rank.at(x) < tree_rank.at(y))
  {
    par.at(x) = y;
  }
  else
  {
    par.at(y) = x;
    if (tree_rank.at(x) == tree_rank.at(y))
    {
      tree_rank.at(x)++;
    }
  }
}

bool same(long long x, long long y)
{
  return find(x) == find(y);
}
// =======================================

long long make_ans(vector<long long> group_num)
{
  long long n = group_num.size();
  long long ans = n * (n - 1) / 2;
  for (long long i = 0; i < n; ++i)
  {
    long long group_i = group_num.at(i);
    if (group_i == 0)
    {
      continue;
    }
    ans -= group_i * (group_i - 1) / 2;
  }
  return ans;
}

int main()
{
  long long N, M;
  cin >> N >> M;
  vector<long long> group_num(N, 1);
  vector<pair<long long, long long>> brige(M);
  init(N);
  for (long long i = 0; i < M; ++i)
  {
    long long a, b;
    cin >> a >> b;
    brige.at(i).first = a - 1;
    brige.at(i).second = b - 1;
  }
  vector<long long> ans_vec;
  long long ans = N * (N - 1) / 2;
  ans_vec.push_back(ans);
  for (long long i = M - 1; i > -1; --i)
  {
    pair<long long, long long> brige_now = brige.at(i);
    if (!same(brige_now.first, brige_now.second))
    {
      long long a, b;
      a = group_num.at(find(brige_now.first));
      b = group_num.at(find(brige_now.second));
      ans -= a * b;
      // group_num.at(find(brige_now.first)) += b;
      // group_num.at(find(brige_now.second)) = 0;
      unite(brige_now.first, brige_now.second);
      group_num.at(find(brige_now.first)) = a + b;
    }
    // cout << "par" << find(brige_now.first) << endl;
    // for (long long z = 0; z < N; ++z)
    // {
    //   cout << par[z] << ' ';
    // }
    // cout << endl;
    ans_vec.push_back(ans);
    // cout << endl;
    // for (long long i = 0; i < N; ++i)
    // {
    //   cout << group_num.at(i) << endl;
    // }
    // cout << endl;
  }
  for (long long i = M - 1; i > -1; --i)
  {
    cout << ans_vec.at(i) << endl;
  }
}


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


int n;
string s;
int ans = 0;

int main() {
  cin >> n >> s;
  for (int i = 0; i < 1000; i++) {
    int c[3] = {i / 100, (i / 10) % 10, i % 10};
    int f = 0;
    for (int j = 0; j < n; j++) {
      if (s[j] == ('0' + c[f])) f++;
      if (f == 3) break;
    } 
    if (f == 3) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;
    cin>>n;
    vint d(n);
    rep(i, n)cin>>d[i];
    sort(all(d));
    cout << d[n/2] - d[n/2-1] << endl;
    return 0;
}


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

typedef long long ll;
const int INF = 1e9+7;

const int LIM = 1e5+10;
ll pd[LIM], h[LIM];
bool calc[LIM];

int N;

ll solve(int n = 0){
    if(n>=N) return INF;
    if(n == N-1) return 0;
    if(calc[n]) return pd[n];
    calc[n] = 1;
    pd[n] = abs(h[n+1]-h[n])+solve(n+1);
    pd[n] = min(pd[n], abs(h[n+2]-h[n]) + solve(n+2));
    return pd[n];
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N;
    for(int i=0; i<N; i++) cin >> h[i];
    cout << solve() << '\n';

    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if((a + b) % 2 == 0)
    cout << (a + b) / 2 << endl;
  else
    cout << (a + b) / 2 + 1 << endl;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

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

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;

    ll ans = N * M / gcd(N, M);
    ll n = ans / N, m = ans / M;

    ll step = ans / gcd(N, M);
    for (ll i = 0; i < ans; i += step) {
        if (S[i / n] != T[i / m]) {
            cout << -1 << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 512
def readlines():
    for _ in range(3):
        yield list(map(int, input().split()))

c = list(readlines())

def it():
    for a1 in range(100):
        b1 = c[0][0] - a1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1
        a2 = c[1][0] - b1
        a3 = c[2][0] - b1
        yield (c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and
               c[2][1] == a3 + b2 and c[2][2] == a3 + b3)

print("Yes" if any(it()) else "No")








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

int main(){
 ll N,M; cin >> N >> M;
  vector<vector<int>> to(N);
  for(ll i = 0; i < M; i++){
    ll a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a);
  }
  
  queue<ll> Q; Q.push(0);
  vector<ll> color(N,-1); // 0が白、1が黒に対応, -1は未決定を意味
  color[0] = 0;
  bool flag = true;
  ll black = 0; ll white = 0;
  
  while(!Q.empty()){
    ll p = Q.front(); Q.pop();
    for(auto q : to[p]){
      if( color[q] == -1){ 
        if( color[p] == 0){ color[q] = 1;} 
        else{ color[q] = 0;
            }
        Q.push(q);
      }
      else{
        if( color[q] == color[p]){
          flag = false; break;
        }
      }
    }
      if(!flag){ break;}
  }
    
  if(!flag){
    // 二部グラフではなかった
    cout <<( (N*(N-1))/2)-M << endl; return 0;}
  else{
    for(ll i = 0; i < N; i++){
      if(color[i] == 0){ white++;}
      else{ black++;}
    }
    
    cout << black*white-M << endl; return 0;
  }
  return 0;
}
    
    
    
                            

Measured memory_bytes: 6656
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(){
	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	string S; cin >> S;
	bool check = true;
	for(int i=A; i<max(C,D)-2; i++){
		if((S[i]=='#')&&(S[i+1]=='#')){
			check = false;
			i = INF;
			break;
		}
	}
	if(D<C && check){
		check = false;
		for(int i=B-2; i<D-1; i++){
			if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
				check = true;
				i = INF;
				break;
			}
		}
	}
	if(check){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 640
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-05-02 21:11:44
*/

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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

int main()
{
    long x;
    cin >> x;

    long y = 100;
    int n = 1;
    while (1) {
        y *= 1.01;

        if (y >= x) {
            break;
        } else {
            n++;
        }
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void)
{
    LL A, B;
    cin >> A >> B;
    if (A <= 9 && B <= 9) {
        cout << A*B << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 768
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, C;
    cin >> N >> C;
    struct Event {
        bool is_start;
        ll channel;
    };
    set<ll> times;
    unordered_map<ll, vector<Event>> events;
    for (ll i = 0; i < N; i++) {
        ll s, t, c;
        cin >> s >> t >> c;
        c--;
        events[s-1].push_back(Event{true, c});
        events[t].push_back(Event{false, c});
        times.insert(s-1);
        times.insert(t);
    }
    vector<ll> program_cnt(C);
    ll max_recorders = numeric_limits<ll>::min();
    for (ll time : times) {
        for (Event e : events[time]) {
            if (e.is_start) {
                program_cnt[e.channel]++;
            } else {
                program_cnt[e.channel]--;
            }
        }
        ll recorders = 0;
        for (ll c = 0; c < C; c++) {
            if (program_cnt[c] > 0) {
                recorders++;
            }
        }
        max_recorders = max(max_recorders, recorders);
    }
    cout << max_recorders << endl;
}

Measured memory_bytes: 18208
a = input().split()
a = [int(i) for i in a]
b = input().split()
b = [int(i) for i in b]
b = sorted(b)
output = 0
end = False

for i in range(len(b)-  1):
	if a[1] - b[i] > 0:
		a[1] += -b[i]
		output += 1
	elif(a[1] - b[i] == 0):
		output += 1
		end = True
		break
	else:
		end = True
		break
		
if end == False:
	if a[1] - b[-1] == 0:
		output += 1
		 
print(output)

Measured memory_bytes: 3064