akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
char c[]="LDUR";
ll n,sum,x[1005],y[1005];
bool ok=true;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		int a=read(),b=read();
		x[i]=a+b,y[i]=a-b;
	}
	for(int i=1;i<=n;i++)
		if((x[i]&1)!=(x[1]&1))
			ok=false;
	if(!ok)return puts("-1"),0;
	bool t=!(x[1]&1);
	printf("%d\n",39+t);
	if(t)printf("1 "),sum++;
	for(int i=0;i<39;i++){
		printf("%lld ",1ll<<i);
		sum+=1ll<<i;
	}
	puts("");
	for(int i=1;i<=n;i++){
		x[i]+=sum,y[i]+=sum;
		if(t)putchar(c[0]);
		for(int j=1;j<=39;j++)
			putchar(c[(((x[i]>>j)&1)<<1)|((y[i]>>j)&1)]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    long A, B, C, D, sum_A, sum_B;
    cin >> A >> B >> C >> D;
    sum_B = B - B / C - B / D;
    if(C < D){ 
        int tmp;
        tmp = C;
        C = D;
        D = tmp;
    }
    long g = C % D, c, d;//Euclid
    c = C;
    d = D;
    while(g != 0){
        c = d;
        d = g;
        g = c % d;
    }
    long l = (C * D) / d;
    sum_B += B / l;

    sum_A = (A - 1) - (A - 1) / C - (A - 1) / D;
    g = C % D;
    c = C;
    d = D;
    while(g != 0){
        c = d;
        d = g;
        g = c % d;
    }
    l = (C * D) / d;
    sum_A += (A - 1) / l;
    cout << sum_B - sum_A << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
int main()
{
    fastio;
    int n;
    cin>>n;
    int a[n];
    map<int,int>mp;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans = 0;
    for(auto it : mp)
    {
        ans+= (1LL*(it.se)*(it.se-1))/2;
    }
    for(int i=0;i<n;i++)
    {
        ll temp = 1LL*mp[a[i]]*(mp[a[i]]-1);
        temp/=2;
        ll ne = 1LL*(mp[a[i]]-1)*(mp[a[i]]-2);
        ne/=2;
        cout<<(ans-temp+ne)<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 8320
X,Y = list(map(int,input().split(" ")))



MOD = 10 ** 9 + 7

def inv_fact(a,mod = MOD): #あるmod下における a ! の逆元を求める関数
    ans = 1
    for i in range(1,a + 1):
        ans *= pow(i, MOD - 2 ,MOD)
        ans %= MOD
    return ans



if (2 * X - Y ) % 3 == 0 and (2 * Y - X ) % 3 == 0 and  (2 * X - Y )  >= 0 and (2 * Y - X ) >= 0:  # 到達可能であれば
    a = (2 * Y - X ) //3
    b = (2 * X - Y) // 3
    a_inv = inv_fact(a)
    b_inv = inv_fact(b)
    ans = 1
    for i in range(1, a + b + 1):
        ans *= i
        ans %= MOD
    mul = (a_inv * b_inv )% MOD
    ans *= (mul)
    ans %= MOD
    print(ans)

else: #
    print(0)


Measured memory_bytes: 40556
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,i;
    cin>>n;
    vector<pair<int,int> >v;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        v.push_back(make_pair(a,i));
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
        cout<<v[i].second<<' ';
    cout<<endl;
}


Measured memory_bytes: 1780
import java.util.*;
 
class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        while(true){
            String s=in.next();
            if(s.equals("-")) break;
            int k=in.nextInt();
            StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        }
    }
}

Measured memory_bytes: 26276
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

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

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4) << endl;
  return 0;
}

Measured memory_bytes: 256
N, M, Q = [int(n) for n in input().split()]

a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q

for i in range(Q):
    a[i],b[i],c[i],d[i] = [int(n) for n in input().split()]

def gen(i, n, m):
    if n == 0:
        yield []
        return
    for f in range(i, m + 1):
        for rest in gen(f, n - 1, m):
            yield [f] + rest

sm = 0
for A in gen(1,N,M):
    s = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    if s > sm:
        sm = s

