akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int solve(int idx , vector<int>&v , vector<int>&dp , int n)
{
    if(idx == n)
      return 0;
    
    if(dp[idx] != -1)
      return dp[idx];
    int op1 = INT_MAX;
    int op2 = INT_MAX;
    if(idx + 1 <= n)
    {
        op1 = solve( idx + 1 , v , dp , n) + abs(v[idx] - v[idx+1]);
    }
    if(idx + 2 <= n)
    {
        op2 = solve(idx + 2 , v , dp , n) + abs(v[idx] - v[idx+2]);
    }

    dp[idx] = min(op1 , op2);

    return dp[idx];
}
int main() {
    

    int n;
    cin>>n;

    vector<int>v(n) ;

    for(int i = 0 ;i<n ;i++)
      cin>>v[i];

   
   vector<int>dp(n+1 , -1);

   int ans = solve( 0 , v , dp , n - 1);

   cout<<ans<<endl;
}   


Measured memory_bytes: 11904
#include<stdio.h>

int main(void){

    int L,R,d;
    int i,count=0;

    scanf("%d %d %d",&L,&R,&d);

    for(i=L;i<=R;i++){
        if(i%d==0) count++;
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 1736
using System;

class Program
{
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int cnt = 0;

            while(n > 0)
            {
                if(n%10 == 2)
                    cnt++;
                n /= 10;
            }

            Console.WriteLine(cnt);

        }
}


Measured memory_bytes: 13140
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

readNWords = readInt >>= flip replicateM getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readNWords >>= putStrLn . which "Yes" "No" . uncurry (&&) . ( solve1 &&& solve2 )

solve1 = all ( == 1 ) . map length . group . sort

solve2 [ _ ] = True
solve2 ( a : rest@( b : ws ) )
	| last a == head b = solve2 rest
	| otherwise = False

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, c, k, i, j, d, a[100100], ans;

    cin >> n >> c >> k;
    for(i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    d = 1; ans = 1; j = a[0];
    for(i = 1; i < n; ++i)
    {
        if(a[i] - j <= k && d + 1 <= c)
            d++;
        else
        {
            ans++;
            j = a[i];
            d = 1;
        }
    }
    cout << ans;

return 0;
}


Measured memory_bytes: 640
n = int(input())
sm = 0
b_first = 0
a_end = 0
b_a = 0

for i in range(n):
    s = input()
    for j in range(len(s)-1):
        if s[j]=="A" and s[j+1]=="B":
            sm += 1
    if s[0]=="B" and s[-1]=="A": b_a += 1    
    elif s[0]=="B": b_first += 1
    elif s[-1]=="A": a_end += 1

ans = sm

if b_a == 0:
    ans += min(b_first,a_end)
elif b_first+a_end==0:
    ans += b_a-1
else:
    ans += b_a + min(b_first, a_end)

print(ans)

Measured memory_bytes: 9236
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;



int main(){
    int n,yen;
    cin>>n>>yen;
    yen/=1000;
    int ans[3]={};
    bool j=false;
    for(int x=0;x*10<=yen && !j;x++){
        for(int y=0;y*5+x*10<=yen && !j;y++){
            int z=yen-y*5-x*10;
            if(x+y+z==n){ans[0]=x;ans[1]=y;ans[2]=z; j=true;}
        }
    }
    if(!j){cout<<"-1 -1 -1"<<endl;}
    else{cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<endl;}
    
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D)) {
    cout << "Left" <<endl;
  }
  
  if ((A + B) == (C + D)) {
    cout << "Balanced" <<endl;
  }
  
  if ((A + B) < (C + D)) {
    cout << "Right" <<endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  char p = '0';
  int ans = 0;
  rep(i, n) {
    if (s[i] == p) {

    } else {
      ans++;
    }
    p = s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] split = str.split(" ");
        int[] nums = new int[split.length];
        for(int i=0 ; i<3; i++){
            nums[i] = Integer.parseInt(split[i]);
        }
        
        for(int i=0; i<=3 ; i++){
            for(int j=i+1; j<=2; j++){
                if(nums[i]>nums[j]){
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j]=temp;
                }
            }
        }
        System.out.println(nums[0]+" "+nums[1]+" "+nums[2]);
    }
}


Measured memory_bytes: 26184
A,B,C,X,Y = map(int,input().split())

