akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int N;
    cin >> N;
    rep(i, 1, 10) rep(j, 1, 10) {
        if (i*j == N) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	string s; cin >> s;
    sort(s.begin(), s.end());
    cout << (s == "abc" ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
parse_input(type=String, x=readline()) = begin
  type == String && return x
  parse(type, x)
end
parse_inputs(type=String) = parse_input.(type, split(readline()))

function main()
  s = parse_input()
  isequal(s, reverse(s)) && isequal(s[1:div(end-1, 2)], reverse(s[1:div(end-1, 2)])) && return "Yes"
  "No"
end

println(main())


Measured memory_bytes: 156040
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,m;
	cin >> n >> m;
	cout << (n * (n-1) + m * (m-1)) / 2 << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

ll X;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> X;

	if (X % 11 == 0) cout << (X / 11) * 2 << "\n";
	else if (X % 11 <= 6) cout << (X / 11) * 2 + 1 << "\n";
	else cout << (X / 11) * 2 + 2 << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int a,b,x1,y1,ans,x2,y2;
	scanf("%d%d",&a,&b);
	if(a%2==0){
		x1=a*25/2;
	}
	else{
		x1=a*25/2+1; 
	}
	x2=25*(a+1);
	y1=10*b;y2=10*(b+1);
	ans=max(x1,y1);
	if(ans*2<x2&&ans<y2){
		printf("%d\n",ans);
	}
	else{
		printf("-1\n");
	}
	return 0;
} 

Measured memory_bytes: 888
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
L = [list(input().strip()) for _ in range(H)]
NL = [["."] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if j < W - 1 and L[i][j] == "#" and L[i][j + 1] == "#":
            NL[i][j] = "#"
            NL[i][j + 1] = "#"
        if i > 0:
            if L[i][j] == "#" and L[i - 1][j] == "#":
                NL[i][j] = "#"
                NL[i - 1][j] = "#"
            
print("Yes" if L == NL else "No")

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

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define TRAV(a, x) for(const auto& a : x)
#define ALL(x) x.begin(), x.end()
#define NEXT_PERM(x) while(next_permutation(ALL(x))) // 순열 알고리즘(오름)
#define PREV_PERM(x) while(prev_permutation(ALL(x))) // 순열 알고리즘(내림)
#define PRINT(x) cout << x
#define PRINT_LN(x) cout << x << endl;
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<char> vc;

void solve() {
  ll s, w;
  cin >> s >> w;
  if (max(s, w) == w){
    PRINT("unsafe");
  } 
  else PRINT("safe");
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<vector<int> > A(N, vector<int>(3, 0));
	int res = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}
	vector<vector<int> > dp(N, vector<int>(3, 0));
	dp[0] = A[0];
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j != k) {
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + A[i][j]);
				}
			}
		}
	}
	res = max(dp.back()[0], max(dp.back()[1], dp.back()[2]));
	cout << res << endl;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int main() {
    char b;
    cin >> b;

    if (b == 'A') {
        cout << "T" << endl;
    } else if (b == 'T') {
        cout << "A" << endl;
    } else if (b == 'C') {
        cout << "G" << endl;
    } else if (b == 'G') {
        cout << "C" << endl;
    }
}

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll  long long  int
#define ld   long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e5+5;