print(sm)


Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
#define int long long
int T,a,b;
bool che(int ip){
	if(ip<=a+1)return (a+1)*ip<a*b;
	int sum=a+1+ip;
	return (sum/2)*(sum/2+(sum&1))<a*b; 
}
signed main(){
	scanf("%lld",&T);
	while(T--){
		scanf("%lld%lld",&a,&b);
		if(a>b)swap(a,b);
		int l=0,r=b-1;
		while(l<r){
			int mid=(l+r+1)>>1;
			if(che(mid))l=mid;
			else r=mid-1;
		}
		printf("%lld\n",l+a-1);
	}
	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 = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        final int MOD = 1000000007;
        long result = 1;
        for (int i = 1; i <= n; i++) {
            result *= i;
            result %= MOD;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>

std::string a[51], b[51];
int n, m;

bool match(int offset_x, int offset_y){
	int min_x = std::max(0, offset_x);
	int min_y = std::max(0, offset_y);
	int max_x = std::min(n, m + offset_x);
	int max_y = std::min(n, m + offset_y);

	for(int y = min_y; y < max_y; y++){
		for(int x = min_x; x < max_x; x++){
			if(a[y][x] != b[y - offset_y][x - offset_x])
				return false;
		}
	}
	return true;
}
int main(int argc, char *argv[]){
	std::cin >> n >> m;
	std::string s;
	std::getline(std::cin, s);
	for(int i = 0; i < n; i++){
		std::getline(std::cin, a[i]);
	}
	for(int i = 0; i < m; i++){
		std::getline(std::cin, b[i]);
	}
	bool flag = false;
	for(int y = 0; y <= n - m && !flag; y++){
		for(int x = 0; x <= n - m; x++){
			if(match(x, y)){
				flag = true;
				break;
			}
		}
	}
	std::cout << (flag ? "Yes" : "No") << std::endl;
	return 0;
}


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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  ll sum=0;
  if(n>k){
    for(int i=0;i<n-k;i++){
      sum= sum+a.at(i);
    }
  }
  cout << sum << endl;
      
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int e = a + b + c + d;
	int f = e % 60;
	int g = (e - f) / 60;
	cout << g << endl << f << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

lint gcd(lint m,lint n){
  if(n==0)return m;
  else return gcd(n,m%n);
}

lint lcm(lint m,lint n){
  return m/gcd(m,n)*n;
}

int main(){
  lint N,M;
  cin>>N>>M;
  lint a[N];
  lint S=1;
  REP(i,N)cin>>a[i];
  REP(i,N){
    S=lcm(S,a[i]/2);
    if(S>1e9){
      cout<<0<<endl;
      return 0;
    }
  }
  // cerr<<S<<endl;
  REP(i,N)if((S/(a[i]/2))%2==0){
    cout<<0<<endl;
    return 0;
  }
  cout<<(M/S+1)/2<<endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end()); // sortするアイデアはなかった、文字列の処理にも使えるの覚えとく
  if ((s[0] == s[1]) && (s[1] != s[2]) && (s[2] == s[3])) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int main(){
  int x;
  cin >> x;
  cout << ((x<=999)?"ABC":"ABD") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> vec(1e6,0);
    for (int i = 0;i<n;i++){
        int x;
        cin >> x;
        vec[x]++;
    }
    sort(vec.begin(), vec.end(), greater<int>());
    ll sum = 0;
    for (int i = k ; i < 1e6;i++){
        sum += vec[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 4096
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
A = LI()
A.sort()
if all([a > 0 for a in A]):
    now = min(A)
    print(sum(A) - now * 2)
    A.remove(now)
    last = A.pop()
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
    print(last, now)
elif all([a < 0 for a in A]):
    now = max(A)
    print(-sum(A) + now * 2)
    A.remove(now)
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
else:
    print(sum([abs(i) for i in A]))
    minus = []
    plus = []
    for a in A:
        if a > 0:
            plus += [a]
        elif a < 0:
            minus += [a]
        else:
            if not plus:
                plus += [a]
            else:
                minus += [a]
    ret = minus[0]
    for j in range(1, len(plus)):
        print(ret, plus[j])
        ret -= plus[j]
    print(plus[0], ret)
    ret = plus[0] - ret
    for k in range(1, len(minus)):
        print(ret, minus[k])
        ret -= minus[k]

Measured memory_bytes: 62488
n = int(input())
X = []
for _ in range(n):
    X += [str(input())]

from collections import Counter

cnt = Counter(X)

s = cnt.most_common()

ans = [s[0][0]]
_cnt0 = s[0][1]

for (word, _cnt) in s[1:]:
    if _cnt0 != _cnt:
        break
    ans += [word]
    _cnt0 = _cnt


ans = sorted(ans)
for x in ans:
    print(x)


Measured memory_bytes: 120656
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int a=1,b=2;
int count=0;
int c=sc.nextInt();
int d=sc.nextInt();
for(int i=1;i<=c;i++){
    count+=(i-1);
}
for(int i=1;i<=d;i++){
    count+=(i-1);
}
System.out.println(count);
}
}

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

int main()
{
  int64_t a;
  long double b;
  cin >> a >> b;
  
  int64_t b100 = (int64_t)(b * 100 + 0.001);
  
  cout << (a * b100) / 100 << endl;
}

Measured memory_bytes: 3712
function Main(input) {

	input = input.split(" ");
	var a = input[0];
	var b = input[1];
	var c = input[2];
	var d = input[3];

	if(Math.abs(b - a) <= d && Math.abs(c - b) <= d || Math.abs(a - c) <= d){
		console.log("Yes");
	} else {
		console.log("No");
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n,ans=1;
  ll a[100000];
  cin>>n;
  rep(i,n) cin>>a[i];
  sort(a,a+n);
  ll p=0;
  if(n%2==0) p++;
  rep(i,n){
    if(n%2==0){
      if(a[i]!=p && a[i+1]!=p){cout<<0<<endl;return 0;}
      i++;
      p+=2;
    }
    if(n%2==1){
      if(i==0){
	if(a[i]!=p) {cout<<0<<endl;return 0;}
      }else if(a[i]!=p || a[i+1]!=p){cout<<0<<endl;return 0;}
      if(i!=0) i++;
      p+=2;
    }
  }
  rep(i,n/2) (ans*=2)%=MOD;
  cout<<ans<<endl;
  return 0;
}








Measured memory_bytes: 1024
n=list(map(int,input().split()))
x=[]
b=[]
s=[]
for i in range(n[0]):
	x.append(list(map(int,input().split())))

for i in range(n[0]):
	a=0
	for j in range(n[1]):
		a+=x[i][j]
	x[i].append(a)
	print(' '.join(list(map(str,x[i]))))
for i in range(n[1]+1):
	l=0
	for j in range(n[0]):
		l+=x[j][i]
	s.append(l)
print(' '.join(list(map(str,s))))
	



Measured memory_bytes: 5700
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n,k,x,y,a,ans=0;
  cin>>n>>k>>x>>y;
  a=x;
  for(int i=0;i<n;i++){
    if(i==k){
      a=y;
    }
    ans+=a;
  }
  cout<<ans<<"\n";
  
  return 0;
}

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

const int MOD = 1000000007;

int main() {

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

vector<int> C(N);

vector<vector<int>> A(N,vector<int>(M));

rep(i,N){
  cin>>C[i];
  rep(j,M){
    cin>>A[i][j];
  }
}

ll ans=1000000000;

bitrep(N){
  ll temp=0;
  vector<int> B(M,0);
  rep(i,N){
    if(bit&(1<<i)){
      temp+=C[i];
      rep(j,M){
        B[j]+=A[i][j];
      }
    }
  }

  bool can=true;

  rep(i,M){
    if(B[i]<X) can=false;
  }

  if(!can) continue;

  ans=min(ans,temp);
 
}

if(ans==1000000000){
  cout << -1 <<endl;
}

else cout << ans << endl;

return 0;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


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

       int n,x;
       cin >> n >> x;
       int i,j;
       int a[n+1][x+1];
       for(i=1; i<=n; i++){
           for(j=1; j<=x; j++){
               cin >> a[i][j];
           }
       }
       int ans=0;
       for(i=1; i<=n; i++){
           for(int k=i+1; k<=n; k++)
           {
               double d=0;
           for(j=1; j<=x; j++){
               d=d+(a[k][j]-a[i][j])*(a[k][j]-a[i][j]);
           }
           int m=sqrt(d);
           d=sqrt(d);
           if(m==d)ans++;
           }
       }
       cout << ans << '\n';

        
        

}

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

import sys
sys.setrecursionlimit(300000)


def solve(H: int, N: int, A: "List[int]", B: "List[int]"):
    dp = [float('inf')] * (H + 1)
    dp[0] = 0
    for i in range(N):
        for j in range(H + 1):
            tmp = min(H, j + A[i])
            dp[tmp] = min(dp[tmp], dp[j] + B[i])
    print(dp[H])
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(H, N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 46224
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost = []
for i in range(n + 1):
  if i in a:
    cost.append(1)
  else:
    cost.append(0)
    
print(min(sum(cost[:(x + 1)]), sum(cost[x:])))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using str = string;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    str S, T;
    cin >> S >> T;
    int N = S.size();
    for(int i = 0; i < N; i++) {
        if(S == T) {
            cout << "Yes" << endl;
            return 0;
        }
        else {
            str U = S;
            for(int j = 0; j < N; j++){
                S[(j + 1) % N] = U[j];
            }
        }
    }
	cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min


#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

////////////////////////////////////////////////

fn main(){
    let inputs = read_ints();
    let (n,m) = (cmp::min(inputs[0],inputs[1]),cmp::max(inputs[0],inputs[1]));
    let ans = 
        if n == 1{
            if m == 1{
                1
            } else {  
                m-2
            }
        }else if n == 2{
            0
        }else{
            (m-2)*(n-2)
        };

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

Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<list>
#include<cstring>
#include<stack>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

const int maxn = 2100;
int arr[maxn], n, q;
int dp[maxn][maxn];
void init()
{
	memset(dp, 0, sizeof dp);
	dp[1][arr[1]] = 1;
	dp[1][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= 2000; j++)
		{
			dp[i-1][0] = 1;
			for (int k = 1; k <= i - 1; k++)
			{

				if (j >= arr[i])
					dp[i][j] |= dp[k][j] | dp[k][j - arr[i]];
				else
					dp[i][j] |= dp[k][j];
			}
		}
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &arr[i]);
	scanf("%d", &q);
	init();
	for (int i = 1; i <= q; i++)
	{
		int pp;
		scanf("%d", &pp);
		if (dp[n][pp] == 1)
			puts("yes");
		else
			puts("no");
	}
	return 0;
}


Measured memory_bytes: 20396
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int ans = num1 < 10 && num2 < 10 ? num1 * num2 : -1;
		System.out.println(ans);
	}
}




Measured memory_bytes: 23892
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        double d = 0;
        
        d = Math.hypot(Math.abs(x1 - x2), Math.abs(y1 - y2));
        System.out.println(d);
    }
}



