akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>


using namespace std;
using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;


void dump(char *s, vvll&m)
{
	printf("%s\n", s);
	for(auto&mm:m)
	{
		printf("%lld %lld %lld\n", mm[0], mm[1], mm[2]);
	}
	printf("\n");
}


vvll alloc(void)
{
	vvll x(3);
	for(auto&xm:x) xm.resize(3);
	return x;
}


vvll mul(vvll&a, vvll&b)
{
	vvll ret=alloc();

	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			ll x=0;
			for(int k=0;k<3;k++)
			{
				x+=a[i][k]*b[k][j];
			}
			ret[i][j]=x;
		}
	}
	return ret;
}


vvll calc(ll k)
{
	vvll m=alloc(), t=alloc();

	for(int i=0;i<3;i++)
	{
		auto&mm=m[i];
		auto&mt=t[i];
		for(int j=0;j<3;j++)
		{
			mt[j]=(i!=j);
			mm[j]=(i==j);
		}
	}
	for(int i=0;k;i++,k>>=1)
	{
		if(k&1)
		{
			m=mul(m, t);
		}
		t=mul(t, t);
	}
	return m;
}


int main(void)
{
	ll a, b, c, k;

	while(scanf("%lld%lld%lld%lld", &a, &b, &c, &k)==4)
	{
		vvll m=calc(k);
/*
		|a'| |0 1 1||a|
		|b'|=|1 0 1||b|
		|c'| |1 1 0||c|
*/
		ll ans=0;
		ans =(m[0][0]*a+m[0][1]*b+m[0][2]*c);
		ans-=(m[1][0]*a+m[1][1]*b+m[1][2]*c);

//		dump("m=", m);

		if(k&1)
		{
			ans=b-a;
		}
		else
		{
			ans=a-b;
		}

		ll a_, b_, c_;
		a_=(m[0][0]*a+m[0][1]*b+m[0][2]*c);
		b_=(m[1][0]*a+m[1][1]*b+m[1][2]*c);
		c_=(m[2][0]*a+m[2][1]*b+m[2][2]*c);
//		printf("a_=%lld b_=%lld c_=%lld\n", a_, b_, c_);
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

using namespace std;

int A[100000]={0},n;


int partition(int p, int r){
    int x,i,t;
    x=A[r];
    i=p-1;
    for(int j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            t=A[i];A[i]=A[j];A[j]=t;
        }
    }
    t=A[i+1];A[i+1]=A[r];A[r]=t;
    return i+1;
}

int main(){
    int p;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    p=partition(0,n-1);
    
    for(int i=0;i<n;i++){
        if(i) printf(" ");
        if(p==i) printf("[");
        printf("%d", A[i]);
        if(p==i) printf("]");
    }
    printf("\n");
}


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

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

    int h,w;
    cin>>h>>w;
    string s;
    for(int i=0;i<h;i++){
        for (int  j = 0; j < w; j++)
        {
            cin>>s;
            if(s=="snuke"){
                char c = 'A'+j;
                cout<<c<<i+1<<endl;
            }
        }
        
    }

}

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

N, M = map(int, input().split())
red = [0] * (N + 1)
white = [1] * (N + 1)
red[1] = 1
white[1] = 0

for _ in range(M):
    x, y = map(int, input().split())
    if red[x]:
        red[y] += 1
    else:
        white[y] += 1
    if white[x]:
        white[x] -= 1
    else:
        red[x] -= 1

print(N-red[1:].count(0))

Measured memory_bytes: 11032
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SuffixArray(object):
    """
    construct:
        suffix array: O(N(logN)^2)
        lcp array: O(N)
        sparse table: O(NlogN)
    query:
        lcp: O(1)
    """
    def __init__(self,s):
        """
        s: str
        """
        self.__s=s
        self.__n=len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()

    # suffix array
    def __suffix_array(self):
        s=self.__s; n=self.__n
        # initialize
        sa=list(range(n))
        rank=[ord(s[i]) for i in range(n)]
        tmp=[0]*n
        k=1
        cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
        # iterate
        while(k<=n):
            sa.sort(key=cmp_key)
            tmp[sa[0]]=0
            for i in range(1,n):
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
            rank=tmp[:]
            k<<=1
        self.__sa=sa
        self.__rank=rank

    # LCP array
    def __lcp_array(self):
        s=self.__s; n=self.__n
        sa=self.__sa; rank=self.__rank
        lcp=[0]*n
        h=0
        for i in range(n):
            j=sa[rank[i]-1]
            if h>0: h-=1
            while j+h<n and i+h<n and s[j+h]==s[i+h]: h+=1
            lcp[rank[i]]=h
        self.__lcp=lcp

    # sparse table
    def __sparse_table(self):
        n=self.__n
        logn=max(0,(n-1).bit_length())
        table=[[0]*n for _ in range(logn)]
        table[0]=self.__lcp[:]
        # construct
        from itertools import product
        for i,k in product(range(1,logn),range(n)):
            if k+(1<<(i-1))>=n:
                table[i][k]=table[i-1][k]
            else:
                table[i][k]=min(table[i-1][k],table[i-1][k+(1<<(i-1))])
        self.__table=table

    def lcp(self,a,b):
        """
        a,b: int 0<=a,b<n
        return LCP length between s[a:] and s[b:]
        """
        if a==b: return self.__n-a
        l,r=self.__rank[a],self.__rank[b]
        l,r=min(l,r)+1,max(l,r)+1
        i=max(0,(r-l-1).bit_length()-1)
        table=self.__table
        return min(table[i][l],table[i][r-(1<<i)])