int main()
{
    FAST
    ll i,j,k,tc;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
        ll n;
        cin>>n;
        bool chk=false;
        ll ans=0,cnt=0;

        for(i=0; i<n; i++)
        {
            ll u,v;
            cin>>u>>v;
            if(u==v)
            {
                cnt++;
                ans=max(ans,cnt);
            }
            else
                cnt=0;
        }
        if(ans>=3)
            cout<<"Yes"<<"\n";
        else
            cout<<"No"<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

int main(){
	cin>>n;
	int res,S=0,T=0;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i],S+=a[i];
	res=S;
	for(int i=0;i<n;i++){
		T+=a[i];
		S-=a[i];
		res=min(res,abs(S-T));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
def main():
    A = set()
    n_prime = 0
    while True:
        try:
            x = int(input())
            A.add(x)
        except:
            break

    for x in A:
        n_prime += is_prime(x)

    print(n_prime)


def is_prime(x):  
    if x == 2:
        return 1
    elif x % 2 == 0:
        return 0
    else:
        return pow(2, x - 1, x) == 1   

main()


Measured memory_bytes: 6312
//Author : Ayush Jain

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;


int main()
{
	ios_base::sync_with_stdio(false);
	int i,n;
	ll a[N],b[N],o=0,t=0;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	for(i=0;i<n;i++){
		if(a[i]>b[i]) o+=a[i]-b[i];
		else{
			if((b[i]-a[i])%2==0) t+=(b[i]-a[i])/2;
			else{
				t+=(b[i]-a[i]+1)/2;
				o++;
			}
		}
	}	
	if(t>=o) cout<<"Yes\n";
	else cout<<"No\n";
		
	
		
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
using namespace std;

int main() {
	int N,x;
	cin >> N >>x;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}

	long long all = 0;
	for (int i = 0; i < N; i++) {
		all += v[i]; // 子供が欲しがる飴の合計個数
	}
	if (all == x) cout << N << endl;

	if (all < x) { // 全員に配れる場合
		cout << N - 1 << endl; // 一人だけ余分にもらってしまう
	}

	if (all > x) {
		sort(v.begin(), v.end());
		int count = 0; // 配ったお菓子の人数
		for (int j=0; v[j] <= x && j < N; j++) {
			x -= v[j]; // 欲しがる個数が少ない順にあげてく
			++count;
		}
		cout << count << endl;
	}

	return 0;
}

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

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

	long long ret = n - 1;
	long long max = sqrt(n);
	long long temp = 0;
	for (long long i = 2; i <= max; ++i) {
		if (n % i == 0) {
			temp = n / i + i - 2;
			if (temp < ret) {
				ret = temp;
			}
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    ull N, M, X, n, m, i, out = 0;
    cin >> N >> M >> X;
    ull C[N], A[N][M], ST[M] = {0, };
    for(n = 0; n < N; n++)
    {
        cin >> C[n];
        out += C[n];
        for(m = 0; m < M; m++)
        {
            cin >> A[n][m];
            ST[m] += A[n][m];
        }
    }
    for(m = 0; m < M; m++)
    {   
        if(ST[m] < X)
        {
            cout << -1 << endl;
            return;
        }
    }
    
    for(i = 1; i < (1<<N); i++)
    {
        ull temp[M]= {0,};
        ull cost = 0;
        bool update = true;
        for(n = 0; n < N; n++)
        {
            if(i&(1<<n))
            {
                for(m = 0; m < M; m++)
                {   
                    temp[m] += A[n][m];
                }
                cost += C[n];
            }
        }
        
        for(m = 0; m < M; m++)
        {   
            if(temp[m] < X)
            {
                update = false;
                break;
            }
        }
        if(update)
        {
            out = MIN(out, cost);
        }
    }
    cout << out << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

var data [3][30]int
var d [][]int
var c [][]int

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	if n >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
const long long oo = 1LL << 60;

int n;
long long a[555][555], sum[555][555];

long long sumRect(int x, int y, int xx, int yy)
{
  return a[xx][yy] + a[x][y] - a[x][yy] - a[xx][y];
}

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

  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
    {
      int x = 0;
      if (i != j)
        cin >> x;
      a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + x;
    }

  for (int i = 0; i < n; i++)
    for (int j = i + 1; j <= n; j++)
      sum[i][j] = sum[i][j - 1] + sumRect(i, j - 1, j - 1, j);

  long long ans = 0;
  for (int i = 1; i <= n; i++)
    ans += sumRect(i - 1, i, i, n);

  long long f[555][555];
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++)
      f[i][j] = oo;

  for (int i = 1; i < n; i++)
    f[0][i] = sum[0][i];

  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
    {
      ans = min(ans, f[i][j] + sum[j][n]);
      for (int k = j + 1; k < n; k++)
        f[j][k] = min(f[j][k], f[i][j] + sum[j][k] + sumRect(k, i, n, j));
    }

  cout << ans << endl;
}


Measured memory_bytes: 7168
#include <iostream>
#include <map>
#include <string>
#include <queue>
using namespace std;
int main()
{
	int n; cin >> n;
	map <string,long> a;
	string* name=new string[n]; int cnt=0;
	string* rank=new string[n];
	while(n--)
	{
		string str; cin >> str;
		int i=0;
		for( ;i<cnt;i++) if(name[i]==str) break;
		if(i>=cnt) name[cnt++]=str;
		int m; cin >> m;
		a[str]+=m;
	}
	//並べ替え
	rank[0]=name[0];
	for(int i=1;i<cnt;i++)
	{
		int j=0;
		for( ;j<i;j++)
		{
			if(name[i].size()<rank[j].size()) break;
			if(name[i]<rank[j] && name[i].size()==rank[j].size()) break;
		}
		if(j==i) rank[j]=name[i];
		else 
		{
			for(int k=0;i-k>j;k++) rank[i-k]=rank[i-k-1];
			rank[j]=name[i];
		}
	}
	for(int i=0;i<cnt;i++)
	cout << rank[i] << ' ' << a[rank[i]] << endl;
	delete[] name;
	delete[] rank;
}

Measured memory_bytes: 1380
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll L;
string S, T;
ll N, M;
string get_result(const string &a, const string &b)
{
    string result = "";
    int cnt1 = 0;
    int cnt2 = 0;
    for (int i = 0; i <= L; i++)
    {
        ll res = L - i * a.size();
        if (res < 0)
        {
            break;
        }
        if (res % b.size() == 0)
        {
            cnt1 = i;
            cnt2 = res / b.size();
        }
    }
    // cerr << a << " " << b << " " << cnt1 << " " << cnt2 << endl;
    for (int i = 0; i < cnt1; i++)
    {
        result += a;
    }
    for (int i = 0; i < cnt2; i++)
    {
        result += b;
    }

    return result;
}
int main()
{
    cin >> L;
    cin >> S;
    cin >> T;
    if (S >= T)
    {
        swap(S, T);
    }
    N = S.size();
    M = T.size();
    bool ok = true;
    for (int i = 0; i < min(N, M); i++)
    {
        if (S[i] != T[i])
        {
            ok = false;
            break;
        }
    }
    if (ok)
    {
        if (S[0] > T[M - 1])
        {
            swap(S, T);
        }
    }
    string result1 = get_result(S, T);
    string result2 = get_result(T, S);
    cout << min(result1, result2) << endl;
    return 0;
}


Measured memory_bytes: 1408
from itertools import combinations
import numpy as np
#S= str(input())
#T= str(input())
N,M,X = map(int,input().split())
#N = int(input())
#A = list(map(int,input().split()))
a=[]
ans=[]
for j in range(N):

    A = list(map(int,input().split()))
    a.append(A)

for i in range(1,N+1):
    for l in list(combinations(a,i)):
        s=np.zeros(M+1)
        for k in l:
            k=np.array(k)
            s=s+k
        #print(s)

        if min(s[1:])>=X:
            ans.append(s[0])
if len(ans)==0:
    print(-1)
else:
    print(int(min(ans)))


Measured memory_bytes: 30508
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i]==s[i+1])
        {
            printf("%d %d\n",i+1,i+2); return 0;
        }
        if(i<s.size()-2&&s[i]==s[i+2])
        {
            printf("%d %d\n",i+1,i+3); return 0;
        }
    }
    printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int n;

