akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define REP(a) while(a--)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	REP(n){
		vi in(3);
		rep(i,3)cin>>in[i];
		sort(all(in));
		if(in[0]*in[0]+in[1]*in[1]==in[2]*in[2])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

}

Measured memory_bytes: 1204
N, M = map(int, input().split())
bibs = [int(input()) for _ in range(N)]
btns = [k+1 for k in range(M)]
for k in btns:
    for i in range(N-1):
        if bibs[i]%k > bibs[i+1]%k:
            bibs[i], bibs[i+1] = bibs[i+1], bibs[i]
print(*bibs, sep='\n')

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

int main() {
  int N, K;
  cin >> N >> K;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  
  for (int i = 0; i < N - K; i++){
    if (A[i + K] > A[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4428
H,W=map(int,input().split())
Map=[]
MAP=[]
Key=[]
cnt=0
import numpy as np

for i in range(H):
    tmp=input()
    if tmp!='.'*W:
        Map.append(tmp)
        
for i in Map:
    MAP.append(list(i))
    
for i in range(W):
    for j in range(len(MAP)):
        if MAP[j][i]=='.':
            cnt+=1
    if cnt==len(Map):
        Key.append(i)
    cnt=0

MAP=np.delete(MAP,Key,1)

for i in MAP:
    a=''.join(i)
    print(a)

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

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

		char[] c1 = nextString().toCharArray();
		char[] c2 = nextString().toCharArray();
		String ans = "NO";
		if(c1[0]==c2[2]&&c1[2]==c2[0]&&c1[1]==c2[1])
			ans="YES";
		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22356
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;


bool canDivide(vector<int>& A, int d, int K){
    int N = A.size();
    vector<int> rem(N);  // 余り
    for(int i = 0; i < N; ++i) rem[i] = A[i]%d;
    sort(rem.begin(), rem.end());
    // 累積和
    vector<int> r(rem), l(rem);  // 右からの累積和と左からの累積和
    for(int i = 1; i < N; ++i) r[i] += r[i-1];
    for(int i = 0; i < N; ++i) l[i] = d - l[i];
    for(int i = N-2; i >= 0; --i) l[i] += l[i+1];

    for(int i = 0; i < N-1; ++i){
        if(r[i]%d == l[i+1]%d and max(r[i], l[i+1]) <= K) return true;
    }
    return false;
}


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];

    int sumA = accumulate(A.begin(), A.end(), 0);

    // sumA の約数について全探索
    int ans = 1;
    for(int i = 1; i*i <= sumA; ++i){
        if(sumA%i != 0) continue;
        if(canDivide(A, i, K)) ans = max(ans, i);
        if(canDivide(A, sumA/i, K)) ans = max(ans, sumA/i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int data[] = new int [n];
		int a,ans = 0;
		for(int i = 0;i < n;i++)data[i]=sc.nextInt();
		for(int i = 0;i < n;i++) {
			for(int j = i+1;j < n;j++) {
				if(data[i] >data[j]) {
					a = data[i];
					data[i] = data[j];
					data[j] = a;
				}
			}
		}
		
		for(int i = n-1;i > n-k-1;i--) {
			ans += data[i];
		}
		System.out.println(ans);
	}

}

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

typedef long long ll;

main()
{
    int a, b, k, i;
    cin >> k >> a >> b;
    for(i = a; i <=b; i++){
        if(i % k == 0){
            cout << "OK";
            break;
        }
    }
    if(i == b+1){
        cout << "NG";
    }



}





///promy_pompom
//hello world


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
int main()
{
	ll a,b,d;
	read(a);read(b);
	d=b-a;
	write(1ll*(1+d)*d/2-b,'\n');
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define max_size (int)(1e5 + 1)

int max(int a, int b){
	return a >= b ? a : b;
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int i, a_num = 0, b_num = 0, c_num = 0;
	char *S = (char *)malloc(sizeof(char) * max_size);
	scanf("%s", S);
	for(i = 0; S[i] != '\0'; i++){
		if(S[i] == 'a'){
			a_num++;
		}
		if(S[i] == 'b'){
			b_num++;
		}
		if(S[i] == 'c'){
			c_num++;
		}
	}
	if(max(a_num, max(b_num, c_num)) - min(a_num, min(b_num, c_num)) <= 1){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 256
# Aの長さ
N = int(input())
# Bは長さ N-1
B = list(map(int, input().split()))
A=[]

if N == 2:
    print(2*B[0])
else :
    B.append(100001)
    ans = 0
    for i in range(N):
        A.append(min([B[i-1], B[i]]))
        ans += A[i]
    print(ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()


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

  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i,n){
    cin >> a[i];
    a[i] %= k;
    a[i]--;
    if(a[i] < 0)a[i] += k;
  }
  vi sum(n+1);
  rep(i,n){
    sum[i+1] = sum[i];
    sum[i+1] += a[i];
    sum[i+1] %= k;
  }

  map<int,ll> cnt;
  cnt[0] = 1;
  ll ret = 0;
  rep(i,n){
    if(i >= k-1){
      cnt[sum[i+1 - k]]--;
    }
    ret += cnt[sum[i+1]];
    cnt[sum[i+1]]++;
  }

  cout << ret << endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug(){cerr<<endl;}
	template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
	template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    int n = s.length();
    vector<ll> cnt(2019);
    cnt[0] = 1;
    int cur = 0, p = 1;
    ll ans = 0;
    reverse(s.begin(), s.end());
    for(int i = 0; i < n; i++) {
        cur += p * (s[i] - '0');
        cur %= 2019;
        ans += cnt[cur]++;
        p *= 10, p %= 2019;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    int h,w;
    cin >> h >> w;

    int sx,sy,gx,gy;
    cin >> sy >> sx >> gy >> gx;
    sx--;sy--;gx--;gy--;

    pair<int,int> s = make_pair(sx,sy), g = make_pair(gx,gy); 
    string sur[h];

    for(int i = 0; i < h; i++) cin >> sur[i];
    queue<pair<int,int>> p,q;

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

    p.push(s);

    int can = 0;

    while(!p.empty()){
        while(!p.empty()){
            pair<int,int> now = p.front();
            p.pop();
            q.push(now);
            for(int i = 0; i < 4; i++){
                pair<int,int> nxt = make_pair(now.first+dx[i],now.second+dy[i]);
                if(0 <= nxt.first && nxt.first < w && 0 <= nxt.second && nxt.second < h){
                    if(sur[nxt.second][nxt.first] == '.'){
                        if(nxt == g){
                            cout << can << endl;
                            return 0;
                        }
                        p.push(nxt);
                        sur[nxt.second][nxt.first] = '#';
                    }
                }
            }
        }
        can++;
        while(!q.empty()){
            pair<int,int> now = q.front();
            q.pop();
            for(int i = -2; i < 3; i++){
                for(int j = -2; j < 3; j++){
                    pair<int,int> nxt = make_pair(now.first+i,now.second+j);
                    if(0 <= nxt.first && nxt.first < w && 0 <= nxt.second && nxt.second < h){
                        if(sur[nxt.second][nxt.first] == '.'){
                            p.push(nxt);
                            sur[nxt.second][nxt.first] = '#';
                            if(nxt == g){
                                cout << can << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


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

using vb=vector<bool>;
using vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using si=set<int>;
using qi=queue<int>;
using pi=pair<int,int>;

void solve() {
    int n,m; cin>>n>>m;
    vi h(n+1);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    vvi g(n+1);
    for(int i=0;i<m;i++){
        int a,b; cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int db=0;
    for(int i=1;i<=n;i++){
        bool good=true;
        for(int j:g[i]){
            if(h[j]>=h[i]){
                good=false;
            }
        }
        if(good){
            db++;
        }
    }
    cout<<db<<endl;
}

bool boosts=false, tests=false;

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

    int tcases=1;
    if(tests) {
        cin>>tcases;
    }
    for(int tcase=1; tcase<=tcases; tcase++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 8804
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            while((s= Console.ReadLine())!=null)
            {
                var ab = s.Split().Select(int.Parse).ToArray();
                Console.WriteLine(ab[0] + ab[1]);
            }

        }
    }
}

Measured memory_bytes: 9500
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func pow(a, b int) int { return int(math.Pow(float64(a), float64(b))) }

func isEven(n int) bool { return n%2 == 0 }

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	ctEven := 0
	for i := 0; i < n; i++ {
		a := ri()
		if isEven(a) {
			ctEven++
		}
	}

	ans := pow(3, n) - pow(2, ctEven)
	fmt.Println(ans)
}


Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        a: i8,
        b: i8,
    }
    println!("{}", std::cmp::max(0, a - b - b));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
pair<ll,pair<ll,ll>> p[110];
int main() {
  ll n,x[114514],y[114514],h[114514];
  cin>>n;
  for(ll i=0;i<n;i++)cin>>p[i].second.second>>p[i].second.first>>p[i].first;
  sort(p,p+n);
  for(ll i=0;i<=100;i++){
    for(ll j=0;j<=100;j++){
      bool f=1;
      ll yan=abs(p[n-1].second.second-i)+abs(p[n-1].second.first-j)+p[n-1].first;
      if(yan<=0)continue;
      for(ll k=0;k<n;k++){
        if(max(yan-abs(p[k].second.second-i)-abs(p[k].second.first-j),0ll)!=p[k].first)f=0;
      }
      if(f){
        cout<<i<<' '<<j<<' '<<yan<<endl;
        return 0;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = k;
    for (int i = 0; i < n - 1; i++) ans *= k - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	static final int mod = (int) (1e9)+7;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		char[] s = sc.nextLine().toCharArray();
		if(s[0]== s[1] && s[0] == s[2] && s[0] == 'R')
			out.println(3);
		else if(s[0] == s[1] && s[0] == 'R')
			out.println(2);
		else if(s[2] == s[1] && s[1] == 'R')
			out.println(2);
		else if(s[0]== s[1] && s[0] == s[2] && s[0] == 'S')
			out.println(0);
		else
			out.println(1);
				
		out.close();
	}
	static void solve(char[] s) {
	}
	static void shuffle(int[] array) {
		Random rand = new Random();
		for (int i = 0; i < array.length; i++) {
			int randomIndexToSwap = rand.nextInt(array.length);
			int temp = array[randomIndexToSwap];
			array[randomIndexToSwap] = array[i];
			array[i] = temp;
		}
	}
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(next());
			}
			return a;
		}
	}

}

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

const int MAX_N = 1e7+2;
string s;
int dp[MAX_N][2];

void solve()
{
	reverse(s.begin(), s.end());
	s += '0';
	const int n = s.length();
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	for(int i=0;i<n;++i)for(int j=0;j<2;++j){
		const int req = s[i]-'0'+j;
		for(int use=0;use<10;++use){
			int borrow = 0, change = use-req;
			if(change < 0){
				change += 10;
				borrow=1;
			}
			dp[i+1][borrow]=min(dp[i+1][borrow],dp[i][j]+use+change);
		}
	}
	cout<<dp[n][0];
}

int main()
{
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 82288
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toDouble() }.toMutableList()
    v.sort()
    var x = (v.first() + v[1]) / 2.0
    if (n > 2) {
        for (i in 2 until n) {
            x = (x + v[i]) / 2.0
        }
    }
    println(x)
}

Measured memory_bytes: 37876
#include <stdio.h>
#include <math.h>
int isPrime(int);
int main(){
  int a[10000],i,count=0,N; 
  scanf("%d",&N);
  for(i=0;i<N;i++){
	scanf("%d",&a[i]);
	if( isPrime(a[i])==1)
	count++;
  }
  printf("%d\n",count);
  return 0;
}
int isPrime(int x){
  int i;
  if(x == 2) 
	return 1;
  else if(x < 2 || x%2 == 0)//前のifで2は除外
	return 0;
  i = 3;
  while(i <= sqrt(x)){
	if(x%i == 0){
	  return 0;
	}
	  i = i + 2;
  }
  return 1;
}



Measured memory_bytes: 2128
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		long target = cin.nextLong();
		cin.close();

		long tmp = (long)target/11;
		long result;
		if(target==tmp*11){
			result = tmp*2;
		}else if(target-tmp*11<=6){
			result = tmp*2+1;
		}else{
			result = tmp*2+2;
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long A, long long B){
    if(A<=9 && B <= 9){
        cout << A*B << endl;
    }else{
        cout << -1 << endl;
    }
}

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


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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            
            var nm = Reads();
            var n = nm[0];
            var m = nm[1];
            if(n<m)
            {
                var tmp = n;
                n = m;
                m = tmp;
            }
            long nn = 1;
            long mm = 1;
            for (int i = 1; i <= n; i++)
            {
                nn = nn * i % ((long)Math.Pow(10, 9) + 7);
            }

            for (int i = 1; i <= m; i++)
            {
                mm = mm * i % ((long)Math.Pow(10, 9) + 7);
            }
            if (n > m + 1) Console.WriteLine(0);
            else if (n == m + 1) Console.WriteLine(nn * mm % ((long)Math.Pow(10, 9) + 7));
            else if (n == m) Console.WriteLine(nn*nn  % ((long)Math.Pow(10, 9) + 7) * 2 % ((long)Math.Pow(10, 9) + 7));




            Console.Out.Flush();
        }
    }
}




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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,m) {
        int k;
        cin >> k;
        rep(j,k) {
            int s; 
            cin >> s;
            s--;
            a[s] |= 1 << i;
        }
    }
    int p = 0, ans = 0;
    rep(i,m){
        int x;
        cin >> x;
        p |= x<<i;
    }

    rep(i,1<<n) {
        int t = 0;
        rep(j,n) {
            if(i>>j&1) t^=a[j];
        }
        if(t==p) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll l, r; ll mod = 2019;
	cin>>l>>r;
	if(r/mod != (l-1)/mod){
		cout<<0<<endl;
	}else{
		ll ans = mod;
		for(ll i = l; i <= r; i++){
			for(ll j = i + 1; j <= r; j++){
				ans = min(ans, (i*j)%mod);
			}
		}
		cout<<ans<<endl;
	}

	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 w = sc.nextInt();// 縦線の本数
    int n = sc.nextInt();// 横棒の本数
    int a[] = new int[n];
    int b[] = new int[n];

    for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    }

    for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    }
  }
}



Measured memory_bytes: 26280
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
res = 0
for i in range(N):
  total = C
  A = list(map(int, input().split()))
  for j in range(M):
    total += A[j] * B[j]
  if total > 0:
    res += 1
print(res)

Measured memory_bytes: 3064
N,Y = map(int,input().split())

flag = 0
for i in range(N+1):
    for j in range(N+1-i):
        if i*10000+j*5000+(N-i-j)*1000 == Y:
            flag = 1
            break
    if flag:
        break

if flag:
    print(i,j,N-i-j)
else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
using namespace std;
const int maxn = 100+5;

int h,w;
char c[maxn][maxn];
bool fh[maxn];
bool fw[maxn];

void solve() {
	for (int i = 1; i <= h; i++) {
		bool flag = true;
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == '#') {
				flag = false;
				break;
			}
		}
		if (flag) fh[i] = true;
	}
	for (int j = 1; j <= w; j++) {
		bool flag = true;
		for (int i = 1; i <= h; i++) {
			if (c[i][j] == '#') {
				flag = false;
				break;
			}
		}
		if (flag) fw[j] = true;
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (fh[i] || fw[j]) continue;
			cout << c[i][j];
		}
		if (!fh[i]) cout << endl;
	}
}

