akhauriyash/Code-Regression huggingface dataset:
def examA():
    R = I()
    ans = R*2*3.141592
    print(ans)
    return

def examB():
    N, M = LI()
    A = LI()
    S = sum(A)
    if N>=S:
        ans = N-S
    else:
        ans = -1
    print(ans)
    return

def examC():
    N = I()
    A = LI()
    ans = [0]*N
    for i in range(N-2,-1,-1):
        ans[A[i]-1] +=1
    for v in ans:
        print(v)
    return

def examD():
    N, K = LI()
    S = [0]*(N+2)
    for i in range(1,N+1):
        S[i+1] = S[i] + i
    #print(S)
    ans = 0
    for i in range(K,N+2):
        cur = (S[N+1] - S[N-i+1]) - (S[i] - S[0]) +1
        ans += cur
        ans %= mod
        #print(cur)

    print(ans)
    return

def examE():
    N = I()
    A = LI()
    S = [[]for _ in range(N)]
    for i in range(N):
        S[i] = [A[i],i]
    S.sort(reverse=True)
    #print(S)
    dp = [[0]*(N+1)for _ in range(N+1)]
    for i in range(N):
        s, x = S[i]
        for j in range(i+1):
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + s*(x-j))
            dp[i+1][j] = max(dp[i+1][j],dp[i][j] + s*(N-i-x+j-1))
            #print(N-i-x+j-1)
    ans = max(dp[-1])
    print(ans)
    #print(dp)
    return

def examF():
    N = I()
    C = LI()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    ans = 0

    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

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

using namespace std;

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

	if((n-1)*(n-2)/2<k){
		cout<<-1<<endl;
	}
	else{
		vector<pair<int,int>> ans;
		rep(i,n-1) ans.emplace_back(i,n-1);

		int num=(n-1)*(n-2)/2;
		rep(i,n-1) for(int j=i+1;j<n-1;j++) {
			if(num>k){
				ans.emplace_back(i,j);
				num--;
			}
		}
		cout<<ans.size()<<endl;
		for(auto e:ans) cout<<e.first+1<<" "<<e.second+1<<endl;
	}

	return 0;
}


Measured memory_bytes: 512
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	h, w, k := nextInt(), nextInt(), nextInt()
	c := make([]string, h)
	for i := range c {
		c[i] = next()
	}

	ans := 0
	for bh := 0; bh < (1 << h); bh++ {
		for bw := 0; bw < (1 << w); bw++ {
			black := 0
			for i := 0; i < h; i++ {
				for j := 0; j < w; j++ {
					if (bh>>i)&1 == 0 && (bw>>j)&1 == 0 && c[i][j] == '#' {
						black++
					}
				}
			}
			if black == k {
				ans++
			}
		}
	}

	puts(ans)
}


Measured memory_bytes: 1784
k = int(input())
a = list(map(int,input().split()))
a.append(0)

money = 1000
stock = 0

for i in range(k):
    if i == 0 and a[i] <= a[i+1] and money >= a[i]:
        stock += money//a[i]
        money -= a[i] * stock
        continue
    elif a[i-1] >= a[i] and a[i] <= a[i+1] and money >= a[i]:
        stock += money//a[i]
        money -= a[i] * stock
        continue
    elif a[i-1] <= a[i] and a[i] >= a[i+1]:
        money += a[i] * stock
        stock = 0
        continue
    else:
        continue
print(money)

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,i,j,k,c,ph,pw;
  cin>>h>>w;
  vector<string> s(h);
  vector<int> dh={-1,-1,-1,0,0,1,1,1},dw={-1,0,1,-1,1,-1,0,1};
  for(i=0;i<h;i++) cin>>s.at(i);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s.at(i).at(j)=='#') continue;
      c=0;
      for(k=0;k<8;k++){
        ph=i+dh.at(k);
        pw=j+dw.at(k);
        if(ph<0||h<=ph||pw<0||w<=pw) continue;
        if(s.at(ph).at(pw)=='#') c++;
      }
      s.at(i).at(j)=(char)('0'+c);
    }
  }
  for(i=0;i<h;i++) cout<<s.at(i)<<endl;
}

Measured memory_bytes: 3624
n,q=map(int,input().split())
#print(n,p)
round_robin=[]
for i in range(n):
    x=input().split()
    name=x[0]
    t=int(x[1])
    round_robin.append([name,t])
#print(round_robin)
finished=[]
counter=0
while round_robin:
    left_time=round_robin[0][1]
    if left_time<=q:
        counter+=left_time
        finished.append([round_robin[0][0],counter])
        del round_robin[0]
    else:
        counter+=q
        left_time-=q
        round_robin[0]=[round_robin[0][0],left_time]
        round_robin.append(round_robin.pop(0))

for i in finished:
    print(*i)