int main()
{
	scanf("%d",&n);
	int sm = 0;
	int i=1;
	while(sm < n){
		sm += i;
		i++;
	}
	printf("%d\n",i-1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;

signed main(){
    int N;cin>>N;
    map<int,int>memo;
    for(int i=2;i<=N;i++){
        int C=i;
        for(int j=2;j<=sqrt(C);j++){
            while(C%j==0){
                memo[j]++;
                C/=j;
            }
        }
        if(C!=1)memo[C]++;
    }
    int ans=1;
    for(auto v:memo){
        ans*=(v.second+1);
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int na,nb,m; cin >> na >> nb >> m;
	vi a(na); rep(i,na) cin >> a[i];
	vi b(nb); rep(i,nb) cin >> b[i];
	vi x(m),y(m),c(m);
	rep(i,m){
		cin >> x[i] >> y[i] >> c[i];
		x[i]--; y[i]--;
	}
	int mina=INF;
	int minb=INF;
	rep(i,na) mina = min(mina,a[i]);
	rep(i,nb) minb = min(mina,b[i]);
	int ans = mina+minb;//使わない場合
	vi d(m);
	rep(i,m) d[i] = a[x[i]]+b[y[i]]-c[i];
	rep(i,m) ans = min(ans,d[i]);
	cout << ans << endl;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		gcd(int a, int b, int c)
{
	int i = min({a, b, c});
	while (i != 1)
	{
		if (a%i == 0 && b%i == 0 && c%i == 0)
			break ;
		i--;
	}
	return (i);
}

int		main(void)
{
	int K;
	cin >> K;
	int sum = 0;
	for (int a = 1; a <= K; a++)
	{
		for (int b = 1; b <= K; b++)
		{
			for (int c = 1; c <= K; c++)
			{
				sum += gcd(a, b, c);
			}
		}
	}
	cout << sum << endl;
}



Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
	int x, y;
	while( cin >> x >> y ) {
		if( x==0 && y==0 ) { break; }
		if( x <= y ) {
			cout << x << " " << y << endl;
		} else {
			cout << y << " " << x << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3056
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val h = sc.nextInt()
    val w = sc.nextInt()
    val k = sc.nextInt()
    val s = Array(h) { Array(w) { 0 } }
    for (i in 0 until h) {
        val t = sc.nextLine()
        for (j in 0 until w) {
            s[i][j] = t[j].toString().toInt()
        }
    }
    val num = Array(h) { Array(w + 1) { 0 } }
    for (i in 0 until h) {
        for (j in 0 until w) {
            num[i][j + 1] = num[i][j] + s[i][j]
        }
    }
    var min = Int.MAX_VALUE
    for (i in 0 until 1.shl(h - 1)) {
        val choice = mutableListOf<Int>()
        for (j in 0 until h - 1) {
            if ((1.shl(j) and i) != 0) {
                choice.add(j)
            }
        }
        val n = choice.count() + 1
        var count = choice.count()
        val space = Array(h) { 0 }
        for (j in 0 until h) {
            space[j] = choice.filter { it < j }.count()
        }
        val total = Array(n) { 0 }
        var ok = true
        for (j in 0 until w) {
            val cur = Array(n) { 0 }
            for (m in 0 until h) {
                cur[space[m]] += s[m][j]
            }
            if (cur.any { it > k }) {
                ok = false
                break
            }
            for (m in 0 until n) {
                total[m] += cur[m]
            }
            if (total.any { it > k }) {
                count++
                for (m in 0 until n) {
                    total[m] = cur[m]
                }
            }
        }
        if (ok) {
            min = Math.min(min, count)
        }
    }
    println(min)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 52536
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    ll n, m;
    cin >> n >> m;
    map<ll, bool> a, b;
    REP(i, n){
        ll t;
        cin >> t;
        if(a[t]){
            cout << 0 << endl;
            return 0;
        }
        a[t] = true;
    }
    REP(i, m){
        ll t;
        cin >> t;
        if(b[t]){
            cout << 0 << endl;
            return 0;
        }
        b[t] = true;
    }
    
    ll ans = 1, a_cnt = 0, b_cnt = 0;
    for(ll i = n * m; i >= 1; i--){
        if(a[i] && b[i]){
            a_cnt++;
            b_cnt++;
            continue;
        }
        else if(a[i]){
            ans *= b_cnt;
            ans %= MOD;
            a_cnt++;
        }
        else if(b[i]){
            ans *= a_cnt;
            ans %= MOD;
            b_cnt++;
        }
        else{
            ans *= (a_cnt * b_cnt - (n * m - i)) % MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 125184
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> v[26];

int main(){
    long ans = 0;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++){
        v[s[i]-'a'].push_back(i);
    }
    int idx;
    if(v[t[0]-'a'].size() == 0){
        cout << -1 << endl;
        return 0;
    }
    idx = v[t[0]-'a'][0];
    ans = 1;
    for(int i = 1; i < t.size(); i++){
        int m = t[i]-'a';
        if(v[m].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        auto ptr = upper_bound(v[m].begin(), v[m].end(), idx);
        if(ptr == v[m].end()){
            ans++;
            idx = v[m][0];
        }else{
            idx = *ptr;
        }
    }
    long cnt = s.size();
    cout << (ans-1)*(cnt)+(long)idx+1 << endl;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> res;
    bool isok = true;
    for(int i=1; i<n+1; i++) cin >> a[i];
    for(int i=n; i>=1; i--) {
        int su = 0;
        for(int j=i; j<n+1; j+=i) su ^= a[j];
        a[i] = su;
        if (su == 1) res.push_back(i);
    }
    if (isok) {
        n = res.size();
        printf("%d\n", n);
        for(int i=0; i<n; i++) printf("%d ", res[i]);
        printf("\n");
    } else {
        printf("-1\n");
    }
    return 0;
}



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

int main(){
	int p[10001], n;
	while( cin >> n, n ){
		memset( p, 0, sizeof(p) );
		for( int i=0; i<n; i++ ){
			int k, d1, d2;
			cin >> k >> d1 >> d2;
			p[k] = d1 + d2;
		}
		int mi=0;
		for( int i=1; i<=10000; i++ ){
			if( p[i] > p[mi] )
				mi = i;
		}
		cout << mi << " " << p[mi] << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
N,M = [int(i) for i in input().split()]
shop_info = []
for i in range(N) :
    shop_info.append([int(i) for i in input().split()])

# 安い順に取り扱えばいいはず
shop_info.sort(key=lambda x:x[0])

cost = 0
current_kan = 0
for info in shop_info:
    price = info[0]
    stock = info[1]
    if (current_kan + stock > M) :
        # 買占めはやりすぎなケース
        want_kan = M - current_kan 
        cost += price * want_kan
        break
    else :
        # 全部
        current_kan += stock
        cost += price * stock

print(cost)

Measured memory_bytes: 22756
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
    	while(sc.hasNext()){
    		int x = sc.nextInt();
    		int y = sc.nextInt();
    		if(x == 0 && y == 0) {break;}
    		
    		else if(x > y){
    			System.out.println(y+" "+x);
    		}
    		
    		else{
    			System.out.println(x+" "+y);
    		}
    		
    	}
    }

}

Measured memory_bytes: 26368
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 input = Reads();
            var n = input[0];
            var c = input[1];
            var k = input[2];
            long p = 0;
            var t = new long[n];
            for (int i = 0; i < n; i++)
            {
                t[i] = Read();
            }
            Array.Sort(t);
           
            p = t[0] + k;
            long ans = 1;
            long count = 1;
            for (int i = 1; i < n; i++)
            {
                if (p < t[i] || c <=count)
                {
                    ans++;
                    p = t[i] + k;
                    count = 1;
                }
                else count++;
            }
            Console.WriteLine(ans);




            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 18140
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int [] br = new int [N];
        for(int i=0; i<M; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a==1||b==1){
                br[Math.max(a,b)-1]++;
            }else if(a==N||b==N){
                br[Math.min(a,b)-1]++;
            }
        }
        for(int i=1; i<N-1; i++){
            if(br[i]==2){
                System.out.println("POSSIBLE");
                System.exit(0);
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}

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

using namespace std;

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

    int a,b,c;
    cin>>a>>b>>c;
    
    if(a+b+c>=22)
        cout<<"bust";
    else
        cout<<"win";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

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

const ll MOD = 1e9+7;

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

	int n; cin >> n;
	string s; cin >> s;

	int cnt = 0;
	for(int i = 0; i < n-2; i++){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
			cnt++;
	}

	cout << cnt << '\n';

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
typedef pair<int, int> P;
bool exist[600][600];
int x[600][600];
int y[600][600];
int main() {
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	for (int i = 0; i < H; i++) cin >> s[i];
	vector<P> coin;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') {
				int nx = j - i + 300, ny = j + i;
				x[ny][nx]++;
				y[ny][nx]++;
				exist[ny][nx] = 1;
				coin.emplace_back(nx, ny);
			}
		}
	}
	for (int i = 0; i < 600; i++) {
		for (int j = 1; j < 600; j++) {
			x[i][j] += x[i][j - 1];
		}
	}
	for (int i = 0; i < 600; i++) {
		for (int j = 1; j < 600; j++) {
			y[j][i] += y[j - 1][i];
		}
	}
	ll ans = 0;
	ll t = 0;
	for (int d = 1; d < 600; d++) {
		for (P p : coin) {
			if (p.first + d < 600 && exist[p.second][p.first + d]) {
				if (p.second + d < 600) {
					ans += x[p.second + d][p.first + d];
					if (p.first > 0) ans -= x[p.second + d][p.first - 1];
				}
				if (p.second - d >= 0) {
					ans += x[p.second - d][p.first + d];
					if (p.first > 0) ans -= x[p.second - d][p.first - 1];
				}
			}
			if (p.second + d < 600 && exist[p.second + d][p.first]) {
				if (p.first + d < 600) {
					ans += y[p.second + d][p.first + d];
					if (p.second > 0) ans -= y[p.second - 1][p.first + d];
				}
				if (p.first - d >= 0) {
					ans += y[p.second + d][p.first - d];
					if (p.second > 0) ans -= y[p.second - 1][p.first - d];
				}
			}
			for (int i = -1; i <= 1; i += 2) {
				int x = p.first + d * i;
				if (x < 0 || x >= 600 || !exist[p.second][x]) continue;
				for (int j = -1; j <= 1; j += 2) {
					int y = p.second + d * j;
					if (y < 0 || y >= 600 || !exist[y][p.first]) continue;
					t++;
				}
			}
		}
	}
	ans -= t;
	cout << ans << endl;
 }

Measured memory_bytes: 4476
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String a1 = scan.next();
    int t = a1.length();
    for (int i=0;i<t;i++){
      System.out.print("x");
    }
    System.out.println("");
  }
}


Measured memory_bytes: 35548
#include <iostream>
#include <vector>

using namespace std;

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

  vector<size_t> D;
  for (size_t i = 0; i < N; i++) {
    size_t d;
    cin >> d;
    D.emplace_back(d);
  }

  size_t sum = 0;
  for (size_t i = 0; i < N - 1; i++) {
    for (size_t j = i + 1; j < N; j++) {
      sum += D[i] * D[j];
    }
  }
  cout << sum << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  rep(i,m) {
    int p;
    string s;
    cin >> p >> s;
    --p;
    if (ac[p]) continue;
    if (s == "AC") {
      ac[p] = 1;
    } else {
      pena[p]++;
    }
  }
  int AC = 0, PENA = 0;
  rep(i,n) {
    AC += ac[i];
    if (ac[i]) PENA += pena[i];
  }
  printf("%d %d\n", AC, PENA);
  return 0;
}

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

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

    char[] s = scanner.next().toCharArray();
    int[] last = new int[26];
    Arrays.fill(last, -1);
    for (int i = 0; i < s.length; i++) {
      int ch = s[i] - 'a';
      if (last[ch] >= 0 && i - last[ch] < 3) {
        System.out.printf("%d %d\n", last[ch] + 1, i + 1);
        return;
      }
      last[ch] = i;
    }
    System.out.println("-1 -1");
  }
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<double>x(N), y(N); rep(i, 0, N) { cin >> x[i] >> y[i]; }

	vector<int>p(N); iota(all(p), 0ll);
	int cnt = 0;
	double ans = 0;
	do {
		double sum = 0;
		rep(i, 1, N) {
			double dx = x[p[i]] - x[p[i - 1]];
			double dy = y[p[i]] - y[p[i - 1]];
			sum += sqrt(dx*dx + dy * dy);
		}
		ans += sum ;
		cnt++;

	} while (next_permutation(all(p)));


	cout << ans / cnt  << endl;


	return 0;
}


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