res = A * X + B * Y
for i in range(2, 4 * (X + Y) + 1,2):
	curr = max(0,A * (X - i // 2)) + max(0,B * (Y - i // 2)) + C * i
#	print(i,curr) 
	res = min(res, curr)

print(res)

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

int main() {
  vector<vector<int>> datas;
  const string SHARP = "#";
  const string DOT = ".";

  while (true) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0) break;
    vector<int> hw = { H, W };
    datas.push_back(hw);
  }

  for (int i = 0; i < (int)datas.size(); i++) {
    for (int j = 0; j < datas[i][0]; j++) {
      for (int k = 0; k < datas[i][1]; k++) {
        if ((j % 2 == 0 && k % 2 == 0) || (j % 2 == 1 && k % 2 == 1)) {
          cout << SHARP;
        } else {
          cout << DOT;
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 200001;
ll n,ans=0,a[N],k;
priority_queue<ll> q;
int main(){
	cin>>n>>k;
	FOR(i,0,N)a[i]=0;
	FOR(i,0,n){
		ll w;
		cin>>w;
		a[w]++;
	}
	FOR(i,0,N){
		if(a[i]!=0){
			q.push(-a[i]);
		}
	}
	while(q.size()>k){
		ll w=-q.top();
		ans+=w;
		q.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << ((a*b) >= (c*d) ? a * b : c * d);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int nearPrice = N % 1000 == 0 ? N / 1000 : N / 1000 + 1;
        int result = 1000 * nearPrice - N;
        pw.println(result);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 32940
K, N = map(int, input().split())
As = list(map(int, input().split()))

# 一番遠いところを避ければ良い
max = 0
for i in range(N-1):
    if As[i+1] - As[i] > max:
        max = As[i+1] - As[i]

if (As[0]+K) - As[N-1] > max:
    max = (As[0]+K) - As[N-1]

print(K-max)


Measured memory_bytes: 26444
from math import gcd
def INT(): return int(input())
 
 
K = INT()
sum = 0
 
for n in range(1, K+1):
  for m in range(1, K+1):
    for l in range(1, K+1):
      sum += gcd(gcd(n, m), l)
 
print(sum)

Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
const int nmax = 8;
bool graph[nmax][nmax];
 
int dfs(int v,int N,bool visited[nmax]){
  bool all_visited = true;
  for(int i = 0; i < N;++i) if(!visited[i]) all_visited=false;
  if(all_visited) return 1;  
  int ret = 0;
  for(int i=0;i<N;++i){
    if(!graph[v][i] || visited[i]) continue;
    visited[i] = true;
    ret+= dfs(i,N,visited);
    visited[i] = false;
  }
  return ret;
}
 
int main(){
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M ; ++i){
    int a,b;
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }
  bool visited[nmax];
  for(int i = 0; i < N ; ++i) visited[i] = false;
  visited[0] = true;
  cout << dfs(0,N,visited) << endl;
}

Measured memory_bytes: 256
/*
    Code by CNH_Tourist
*/
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")

using namespace std;

/*----------------Define----------------*/
#define inp "TestCode.inp"
#define out "TestCode.out"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileInOut freopen(inp,"r",stdin);freopen(out,"w",stdout);
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define pi acos(-1)
#define pii pair<int,int>
#define ppiii pair< pair <int,int> ,int>
#define INF 1000000
#define endl '\n'
#define ll long long
#define pq priority_queue
const ll mod=1e9+7;
int test=1;
/*--------------------------------------*/

int h,w;
char a[1010][1010];
ll dp[1010][1010];

int main()
{
    FAST
    //FileInOut
    cin>>h>>w;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>a[i][j];
    for(int i=0;i<=max(h,w)+1;i++)
    {
        dp[i][0]=0;
        dp[0][i]=0;
    }
    dp[1][1]=1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(i==1 && j==1) continue;
            if(a[i][j]=='.')
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            else
                dp[i][j]=0;
        }
    }
    cout<<dp[h][w];
}



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

typedef long long ll;

using vi = vector<int>;
using vl = vector<long long int>;
using vii = vector<vector<int>>;
using vll = vector<vector<long long int>>;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
       const int INF=1e9+7;
   int h,w;
   cin>>h>>w;
   vector<vector<char>>ch(h+1,vector<char>(w+1));
   for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)cin>>ch[i][j];
vii dp(h+1,vi(w+1));

for(int i=1;i<=h;i++)
{
    if(ch[i][1]=='#')break;
    else dp[i][1]=1;
}
for(int j=1;j<=w;j++)
{
    if(ch[1][j]=='#')break;
    else dp[1][j]=1;
}

for(int i=2;i<=h;i++)
{
    for(int j=2;j<=w;j++)
    {
        if(ch[i][j]=='#')dp[i][j]=0;
        else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%INF;
    }
}

cout<<dp[h][w]<<"\n";



return 0;

}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define re register
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define lb long double
const int N=1e6+10;
const int mod=10086;
const int mod2=19260811;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int x,y,A,B,C;
int a[N],b[N],c[N];
queue <int> q1,q2,q3;
bool cmp(int x,int y) {return x>y;}
int main()
{
    ll ans=0;
    read(x),read(y),read(A),read(B),read(C);
    for(re int i=1;i<=A;i++) read(a[i]);
    for(re int i=1;i<=B;i++) read(b[i]);
    for(re int i=1;i<=C;i++) read(c[i]);
    sort(a+1,a+1+A,cmp);sort(b+1,b+1+B,cmp);sort(c+1,c+1+C,cmp);
    for(re int i=x;i>=1;i--) q1.push(a[i]);
    for(re int i=y;i>=1;i--) q2.push(b[i]);
    for(re int i=1;i<=C;i++) q3.push(c[i]);
    while(!q1.empty()&&!q2.empty()&&!q3.empty())
    {
        int t1=q1.front(),t2=q2.front(),t3=q3.front();
        if(t1<t2)
        {
            q1.pop();
            if(t1<t3)
            {
                ans+=t3;
                q3.pop();
            }
            else ans+=t1;
        }
        else
        {
            q2.pop();
            if(t2<t3)
            {
                ans+=t3;
                q3.pop();
            }
            else ans+=t2;
        }
    }
    //cout<<ans<<endl;
    while(!q1.empty()&&!q3.empty())
    {
        int t1=q1.front(),t2=q3.front();
        q1.pop();
        if(t1<t2)
        {
            ans+=t2;
            q3.pop();
        }
        else ans+=t1;
    }
    //cout<<ans<<endl;
    while(!q2.empty()&&!q3.empty())
    {
        int t1=q2.front(),t2=q3.front();
        q2.pop();
        if(t1<t2)
        {
            ans+=t2;
            q3.pop();
        }
        else ans+=t1;
    }
    //cout<<ans<<endl;
    while(!q1.empty())
    {
        int t=q1.front();
        q1.pop();
        ans+=t;
    }
    //cout<<ans<<endl;
    while(!q2.empty())
    {
        int t=q2.front();
        q2.pop();
        ans+=t;
    }
    printf("%lld\n",ans);
    return 0;
}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int a;
    string s, t;
    cin >> s >> t;

    int ans = 0;

    rep(i, s.size()) {
        if (s[i] != t[i])
            ans++;
    }

    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3924
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

int main(){

    int a,b;
    cin>>a>>b;

    if(a>=13) cout<<b<<endl;
    else if(a>=6) cout<<b/2<<endl;
    else cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
	  cout<<'a'<< " < "<<'b'<<endl;
	}else if(a>b){cout<<'a'<<" > "<<'b'<<endl;
	}else{cout<<'a' <<" == "<<'b'<<endl;}
	
}


Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C;
    while(scanf("%d %d %d",&A,&B,&C)!=EOF)
    {
        if(C>=A && C<=B)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;


        }
    }
    return 0;
}