int main() {
	scanf("%d%d",&h,&w);
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++){
			cin >> c[i][j];
		}
	}
	solve();
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi pair<ll,int> 
#define pii pair<int,ll>
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
bool ispalin(string s)
{
    ll n=s.length();
    for(ll i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        return(false);
    }
    return(true);
}
int main()
{
    string s1,s2,s3;
    cin>>s1;
    ll n=s1.length();
    for(ll i=0;i<(n-1)/2;i++)
    s2+=s1[i];
    for(ll i=(n+3)/2-1;i<n;i++)
    s3+=s1[i];
    if(ispalin(s1) && ispalin(s2) && ispalin(s3))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return(0);
}


Measured memory_bytes: 256
from operator import itemgetter
import sys
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
  
listB = sorted(listA)
la = sorted(listB, key=itemgetter(1))
 
t = 0
for i in range(N):
	t += la[i][0]
	#print(t)
	if t > la[i][1]:
		print('No')
		sys.exit()
 
print('Yes')



Measured memory_bytes: 56772
N = int(input())
Ws = list(map(int, input().split()))

i = 0
j = N - 1
asc = False
res = 0
for _ in range(N):
    if asc:
        res += Ws[i]
        i += 1
    else:
        res -= Ws[j]
        j -= 1
    asc = res < 0