int main()
{
    long long Q, H, S, D, N;
    cin>>Q>>H>>S>>D>>N;
    H = min(H, 2*Q);
    S = min(S, 2*H);
    D = min(D, 2*S);
    cout<<(N/2)*D + (N%2)*S;
}

Measured memory_bytes: 256
#include<cstdio>
const int MAXN = 500000;
struct node{
	int key;
	node *ch[2];
};
node tree[MAXN + 5];
node *Root,*NIL,*ncnt;
void Init() {
	NIL = &tree[0];
	Root = NIL -> ch[0] = NIL -> ch[1] = NIL;
	ncnt  = &tree[1];
}
inline node * NewNode(int val) {
	node *p = (++ncnt);
	p->key = val;
	p->ch[0] = p->ch[1] = NIL;
	return p;
};
void Insert(node *&rt,int val) {
	if( rt == NIL ) {
		rt = NewNode(val);
		return ;
	}
	int d = (val > rt->key);
	Insert(rt->ch[d],val);
}
node * Find(node *rt,int val){
	if( rt == NIL ) return NIL;
	if( rt->key == val ) return rt;
	return Find(rt->ch[val>rt->key],val);
}
void InOrder(node *rt){
	if( rt == NIL ) return ;
	InOrder(rt->ch[0]);
	printf(" %d",rt->key);
	InOrder(rt->ch[1]);
}
void PreOrder(node *rt){
	if( rt == NIL ) return ;
	printf(" %d",rt->key);
	PreOrder(rt->ch[0]);
	PreOrder(rt->ch[1]);
}
char s1[10];
int main()
{
	int n,x;
	Init();
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s1);
		if( s1[0] == 'p' )
		{
			InOrder(Root);
			puts("");
			PreOrder(Root);
			puts("");
		}
		else if( s1[0] == 'i' )
		{
			scanf("%d",&x);
			Insert(Root,x);
		}
		else
		{
			scanf("%d",&x);
			printf("%s\n",Find(Root,x) != NIL ?"yes":"no");
		}
	}
}