Measured memory_bytes: 256
s = list(input())
mod = 1000000007
c = [1] + [0] * 3
for i in s:
    if i == 'A':
        c[1] = (c[1] + c[0]) % mod
    elif i == 'B':
        c[2] = (c[2] + c[1]) % mod
    elif i == 'C':
        c[3] = (c[3] + c[2]) % mod
    else:
        c[3] = (c[3] * 3 + c[2]) % mod
        c[2] = (c[2] * 3 + c[1]) % mod
        c[1] = (c[1] * 3 + c[0]) % mod
        c[0] = c[0] * 3 % mod
print(c[3])

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

int solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}

int solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  // lcmの素因数get
  map<int, int> mp;
  rep(i, n) {
    int A = a[i];
    for (int j = 2; j * j <= A; ++j) {
      int cnt = 0;
      while (A % j == 0) {
        A /= j;
        ++cnt;
      }
      chmax(mp[j], cnt);
    }
    chmax(mp[A], 1);
  }

  ll L = 1;
  for (auto e : mp) (L *= modpow(e.F, e.S)) %= mod;
  ll ans = 0;
  // L / a[i]
  rep(i, n) (ans += L * modpow(a[i], mod - 2) % mod) %= mod;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  while (a > 0 || c > 0) {
    c = c-b;
    if(c<=0) {
      std::cout << "Yes" << '\n';
      break;
    }
    a = a-d;
    if(a<=0) {
      std::cout <<"No"<< '\n';
      break;
    }
  }
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	int a, b; std::cin >> a >> b;
	if (a <= 9 && b <= 9)
		std::cout << a * b << "\n";
	else
		std::cout << -1 << "\n";
}


Measured memory_bytes: 256
n, a, b = gets.split.map(&:to_i)
all = 0

(1..n).each do |i|
  if (a <= i.to_s.split('').map(&:to_i).inject(:+)) && (b >= i.to_s.split('').map(&:to_i).inject(:+))
    all = all + i
  end
end


puts all

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n);
  Cins(int, n, v);
  sort(rng(v));

  double ans = v[0];
  for (int i = 1; i < n; ++i) ans = (ans + v[i]) / 2.;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[11114514];
signed main()
{
	int cnt = 0;
	int n;
	cin >> n;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=2; i<=n; i++)
	{
		int added = a[i-1] - a[i];
		if(added < 0) added = 0;
		a[i] += added;
		cnt += added;
	}
	cout << cnt;
	return 0;
}


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