print(abs(res))

Measured memory_bytes: 3064
#include<cstdio>
 
int n, m, x, y, ans = 0;
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++)
    {
        scanf("%d%d", &x, &y);
        ans ^= x ^ y;
    }
    if(!ans) printf("YES\n"); else printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
import math

n = int(input())
s = input()
S = [ord(i) - 97 for i in s]
q = int(input())
HEIGHT = math.ceil(math.log(n) / math.log(2))
SIZE = 1 << HEIGHT

def build_tree():
    tree = [0 for _ in range(SIZE<<1)]

    for i, letter in enumerate(s):
        tree[i+SIZE] = 1<<(ord(letter)-97)

    for i in range(HEIGHT - 1, -1, -1):
        for x in range(1<<i, 2<<i):
            tree[x] = tree[x<<1] | tree[(x<<1)+1]

    return tree




def update(x, number):
    tree[x] = number
    while x > 1:
        x >>= 1
        tree[x] = tree[x << 1] | tree[(x << 1) + 1]


def query(l, r):
    total = 0
    while l < r:
        if l&1:
            total |= tree[l]
            l += 1
        l >>= 1
        if r&1:
            r -= 1
            total |= tree[r]
        r >>= 1
    return bin(total).count('1')



tree = build_tree()

for i in range(q):
    a, b, c = input().split()
    b = int(b) - 1
    if int(a) == 1:
        update(b + SIZE, S[b])
        c = 1 << (ord(c) - 97)
        S[b] = c
        update(b + SIZE, c)
    else:
        print(query(b + SIZE, int(c)+SIZE))