Measured memory_bytes: 12048
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

char N, M;

void input() {
  cin>>N>>M;
}
void solve() {
  debug(N);
  debug(M);
  int k=N,l=M;
  debug(k);
  debug(l);
  cout<<(k<l ? "<" : (k==l ? "=" : ">"))<<endl; 
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main()
{
        long long N, M, A;
        cin >> N >> M;

        long long sum = 0;

        for(int i = 0; i < M; i++)
        {
                cin >> A;
                sum += A;
        }

        if(N - sum >= 0)
        {
                cout << N - sum << endl;
        }
        else
        {
                cout << -1 << endl;
        }


        return 0;
}


Measured memory_bytes: 3596
using System;
using System.Linq;

namespace ConsoleApp6
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(Enumerable.Range(0, n).Select(_ => int.Parse(Console.ReadLine())).GroupBy(x => x).Count());
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>A (n);
    for(int i=0;i<n;i++) cin>>A[i];
    // unordered_map<int,int> pos;
    // for(int i=0;i<n;i++) pos[A[i]]=i;
    
    bool dp[k+1]={false};
    dp[0]=true;
    for(int i=1;i<=k;i++)
    {
        dp[i]=false;
        for(int num : A)
        {
            dp[i]=false;
            if(i-num==0 || (i-num>0 && dp[i-num]==false))
            {
                dp[i]=true;
                break;
            }
        }
    }
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using  namespace std;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 /// freopen("testcase.txt","r",stdin);
  string s1;
  string s2;
  cin>>s1>>s2;
  int c=0;
  for(int i=0;i<3;i++)
  {
      if(s1[i]==s2[i])
      {
          c++;
      }
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
A = input().split()
n = len(A)
B = []

for i in range(n):
    B.append(A[i])
    if B[-1] == '+':
        B[-3] = int(B[-3]) + int(B[-2])
        B.pop()
        B.pop()
    elif B[-1] == '-':
        B[-3] = int(B[-3]) - int(B[-2])
        B.pop()
        B.pop()
    elif B[-1] == '*':
        B[-3] = int(B[-3]) * int(B[-2])
        B.pop()
        B.pop()

print(B[0])


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1


ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int w, h;
ll d[100][100];
string s[100];
vector<P> vp;
ll dd[100][100];

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

void solve(P p) {
	queue<P> que;
	que.push(P(p.first, p.second));
	rep(i, 100)rep(j, 100)d[i][j] = INF;
	d[p.first][p.second] = 0;

	while (que.size()) {
		P p = que.front();
		que.pop();
		int y = p.first;
		int x = p.second;
		rep(i, 4) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (ny >= 0 && ny < h&&nx >= 0 && nx < w) {
				if (s[ny][nx] != 'x') {
					if (d[ny][nx] > d[y][x] + 1) {
						d[ny][nx] = d[y][x] + 1;
						que.push(P(ny, nx));
					}
				}
			}
		}
	}
}


int main() {
	while (cin >> w >> h&&w + h) {
		int cnt = 0;
		rep(i, 100)rep(j, 100)if (i != j)dd[i][j] = INF;
		vp.clear();
		P sp;
		rep(i, h) {
			cin >> s[i];
			rep(j, w) {
				if (s[i][j] == '*') {
					vp.push_back(P(i, j));
				}
				else if(s[i][j] == 'o'){
					sp = { i,j };
				}
			}
		}
		vp.push_back(sp);
		reverse(ALL(vp));
		rep(i, vp.size()) {
			solve(vp[i]);
			rep(j, vp.size()) {
				if (i != j) {
					dd[i][j] = d[vp[j].first][vp[j].second];
				}
			}
		}
		//rep(i, vp.size()) {
		//	rep(j, vp.size()) {
		//		if (dd[i][j] == INF)cout << -1 << " ";
		//		else cout << dd[i][j] << " ";
		//	}
		//	cout << endl;
		//}
		//cout << endl;
		ll ans = INF;
		vector<int> vi;
		rep(i, vp.size())vi.push_back(i);
		sort(ALL(vi));
		do {
			if (vi[0] != 0)continue;
			ll sum = 0;
			rep(i, vi.size() - 1) {
				sum += dd[vi[i]][vi[i + 1]];
			}
			ans = min(ans, sum);
		} while (next_permutation(ALL(vi)));
		if (ans >= INF)cout << -1 << endl;
		else cout << ans << endl;
	}
}


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

using namespace std;

int main() {
    int k,n,tmp,first = 0, last = 0;
    cin >> k >> n;
    vector<int> i(n);
    vector<int> dis(n);
    for (int a=0; a<n; ++a)
        cin >> i.at(a);
    for (int a=1; a<n; ++a) {
        if (first != i.at(0)) {
            first = i.at(0);
            last = i.at(0);
        }
        tmp = i.at(a);
        dis.at(a - 1) = tmp - last;
        last = tmp;
        if (a == n-1)
            dis.at(a) = k - last + first;
    }
    auto iter = max_element(dis.begin(), dis.end());
    auto index = distance(dis.begin(), iter);
    dis.erase(dis.begin() + index);
    cout << accumulate(dis.begin(), dis.end(), 0);
}


Measured memory_bytes: 1792
import java.util.Scanner;


public class Main {
	
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			int year = sc.nextInt();
			int month = sc.nextInt();
			int day = sc.nextInt();
			
			int count_day = 0;
			
			if(day > 1){
				if(year % 3 == 0){
					count_day += 21 - day;
				}else{
					if(month % 2 == 0){
						count_day += 20 - day;
					}else{
						count_day += 21 - day;
					}
				}
				
				month++;
				day = 1;
				
				if(month > 10){
					month = 1;
					year++;
				}
			}
				
			while(!(year == 1000 && month == 1 && day == 1)){
				if(year % 3 == 0){
					count_day += 21 - day;
				}else{
					if(month % 2 == 0){
						count_day += 20 - day;
					}else{
						count_day += 21 - day;
					}
				}
				
				month++;
				
				if(month > 10){
					month = 1;
					year++;
				}
			}
			
			System.out.println(count_day);
			
		}
		
	}
}	

Measured memory_bytes: 12000
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete


main = do
    cs <- replicateM 3 getInts
    putStrLn $ cond "Yes" "No" $ ((==1) $ length $ group $ map (binMap subtract) cs) && ((==1) $ length $ group $ map (binMap subtract) $ transpose cs)

Measured memory_bytes: 508