typedef long long ll;

int is(int x, int y)
{
  if((x ^ y) == (x + y)) return 1;
  else return 0;
}

int main()
{
  ll n, a[200000];

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  ll l, r;
  ll sum = 0;
  ll ans = 0;
  l = r = 0;

  while(r != n){
    while(is(sum, a[r])){
      sum += a[r];
      r++;
      ans += r - l;
      if(r == n) break;
    }

    sum -= a[l];
    l++;
  }
  
  cout << ans << endl; 

  return 0;
}


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

int main(){
  int dp[21][50001]={0},y[21]={0},n,m,a;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    cin>>y[i];
  }
  for(int i=0;i<=n;i++)dp[0][i]=50050;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(j-y[i]>=0)dp[i][j]=min(dp[i-1][j],dp[i][j-y[i]]+1);
      else dp[i][j]=dp[i-1][j];
    }
  }
  
  /*for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      cout<<dp[i][j]<<" ";	  
    }
    cout<<endl;
  }/////////////*/
  
  cout<<dp[m][n]<<endl;
  return 0;
}

Measured memory_bytes: 7204
import sys
import math
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
import numpy as np
from array import array

# sys.setrecursionlimit(10**6)
# input = sys.stdin.buffer.readline

MAX_INT = 2**62-1
MOD = 10**9 + 7


if __name__ == "__main__":
    n, m, s = map(int, input().split())
    cost = {}
    time = {}
    g = defaultdict(list)

    for _ in range(m):
        u, v, a, b = map(int, input().split())
        cost[u, v] = cost[v, u] = a
        time[u, v] = time[v, u] = b
        g[u].append(v)
        g[v].append(u)

    for i in range(1, n+1):
        c, d = map(int, input().split())
        cost[i, i] = -c
        time[i, i] = d
        g[i].append(i)

    max_money = n * 50
    s = min(max_money, s)
    pq = [(0, 1, s)]
    time_usage = [[float('inf')] * (max_money+1) for _ in range(n+1)]
    time_usage[1][s] = 0

    while pq:
        t, cur, money = heappop(pq)
        if t > time_usage[cur][money]:
            continue
        for nxt in g[cur]:
            nt = t + time[cur, nxt]
            nm = min(money - cost[cur, nxt], max_money)
            if nm >= 0 and nt < time_usage[nxt][nm]:
                time_usage[nxt][nm] = nt
                heappush(pq, (nt, nxt, nm))

    for ts in time_usage[2:]:
        print(min(ts))


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

#define ll long long
#define sz(x) (int)x.size();

using namespace std;

int n,x;
string s;
vector<pair<string,pair<int,int>>>v;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s>>x;
		v.push_back({s,{-x,i+1}});
	}
	sort(v.begin(), v.end());
	for(auto i:v){
		cout<<i.second.second<<'\n';
	}
}


Measured memory_bytes: 3604
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

s = sum(A)
for i in range(N):
    m = min(A[i], B[i])
    A[i]-=m
    A[i+1]-=min(A[i+1], (B[i]-m))
    
print(s-sum(A))

Measured memory_bytes: 19116
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,d;

    cin >> d >> n;

    LL result = 1;

    for(int i = 0; i < d; i++){
        result *= 100;
    }
    

    if(n == 100){
        cout << result * (n+1) << endl;
    }else{
        cout << result * n << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
$W = trim(fgets(STDIN));
$arrayW = explode(' ', $W);

$S1 = array_sum($arrayW);
$S2 = 0;
$abs = abs($S1 - $S2);

for ($i = $N - 1; $i >= 0; $i--) {
  $tmp = $arrayW[$i];
  $S1 -= $tmp;
  $S2 += $tmp;
  $tmpAbs = abs($S1 - $S2);
  if ($abs <= $tmpAbs) {
    break;
  } else {
    $abs = $tmpAbs;
  }
}
print $abs;

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
string n;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n;
  if(n == "ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    int one = 0, two = 0, four = 0;
    REP(i, n) {
        if (a[i] % 4 == 0) four++;
        else if (a[i] % 2 == 0) two++;
        else one++;
    }
    if (two == 0 && four + 1 >= one) cout << "Yes" << endl;
    else if (four >= one) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include<cstdio>
using namespace std;
bool a[1000010];
int b[1010];
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> b[i];
    }
    int t=0;
    for (int i=1;i<=n;i++)
    {
       // cout<<i<<" "<<t<<" "<<"dd"<<endl;
        t=0;
        for (int j=i;j<=i+4&&j<=n;j++)
        {
            t=(t*10+b[j]);
            a[t]=1;
            //cout<<t<<endl;
        }
    }
    //cout<<"defee"<<endl;
    for (int i=0;i<=n*n;i++)
    {
        if (!a[i]) {printf("%d\n",i);return 0;}
    }

}