Measured memory_bytes: 48152
n, m = map(int, input().split())
Py = []
for i in range(m):
    py = list(map(int, input().split()))
    Py.append(py+[i])
Py = sorted(sorted(Py, key = lambda x: x[1]))
tmp = -1
ans = []
for i in range(m):
    out = str(Py[i][0]).zfill(6)
    cnt = cnt + 1 if Py[i][0] == tmp else 1
    out += str(cnt).zfill(6)
    tmp = Py[i][0]
    ans.append([Py[i][2], out])
ans.sort()
for i in range(m):
    print(ans[i][1])

Measured memory_bytes: 41476
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long
#define pb push_back

int n, w, e;
char s[300100];
pair <int, int> a[300100];
vector <int> v;

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	w = 0, e = 0;
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> s[i];
	for(int i = 0; i < n; ++i) {
		a[i].first = w;
		if (s[i] == 'W') ++w;
	}
	for(int i = n-1; i >= 0; --i) {
		a[i].second = e;
		if (s[i] == 'E') ++e;
	}
	for(int i = 0; i < n; ++i) {
		v.pb(a[i].first + a[i].second);
	}
	cout << *min_element(v.begin(), v.end());
}

Measured memory_bytes: 12400
// Problem : B - Comparing Strings
// Contest : AtCoder Beginner Contest 152
// URL : https://atcoder.jp/contests/abc152/tasks/abc152_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string a,b;
cin>>a>>b;
string s1,s2;
for(int i=0;i<stoi(b);i++)
s1+=a;
for(int i=0;i<stoi(a);i++)
s2+=b;
if(s1<s2)
cout<<s1;
else
cout<<s2;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,m,l,i,j,k;
        n=scan.nextInt();
        m=scan.nextInt();
        l=scan.nextInt();
        long arraya[][]=new long[n][m],arrayb[][]=new long[m][l],arrayc[][]=new long[n][l];
        for(i=0;i<n;i++) {
            for(j=0;j<m;j++) {
                arraya[i][j]=scan.nextInt();
            }
        }
        for(i=0;i<m;i++) {
        	for(j=0;j<l;j++) {
                arrayb[i][j]=scan.nextInt();
            }
        }
        for(i=0;i<n;i++) {
        	for(j=0;j<l;j++) {
                arrayc[i][j]=0;
            }
        }
        for(i=0;i<n;i++) {
        	for(j=0;j<m;j++) {
        		for(k=0;k<l;k++) {
                	arrayc[i][k]+=arraya[i][j]*arrayb[j][k];
                }
            }
        }
        for(i=0;i<n;i++) {
        	for(j=0;j<l;j++) {
                if(j<l-1) {
                	System.out.print(arrayc[i][j] + " ");
                }
                else {
                	System.out.println(arrayc[i][j]);
                }
            }
        }
    }
}