Measured memory_bytes: 28088
<?php
class Stack{
  public $data=[];
  public $size=101;
  public $top=0;
  function init(){$this->top=0;}
  function isEmpty(){return $this->top==0;}
  function isFull(){return $this->top==$this->size-1;}
  function push($x){
    if($this->isFull()) return false;
    $this->data[++$this->top]=$x;
  }
  function pop(){
    if($this->isEmpty()) return false;
    return $this->data[$this->top--];
  }
}
$stack=new Stack();
$data=explode(' ',trim(fgets(STDIN)));
foreach($data as $d){
  if($d=='+')
    {$y=$stack->pop();$x=$stack->pop();$stack->push($x+$y);}
  elseif($d=='-')
    {$y=$stack->pop();$x=$stack->pop();$stack->push($x-$y);}
  elseif($d=='*')
    {$y=$stack->pop();$x=$stack->pop();$stack->push($x*$y);}
  else $stack->push($d);
}
echo $stack->pop();
?>

Measured memory_bytes: 15552
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int n,m;
		String num = new String();
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();m=sc.nextInt();
		int[] s = new int[m];
		int[] c = new int[m];

		for(int i = 0; i < m; i++) {
			s[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}

		for(int i = 0 ; i < 1000; i++) {//1to1000までの数
			String temp = String.valueOf(i);
			if(temp.length() !=n) {//桁数と要求されたのが違うとき
				continue;
			}
			for(int j = 0; j < m; j++) {
				if(temp.charAt(s[j]-1)-'0'!=c[j]) {
					break;
				}else {
					if(j == m -1) {
						System.out.println(i);
						return;
					}
				}
			}
		}

		if(m == 0&&n==1) {
			System.out.println(0);
			return;
		}
		if(m == 0&&n==2) {
			System.out.println(10);
			return;
		}
		if(m == 0&&n==3) {
			System.out.println(100);
			return;
		}
		System.out.println(-1);
		return;




	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> lis;
    rep(i,n){
        lis.push_back(0);
    }
    rep(i,n-1){
        int a;
        cin >> a;
        lis[a-1] += 1;
    }
    rep(i,n){
        cout << lis[i] << endl;
    }

    
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }

template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

template <typename T> inline T gcd(T a, T b) {
	//if (b == 0) return a;
	T r; while ((r = a % b) != 0) a = b, b = r;
	return b;
}

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

    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    cin >> A;

    rep1(i, N) {
        A[0][i] += A[0][i-1];
        A[1][N-i-1] += A[1][N-i];
    }

    int ans = -1;
    rep(i, N) {
        chmax(ans, A[0][i] + A[1][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, h, m, s;
	m < 60;
	s < 60;
	scanf("%d", &n);
	h = n/3600;
	m = n%3600/60;
	s = n%60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}



Measured memory_bytes: 2100
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	ll n, m, v, p;
	cin >> n >> m >> v >> p;


	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	
	

	
	int l = -1;
	int r = n;
	int mid = (l + r) / 2;
	while (mid != l) {
		ll sum = (p - 1 + mid) * m;
		

		
		for (int i = mid; i <=n- p; i++) {
			ll aff = a[mid] + m - a[i];
			if (aff < 0) {
				sum = -INF;
				break;
			}
			sum += aff;
		}

		if (sum >= m * v) {
			r = mid;
		}
		else {
			l = mid;
		}
		//cout << sum << endl;
		mid = (l + r) / 2;
		//cout << l << " " << mid << " "<< r << endl;
		if (r == 0 && l == -1) {
			break;
		}
	}

	cout << n - r << endl;

}

Measured memory_bytes: 4012
/*
 *
 *
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int main() {
  int n, m;
  while(cin >> n >> m, n) {
    vi carda(n);
    vi cardb(m);
    REP(i, n) cin >> carda[i];
    REP(i, m) cin >> cardb[i];
    int suma = accumulate(ALL(carda), 0);
    int sumb = accumulate(ALL(cardb), 0);

    int a = 100000, b = 100000;

    REP(i, n){
      REP(j, m){
        if (suma - carda[i] * 2 + cardb[j] * 2 == sumb) {
          if (a + b > carda[i] + cardb[j]) {
            a = carda[i];
            b = cardb[j];
          }
        }
      }
    }
    if (a == 100000)
      cout << -1 << endl;
    else{
      cout << a << ' ' << b << endl;
    }
  }
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  ll n;
  scanf("%lld", &n);
  vector<char> o;
  do {
    n--;
    o.push_back(n % 26);
    n /= 26;
  } while(n);
  for(int i = o.size() - 1; i >= 0; i--) printf("%c", o[i] + 'a');
  printf("\n");
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
const ll INF = 1e18;
 
VV<> dp(301, V<>(301, INF));
ll res = INF;
 
int main(){
    INT(n, k); 
    VEC(int, h, n); h.pb(0);
    dp[0][n] = 0;
    REP(i, n) REP(j, i + 1) REP(k, n + 1) if(i != k)
        chmin(dp[j + 1][i], dp[j][k] + max(h[i] - h[k], 0));
    REP(j, n + 1) chmin(res, dp[n - k][j]);
    print(res);
}

Measured memory_bytes: 4348
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}

int main(){
	int X;
	cin>>X;
	int t=0;
	while(t*(1+t)/2<X)t++;
	cout<<t<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> v0,v1,v2,v3,v4;
  for(int i=0; i<n; i++) {
    int x;
    cin >> x;
    if(x==0) v0.push_back(x);
    else if(x==1) v1.push_back(x);
    else if(x==2) v2.push_back(x);
    else if(x==3) v3.push_back(x);
    else v4.push_back(x);
  }
  sort(v4.begin(),v4.end());
  if(v3.size()==1 && v4.size()==0) {
    if(v0.size()%2==0) {
      for(int i=0; i<(int)v2.size()-1; i++) cout << v2[i] << endl;
      cout << v3[0] << endl;
      if(v2.size()) cout << v2[0] << endl;
      for(int i=0; i<v0.size(); i++) cout << v0[i] << endl;
      for(int i=0; i<v1.size(); i++) cout << v1[i] << endl; 
    } else {
      int M=0,k=0;
      if(v4.size()) M=v4[0],k=4;
      if(v3.size()) M=v3[0],k=3;
      if(v2.size()) M=v2[0],k=2;
      if(v1.size()) M=v1[0],k=1;
      for(int i=k==2; i<(int)v2.size()-1; i++) cout << v2[i] << endl;
      if(k!=3) cout << v3[0] << endl;
      if(v2.size()) {
        if(k==2) {if(v2.size()>=2) cout << v2[0] << endl;}
        else if(v2.size()) cout << v2[0] << endl;
      }
      for(int i=k==0; i<(int)v0.size()/2*2; i++) cout << v0[i] << endl;
      cout << M << endl;
      cout << 0 << endl;
      for(int i=k==1; i<v1.size(); i++) cout << v1[i] << endl;
    } 
  } else {
    if(v0.size()%2==0) {
      for(int i=0; i<v2.size(); i++) cout << v2[i] << endl;
      for(int i=0; i<v3.size(); i++) cout << v3[i] << endl;
      for(int i=0; i<v4.size(); i++) cout << v4[i] << endl; 
      for(int i=0; i<v0.size(); i++) cout << v0[i] << endl; 
      for(int i=0; i<v1.size(); i++) cout << v1[i] << endl; 
    } else {
      int M=0,k=0;
      if(v4.size()) M=v4[0],k=4;
      if(v3.size()) M=v3[0],k=3;
      if(v2.size()) M=v2[0],k=2;
      if(v1.size()) M=v1[0],k=1;
      for(int i=k==2; i<v2.size(); i++) cout << v2[i] << endl;
      for(int i=k==3; i<v3.size(); i++) cout << v3[i] << endl;
      for(int i=k==4; i<v4.size(); i++) cout << v4[i] << endl;
      for(int i=k==0; i<(int)v0.size()/2*2; i++) cout << v0[i] << endl;
      if(M!=0 || M==0 && v0.size()>2) cout << M << endl;
      cout << 0 << endl;
      for(int i=k==1; i<v1.size(); i++) cout << v1[i] << endl;
    }
  } 
  return 0;
}


Measured memory_bytes: 1228
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    REP(i,10){
        REP(j,10){
            REP(k,10){
                int now = 0;
                while(now<n){
                    if(s[now]-'0'==i) break; 
                    now++;
                }
                now++;
                while(now<n){
                    if(s[now]-'0'==j) break; 
                    now++;
                }
                now++;
                while(now<n){
                    if(s[now]-'0'==k) {
                        ans++;
                        break;
                    } 
                    now++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
def selectionSort(A, N):
	global cnt

	for i in range(N):
		minj = i
		for j in range(i, N):
			if A[j] < A[minj]:
				minj = j
		if i != minj:
			tmp = A[i]
			A[i] = A[minj]
			A[minj] = tmp
			cnt = cnt + 1 #

	return A

if __name__ == '__main__':
	n = int(input())
	R = list(map(int, input().split()))
	cnt = 0
	R = selectionSort(R, n)
	print(" ".join(map(str, R)))
	print(cnt)


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

int		main(void)
{
	string a, b;

	cin >> a >> b;
	reverse(a.begin(), a.end());
	if (a == b)
		cout << "YES";
	else
		cout << "NO";
	cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	//0250 start
	//0315 acording end
	//0342 samplematched 
	int INF = 1 << 24;
	
	class State {
		int step, time, pos, bal;
		int dis;
		public State(int step, int time,int pos, int dis, int bal) {
			this.step = step;
			this.time = time;
			this.pos = pos;
			this.dis = dis;
			this.bal = bal;
		}
		@Override
		public String toString() {
			return "State [step=" + step + ", time=" + time + ", pos=" + pos
					+ ", bal=" + bal + ", dis=" + dis + "]";
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if (n == 0 ) break;
			int [] pos = new int[n+1];
			int [] time = new int[n+1];
			int maxtime = 0;
			for(int i = 1; i < n+1; i++){
				pos[i] = sc.nextInt();
				time[i] = sc.nextInt();
				maxtime = Math.max(maxtime, time[i]);
			}
			if(pos[1] > time[1]){
				System.out.println("NG 1");
				continue;
			}
			
			LinkedList<State> open = new LinkedList<Main.State>();
			open.add(new State(1, time[1], pos[1], pos[1], 1));
			double [][] close = new double[n+1][n+1];
//			double [][][] close = new double[n+1][n+1][maxtime + 1];
			for(int i = 0 ; i < n + 1; i++){
				Arrays.fill(close[i], INF);
			}
			
			int ansstep = 0;
			int ansdis = INF;
			while(! open.isEmpty()){
				State now = open.poll();
				//System.out.println(now);
				ansstep = Math.max(ansstep, now.step);
				if(n == now.step){
					//かえる
					ansdis = Math.min(ansdis, now.dis + now.pos);
					continue;
				}
				//ハウスに戻る
				int nextstep = now.step + 1;
				int nextpos =  pos[nextstep];
				int nextdis = now.pos + now.dis + nextpos;
				int nexttime = now.time + now.pos * (now.bal + 1) + nextpos;
				
				if(nexttime <= time[nextstep]){
					if(close[nextstep][0] > nextdis){
						open.add(new State(nextstep, time[nextstep], nextpos, nextdis, 1));
						close[nextstep][0] = nextdis;
					}
				}
				
				//そのまま
				if(now.bal == 3) continue;
				nextdis = now.dis + Math.abs(now.pos - nextpos);
				nexttime = now.time + Math.abs(now.pos - nextpos) * (now.bal + 1);
				if(nexttime <= time[nextstep]){
					if(close[nextstep][now.bal + 1] > nextdis){
						open.add(new State(nextstep, time[nextstep], nextpos, nextdis, now.bal + 1));
						close[nextstep][now.bal + 1 ] = nextdis;
					}
				}
			}
			if(ansdis == INF){
				System.out.println("NG " + (ansstep + 1));
			}
			else{
				System.out.println("OK " + ansdis);
			}
		}
	}
	
	
	public static void main(String [] args){
		new Main().doit();
	}
}

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

#define int long long int
int const M = 1e9 + 7, N = 2e5 + 1;
int f1[N], f2[N], iv[N];

int mult(int a, int b) { 
  return (a%M * (b%M)) % M;
}

int nck(int n, int k){
    return f1[n] * f2[n-k] % M * f2[k] % M;
}

signed main() {
  iv[1] = f1[0] = f2[0] = 1;
  for (int i=2; i < N; i++) {
    iv[i] = (M - (M/i) * iv[M%i] % M) % M;
  }
  for (int i=1; i < N; i++){
      f1[i] = f1[i-1] * i % M;
      f2[i] = f2[i-1] * iv[i] % M;
  }
  int n, k;
  cin >> n >> k;
  k = min(k, n - 1);
  int ans = 0;
  for(int i = 0; i <= k; i++) {
    // nck(n, i) => choosing i points where there can be a 0
    // now we have to fit i people in n - i non-empty rooms => STARS AND BARS
    ans += (nck(n, i) % M * nck(n - i + i - 1, i) % M) % M;
    ans %= M;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <queue>

using namespace std;

#define ll long long
#define MOD 1000000007LL


class Main {
public:
	bool isPossible(vector<string> map) {
		int h = map.size();
		int w = map[0].size();
		vector<string> temp = map;

		int x = 0;
		int y = 0;
		temp[y][x] = '.';

		while (!(x == w-1 && y == h-1)) {
			bool isMovableX = (x != w - 1 && map[y][x+1] == '#');
			bool isMovableY = (y != h - 1 && map[y+1][x] == '#');

			if (isMovableX && !isMovableY) {
				x++;
				temp[y][x] = '.';
			}
			else if(!isMovableX && isMovableY) {
				y++;
				temp[y][x] = '.';
			}
			else {
				return false;
			}
		}

		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++) {
				if (temp[i][j] == '#') {
					return false;
				}
			}
		}

		return true;
	}
};


int main()
{
	Main m;
	int w, h;
	vector<string> map;

	cin >> h >> w;
	for (int i = 0;i < h;i++) {
		string s;
		cin >> s;
		map.push_back(s);
	}

	cout << (m.isPossible(map) ? "Possible" : "Impossible") << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

    long N = scanner.nextLong();
    long M = scanner.nextLong();

    long res;
    if (N < M / 2) {
      res = N;
      M -= N * 2;
      res += M / 4;
    } else {
      res = M / 2;
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 21844
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
#define mod  100007
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline ll add(ll a, ll b) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bpw(ll a, ll p){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

int main(){
	ll n, k; read(n), read(k);
	ll ans = 0;
	FER(i, 0, n) {
		ll x; read(x);
		if(x >= k) ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <vector <ll>> dp(n+1, vector<ll>(3, 0));
    for(int i=1; i<=n; i++){
        ll a; ll b; ll c;
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i-1][1] + b, dp[i-1][2] + c);
        dp[i][1] = max(dp[i-1][2] + c, dp[i-1][0] + a);
        dp[i][2] = max(dp[i-1][0] + a, dp[i-1][1] + b);
    }
    ll ret = 0;
    REP(i, 3){
        ret = max(ret, dp[n][i]);
    }
    cout << ret << endl;
    return 0;
}

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

int main(){
  ll x;
  cin>>x;
  ll ans=2*(x/11);
  x%=11;
  if (x > 0 && x <= 6){
    ans++;
  }
  else if (x > 6){
    ans += 2;
  }
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
#define p push_back
int main()
{
  ll  n,cnt=0;
  string s;
  cin>>n;

  vector<int>v1,v2;
  for(int i=1;i<=n;i++)
   {
    char ch ;
    cin>>ch;
    if(ch=='W')
      v1.push_back(i);
    else
      v2.push_back(i);
   }
  int i =0,j=v2.size()-1;
 
  while(i<v1.size() && j>=0 )
  {
   // cout<<v1[i]<< " " <<v2[j]<<endl;
    if(v1[i]<v2[j])
    cnt++;
    i++;
    j--;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 4532
#%reset
import copy
dataSetNumber = 0
card=[]
shuffledCard = []
while(True):
    card.append([i for i in input()])
    if dataSetNumber == 0:
        shuffledCard = copy.deepcopy(card)
    else:
        shuffledCard.append(copy.deepcopy(card[dataSetNumber][:]))
                            
    if card[dataSetNumber][0] == '-':
        break
    else:
        lengthCard = len(card[dataSetNumber][:])
        shuffleCommandNumber=str(input())
        shuffleTimes = 0
        for shuffleCount in range(int(shuffleCommandNumber)):
            shuffleCommand = input()
            shuffleTimes += int(shuffleCommand)
            
        cardMoveNumber = shuffleTimes%(lengthCard)
        for index in range(lengthCard):
            shuffledCard[dataSetNumber][index] = card[dataSetNumber][(cardMoveNumber+index)%lengthCard]
        dataSetNumber += 1
for i in range(dataSetNumber):
    print( ''.join(shuffledCard[i][:]))
    


Measured memory_bytes: 6336
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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(){
	string s,t;
	cin >> s >> t;
	
	int ans = 100000;

	for(int i=0; i<s.size()-t.size()+1; i++){
		
		int count = 0;
		for(int j=0; j<t.size();j++){
			if(s[i+j]!=t[j]) count++;
		}
		chmin(ans,count);
	}
	
	cout << ans <<  endl;
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

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

	rep(i, 9) {
		if ((N % (i + 1) == 0) && (N / (i + 1) < 10)) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 256