Measured memory_bytes: 3320
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int h, n, a, sum = 0;
    cin >> h >> n;
    bool win = false;
    rep(i, n) {
        cin >> a;
        sum += a;
        if (sum >= h) {
            win = true;
            break;
        }
    }
    cout << (win ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

H.append(10**10) 
r, ans = 0, 0
for l in range(N):
    while r < N and H[r] >= H[r+1]:
        r += 1
    ans = max(ans, r-l)
    if l == r:
        r += 1
        l += 1
print(ans)

Measured memory_bytes: 20444
H, W = map(int, input().split())
s = []
for i in range(H):
    s.append(input())
ans = 0
ls = [[0 for i in range(W)] for j in range(H)]
for i, x in enumerate(s):
    cur = 1
    for j, y in enumerate(x):
        if y == '.':
            ls[i][j] += cur
            cur += 1
        else:
            ls[i][j] = 0
            cur = 1
    cur = 1
    for j, y in enumerate(x[::-1]):
        if y == '.':
            ls[i][W-j-1] += cur
            cur += 1
        else:
            ls[i][W-j-1] = 0
            cur = 1
for i in range(W):
    cur = 1
    for j in range(H):
        if s[j][i] == '.':
            ls[j][i] += cur
            cur += 1
        else:
            ls[j][i] = 0
            cur = 1
    cur = 1
    for j in range(H):
        if s[H-j-1][i] == '.':
            ls[H-j-1][i] += cur
            cur += 1
        else:
            ls[H-j-1][i] = 0
            cur = 1
for x in ls:
    for y in x:
        ans = max(ans, y)
print(ans-3)

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

bool isKaibun(string str){
    int len = str.length();
    int n = len/2;

    for(int i=0;i<n;i++){
        if(str[i]!=str[len-1-i]){
            return false;
        }
    }

    return true;

}

int main() {
    
    string S;
    
    // input
    cin >> S;
    int N = S.length();
    bool ans=true;

    //jouken1
    ans = ans && isKaibun(S);
    //jouken2
    ans = ans && isKaibun(S.substr(0,(N-1)/2));

    //output
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#B問題
A=[int(input()) for i in range(5)]
a=[]
for i in range(5):
    ain = A[i]%10
    if ain == 0:
        ain+=10
    a.append(ain)
MINA=min(a)
if MINA == 10:
    print(sum(A))
else:
    flag=0
    ans=0
    for i in range(5):
        if A[i]%10==MINA and flag == 0:
            flag=1
            ans+=A[i]
        else:
            if A[i]%10==0:
                ans+=A[i]
            else:
                ans+=(A[i]+10-A[i]%10)
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int solve(vector<vector<int> >& b, vector<vector<long long> >& f)
{
    int n = b.size();
    vector<bool> check(n, false);

    long long ret = 1;
    for(int i=0; i<n; ++i){
        if(check[i])
            continue;

        int prev = i;
        int j = b[i][0];
        long long maxCost = f[i][0];
        int num = 1;
        for(;;){
            check[j] = true;
            if(j == i)
                break;
            long long cost;
            int next;
            if(b[j][0] != prev){
                cost = f[j][0];
                next = b[j][0];
            }else{
                cost = f[j][1];
                next = b[j][1];
            }

            if(cost == maxCost){
                ++ num;
            }else if(cost > maxCost){
                maxCost = cost;
                num = 1;
            }
            prev = j;
            j = next;
        }
        ret *= num;
        ret %= 10007;
    }
    return ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;
        vector<vector<int> > b(n, vector<int>(2));
        vector<vector<long long> > f(n, vector<long long>(2));
        for(int i=0; i<n; ++i)
            cin >> b[i][0] >> f[i][0] >> b[i][1] >> f[i][1];
        cout << solve(b, f) << endl;
    }
}

Measured memory_bytes: 1044
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ll q, h, s, d, n,p[4],sum =0;cin >> q >> h >> s >> d >> n;
	if (n == 1) {
		q = min(q * 4, h * 2);
		cout << min(q, s)<< endl;
	}
	else {
		p[0] = 8 * q, p[1] = h * 4, p[2] = s * 2;p[3] = d;
		sort(p, p + 4);
		sum = (n / 2) * p[0];
		q = min(q * 4, h * 2);
		sum += min(q, s) * (n % 2);
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 3592
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<set>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#define mp make_pair
using namespace std;
typedef long long ll;
inline ll in()
{
    ll res=0,p=1;
    char c=getchar();
    while(c<'0'||c>'9') {if(c=='-') p=-1; c=getchar();}
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return p*res;
}
void out(ll x)
{
    if (x>9) out(x/10);
    putchar(x%10+48);
}
void outn(ll x)
{
    if (x<0){
        putchar('-');
        out(-x);
    }else out(x);
    putchar(10);
}
const int mod = 1e9 + 7, inf = 0x3f3f3f3f;
//const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll quickpow(ll x, ll k)
{
    ll res = 1;
    while(k){
        if(k & 1) res = (res * x) % mod;
        k >>= 1, x = (x * x) % mod;
    }
    return res;
}

const int maxn = 1e5 + 5;
int par[maxn], r[maxn];
int findp(int x)
{
    if (par[x] < 0) return x;
    else{
        int fx = findp(par[x]);
        r[x] = (r[x] + r[par[x]]) % 2;
        par[x] = fx;
    }
}
void unite(int x, int y)
{
    int fx = findp(x), fy = findp(y);
    if (fx != fy){
        r[x] = (r[x] - r[y] + 1) % 2;
        par[fy] = fx;
    }
}
bool same(int x, int y){return findp(x) == findp(y);}
int no[15];
bool check(int x)
{
    while (x){
        if (no[x % 10]) return 1;
        x /= 10;
    }
    return 0;
}
int main()
{
    int n, k, x;
    cin >> n >> k;
    for (int i = 0; i < k; ++i){
        cin >> x;
        no[x] = 1;
    }
    int ans = n;
    while (check(ans)) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vl = vector<ll>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using vs = vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.141592653589793

template<class S, class T>ostream&operator<<(ostream&os, pair<S, T>p)
{
	os << "[" << p.first << "," << p.second << "]"; return os;
}
template<class S>auto&operator<<(ostream&os, vector<S>t)
{
	bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; }
	return os;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	while (cin >> h>>w, h) {
		vvi f(h, vi(w));
		vvi fsum(h+1, vi(w+1,0));
		rep(i, h)rep(j, w)cin >> f[i][j];
		int MIN[10][10][10][10];
		int MAX[10][10][10][10];
		rep(i, 10)rep(j, 10)rep(k, 10)rep(l, 10)MIN[i][j][k][l] = 0;
		rep(i, 10)rep(j, 10)rep(k, 10)rep(l, 10)MAX[i][j][k][l] = 0;
		rep(i, h)rep(j, w) {
			MIN[i][j][i][j] = f[i][j];
			MAX[i][j][i][j] = f[i][j];
			fsum[i + 1][j + 1] = f[i][j];
		}
		range(i,0, h + 1)range(j, 1, w + 1)fsum[i][j] += fsum[i][j - 1];
		range(i,1, h + 1)range(j, 0, w + 1)fsum[i][j] += fsum[i-1][j];
		//for (auto l : fsum)cout << l << endl;

		range(ylen,0,  h) rep(y, h - ylen ) {
			range(xlen,0, w ) rep(x, w - xlen) {
				if (ylen + xlen == 0)continue;
				//cout << pii(y, x) << "," << pii(y + ylen, x + xlen) << ":";
				if (ylen != 0) {
					MIN[y][x][y + ylen][x + xlen] = min(MIN[y][x][y + ylen - 1][x + xlen], MIN[y + ylen][x][y + ylen][x + xlen]);
					MAX[y][x][y + ylen][x + xlen] = max(MAX[y][x][y + ylen - 1][x + xlen], MAX[y + ylen][x][y + ylen][x + xlen]);
				}
				else {
					MIN[y][x][y + ylen][x + xlen] = min(MIN[y][x][y + ylen][x + xlen - 1], MIN[y + ylen][x + xlen][y + ylen][x + xlen]);
					MAX[y][x][y + ylen][x + xlen] = max(MAX[y][x][y + ylen][x + xlen - 1], MAX[y + ylen][x + xlen][y + ylen][x + xlen]);
				}
			}
		}
		int ans = 0;
		rep(ay, h)rep(ax, w)range(by,ay+2, h)range(bx,ax+2, w) {
			int inner = MAX[ay+1][ax+1][by-1][bx-1];
			int outer = INF;
			outer = min(outer, MIN[ay][ax][ay][bx]);
			outer = min(outer, MIN[ay][ax][by][ax]);
			outer = min(outer, MIN[ay][bx][by][bx]);
			outer = min(outer, MIN[by][ax][by][bx]);
			//cout << pii(ay, ax) << pii(by, bx) << outer << "," << inner << endl;
			if (outer > inner) {
				int high = fsum[by][bx] + fsum[ay + 1][ax + 1] - fsum[by][ax + 1] - fsum[ay + 1][bx];
				ans = max(ans, (by-ay-1)*(bx - ax - 1)*outer-high);
				//cout << pii(by, bx) << pii(ay, ax) << "=" << fsum[by][bx] + fsum[ay + 1][ax + 1] - fsum[by][ax + 1] - fsum[ay + 1][bx] << endl;
			}
		}
		cout << ans << endl;
		//cout << "=====" << endl;
	}
	return 0;
}


Measured memory_bytes: 3216
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String,Integer> map = new HashMap<String,Integer>();
        String temp = sc.nextLine();

        String[] tempArr = temp.split(" ");
        int N = Integer.parseInt(tempArr[0]);
        int M = Integer.parseInt(tempArr[1]);

        for (int m = 0; m < M; m++) {
            map.put((m + 1) + "", 0);
        }

        for (int n = 0; n < N; n++) {
            temp = sc.nextLine();
            tempArr = temp.split(" ");
            int K = Integer.parseInt(tempArr[0]);
            for (int k = 1; k <= K; k++) {
                map.put(Integer.parseInt(tempArr[k]) + "", map.get(Integer.parseInt(tempArr[k]) + "") + 1);
            }
        }

        int count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            if (entry.getValue() == N) {
                count++;
            }
        }

        System.out.println(count);


    }

}