Measured memory_bytes: 54224
N = int(input())
d1 = [0]*N
d2 = [0]*N
tmp = 0
for i in range(N):
    d1[i], d2[i] = map(int, (input().split(' ')))

for i in range(N-2):
    if d1[i] == d2[i]:
        if d1[i+1] == d2[i+1]:
            if d1[i+2] == d2[i+2]:
                tmp += 1

if tmp >= 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9188
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
H = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

ans = 0
for s, h in enumerate(H, start=1):
    if not edge[s]:
        ans += 1
    else:
        tmp = [H[i-1] < h for i in edge[s]]
        if all(tmp):
            ans += 1

print(ans)

Measured memory_bytes: 30152
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    ll A = readInt(), B = readInt(), C = readInt();
    if ((A & 1) && (B & 1) && (C & 1)) {
    	cout << min(min(A * B, B * C), A * C);
    } else {
    	cout << 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int N = 2e5 + 100;
 
ll n, k;
int val[N];
 
int Check(int len) {
	ll res = 0;
	for(int i = 1;i <= n; ++i)
		res += (val[i] - 1) / len;
	return res <= k;
}
 
int main() {
	cin >> n >> k; int L = 0, R = 1;
	for(int i = 1;i <= n; ++i) cin >> val[i], R = max(R, val[i]);
	while(R - L > 1) {
		int mid = (L + R) >> 1;
		if(Check(mid)) R = mid;
		else L = mid;
	}
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
vi a;
int n;
int main(){
    cin >> n;
    a = vi(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int d[n];
    d[0] = 0;
    d[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; i++){
        d[i] = min(d[i-1] + abs(a[i] - a[i-1]), d[i-2] + abs(a[i] - a[i-2]));
    }
    cout << d[n-1];
}    

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   string s,t;
   cin >> s >> t;
   sort(s.begin(),s.end());
   sort(t.begin(),t.end());
   reverse(t.begin(),t.end());
   if (s < t) cout << "Yes" << endl;
   else cout << "No" << endl;
   
   
   
   return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

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;}

const int64 mod = 1e9+7;

int32 H, W;
vector<vector<int32>> v;
vector<string> s;

int main(void){
	cin >> H >> W;
	s.resize(H);
	v = vector<vector<int32>>(H-1, vector<int32>(W-1, 0));
	REP(i, H){
		cin >> s[i];
	}
	REP(i, H-1){
		REP(j, W-1){
			int32 cnt = 0;
			REP(k, 2){
				REP(l, 2){
					cnt += s[i+k][j+l] == '.';
				}
			}
			if(cnt%2 == 0) v[i][j] = 1;
		}
	}
	FOR(i, 1, H-1){
		REP(j, W-1){
			if(v[i][j] == 1) v[i][j] += v[i-1][j];
		}
	}
	int64 res = max(H, W);
	REP(i, H-1){
		stack<PLL> st;
		st.push(PLL(-1, -1));
		v[i].push_back(0);
		REP(j, W){
			int32 l = j;
			while(st.top().fs >= v[i][j]){
				res = max(res, (st.top().fs+1)*(j-st.top().sc+1));
				l = st.top().sc;
				st.pop();
			}
			st.push(PLL(v[i][j], l));
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 55424
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;

const int root = 646;

const int root_1 = 208611436;

const int root_pw = 1<<20;

int mult(int a, int b) {
    return (1LL * a * b) % mod;
}

int pw(int a, int b) {
    if (b == 0) return 1;
    if (b & 1) return mult(a, pw(a, b - 1));
    int res = pw(a, b / 2);
    return mult(res, res);
}

int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}

int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}

int n, k;
int getAll(int n) {
    if (n % 2 == 1) {
        return mult(n, pw(k, (n + 1) / 2));
    }
    else {
        return mult(n / 2, pw(k, n / 2));
    }
}
int val(int x, int y) {
    if (x % 2 == 1) {
        return pw(k, (x + 1) / 2);
    }
    if (y % 2 == 0) {
        return pw(k, (x / 2) + 1);
    }
    else {
        return pw(k, x / 2);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> k;
    vector < int > divs;
    int pp = n;
    if (n % 2 == 0) pp /= 2;
    for (int i = 1; 1LL * i * i <= pp; i++) {
        if (pp % i == 0) {
            divs.emplace_back(i);
            if (i != (pp / i)) divs.emplace_back(pp / i);
        }
    }
    sort(divs.begin(), divs.end());
    vector < int > calc(divs.size());
    for (int i = 0; i < divs.size(); i++) {
        calc[i] = divs[i];
    }
    for (int i = divs.size() - 1; i >= 0; i--) {
        for (int j = i + 1; j < divs.size(); j++) {
            if (divs[j] % divs[i] == 0) {
                calc[i] = sub(calc[i], calc[j]);
            }
        }
    }
    /*int my_ans = 0;
    map < int, int > he;
    for (int mask = 0; mask < (1 << n); mask++) {
        if (mask == 0) continue;
        int d = n;
        int frst = -1;
        int p = 0;
        for (int bit = 0; bit < n; bit++) {
            if (mask & (1 << bit)) {
                p++;
                if (frst == -1) frst = bit;
                else {
                    d = __gcd(d, abs(frst - bit));
                }
            }
        }
        int cur_ans = val(d, frst);
        if (p % 2 == 1) {
            my_ans = sum(my_ans, cur_ans);
            he[d]++;
        }
        else {
            my_ans = sub(my_ans, cur_ans);
            he[d]--;
        }

    }
    for (auto it : he) {
        cout << it.first << " " << it.second << endl;
    }
    cout << "-----------------" << endl;
    cout << "I got " << my_ans << endl;
     */

    int ans = 0;
    if (n % 2 == 0) {
        for (int i = 0; i < divs.size(); i++) {
            ans = sum(ans, mult(getAll(2 * divs[i]), mult(calc[i], pw(divs[i], mod - 2))));
        }
    }
    else {
        for (int i = 0; i < divs.size(); i++) {
            ans = sum(ans, mult(getAll(divs[i]), mult(calc[i], pw(divs[i], mod - 2))));
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 1000000

int N, pol[MAX], odd[MAX];

int main() {
	for (int i = 0; i < MAX; i++) {
		pol[i] = MAX;
		odd[i] = MAX;
	}

	pol[0] = odd[0] = 0;

	for (int i = 0; i < MAX; i++)
		for (int j = 1; j < MAX; j++) {
			int k = j * (j + 1) * (j + 2) / 6;
			if (i + k >= MAX)
				break;
			pol[i + k] = min(pol[i + k], pol[i] + 1);
			if ((k & 1) == 1)
				odd[i + k] = min(odd[i + k], odd[i] + 1);
		}

	while (1) {
		scanf("%d", &N);
		if (N == 0)
			return 0;
		printf("%d %d\n", pol[N], odd[N]);
	}
}

Measured memory_bytes: 8444
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int INF = std::numeric_limits<int>::max()>>2;

int A, B;
int d[10][10];
int c[100][100];

int main()
{
  scanf( "%d%d", &A, &B );
  rep( i, A ) rep( j, B )
    scanf( "%d", &d[i][j] );

  rep( i, 101 ) rep( j, 101 )
  {
    rep( a, A ) rep( b, B )
      c[i][j] = std::max( c[i][j], d[a][b]-i*(a+1)-j*(b+1) );
  }

  bool fl = true;
  rep( a, A ) rep( b, B )
  {
    int D = INF;
    rep( i, 101 ) rep( j, 101 )
      D = std::min( D, i*(a+1)+j*(b+1)+c[i][j] );
    
    fl &= D == d[a][b];
  }

  if( !fl )
    puts( "Impossible" );
  else
  {
    puts( "Possible" );
  
    printf( "%d %d\n", 202, 101*101+200 );

    rep( i, 100 )
      printf( "%d %d X\n", i+1, i+2 );
    rep( i, 100 )
      printf( "%d %d Y\n", i+102, i+103 );  
    rep( i, 101 ) rep( j, 101 )
      printf( "%d %d %d\n", i+1, 202-j, c[i][j] );
    printf( "%d %d\n", 1, 202 );
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    ll a, b, c, x, y, res = 0;
    cin >> a >> b >> c >> x >> y;
    ll C = 2*c;
    if(a+b < C) res = a*x + b*y;
    else{
        res += C * min(x,y);
        if(x>=y) res += min(C,a) * (x-y);
        else res += min(C,b) * (y-x);
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  
  vector<int> A(5);
for (int i = 0; i < 5; i++) {
  cin >> A.at(i);
 // cout<<A.at(i)<<endl;
}
  
  vector<int> B(5);
for (int i = 0; i < 5; i++) {
  //cin >> vec.at(i);
  B.at(i)=A.at(i)%10;
 // cout<<B.at(i)<<endl;
}
  
  int C=10;
  int D;
  for (int i = 0; i < 5; i++) {
    if(B.at(i)<C&&B.at(i)!=0){
      C=B.at(i);
      D=i;
   //   cout<<D<<endl;
      
    }
  }
  
  
  //cout<<D<<endl;
  
  
  int E=0;
  for (int i = 0; i < 5; i++) {
    if(i==D){
      E=E+A.at(i);
     // cout<<E<<endl;
    }
    else if(B.at(i)==0){
      E=E+A.at(i);
      //cout<<E<<endl;
    }
    else{
      E=E+A.at(i)+10-B.at(i);
    }
  }
  
  cout<<E<<endl;
  
  
  
  
  
}
  
  
  
  

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    count = 0
    for i in range(3):
        if S[i] == T[i]:
            count += 1
    print(count)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060