def resolve():
    n=int(input())
    s=input()
    sa=SuffixArray(s)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            ans=max(ans,min(sa.lcp(i,j),j-i))
    print(ans)
resolve()

Measured memory_bytes: 53636
import java.util.Scanner;

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

        while(N != 0) {
            int r = N % 2;
            if(r < 0) r += 2;
            N = (N - r) / (-2);

            s += r;
        }
        StringBuffer sb = new StringBuffer(s);
        String str = sb.reverse().toString();

        if(str.isEmpty()){
            str = "0";
        }
        System.out.println(str);
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  forn(nup,n){
    in ndn=n-1-nup;
    in mn=a+c*nup-d*ndn;
    in mx=a+d*nup-c*ndn;
    if(mn<=b && mx>=b){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,x;
  int count=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(x==i*500+j*100+k*50)count++;
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
  int i,j=0,k;
  char a,b;
  string s,t;
  
  cin>>s>>t;
  
  for(i=s.length()-1;i>=0;i--){
    a=s[s.length()-1];
    for(k=s.length()-2;k>=0;k--){
      b=s[k];
      s[k+1]=b;
    }
    s[0]=a;
    if(s==t){
      j++;
      break;
    }
  }
  cout<<(j==1?"Yes":"No")<<endl;
  return 0;
}

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

int a, b;
int main() {
    cin >> a >> b;
    for(int i = 0; i < 20000; i++) {
    	if(int(0.08 * i) == a && int(0.1 * i) == b) {
        	cout << i;
         	return 0;
        }
    }
  	cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;
int main() {
   int W, H;
   cin >> W >> H;
   int x, y, r;
   cin >> x >> y >> r;
   if (x >= r && x <= W - r && y >= r && y <= H - r)
      printf("Yes\n");
   else
      printf("No\n");
   return 0;
}


Measured memory_bytes: 3100
$memo = {}
def ask(idx)
  return $memo[idx] if $memo[idx] != nil
  p idx
  STDOUT.flush
  s = gets.chomp[0]
  $memo[idx] = s
  exit 0 if s == 'V'
  return s
end

n = gets.to_i
left = 0
right = n

while left + 1 < right

  mid = (left + right) / 2
  # p [left, mid, right]

  if ask(left) == ask(mid) and (mid-left).odd?
    right = mid
  elsif ask(left) != ask(mid) and (mid-left).odd?
    left = mid
  elsif ask(left) == ask(mid) and (mid-left).even?
    left = mid
  elsif ask(left) != ask(mid) and (mid-left).even?
    right = mid
  end

end

while left < right
  ask(left)
  left += 1
end


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int arr[maxn];

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s,r;
    cin >> s;
    cin >> r;

    int cnt=0;
    f0(i,3){
        if(s[i]==r[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 512
num1,num2=input().split(" ")
vec=[]
a=[]
for i in range(int(num1)):
    c=[]
    b=input().split(" ")
    for j in range(int(num2)):
        c.append(int(b[j]))
    a.append(c)
for k in range(int(num2)):
    num4=int(input())
    vec.append(num4)
for l in range(int(num1)):
    sum=0
    for m in range(0,len(vec),1):
        sum=sum+(a[l][m]*vec[m])
    print(sum)


Measured memory_bytes: 6012
#include <cstdio>

using namespace std;

bool isXInList(int x, int L[], int N) {
    for (int i = 0; i < N; i++) {
        if (x == L[i]) {
            return true;
        }
    }
    return false;
}

int main() {
    int sum = 0;
    int n, q;
    int S[10005], T[505]; 
    scanf("%d", &n);
    for (int i = 0; i < n; i++)  scanf("%d", &S[i]);
    scanf("%d", &q);
    for (int i = 0; i < q; i++)  scanf("%d", &T[i]);
    for (int i = 0; i < q; i++) {
        if (isXInList(T[i], S, n))  sum++;
    }
    printf("%d\n", sum);
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int d, n; cin >> d >> n;
    int s = 0;
    if(n < 100){
        s = pow(100, d) * n;
    }else{
        s = pow(100, d) * 101;
    }
    cout << s << endl;
}



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

using namespace std;
int main(void){
    // Here your code !
  int n;
  int a[100];
  cin>>n;
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
int i;
for ( i = n-1; i >0; i-- ){

    cout<< a[i] <<(" ");
}
cout<<a[0]<<endl;
}

Measured memory_bytes: 1160
city=[0,0,0,0,0]
for i in range(3):
    a,b=[int(i) for i in input().split(" ")]
    city[a]+=1
    city[b]+=1

city.pop(0)
city=sorted(city)
if city==[1,1,2,2]:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn gcd(a: i64, b: i64) -> i64 {
  if a % b == 0 {
    b
  } else {
    gcd(b, a % b)
  }
}

fn lcm(a: i64, b: i64) -> i64 {
  a * b / gcd(a, b)
}

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  println!(
    "{}",
    if a % 2 == 0 || b % 2 == 0 {
      "Even"
    } else {
      "Odd"
    }
  );
}


Measured memory_bytes: 4352
N, M = map(int , input().split())

a = [0] * M
b = [0] * M

count = [0] * N

for i in range(0, M):
    a[i], b[i] = map(int, input().split())
    count[a[i] - 1]+=1
    count[b[i] - 1]+=1

for i in range(N):
    print(count[i])




Measured memory_bytes: 3064
/*
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 |                                                                 |
 |   author : yash1399     Language : C ++                         | 
 |   college : MSIT                                                | 
 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |  
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
# define ll  long long int 
# define TEST int t ; cin>>t; while(t--)
# define line cout<<endl;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define loop(i,a,b) for(long long int i=a;i<b;i++)
# define loopIn(i,a,b) for(long long int i=a;i<=b;i++)
#define MAX_SIZE 10000000
vector<bool> V(MAX_SIZE,false);
int main(){
      fast
      ll n;
      cin>>n;
      string s;
      cin>>s;
      string ans1,ans2;
      for(int i=0;i<n/2;i++){
          ans1 =ans1 + s[i];
      }
    for(int i=n/2;i<n;i++){
          ans2 =ans2 + s[i];
      }
      if(ans1==ans2) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      return 0;
}

Measured memory_bytes: 1536
/*
 * Author: xn_rookie
 * Created Time:  2012/2/19 12:03:13
 * File Name: 
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    vector <int> a;
    a.clear();
    for(int i=1;i<=10;i++)
     {
          int x;
          cin>>x;
          a.push_back(x);
    }
    sort(a.begin(),a.end());
    cout<<a[a.size()-1]<<endl<<a[a.size()-2]<<endl<<a[a.size()-3]<<endl;
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  int N,a,e=0;cin>>N;
  REP(i,0,N){
    cin>>a;
    if(a%2==0)e++;
  }
  int ans=pow(3,N)-pow(2,e);
  print(ans);


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  vector<int64_t>A(N+2);
  vector<int64_t>B(N+2);
  for(int i=0;i<=N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }

  int64_t sum=0;
  for(int i=0;i<=N;i++){
    int k=min(A[i],B[i]);
    sum+=k;
    A[i]-=k;
    B[i]-=k;
    int c=min(A[i+1],B[i]);
    sum+=c;
    A[i+1]-=c;
    B[i]-=c;
  }
  cout<<sum<<endl;
  return 0;}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

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

  rep(i, s.length()) {
    cout << "x";
  }
  
  cout << endl;

}


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

using namespace std;

#define LL long int

const int MAX = 1e6;
const int MOD = 1e9+7;



int main(){
    string a;

    cin >> a;

    if(a.back() == 's'){
        cout << a << "es" << endl;
    }else{
        cout << a << "s" << endl;
    }
    


    return 0;
}

Measured memory_bytes: 3624
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a + b + c + d == 7:
    print("{}+{}+{}+{}=7".format(a,b,c,d))
elif a - b + c + d == 7:
    print("{}-{}+{}+{}=7".format(a,b,c,d))
elif a + b - c + d == 7:
    print("{}+{}-{}+{}=7".format(a,b,c,d))
elif a + b + c - d == 7:
    print("{}+{}+{}-{}=7".format(a,b,c,d))
elif a - b - c + d == 7:
    print("{}-{}-{}+{}=7".format(a,b,c,d))
elif a - b - c - d == 7:
    print("{}-{}-{}-{}=7".format(a,b,c,d))
elif a - b + c - d == 7:
    print("{}-{}+{}-{}=7".format(a,b,c,d))
elif a + b - c - d == 7:
    print("{}+{}-{}-{}=7".format(a,b,c,d))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL d[100001];
vector<LL>v;
int main(){
	cin>>N;
	REP(i,N){
		cin>>d[i];
		v.push_back(d[i]);
	}
	sort(v.begin(),v.end());
	LL a=N/2-1;
	LL b=N/2;
	if(v[a]==v[b]){
		cout<<0<<endl;
	}else{
		cout<<v[b]-v[a]<<endl;
	}
}

Measured memory_bytes: 1912
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	var cost int

	if a <= 5 {
		cost = 0
	} else if a <= 12 {
		cost = b / 2
	} else {
		cost = b
	}

	fmt.Println(cost)
}


Measured memory_bytes: 512
// abc175_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B>
bool cmin(A &a, const B &b)
{
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B>
bool cmax(A &a, const B &b)
{
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#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()
{
  string S;
  cin >> S;
  bool before = false;
  int ans = 0;
  for(int i = 0, cnt = S.size(); i < cnt; ++i) {
    if(S[i] == 'R') {
      if(before) {
        ans++;
      } else {
        ans = 1;
      }
      before = true;
    } else {
      before = false;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long mod = 2000000001;
long long power[1 << 18];

long long N, A[1 << 18], B[1 << 18];
long long C0[1 << 18], C1[1 << 18], C2[1 << 18];
long long D0[1 << 18], D1[1 << 18];
bool flag[1 << 18];
long long ans[1 << 18];

void init() {
	power[0] = 1;
	for (int i = 1; i <= 200000; i++) power[i] = (2LL * power[i - 1]) % mod;
}

int main() {
	scanf("%lld", &N); init();
	for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
	for (int i = 0; i < N; i++) scanf("%lld", &B[i]);

	for (int i = 29; i >= 0; i--) {
		for (int j = 0; j < N; j++) C1[j] = (A[j] / (1LL << i)) % 2;
		for (int j = 0; j < N; j++) C2[j] = (B[j] / (1LL << i)) % 2;
		for (int j = 0; j < N; j++) C0[j] = (1LL ^ C1[j]);

		// 2 について求める
		long long val = 0;
		for (int j = 0; j < N; j++) { val = val * 2LL + C2[j]; val %= mod; }

		// 1 について求める
		D1[0] = 0; for (int j = 1; j <= N; j++) D1[j] = (2LL * D1[j - 1] + C1[j - 1]) % mod;
		D0[0] = 0; for (int j = 1; j <= N; j++) D0[j] = (2LL * D0[j - 1] + C0[j - 1]) % mod;

		// それぞれ判定する
		for (int j = 0; j < N; j++) {
			long long val1 = (D1[N] - D1[j] * power[N - j] + mod * mod) % mod;
			long long val2 = D1[j];
			long long val3 = (val1 * power[j] + val2) % mod;

			long long rem1 = (D0[N] - D0[j] * power[N - j] + mod * mod) % mod;
			long long rem2 = D0[j];
			long long rem3 = (rem1 * power[j] + rem2) % mod;

			if (val != val3 && val != rem3) flag[j] = true;
			if (val == rem3) ans[j] += (1LL << i);
		}
	}

	// 最後
	for (int i = 0; i < N; i++) {
		if (flag[i] == false) printf("%lld %lld\n", 1LL * i, ans[i]);
	}
	return 0;
}

Measured memory_bytes: 21376
#include <iostream>

using namespace std;

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

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

  rep(i, 0, n+1) {
    rep(j, 0, n+1) {
      int k = n - i - j;
      if (i*10000 + j*5000 + k*1000 == y && k >= 0) {
        printf("%d %d %d\n", i, j, k);
        exit(0);
      }
    }
  }
  printf("-1 -1 -1\n");
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

long long modpow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	map<int, int> vmap;
	cin >> N;
	int A;
	bool ok = true;
	rep(i, 0, N)
	{
		cin >> A;
		vmap[A]++;
		if (N % 2 == 0 && A % 2 == 0 || N % 2 == 1 && A % 2 == 1 || A > 0 && vmap[A] > 2 || A == 0 && vmap[A] > 1)
		{
			ok = false;
		}
	}

	if (ok)
	{
		cout << modpow(2, N / 2);
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
/* function */
/* main */
int main() {
    int n, k;
    cin >> n >> k;
    mint ans = k;
    ans = ans.pow(n);
    cout << ans << '\n';
}



Measured memory_bytes: 3092
n, m = map(int, input().split())

#(year, city)
prefs = [[] for _ in range(n + 1)]

#this list includes rel between city/pref
cities = []

for i in range(m):
    p, y = map(int, input().split())
    cities.append(p)
    prefs[p].append((y, i + 1))

for i in range(1, n + 1):
    prefs[i].sort()

table = {}

for i in range(1, n + 1):
    for j in range(len(prefs[i])):
        year, city = prefs[i][j]
        pref = i
        table[(pref, city)] = j + 1

for i in range(m):
    city = i + 1
    pref = cities[i]
    order = table[(pref, city)]

    pref = str(pref)
    order = str(order)
    ans = format(pref, '0>6') + format(order, '0>6')
    print(ans)

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

class Main {
	static final String YES = "Yes";
	static final String NO = "No";

	static char[][] A, B;

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		A = new char[N][N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.next().toCharArray();
		}
		B = new char[M][M];
		for (int i = 0; i < M; i++) {
			B[i] = sc.next().toCharArray();
		}

		for (int i = 0; i < N; i++) {
			if (N - M < i) break;
			for (int j = 0; j < N; j++) {
				if (N - M < j) break;
				if (check(i, j, M)) {
					System.out.println(YES);
					return;
				}
			}
		}

		System.out.println(NO);
	}

	private static boolean check(int i, int j, int M) {
		for (int k = 0; k < M; k++) {
			for (int l = 0; l < M; l++) {
				if (A[i + k][j + l] != B[k][l]) {
					return false;
				}
			}
		}
		return true;
	}
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=200005;

int a[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int main(void) {
	int n=read(),m=read(),T=read();
	int id=0;
	rep(i,0,n-1) {
		int x=read(),w=read();
		if (w==1) {
			id+=(x+T)/m;
			a[i]=(x+T)%m;
		} else {
			if ((x-T)%m<0) {
				a[i]=(x-T)%m+m;
				id+=(x-T)/m-1;
			} else {
				a[i]=(x-T)%m;
				id+=(x-T)/m;
			}
		}
	}
	std:: sort(a,a+n);
	id=(id%n+n)%n;
	rep(i,id,n-1) printf("%d\n", a[i]);
	rep(i,0,id-1) printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 1536
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
l=[a,b,c,d,e]
last=9
for i in range(5):
    if l[i]%10!=0:
        last=min(last,l[i]%10)
        
g=0
if a%10==0 and b%10==0 and c%10==0 and d%10==0 and e%10==0:
    print(sum(l))
else:
    for i in range(5):
        if l[i]%10==0:
            g+=l[i]
        else:
            g+=l[i]+10-l[i]%10
    print(g-10+last)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
  int a, b, c;
  int n, i;

  scanf("%d", &n);
  for (i = 0; i < n; i ++){
    scanf("%d %d %d", &a, &b, &c);
    if ((a * a) + (b * b) == (c * c)){
      printf("YES\n");
    }
    else if ((a * a) + (c * c) == (b * b)){
      printf("YES\n");
    }
    else if ((b * b) + (c * c) == (a * a)){
      printf("YES\n");
    }
    else {
      printf("NO\n");
    }
  }

  return (0);
}

Measured memory_bytes: 580
#include <stdio.h>
#include <math.h>

int main(void){
    int n;
    int count = 0;
    scanf("%d", &n);
    int m = pow(2, n);
    int honest[15] = {0};
    int unkind[15] = {0};

    int a;
    int x, y;
    for(int i = 0; i < n; i++){
        scanf("%d", &a);
            for(int j = 1; j < a + 1; j++){
                scanf("%d%d", &x, &y);
                if(y == 1){
                    honest[i] |= 1 << (x - 1);
                }else{
                    unkind[i] |= 1 << (x - 1);
                }
            }
    }

    for(int v = 0; v < m; v++){
        int ok = 1;
        for(int i = 0; i < n; i++){
            if(((v >> i) & 1) == 0){
                continue;
            }else{
                if((honest[i] & ~v) != 0){
                    ok = 0;
                }
                
                if((unkind[i] & v) != 0){
                    ok = 0;
                }
            }  
        }
        if(ok == 1){
            int c = 0;
            for(int k = 0; k < n; k++){
                c += (v >> k) & 1;                
            }
            if(count < c){
                count = c;
            }
        }
    }
    

    printf("%d", count);

    
}

Measured memory_bytes: 128
#include <iostream>
#include <stdlib.h>
#include <vector> 
#include <algorithm> 

using namespace std;
int main(){
    int stones = 2000001;
    int K = 3; //黒く塗られたK個の石
    int X = 7; //黒い石の座標

    cin >> K >> X;

    //+に長い
    // string right_stone;

    vector<int> ans;

    int right_pos;

    for(int i=X; i<=X+K-1; i++){
        ans.push_back(i);
    }

    //-に長い
    // string left_stone;
    
    for(int i=X; i>=X-K+1; i--){
        ans.push_back(i);
    }

    // sort(ans.begin(), ans.end());
    // unique(ans.begin(), ans.end());

    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());

    for(int i=0; i<ans.size(); i++) {
        cout << ans.at(i) << " ";
    }
    //todo:重複文字を削除してsortしてintへ変換して出力

    return 0;
}

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

const int N = 100;
const int white = 0;
const int gray = 1;
const int black = 2;

int n,M[N][N];
int color[N],d[N],f[N],tt;

//?????°dfs
void dfs_visit(int u){
    int v;
    color [u] = gray;
    d[u] = ++tt; //??????????¨????
    for ( v = 0; v < n ; ++v) {
        if (M[u][v] == 0)continue;
        if (color[v] == white){
            dfs_visit(v);
        }
    }
    color[u] = black;
    f[u] = ++tt; //?¨?????????????
}

void dfs(){
    int u;
    for (u = 0; u < n; ++u) {
        color[u] = white;
    }
    tt = 0;

    for (int u = 0; u < n ; ++u) {
        //????¨???????u????§??????¨????????±???????????¢?´¢
        if(color[u] == white) dfs_visit(u);
    }
    for (int u = 0; u < n ; ++u) {
        cout << u+1 << " " << d[u] << " " << f[u] << endl;
    }
}

int main(){
    int u,v,k;
    M[N][N] = {0};
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> u >> k;
        u --;
        for (int j = 0; j < k ; ++j) {
            cin >> v;
            v --;
            M[u][v] = 1;
        }
    }
    
    dfs();
    return 0;

}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q,count=0,time;
    string name;
    queue<pair<string,int> >que;
    cin>>n>>q;
    rep(i,n){
        cin>>name>>time;
        que.push(make_pair(name,time));
    }
    pair<string,int> u;
    int a;
    while(!que.empty()){
        u=que.front();
        que.pop();
        a=min(u.second,q);
        u.second-=a;
        count+=a;
        if(u.second>0){
            que.push(u);
        }
        else{
            cout<<u.first<<' '<<count<<'\n';
        }
    }
    return(0);
}


Measured memory_bytes: 6272
# coding: utf-8
import numpy as np
H, W = map(int, input().split())
maze = []
#入力の時点で行で削れるとことは削る
for _ in range(H):
    s = list(input())
    if s != ["."]*W:
        maze.append(s)
maze = np.array(maze)
#列で削れるところを削る
undels = []
for i in range(maze.shape[1]):
    if sum(maze[:, i] == ".") != maze.shape[0]:
        undels.append(i)
ans = maze[:, undels]
for i in range(ans.shape[0]):
    print(*ans[i], sep="")

Measured memory_bytes: 13900
n, m=map(int, input().split())
t=[list(map(int, input().split())) for i in range(n)]

l=sorted(t, key=lambda x: x[0])

money=0

for i in range(n):
    if m >= l[i][1]:
        money+=l[i][0]*l[i][1]
        m-=l[i][1]
    else:
        money+=l[i][0]*m
        m=0

    if m==0:
        break

print(money)

Measured memory_bytes: 29792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
int main()
{
    static const double pi = 3.141592653589793;
    cin.tie(0);
    ios::sync_with_stdio(false);  
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double time =h*60+m;
    cout<<setprecision(20)<<pow(a*a+b*b-2*a*b*cos(pi*(2./60-2./720)*time),0.5);

}

Measured memory_bytes: 4376
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> s(N);
    for(int i=0; i<N; i++) {
        cin >> s[i];
    }

    int sum = accumulate(s.begin(), s.end(), 0);

    if(sum % 10) {
        cout << sum << endl;
    } else {
        set<int> st;
        for(auto e: s) {
            if(e % 10) {
                st.insert(e);
            }
        }
        sum -= *st.begin();
        if(sum % 10) {
            cout << sum << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

w = [0] * N
b = [0] * N
for c in range(N):
    if c == 0:
        if S[c] == '.':
            w[c] = 1
            b[c] = 0
        else:
            w[c] = 0
            b[c] = 1
    else:
        if S[c] == '.':
            w[c] = w[c-1] + 1
            b[c] = b[c-1]
        else:
            w[c] = w[c-1]
            b[c] = b[c-1] + 1

mn = float('inf')
for c in range(N):
    mn = min(mn, b[c] + w[N-1] - w[c])

mn = min(mn, N - w[N-1])
mn = min(mn, N - b[N-1])

print(mn)


Measured memory_bytes: 14344
class Factorization:
  def __init__(self):
    self.F={}
    self.i=2
    self.c=0
    
  def factorint(self,x):
    while self.i**2<=x:
      if x%self.i==0:
        self.c=0
        while x%self.i==0:
          x=x//self.i
          self.c+=1
        self.F[self.i]=self.c
      self.i+=1
    if x!=1:
      self.F[x]=1
    return self.F
fac=Factorization()
N,P=map(int,input().split())
A=fac.factorint(P)
ans=1
for i,q in A.items():
  ans*=i**(q//N)
print(ans)

Measured memory_bytes: 39280
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> lp;
const int inf=0x3f3f3f3f;
const ll alph=26;
void A() {
    char c;
    cin>>c;
    if(c<='z'&&c>='a') cout<<'a'<<endl;
    else cout<<'A'<<endl;
}
void B() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n,0);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int res=0;
    for(int i=0;i<k;i++) res+=a[i];
    cout<<res<<endl;
}
void C() {
    ll n;
    cin>>n;
    string s;
    while(n>0){
        s+=((n-1)%alph+'a');
        n=(n-1)/alph;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}
void D() {
    ll n;
    cin>>n;
    unordered_map<ll,ll> cnt;
    ll sum=0;
    for(int i=0;i<n;i++) {
        ll a;
        cin>>a;
        sum+=a;
        cnt[a]++;
    }
    ll q;
    cin>>q;
    for(int i=0;i<q;i++){
        ll b,c;
        cin>>b>>c;
        if(!cnt.count(b)){
            cout<<sum<<endl;
            continue;
        }
        sum+=(c-b)*cnt[b];
        cnt[c]+=cnt[b];
        cnt.erase(b);
        cout<<sum<<endl;
    }
}
void E(){

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


Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
    int n, m, l, i, j, k;
    scanf("%d %d %d", &n, &m, &l);
    int a[n][m], b[m][l];
    long long int c[n][l];
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            c[i][j]=0;
        }
    }
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(i=0; i<m; i++){
        for(j=0; j<l; j++){
            scanf("%d", &b[i][j]);
        }
    }
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            for(k=0; k<m; k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            if(j==0){
                printf("%lld", c[i][j]);
            } else {
                printf(" %lld", c[i][j]);
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
const int m=2000000;
 vi arr(105);
 vi wrr(105);
 int dp[105][100005];
  int memo(int n,int w)
  {
       if(n==0||w<=0)
       {
           return dp[n][w]=0;
       }
       if(dp[n][w]!=-1)
       return dp[n][w];
       if(arr[n]>w)
       return dp[n][w]=memo(n-1,w);
       return dp[n][w]=max((memo(n-1,w-arr[n])+wrr[n]),memo(n-1,w));
  }
 
int32_t main()
{
    c_p_c();
    memset(dp,-1,sizeof(dp));
   int n,w;
   cin>>n>>w;
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
       cin>>wrr[i];
   }
   
   int x=memo(n,w);
    
     cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 82304
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  while(x->left !=NIL){
    x=x->left;
  }
  return x;
 
}
 
Node treeMaximum(Node x){
  while(x->right !=NIL){
    x=x->right;
  }
  return x;
 
}
Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
   
  if(k<u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k); 
 
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  else if(x->left !=NIL ) return treeMaximum(x->left);
 
  y=x->parent;
  while(y!=NIL && x==y->right) {
    x=y;
    y=y->parent;
  }
  return y;
 
}
 
void treeDelete(Node z){
  Node y;
  Node x; 
 
  if(z->left==NIL || z->right == NIL) y=z;
  else y=treeSuccessor(z);
 
  if(y->left!=NIL) x=y->left;
  else x= y->right;
 
  if(x!=NIL) x->parent=y->parent;
 
  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;
 
  if(y!=z) z->key=y->key;
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
 
  if(y==NIL) root=z;
  else if(z->key< y->key) y->left=z;
  else y->right=z;
 
}
 
void inorder(Node u){
  if(u!=NIL) {
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
 
 
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
 
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
 
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } 
 
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
  
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
 
     
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
    
  }
 
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());

    vector<map<int, int64_t>> DP(n + 2);
    DP[0][0] = 0;
    const constexpr int64_t INF = 1e17;
    vector<int> B(n);
    for (int i = 0; i < n; i++){
        B[i] = n / 2 - (n - i + 1) / 2;
    }

    for (int i = 0; i < n; i++){
        for (const auto &[k, v]: DP[i]){
            if (k < B[i])
                continue;
            if (DP[i + 1].count(k) == 0)
                DP[i + 1][k] = -INF;
            DP[i + 1][k] = max(DP[i + 1][k], DP[i][k]);
            if (DP[i + 2].count(k + 1) == 0)
                DP[i + 2][k + 1] = -INF;
            DP[i + 2][k + 1] = max(DP[i + 2][k + 1], DP[i][k] + A[i]);
        }
    }

    int64_t ans = -INF;
    for (int i = 0; i <= n + 1; i++){
        if (DP[i].count(n / 2) != 0)
            ans = max(ans, DP[i][n / 2]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 39892
#include <iostream>
#include <vector>
#include <functional>
#include <stack>

template<class T>
struct segment_tree {
	using value_type = T;
	using F = std::function<T(T, T)>;
private : 
	int n;
	F f;
	value_type ie;
	std::vector<value_type> node;

public : 
	segment_tree () { }

	segment_tree (const F &f, const value_type &ie) : f(f), ie(ie) { }

	void reset (const F &f, const value_type &ie) noexcept {
		(this->f) = f;
		(this->ie) = ie;
	}

	void assign (int _n) noexcept {
		n = 1;
		while (n < _n) n <<= 1;
		node.resize(2 * n);
		std::fill(node.begin(), node.end(), ie);
	}

	void assign (int _n, const value_type &e) noexcept {
		assign(_n);
		for (int i = n; i < 2 * n; i++) node[i] = e;
		for (int i = n; i--> 0;) {
			node[i] = f(node[i << 1 | 0], node[i << 1 | 1]);
		}
	}

	template<class iter>
	void build (iter l, iter r) {
		assign(r - l);
		for (int i = n; l != r; i++, l++) node[i] = *l;
		for (int i = n; i--> 0;) {
			node[i] = f(node[i << 1 | 0], node[i << 1 | 1]);
		}
	}

	template<class data_list>
	void build (const data_list &rhs) {
		build(rhs.begin(), rhs.end());
	}

	void set_val (int i, const value_type &x) {
		i += n;
		node[i] = x;
		for (i >>= 1; i > 0; i >>= 1) {
			node[i] = f(node[i << 1 | 0], node[i << 1 | 1]);
		}
	}

	constexpr value_type fold (int l, int r) {
		value_type vl = ie, vr = ie;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) vl = f(vl, node[l++]);
			if (r & 1) vr = f(node[--r], vr);
		}
		return f(vl, vr);
	};

	constexpr const value_type& fold_all() const {
		return (node[1]);
	}

	constexpr const value_type& operator[] (int i) const {
		return node[i + n];
	}

	constexpr const value_type& at (int i) const {
		return node.at(i + n);
	}

	void swap (segment_tree<value_type> &rhs) {
		(this->node).swap(rhs.node);
	}

};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	std::size_t n;
	std::cin >> n;
	std::vector<std::vector<int>> g(n);
	for (std::size_t p = 0; p < n; p++) {
		int sz;
		std::cin >> sz;
		while (sz--) {
			int v;
			std::cin >> v;
			g[p].push_back(v);
		}
	}
	
	std::size_t size = 0;
	std::vector<int> idx1(n, -1), idx2(n, -1);
	{
		std::vector<bool> status(n, false);
		std::stack<int> sta;
		sta.push(0);
		while (not sta.empty()) {
			int v = sta.top();
			if (status[v] == false) {
				idx1[v] = size++;
				status[v] = true;
				for (int u : g[v]) sta.push(u);
			} else {
				sta.pop();
				idx2[v] = size++;
			}
		}
	}
	
	segment_tree<int> seg([](int a, int b) { return (a + b); }, 0);
	seg.assign(size);
	
	int query;
	std::cin >> query;
	while (query--) {
		int type;
		std::cin >> type;
		if (type == 0) {
			int v, w;
			std::cin >> v >> w;
			int u = idx1[v], d = idx2[v];
			seg.set_val(u, seg[u] + w);
			seg.set_val(d, seg[d] - w);
		} else {
			int v;
			std::cin >> v;
			std::cout << seg.fold(0, idx1[v] + 1) << '\n';
		}
	}
	
	return 0;
}


Measured memory_bytes: 11292