Measured memory_bytes: 17644
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    double a[n];
    rep(i,0,n) cin>>a[i];
    double dp[n+1][n];
    rep(i,0,n+1) rep(j,0,n) dp[i][j]=0;
    dp[0][0]=1-a[0];
    dp[1][0]=a[0];
    rep(j,1,n){
        rep(i,0,min(n+1,j+2)){
            if(i==0) dp[i][j]=dp[i][j-1]*(1-a[j]);

            else{
                dp[i][j]+=dp[i][j-1]*(1-a[j]);
                dp[i][j]+=dp[i-1][j-1]*a[j];
            }
        }
    }

    double ans=0;
    int hf=n/2;
    if(n&1)hf++;
    rep(i,hf,n+1) ans+=dp[i][n-1];
    cout<<setprecision(12)<<ans;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (auto&& vv : v) cin >> vv;
	sort(v.begin(), v.end(), greater<int>());
	int ans = 0, flag = 1;
	for (auto&& vv : v) {
		ans += flag * vv;
		flag *= -1;
	}
	cout << ans << endl;
	return 0;
}


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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

a = int(readline())

print(int(a + pow(a, 2) + pow(a, 3)))


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

using namespace std;
typedef long long ll;
typedef long double ld;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef map<ll,ll> mpll;
typedef set<ll> setll;
typedef multiset<ll> msetll;

#define F first
#define S second
#define pb push_back
#define mp make_pair

const ll mod = 1e9 + 7;
const ll inf = 99999999999999999;
ll n,c;
vll v;
ll arr[200001];

struct line{
	ll x;
	ll y;
};
deque<line> dq;


ll dot(line l1,line l2){
	return l1.x*l2.x + l1.y*l2.y;
}

bool check(line o,line a,line b){
	return (__int128)(a.x-o.x)*(b.y-o.y) >= (__int128)(a.y-o.y)*(b.x-o.x);
}

int main()
{

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	#ifdef DEBUG_
		freopen("input.txt","r",stdin);
	#endif
	
	cout.setf(ios::fixed), cout.precision(20);

	cin >> n >> c;
	v.resize(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}

	for(int j=0;j<=n;j++){
		arr[j]=inf;
	}
	arr[0]=0;

	
	dq.push_back({v[0],v[0]*v[0]});
	bool cv = false;
	for(int i=1;i<n;i++){
		ll xx = v[i]*v[i] + c;
		int low=0;
		ll si = dq.size();
		int high=si - 1;
		int mid=0;
		if(si>1){
		while(low<=high){
			mid = (low + high) / 2;
			if(mid==0){
					//v[mid]*2*v[i] - arr[mid] - v[mid]*v[mid]
					if(dot(dq[mid],{2*v[i],-1}) > dot(dq[mid+1],{2*v[i],-1}))
						break;
					else
					{
						low=1;
						//break;
					}
			}
			else if(mid == si-1){
				if(dot(dq[mid],{2*v[i],-1}) > dot(dq[mid-1],{2*v[i],-1}))
						break;
				else
					{
						high=mid-1;
						//break;
					}
			}
			else{
				if((dot(dq[mid],{2*v[i],-1}) > dot(dq[mid-1],{2*v[i],-1})) && (dot(dq[mid],{2*v[i],-1}) > dot(dq[mid+1],{2*v[i],-1})))
					break;
				else if((dot(dq[mid],{2*v[i],-1}) >= dot(dq[mid-1],{2*v[i],-1})) && (dot(dq[mid],{2*v[i],-1}) <= dot(dq[mid+1],{2*v[i],-1})))
					low=mid+1;
				else
				{
					high=mid-1;
				}
					
			}
		}
	}
	// arr[i] = arr[mid]+(v[i]-v[mid])*(v[i]-v[mid])+c;
	

	arr[i] = xx + dot(dq[mid],{-2*v[i],1});
	//if(v[i]==2019)
	//cout<<arr[i]<<"\n";
	//arr[i]=mi;
	line lnew = {v[i],v[i]*v[i]+arr[i]};
	while(dq.size()>1 && !check(dq[dq.size()-2],dq[dq.size()-1],lnew))
		dq.pop_back();	
	dq.push_back(lnew);
	}
	cout<<arr[n-1]<<"\n";
	return 0;
}



Measured memory_bytes: 6656
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
//K通り->(K-1)通り->(K-1)通り->...N回かける
int main(){
    int N,K;
    ll ans;
    cin>>N>>K;
    ans = K;
    FOR(i, 0, N-1) ans *= (K-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace ITP1_3_C
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string[] i = Console.ReadLine().Split(' ');
                int x = int.Parse(i[0]);
                int y = int.Parse(i[1]);
                
                if (x == 0 && y == 0) break;
                Console.WriteLine("{0} {1}", Math.Min(x, y), Math.Max(x, y));
            }
        }
    }
}