Measured memory_bytes: 21716
#include <stdio.h>

int gcd(int,int);

int main(){
  int x,y;
  
  scanf("%d%d",&x,&y);
  
  if(x < 1 || y < 1)return 0;

  printf("%d\n",gcd(x,y));
 
  return 0;
}

int gcd(int x,int y){

int a,b,c;
 if(x > y){
    a = x%y;
    b = y;
  }
  else if(x < y){
    a = y%x;
    b = x;
  }
  else {
    a = x;
   return a;
  }

  while(a != 0){
    c = a;
    a = b%a;
    b = c;
  }
   return b;
 }




Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
char s[10][10];

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt","w",stdout);
    for(int i = 0; i < 3; i ++)
        scanf("%s", s[i]);
    printf("%c%c%c\n", s[0][0], s[1][1], s[2][2]);
    return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		
		int[][] a = new int[n][m];
		int[][] b = new int[m][l];
		
		for(int ar = 0; ar < n; ar++) {
			for(int ac = 0; ac < m; ac++) {
				a[ar][ac] = sc.nextInt();
			}
		}
		
		for(int br = 0; br < m; br++) {
			for(int bc = 0; bc < l; bc++) {
				b[br][bc] = sc.nextInt();
			}
		}
		
		for(int cr = 0; cr < n; cr++) {
			for(int cc = 0; cc < l; cc++) {
				long i = 0;
				for(int ca = 0; ca < m; ca++) {
					i += a[cr][ca] * b[ca][cc];
				}
				if(cc != 0) {
					System.out.print(" ");
				}
				System.out.print(i);
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 56436
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int p[100000];
  int j[100000];
  long long ans;
  long long len;
  long long num;

  cin >> n;
  while(n != 0){
    len = 0;
    num = n;
    for(int i = 0;i < n;i++){
      cin >> p[i];
      len += p[i];
    }
    ans = len * num;
    
    for(int i = 0;i < n - 1;i++){
      cin >> j[i];
    }

    sort(p, p + n);
    sort(j, j + (n - 1));
    reverse(p, p + n);
    reverse(j, j + (n - 1));

    for(int i = 0;i < n - 1;i++){
      if((len + j[i]) * (num - 1) > ans){
	ans = (len + j[i]) * (num - 1);
	len += j[i];
	num --;
      }
    }

    cout << ans << endl;
    cin >> n;
  }
  return 0;
}




Measured memory_bytes: 3548
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>

using namespace std;

inline void read(int &x)
{
    int s = 0, w = 1;
    char c = getchar();
    while(!isdigit(c)){if(c == '-')w = -1; c = getchar();}
    while(isdigit(c)){s = (s << 3) + (s << 1) + c - '0', c = getchar();}
    x = s * w;
}

typedef long long ll;
#define rg register int

const int N = 200010;

int n, a, b, c, d;
char s[N];
bool v[N];

int main()
{
    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
    scanf("%s", s + 1);
    if(s[a] == '#' || s[b] == '#' || s[c] == '#' || s[d] == '#')
        return puts("No"), 0;
    for (rg i = a; i < c; i++)
        if(s[i] == '#' && s[i + 1] == '#')
            return puts("No"), 0;
    for (rg i = b; i < d; i++)
        if(s[i] == '#' && s[i + 1] == '#')
            return puts("No"), 0;
    if(c < d)return puts("Yes"), 0;
    bool fla = 0;
    for (rg i = b - 1; i <= d + 1; i++)
        v[i] = (s[i] == '.');
    for (rg i = 1; i <= n - 2; i++)
        if(v[i] && v[i + 1] && v[i + 2])
            return puts("Yes"), 0;
    puts("No");
    return 0;
}

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

using namespace std;

const int maxn = 2e5 + 5;

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

int n, q;
char t[maxn], d[maxn];
string s;

int cal(int u) {
	rep(i, 0, q) {
		if (u == -1 || u == n) return u;
		if (t[i] == s[u]) {
			if (d[i] == 'L') {
				u--;
			} else {
				u++;
			}
		}
	}
	return u;
}

int main() {
	cin >> n >> q;
	
	cin >> s;
	
	rep(i, 0, q) {
		cin >> t[i] >> d[i];
	}
	
	int l = 0, r = n - 1, found1 = -1, found2 = n;
	
	while (l <= r) {
		int m = (l + r) >> 1;
		int pos = cal(m);
		if (pos == -1) {
			found1 = m;
			l = m + 1;
		} else {
			r = m - 1;
		}
	}
	
	l = 0, r = n - 1;
	
	while (l <= r) {
		int m = (l + r) >> 1;
		int pos = cal(m);
		if (pos == n) {
			found2 = m;
			r = m - 1;
		} else {
			l = m + 1;
		}
	}
	
	int ans = n - (found1 + 1) - (n - found2);
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 900
#include<stdio.h>
int main(void)
{
  int i,j,k;
  while(1){
    scanf("%d %d",&j,&k);
    if(j==0&&k==0)break;
    if(j>k)printf("%d %d\n",k,j);
    else printf("%d %d\n",j,k);
  }
  return 0;
}



Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1000000007;

int32_t main()
{
   string s1,s2;
   cin>>s1>>s2;
   cout<<s2+s1<<endl;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
	ll n,m; cin>>n>>m;
	ll count=0;
	map<ll,ll> mp,mp1;
	map<ll,ll> :: iterator it;
	for(ll i=0;i<m;i++) {
		ll p; cin>>p;
		string s; cin>>s;
		if(mp.find(p)==mp.end()) {
			if(s[0]=='W') mp1[p]++;
			else mp[p]++;
		}
	}
	for(it=mp.begin();it!=mp.end();it++) {
		count+=mp1[it->first];
	}
	cout<<mp.size()<<" "<<count<<endl;
	return 0;
}

Measured memory_bytes: 12800
import numpy as np
N = int(input().strip('\n'))
T,A = [int(x) for x in input().strip('\n').split(' ')]
H = np.array([int(x) for x in input().strip('\n').split(' ')])
H = T-0.006*H
H_res = np.abs(H-A)
print(int(np.argmin(H_res))+1)

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int a = Integer.parseInt(input.readLine());
        int b = Integer.parseInt(input.readLine());
        int h = Integer.parseInt(input.readLine());

        System.out.println((a+b)*h/2);
    }
}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
ll dp[1000006];
int main()
{
    fast;
    int n,k;
    cin>>n>>k;
    ll a[n+3];
    for(int i=0;i<n;i++)cin>>a[i];
    int i=0;
    for(;i<=k && i<a[0];i++)dp[i]=2;
    // 2 -> no more move possible
    for(;i<=k;i++)
    {
        int j=0,f=1;
        for(;j<n;j++)
        {
            if(i>=a[j] && dp[i-a[j]] == 2){
                dp[i]=1;
                break;
            }
        }
        if(j==n)
        {
            dp[i]=2;
        }
    }
    if(dp[k]==2) cout<<"Second";
    else cout<<"First";
return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // int H = sc.nextInt();
    // int W = sc.nextInt();
    int[] H;
    int[] W;
    int num = 0;
    H = new int[300];
    W = new int[300];
    for (int i = 0; i < 300; i++) {
      H[i] = sc.nextInt();
      W[i] = sc.nextInt();
      if (H[i] == 0 && W[i] == 0) {
        num = i;
        break;
      }
    }
    for (int k = 0; k < num; k++) {
      for (int i = 0; i < W[k]; i++) {
        System.out.printf("#");
      }
      System.out.printf("\n");
      for (int i = 0; i < H[k] - 2; i++) {
        System.out.printf("#");
        for (int j = 0; j < W[k] - 2; j++) {
          System.out.printf(".");
        }
        System.out.printf("#");
        System.out.printf("\n");
      }
      for (int i = 0; i < W[k]; i++) {
        System.out.printf("#");
      }
      System.out.printf("\n");
      System.out.printf("\n");
    }
  }
}


Measured memory_bytes: 57664
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

int main(){
    set<int> a, b, c;
    int n, m, x;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        a.insert(x);
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> x;
        b.insert(x);
    }

    set_intersection(a.begin(), a.end(), b.begin(), b.end(), inserter(c, c.end()));

    for(int x : c)  printf("%d\n", x);

    return 0;
}


Measured memory_bytes: 23832
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  cin >> n ;
  vector<int> p(n) ;
  
  for(int i=0;i<n;i++)
    cin >>  p[i] ;
  
  sort(p.begin(), p.end(), greater<int>());
  
  p[0] = p[0]/2 ;
  int sum = 0 ;
  
  for(int i=0;i<n;i++){
    sum += p[i] ;
  }

  cout << sum << endl;
  

}


Measured memory_bytes: 256
N=gets.chomp.to_i
S=N.times.map { gets.chomp }
a=Hash.new(0)
S.each do |i|
  a[i.to_sym]+=1
end
m=a.max{ |x, y| x[1] <=> y[1] }
n=0
m.each do |i|
  n=i
end
b=[]
a.each do |i,j|
  if j==n then
    b.push(i.to_s)
  end
end
puts b.sort!

Measured memory_bytes: 87272