Measured memory_bytes: 17924
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    bool rev = false;
    int ans = 0;
    
    if((x < 0 && y > 0) || (x > 0 && y < 0)) {
        rev = true;
        x = -x;
        ++ans;
    }
    if(x > y) {
        ans += rev ? 0 : 2;
        if(y == 0 || x == 0) --ans;
    }
    
    ans += abs(x - y);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll h,w;
	cin>>h>>w;
	ll a=0,b=0,c=0,mind=h*w,M,m;
	for(ll i=1;i<=h-1;i++)
	{
		b = ((h-i)/2)*w;
		c = ((h-i+1)/2)*w;
		a = i*w;
		M = max(a,max(b,c));
		m = min(a,min(b,c));
		if(M-m<mind)
			mind = M-m;
		b = (h-i)*(w/2);
		c = (h-i)*((w+1)/2);
		a = i*w;
		M = max(a,max(b,c));
		m = min(a,min(b,c));
		if(M-m<mind)
			mind = M-m;

	}

	for(ll i=1;i<=w-1;i++)
	{
		b = ((w-i)/2)*h;
		c = ((w-i+1)/2)*h;
		a = i*h;
		M = max(a,max(b,c));
		m = min(a,min(b,c));
		if(M-m<mind)
			mind = M-m;		
		b = (w-i)*(h/2);
		c = (w-i)*((h+1)/2);
		a = i*h;
		M = max(a,max(b,c));
		m = min(a,min(b,c));
		if(M-m<mind)
			mind = M-m;
	}
	cout<<mind<<"\n";
}
	
	


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int r,g,b;
	cin >> r >> g >> b;

	int ans = r * 100 + g * 10 + b;
	if(ans % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

int n;
int pre[maxn];
int f[maxn];

void add(int &a, int b) {
    a += b;
    while (a >= mod) a -= mod;
}

int main() {
    cin >> n;
    f[0] = 1;
    for (int i = 1; i <= n; i++) {
        int c;
        cin >> c;
        f[i] = f[i - 1];
        if (pre[c] && pre[c] < i - 1) {
            add(f[i], f[pre[c]]);
        }
        pre[c] = i;
    }
    cout << f[n] << endl;
}


Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>


using namespace std;


using namespace std;

int main() {
    int A, B;
    cin >> A >> B;


    if(B%A==0){

        cout<<A+B<<endl;

        return 0;
    }

    cout<<B-A<<endl;



}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int A, B, T;
        int sum = 0;
        int i = 1;
        A = sc.nextInt();
        B = sc.nextInt();
        T = sc.nextInt();
        while (A * i <= T + 0.5) {
            sum = sum + B;
            i++;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23892
N, r = map(int, input().split())
hs = list(map(int, input().split()))
g = [1]*N
for i in range(r):
    road = list(map(int, input().split()))
    if hs[road[0] - 1] >= hs[road[1] - 1]:
        g[road[1] - 1] = 0
    if hs[road[0] - 1] <= hs[road[1] - 1]:
        g[road[0] - 1] = 0
print(sum(g))


Measured memory_bytes: 20080
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int main(){
    int N, a;cin >> N;
    vector<pii> A(N);
    for( int i = 0; i < N; i++ ){
        cin >> a;
        A[i].first = a; A[i].second = i+1;
    } 
    sort(A.begin(), A.end());

    for( int i = 0; i < N; i++ ){
        cout << A[i].second << endl;
    }
}

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

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        try {
            int N = Integer.valueOf(br.readLine());
            // int[][] arr = new int[N][3];

            int[] dp = new int[3];
            for (int i = 0; i < N; i++) {
                String[] tmp = br.readLine().split(" ");
                int a = Integer.valueOf(tmp[0]), b = Integer.valueOf(tmp[1]), c = Integer.valueOf(tmp[2]);
                if (i == 0) {
                    dp[0] = a;
                    dp[1] = b;
                    dp[2] = c;
                } else {
                    int x = a + Math.max(dp[1], dp[2]);
                    int y = b + Math.max(dp[0], dp[2]);
                    int z = c + Math.max(dp[0], dp[1]);
                    dp[0] = x;
                    dp[1] = y;
                    dp[2] = z;
                }
            }

            int res = Math.max(dp[0], Math.max(dp[1], dp[2]));
            System.out.println(res);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }
}

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

#define INF 500

//a < b ならtrue
bool comp(int ah, int aw, int bh, int bw){
  if(ah*ah+aw*aw == bh*bh+bw*bw)
    if(ah<bh)return true;
    else return false;
  if(ah*ah+aw*aw < bh*bh+bw*bw)return true;
  return false;
}

int main(){
  int h, w;
  while(true){
    cin>>h>>w;
    if(h==0&&w==0)break;
    int mini=INF*INF, mini_h=INF, mini_w=INF;
    for(int i=1; i*i+1<=h*h+w*w; i++){
      for(int j=i+1; ; j++){
        //      cout<<i<<" "<<j<<endl;
        if(comp(h, w, i, j)){
          if(comp(i, j, mini_h, mini_w)){
            mini=i*i+j*j; mini_h=i; mini_w=j;
          }
          break;
        }
      }
    }
    cout<<mini_h<<" "<<mini_w<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    long long ans = 0;
    for(int i = 1; i < N; i++){
        long long cnt = 0;
        for(int j = 0; j + i < N; j++){
            if(S[j] == S[i + j]) cnt++;
            else cnt = 0;
            if(cnt > i) ans = max(ans, (long long)i);
            else ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int tdfb(int,int,int);
int main(){
  int mi;
  mi=tdfb(1000,1,1);
  int n,y,m,d,t;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> y >> m >> d;
    t=tdfb(y,m,d);
    cout << mi-t << endl;
  }
  return 0;
}
int tdfb(int y,int m,int d){
  int t=0;
  for(int i=1;i<y;i++){
    if(i%3==0){
      t+=200;
    }
    else t+=195;
  }
  for(int i=1;i<m;i++){
    if(y%3!=0&&i%2==0){
      t+=19;
    }
    else t+=20;
  }
  t+=d;
  return t;
}
      

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

string s;

int main(void)
{
	int i, res = 0;
	
	cin >> s;
	
	for (i = 1; i < s.size(); ++i)
	{
		if (s[i] != s[i-1])
		{
			++res;
		}
	}
	
	printf("%d\n", res);
	
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=1e9+7;
const int N=500000;


main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<max({a,b,c})*9+a+b+c;
}

Measured memory_bytes: 256
while true
    a, op, b = gets.chomp.split
    break if op == "?"

    result = 0
    a = a.to_i
    b = b.to_i
    case op
    when "+" then result = a + b
    when "-" then result = a - b
    when "*" then result = a * b
    when "/" then result = a / b
    end

    puts result
end

Measured memory_bytes: 8688
#include<iostream>
using namespace std;
int main(void) {
	int red; cin >> red;
	int green; cin >> green;
	int blue; cin >> blue;
	int K; cin >> K;

	for (int i = 0; i < K; i++) {
		if (red >= blue) {
			blue = blue * 2;
		}
		else if (green >= blue) {
			blue = blue * 2;
		}
		else if (red >= green) {
			green = green * 2;
		}
	
	}
	if (red < green && green < blue && red < blue) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<"\n";
#define imod(a , n) (a % n + n ) % n ;
#define int long long
const double eps = 1e-9 , PI = acos(-1) ;
const int N = 100;
int n , w , wt[N] , val[N] ;
vector<vector<int>> dp(101 , vector<int> (1e5 + 1 , -1));
int calc(int idx , int cap){
    if(idx == n )return  0 ;
    if(dp[idx][cap] != -1)return dp[idx][cap];
    int a1 = 0 , a2 = 0 ;
    if(cap >= wt[idx])a1 = val[idx] + calc(idx + 1 , cap - wt[idx]);
    a2 = calc(idx + 1 , cap);
    return dp[idx][cap] = max(a1 , a2);

}
int32_t main(){
    cin >> n >> w ;
    for(int x = 0 ;x < n ;x++){
        cin >> wt[x] >> val[x] ;
    }
    cout << calc(0 , w);





        return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e2+2;

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

	int n;
	cin>>n;
	string s;
	cin>>s;
	map<char,set<int>> ma;
	for(int i=0;i<n;i++)
	{
		ma[s[i]].insert(i);
	}
	int q;
	cin>>q;
	while(q--)
	{
		int in;
		cin>>in;
		if(in==1)
		{
			int pos;
			char c;
			cin>>pos>>c;
			pos--;
			char prev=s[pos];
			ma[prev].erase(pos);
			ma[c].insert(pos);
			s[pos]=c;
		}
		else{
			int l,r;
			cin>>l>>r;
			l--; r--;
			int ans=0;
			for(int i='a';i<='z';i++)
			{
				bool ok=false;
				auto it=ma[i].upper_bound(l-1);
				if(it==ma[i].end())
				{

				}
				else{
					int lol=*it;
					if(lol>=l&&lol<=r) ok=true;
				}
				if(ok) ans++;
			}
			cout<<ans<<"\n";
		}
	}
}
// I never lose. I either win or I learn

Measured memory_bytes: 24220
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

vector<int> cal;
int n,k,t,u,v,l;

bool input(){	
	if(!(cin>>n>>k>>t>>u>>v>>l))return 0;
	
	cal = vector<int>(l+1);
	rep(i,n){
		int a;
		cin>>a;
		cal[a] = 1;
	}
	return 1;
}

double solve(){
	
	bool dush = 0;
	int stop = 0;
	int stock = 0;
	
	double time = 0;
	
	for(int i=1;i<l+1;i++){
		
		time += (dush) ? 1.0/v : 1.0/u;
		
		//printf("dush %d   stop %d  stock %d   time  %lf  i=%d\n",dush,stop,stock,time,i);
		
		
		if(stop==i){
			dush = 0;
		}
		
		if(!dush && stock){
			dush = 1;
			stop = i+v*t;
			stock--;
		}
		
		if(cal[i]==1){
			if(!dush){
				dush = 1;
				stop = i+v*t;
			}else{
				if(stock!=k)stock++;
				else{
					stop = i+v*t;
				}
			}
		}
		
	}
	
	return time;
	
}

void call_solve(){
	printf("%.9lf\n",solve());
}


int main(){
	while(input()){
		call_solve();
	}
}

Measured memory_bytes: 1316
#include<cstdio>
#include<iostream>
#include<stack>
#include<algorithm>

#define MAX 1400

using namespace std;

#define MAX 1400

struct Rectangle {
  int height;
  int pos;
};

int getLargestRectangle(int size, int buffer[]) {
  stack<Rectangle> S;
  int maxv = 0;
  buffer[size] = 0;

  for (int i = 0; i <= size; i++) {
    Rectangle rect;
    rect.height = buffer[i];
    rect.pos = i;
    if (S.empty()) {
      S.push(rect);
    } else {
      if (S.top().height < rect.height) {
        S.push(rect);
      } else if (S.top().height > rect.height) {
        int target = i;
        while (!S.empty() && S.top().height >= rect.height) {
          Rectangle pre = S.top(); S.pop();
          int area = pre.height * (i - pre.pos);
          maxv = max(maxv, area);
          target = pre.pos;
        }
        rect.pos = target;
        S.push(rect);
      }
    }
  }
  return maxv;
}

int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle() {
  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if (buffer[i][j]) {
        T[i][j] = 0;
      } else {
        T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1;
      }
    }
  }

  int maxv = 0;
  for (int i = 0; i < H; i++) {
    maxv = max(maxv, getLargestRectangle(W, T[i]));
  }

  return maxv;
}

int main() {
  scanf("%d %d", &H, &W);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("%d", &buffer[i][j]);
    }
  }

  cout << getLargestRectangle() << endl;

  return 0;
}


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

long long dp[100010];

int main() {
  int n;
  cin >> n;
  vector<long long> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < 100010; i++) {
    dp[i] = 1LL << 60;
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}

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

int main() {
  int a,b,c,d;cin>>a>>b>>c>>d;
  if (a+b==c+d) cout<<"Balanced"<<endl;
  else if (a+b>c+d) cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b < c + d) {
		cout << "Right"  << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define int long long
# define mo 1000000007
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define fi first
# define se second
signed main()
{
   gok
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
      s[i]='x';
  }
  cout<<s;
   return 0;
}


Measured memory_bytes: 256
from functools import reduce

def gcd(a,b): #最小公約数
    if ((a%b) == 0 ):
        return b
    else:    
        return (gcd(b,a%b))

def lcm(a,b):
    return a * b // gcd(a,b)

n = int(input())
l = list(map(int,input().split()))

print (reduce(lcm,l))


Measured memory_bytes: 6280
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int main(void) {
	// in = fopen("A.in", "rt");
	
	int X, Y;
	fscanf(in, "%d %d", &X, &Y);
	fprintf(out, "%d\n", X + Y / 2);
	
	return 0;
}

Measured memory_bytes: 128
import re
import itertools
chars = ["A","G","T","C"]
avoid = ["AGC","GAC","ACG",]
avoid_pattern = r"(.AGC|AGC.|.GAC|GAC.|.ACG|ACG.|A.GC|AG.C)"
MOD = (10**9) + 7
states = [ "".join([c1,c2,c3]) for  c1,c2,c3 in itertools.product(chars,chars,chars)]
states = [state for state in states if state not in avoid ]
def forward(states_num):
    update = dict([ (state,0) for state in  states_num.keys()])
    for current_state,current_num in states_num.items():
        for char in chars:
            if re.search(avoid_pattern,current_state + char) :
                pass
            else:
                new_state = current_state[1:]+char
                update[new_state] += current_num %MOD
    return update

def get_number(N):
    if N ==1 :
        return 4
    elif N ==2:
        return 16
    else:
        states_num = dict([ (state, 1)for state in states])
        for i in range(N-3):
            states_num = forward(states_num)
        return sum([  v for k,v in states_num.items()])%MOD

N = int(input())
#strings = ["".join(_) for _ in itertools.product(*([chars]*N)) ]
#strings = [string for string in strings if not re.search(avoid_pattern,string)]
#print(len(strings))
print(get_number(N))

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  string S1, S2;
  cin >> N >> S1 >> S2;

  unordered_map<string, long> state;
  if (S1[0] == S2[0]) {
    state["aa"] = 1;
    state["bb"] = 1;
    state["cc"] = 1;
  } else {
    state["ab"] = 1;
    state["ac"] = 1;
    state["ba"] = 1;
    state["bc"] = 1;
    state["ca"] = 1;
    state["cb"] = 1;
  }

  for (long i = 1; i < N; i++) {
    if (S1[i-1] == S1[i]) continue;
    unordered_map<string, long> next_state;
    if (S1[i-1] == S2[i-1]) {
      if (S1[i] == S2[i]) {
        next_state["aa"] = state["bb"] + state["cc"];
        next_state["bb"] = state["aa"] + state["cc"];
        next_state["cc"] = state["aa"] + state["bb"];
      } else {
        next_state["ab"] = state["cc"];
        next_state["ac"] = state["bb"];
        next_state["ba"] = state["cc"];
        next_state["bc"] = state["aa"];
        next_state["ca"] = state["bb"];
        next_state["cb"] = state["aa"];
      }
    } else {
      if (S1[i] == S2[i]) {
        next_state["aa"] = state["bc"] + state["cb"];
        next_state["bb"] = state["ac"] + state["ca"];
        next_state["cc"] = state["ab"] + state["ba"];
      } else {
        next_state["ab"] = state["ba"] + state["bc"] + state["ca"];
        next_state["ac"] = state["ba"] + state["ca"] + state["cb"];
        next_state["ba"] = state["ab"] + state["ac"] + state["cb"];
        next_state["bc"] = state["ab"] + state["ca"] + state["cb"];
        next_state["ca"] = state["ab"] + state["ac"] + state["bc"];
        next_state["cb"] = state["ac"] + state["ba"] + state["bc"];
      }
    }
    for (auto it: next_state) next_state[it.first] %= MOD;
    state = next_state;
  }
  
  long ans = 0;
  for (auto it: state) ans += it.second;
  ans %= MOD;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N,K,X,Y,fee;
	scanf("%d%d%d%d",&N,&K,&X,&Y);
	if(N<=K)
		fee=N*X;
	else
		fee=K*X+(N-K)*Y;
	printf("%d",fee);
	return 0;
}

Measured memory_bytes: 128
// 公式解説
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans;
    if(x/d > k){
        ans=x-d*k;
    }
    else{
        ll e=x/d;
        k-=e;
        x-=e*d;
        if(k%2 == 1){
            x=abs(x-d);
        }
        ans=x;
    }
    cout << ans << endl;
    return 0;
}

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

if N == 0 or N == 1:
    print(0)
    exit()

if N % 2 == 1:
    print(0)
    exit()

answer = 0
cnt = 1
while 5 ** cnt * 2 <= N:
    answer += N // (5 ** cnt * 2)
    cnt += 1

print(answer)

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    string s;
    cin>>s;
    vector<int> ctoi(256);
    ctoi['r'] = 2;
    ctoi['c'] = 0;
    ctoi['p'] = 1;
    int ans = 0;
    rep(i,k) {
    vector<int> x;
    for (int j = i; j < n; j += k) {
      x.push_back(ctoi[s[j]]);
    }
        vector<int> dp(2);
        int pre = -1;
        for(int nx: x){
            vector<int> p(2);
            swap(dp, p);
            dp[0] = max(p[0], p[1]);
            if(pre == nx){
                dp[1] = p[0] + a[nx];
            }else{
                dp[1] = max(p[0], p[1]) + a[nx];
            }
            pre = nx;
        }
        ans += max(dp[0], dp[1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
c=list(range(1,53))
n=int(input())
d=[]
for i in range(n):
    a,b=input().split()
    b=int(b)
    if a=="S":
        d.append(b)
    elif a=="H":
        d.append(b+13)
    elif a=="C":
        d.append(b+26)
    else:
        d.append(b+39)
        
for i in range(52):
    
    if c[i] in d:
        continue
    else:
        if c[i]<=13:
            print('S {}'.format(c[i]))
        elif c[i]<=26:
            print('H {}'.format(c[i]-13))
        elif c[i]<=39:
            print('C {}'.format(c[i]-26))
        else:
            print('D {}'.format(c[i]-39))


Measured memory_bytes: 5604
class UnionFind {
    constructor(N){
        this.par = new Array(N).fill(-1)
    }

    root(x) {
        if (this.par[x] < 0) return x;
        return this.par[x] = this.root(this.par[x]);
    }

    unite(x, y) {
        let rx = this.root(x);
        let ry = this.root(y);
        if (rx == ry) return;
        if(this.par[rx] > this.par[ry]) [rx, ry] = [ry, rx]
        this.par[rx] += this.par[ry]
        this.par[ry] = rx
    }

    isSame(x, y) {
        let rx = this.root(x);
        let ry = this.root(y);
        return rx == ry;
    }
    
    size(x) {
        return -this.par[this.root(x)];
    }
};

function main(arg) {
    
    arg = arg.split("\n")
    let [N,M] = arg[0].split(" ").map(Number)
    let A = arg.slice(1).map(x=>Number(x.split(" ")[0]))
    let B = arg.slice(1).map(x=>Number(x.split(" ")[1]))
    

    let tree = new UnionFind(N)
    for(let i=0; i<M; i++) {
        tree.unite(A[i]-1,B[i]-1)
    }

    let ans=0
    for(let i=0; i<N; i++) {
        ans = Math.max(ans, tree.size(i))
    }
    console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

using namespace std;

const int MAXC = 10;

int n;

int qtdColor[MAXC];

int color(int k) { return k/400; }

int main()
{
	scanf("%d",&n);

	int choose = 0;

	for(int i = 1 ; i <= n ; i++)
	{
		int v;
		scanf("%d",&v);

		if( v >= 3200 ) choose++;
		else qtdColor[ color(v) ]++;
	}

	if( choose == n )
	{
		printf("1 %d\n",n);
		return 0;
	}

	int mn = 0;

	for(int i = 0 ; i < MAXC ; i++)
		if( qtdColor[i] > 0 ) mn++;

	int mx = mn + choose;

	printf("%d %d\n",mn,mx);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b[10000],c,d,s,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  d=a-1;
  for(i=d;i>=0;i--){
    if (i>0)printf("%d ",b[i]);
    else printf("%d",b[i]);
  }
  printf("\n");
  return 0;
}



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

int main(){
    //A[i]...家(i)と(i+1)との距離.
    ll K,N;cin>>K>>N;
    vector<ll> lst(N);
    vector<ll> A(N);
    rep(i,N)cin>>lst[i];
    rep(i,N){
        if(i!=(N-1)){
            A[i] = lst[i+1]-lst[i];
        }else{
            A[i] = lst[0] + (K - lst[i]);
        }
    }
    ll ans = 0;
    ll maxl = -1;
    rep(i,N){
        ans += A[i];
        maxl = max(maxl,A[i]);
    }
    ans -= maxl;
    cout<<ans<<endl;
    return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
    cin >> N;

    if(N <= 104)
        cout << 0 << endl;
    else if (N <= 134)
        cout << 1 << endl;
    else if(N <= 164)
        cout << 2 << endl;
    else if(N <= 188)
        cout << 3 << endl;
    else if(N <= 194)
        cout << 4 << endl;
    else
        cout << 5 << endl;

	return 0;
}


Measured memory_bytes: 384
use proconio::input;

fn main() {
    input! {
        n: i64,
        a: [u128;n],
    }

    let con0 = a.contains(&0);
    let ans = a
        .into_iter()
        .fold(1u128, |s, a| if s * a > 10u128.pow(18) { 0 } else { s * a });
    if con0 {
        println!("0")
    } else if ans == 0 {
        println!("-1")
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 5312
#include <iostream>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

struct Mod {
    static constexpr auto kMod = 1000000007L;
    static constexpr auto kIMod = 1000000005L;

    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const {
        return (n * (m.n % kMod)) % kMod;
    }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p/2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kIMod);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const {
        return (n + m.n) % kMod;
    }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

  int64_t n;
};

int64_t solve(int n, int m) {
    if (n > m) {
        swap(n, m);
    }

    assert(n <= m);
    if (m - n > 1) {
        return 0;
    }

    Mod ans(1);

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

    for (int i = 1; i <= m; ++i) {
        ans *= i;
    }

    if (n == m) {
        ans *= 2;
    }

    return ans.n;
}

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

    cout << solve(n, m) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main{
	
	int N;
	int[] A;
	public void solve(){
		N = nextInt();
		A = new int[N];
		long sum = 0;
		for(int i = 0; i < N; i++){
			A[i] = nextInt();
			sum += A[i];
		}
		long min = Long.MAX_VALUE;
		long sum2 = 0;
		for(int i = 0; i < N - 1; i++){
			sum -= A[i];
			sum2 += A[i];
			min = Math.min(min, Math.abs(sum - sum2));
		}
		out.println(min);
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

int main(){
   int n,m,l;
   cin >> n >> m >> l;
   long long matrixA[100][100];
   int matrixB[100][100];
   long long matrixAB[100];
   long long matrixC[100][100];
   
   for (int i = 0; i < n; i++) {
       for (int j = 0; j < m; j++) {
           matrixA[i][j] = 0;
       }
   }
   
   for (int i = 0; i < m; i++) {
       for (int j = 0; j < l; j++) {
           matrixB[i][j] = 0;
       }
   }
   
    for (int i = 0; i < n; i++) {
       for (int j = 0; j < l; j++) {
           matrixC[i][j] = 0;
       }
   }
   
   for (int i = 0; i < n; i++) {
       for (int j = 0; j < m; j++) {
           cin >> matrixA[i][j]; 
            
       }
   }
    for (int i = 0; i < m; i++) {
       for (int j = 0; j < l; j++) {
           cin >> matrixB[i][j];
       }
   }
   
   
   for (int i = 0; i < n; i++) {
       for (int j = 0; j < m; j++) {
           for (int k = 0; k < l; k++) {
            
             matrixC[i][k] += matrixA[i][j] * matrixB[j][k];     
           }
           
       }
   }
   
   for (int i = 0; i < n; i++) {
       for (int k = 0; k < l; k++) {
           if (k) cout << " ";
           cout << matrixC[i][k];
       }
       cout << endl;
   }
   
    return 0;
}

Measured memory_bytes: 1356
#include<iostream>

using namespace std;

long long int dp[1123][1123];
char tb[1123][1123];
long long int MOD = 1e9+7;

int H,W;
int main () {
    cin >> H >> W;
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            cin >> tb[i][j];
        }
    }
    dp[1][1] = 1;
    for(int k=1; k<=H&&k<=W; k++) {
        if( tb[k][k] == '.') dp[k][k] += ((dp[k-1][k]+dp[k][k-1]) % MOD);
        int i=k+1;
        int j=k+1;
        while(i<=H) {
            if(tb[i][k] == '#') i++;
            else {
                dp[i][k] += ((dp[i-1][k]+dp[i][k-1]) % MOD);
                i++;
            }
        }
        while(j<=W )  {
            if(tb[k][j] == '#') j++;
            else {
                dp[k][j] += ((dp[k-1][j]+dp[k][j-1]) % MOD);
                j++;
            }
        }
    }
    cout << dp[H][W] << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define puts(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){

	int N;
	cin >> N;
	vector <int> as(N), bs(N);
	rep(N, i) cin >> as[i];
	rep(N, i) cin >> bs[i];

	ll sum = 0;

	rep(N, i)
	{
		if (as[i] >= bs[i])
		{
			sum -= as[i]-bs[i];
		}
		else
		{
			sum += abs(as[i]-bs[i])/2;
		}
	}

	putln((sum>=0?"Yes":"No"));
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define N 101

void AdjacencyList(int,int,int *);
int A[N][N];

int main(){
  int u[N],v[N],i,j,d,n,k;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&u[i]);
    scanf("%d",&d);
    for(j=1;j<=d;j++){
      scanf("%d",&v[j]);
    }
    AdjacencyList(n,d,v);
  }
  for(k=1;k<=n;k++){
    for(j=1;j<=n;j++){
      if(A[k][j]==1){
	printf("%d",A[k][j]);
	if(j!=n)
	  printf(" ");
      }
      if(A[k][j]!=1){
	printf("0");
	if(j!=n)
	  printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}



  void AdjacencyList(int n,int d,int *v){
    int i,j;
    int static k=1;
    for(i=1;i<=n;i++){
      for(j=1;j<=d;j++){
	if(v[j]==i)
	  A[k][i]=1;
      }   
    }
    k++;
  }

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

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 1e5+10;
                        
int fa[maxn];
int find(int x){
    if(x==fa[x]) return x;
    return fa[x]=find(fa[x]);
}
void merge(int u,int v){
    int x = find(u);
    int y = find(v);
    if(x!=y) 
        fa[x] = y; 
}
int main(void){
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int n,m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) fa[i] = i;
    for(int i = 1; i <= m; i++){
        int u,v;
        cin >> u >> v;
        merge(u,v);
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(fa[i]==i) cnt++;
    }
    cout<<cnt-1<<endl;
    return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include<math.h>
#include<cstdlib>


using namespace std;
typedef long long ll;

int main()
{
   ll a,b;
   cin>>a>>b;
   if(a>b)
    swap(a,b);

   ll temp = b - a;
   ll temp2 = temp/2;
   ll result;

   ll resa = a+temp2;
   ll resb = b-temp2;


   if(resa == resb){
      result = b - temp2;
      cout<<result<<endl;
   }
   else
    cout<<"IMPOSSIBLE"<<endl;

}

Measured memory_bytes: 256
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = list(map(int, input().split()))
    s = 0
    for a in A:
        s = s^a
    B = [s^a for a in A]
    print(*B)



if __name__ == '__main__':
    main()

Measured memory_bytes: 31604
N,T,*ABf = map(int, open(0).read().split())
AB = [ABf[i:i+2] for i in range(0, len(ABf), 2)]
AB.sort()
dp = [[0] * 2 for _ in range(6000)]
filled = set([0])
for x in AB:
    temp = set()
    change = []
    for y in filled:
        if y + x[0] <= (T-1) + max(dp[y][1],x[0]):
            if dp[y+x[0]][0] <= dp[y][0] + x[1]:
                change.append((y,y+x[0],dp[y][0]+x[1],x[0]))
    for y in change:
        if dp[y[1]][0] == y[2]:
            dp[y[1]][1] = y[3]
        else:    
            dp[y[1]][0] = y[2]
            dp[y[1]][1] = y[3]
            temp.add(y[0]+x[0])
    filled = filled | temp
print(max(dp)[0])

Measured memory_bytes: 119004
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    ll sum1=0;
    ll sum2=0;
    ll sum3=0;
    for(ll i=1;i<=n;i++){
        if(i%15==0){
            sum3+=i;
            continue;
        }
        if(i%3==0){
            sum1+=i;
            continue;
        }
        if(i%5==0){
            sum2+=i;
            continue;
        }
    }
    cout << n*(n+1)/2-sum1-sum2-sum3 << endl;
    return 0;
} 

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

int main(){
	string s;
  	cin >> s;
  	int n[30]={};
  	for (int i=0;i<s.size();i++){
    	n[s[i]-'a']++;
    }
  	bool x=true;
  	for (int i=0;i<30;i++){
    	if(n[i]%2!=0) x=false;
    }
  	if (x==true) cout <<"Yes"<<endl;
  	else cout <<"No"<<endl;
}

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



int main()
{
  int N;
  cin >> N;
  
  string s;
  cin >> s;
  
  //for(int i = 0; i< s.size() ; i++) cout << s.at(i) << " ";//取得できたか確認
  string ans = "Yes";
  
  if(s.size() % 2 == 1){
    ans = "No";
    cout << ans << endl;
    return 0;
  }
  
  //ans = "Yes";
  int num = s.size()/2;//
  for(int i = 0; i < num ; i++)
  {
    if(s.at(i) == s.at(i+num) ) continue;
    ans = "No";
  }
  
  cout << ans << endl;
  
 
}

Measured memory_bytes: 256