akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int dp[1<<18][51];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n),b(n);
    cin >> a >> b;
    rep(i,1<<18) rep(j,51) dp[i][j] = inf;
    dp[0][0] = 0;
    rep(bit,1<<n) rep(i,51) {
        if(dp[bit][i] == inf) continue;
        int k = __builtin_popcount(bit);
        int cnt = 0;
        rrep(j,n) {
            if(bit>>j&1) {
                cnt++;
                continue;
            }
            int nx = (abs(k-j)%2 == 0 ? a[j] : b[j]);
            if(nx >= i) chmin(dp[bit|1<<j][nx],dp[bit][i]+cnt);
        }
    }
    int m = *min_element(dp[(1<<n)-1],dp[(1<<n)-1]+51);
    cout << (m == inf ? -1 : m) << endl;
}


Measured memory_bytes: 55900
#include <iostream>
using namespace std;
int main(void)
{
    int N, loop, student[100000];
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> loop;
        student[loop-1] = i;
    }
    cout << student[0];
    for(int i = 1; i < N; i++){
        cout << " " << student[i];
    }
    cout << "\n";
}

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

int main() {
  int N;
  cin >> N;
  N *= 2;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N; i += 2) {
    ans += min(L[i], L[i+1]);
  }
  cout << ans << endl;
}

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

int main(){
  int w,h;
  int nums[26] = {0};

  string result = "Yes";

  cin >> h >> w;

  int onecount = h%2 * w%2;
  int twocount = (h%2) * w / 2 + (w%2) * h / 2;

  for(int i = 0;i < h;i++){
    string s;
    cin >> s;

    for(int j = 0;j < w;j++){
      int asciinumber = s[j] - 'a';
      if(asciinumber >= 0 && asciinumber <= 25){
	nums[asciinumber]++;
      }
    }
  }

  for(int i = 0; i < 26;i++){
    switch(nums[i] % 4){
    case 0:
      break;
    case 1:
      onecount -= 1;
      break;
    case 2:
      twocount -= 1;
      break;
    case 3:
      onecount -= 1;
      twocount -= 1;
      break;
    default:
      break;
    }
    if(onecount < 0 || twocount < 0){
      result = "No";
      break;
    }
  }

  if(result == "Yes"){
    if(onecount != 0)result = "No";
  }

  cout << result << endl;

  return 0;
}


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

#define ll long long int

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll unit = 1, length = s.length(), r = 0, sum = 0;
  vector<ll> remainder(2019, 0);
  remainder[0]++;
  reverse(s.begin(), s.end());
  for (ll i = 0; i < length; i++){
    r = ((s[i] - '0') * unit + r) % 2019;
    sum += remainder[r];
    remainder[r]++;
    unit = unit * 10 % 2019;
  }
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 3664
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		List<String> alphabetList = Arrays.asList("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
		int n = sc.nextInt();
		String[] inputArray = sc.next().split("");
		StringBuilder answer = new StringBuilder();
		int index =0;
		for(int i= 0;i < inputArray.length;i++) {
			index =  alphabetList.indexOf(inputArray[i]);
			index += n;
			if(index >=26) {
				index -= 26;
			}
			answer.append(alphabetList.get(index));
		}

		System.out.println(answer);

	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=1e5+10;
const int M=500;
const int mod=998244353;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

void inc(int &a,int b) {
	a=a+b>=mod?a+b-mod:a+b;
}

int pw[N],n;

struct graph {
	vi E[N];
	int vis[N],sg[N];

	void adde(int u,int v) {
		E[u].pb(v);E[v].pb(u);
	}

	vi cal() {
		int m=gi();
		vi ret;
		for(int i=1,u,v;i<=m;i++) u=gi(),v=gi(),adde(u,v);
		for(int u=n;u;u--) {
			for(auto v:E[u]) if(u<v) vis[sg[v]]=u;
			for(int i=0;;i++)
				if(vis[i]!=u) { sg[u]=i;break; }
			while(sz(ret)<=sg[u]) ret.pb(0);
			inc(ret[sg[u]],pw[u]);
		}
		return ret;
	}
} G1,G2,G3;

int main() {
	pw[0]=1;
	pw[1]=1;for(int i=1;i<=18;i++) pw[1]=10ll*pw[1]%mod;
	for(int i=2;i<N;i++) pw[i]=1ll*pw[i-1]*pw[1]%mod;
	cin>>n;
	vi v1=G1.cal(),v2=G2.cal(),v3=G3.cal();
	int ans=0;
	for(int i=0;i<sz(v1);i++)
		for(int j=0;j<sz(v2);j++) {
			int k=i^j;
			if(k<sz(v3)) inc(ans,1ll*v1[i]*v2[j]%mod*v3[k]%mod);
		}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 18048
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int A[] = new int[N];
		int Asum = 0; //そう得票
		int yes =0;
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextInt();
			Asum  += A[i];
		}
		for (int i = 0; i < A.length; i++) {
			if((double)A[i]>=(double)Asum/(4*M)){
				yes++;
			}
		}
		if (yes>=M) {
			System.out.println("Yes");	
		} else {
			System.out.println("No");
		}
		sc.close();
    }
		
		
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, L, R;
	cin >> n >> L >> R;
	swap(L,R);

	vl p(n+2);
	FOR(i,1,n+1) cin >> p[i];
	p[n+1] = n+1;
	n += 2;

	vl dp(n);
	vl inv(n);

	FOR(i,1,n) {
		FOR(j,0,i) if (p[j] > p[i]) inv[j]++;
		
		dp[i] = oo;
		ll cntR = 0;
		FORD(j,0,i) {
			if (p[j] > p[i]) {
				cntR++;
			} else {
				ll cntL = (i-j-1) - cntR; //inv[j];
				dp[i] = min(dp[i], dp[j] + cntL*L + cntR*R);
			}
		}	
	}
	cout << dp[n-1] << endl;
}



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

int main(){
  int n,i;
  cin >> n;
  vector<pair<ll,ll>> p(n);
  for(i=0;i<n;i++){
    cin >> p.at(i).second >> p.at(i).first;
  }
  
  sort(p.begin(),p.end());
  ll t=0;
  for(i=0;i<n;i++){
    t += p.at(i).second;
    if(t>p.at(i).first){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string S;
    cin >> S;

    vector<int> vec(26, 0);

    if (S.size() == 26) {
        if (S == "zyxwvutsrqponmlkjihgfedcba") {
            cout << -1 << endl;
            return 0;
        }
        string T = S;
        next_permutation(ALL(S));
        string ans = "";
        // cout << S << endl;
        
        for(int i = 0; i < S.size(); i++) {
            ans += S[i];
            if (S[i] > T[i]) {
                break;
            }
        }
        cout << ans << endl;
        return 0;
    }

    for(int i = 0; i < S.size(); i++) {
        vec[S[i] - 'a']++;
    }

    char ans;
    for(int i = 0; i < 26; i++) {
        if (vec[i] == 0) {
            ans = 'a' + i;
            break;
        }
    }
    cout << S << ans <<endl;


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

Measured memory_bytes: 256
# 入力xyz
# ["a", "x", "y"]
a = gets.chomp.split("").sort!.join
b = gets.chomp.split("").sort.reverse!.join

# ["axy", "ayx", "xay", "xya", "yax", "yxa"]
# arry = a.permutation(a.length).collect {| tmpa | tmpa.join }
# brry = b.permutation(b.length).collect {| tmpb | tmpb.join }
# result = arry.product(brry).collect {|seta, setb| seta < setb }

if a < b
    puts 'Yes'
else
    puts 'No'
end

Measured memory_bytes: 3836
#include <iostream>

using namespace std;

const int limit = 1000001;
int a[limit];
bool visited[limit];
int cnt = 0;

void dfs (int v1);

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

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

    dfs(1);
    cout << ((visited[2])? cnt: -1) << endl;

    return 0;
}

void dfs (int v1)
{
    visited[v1] = true;
    if (v1 == 2) {
        return;
    }
    cnt++;
    
    int v2 = a[v1];
    if (visited[v2]) {
        return;
    }
    dfs(v2);
}

Measured memory_bytes: 768
//
//  main.cpp
//  2584 Broken Cipher Generator
//
//  Created by 13B15237 on 2015/06/18.
//  Copyright (c) 2015??´ 13B15237. All rights reserved.
//

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int getRevEndPos(string str) {
    int indent = 0;
    for (int i = 1; i < str.length(); ++i) {
        if (str[i] == '[') {
            ++indent;
        }
        else if (str[i] == ']') {
            if (!indent) return i;
            else --indent;
        }
    }
    
    return 0;
}

string decode(string cipher, bool reverse)
{
    if (cipher.empty()) return cipher;
    
    if (cipher[0] == '[') {
        int end = getRevEndPos(cipher);
        string c1 = cipher.substr(1, end - 1);
        string c2 = cipher.substr(end + 1, cipher.size());
        
        string d1 = decode(c1, !reverse);
        string d2 = decode(c2, reverse);
        
        string d1rev(d1.rbegin(), d1.rend());
        
        return d1rev + d2;
    }
    
    int i = 0;
    int offset = 0;
    char ch;
    
    while (1) {
        if (cipher[i] == '+') {
            ++offset;
        }
        else if (cipher[i] == '-') {
            --offset;
        }
        else {
            ch = cipher[i];
            break;
        }
        ++i;
    }
    
    while (1) {
        if (offset < 0) offset += 26;
        else if (offset >= 26) offset -= 26;
        else break;
    }
    
    if (ch == '?') {
        ch = 'A';
    } else {
        ch = 'A' + (ch  - 'A' + offset) % 26;
    }
    
    string c1(" ");
    c1[0] = ch;
    string c2 = cipher.substr(i + 1, cipher.size());
    
    string d2 = decode(c2, reverse);
    
    return c1 + d2;
}

string str;

bool input() {
    cin >> str;
    if (str == ".") return false;
    
    return true;
}

bool solve() {
    cout << decode(str, false) << endl;
    return true;
}

int main(int argc, const char * argv[]) {
    while (input()) {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <ctype.h>

static int
mtoi (
  const char * s
  )
{
  int res = 0;
  int t = 1;

  for ( ; *s != '\0'; ++s )
  {
    if ( isdigit ( *s ) ) t = *s - '0';
    else
    {
      switch ( *s )
      {
        case 'm': t *= 1000; break ;
        case 'c': t *= 100;  break ;
        case 'x': t *= 10;   break ;
      }

      res += t;
      t = 1;
    }
  }

  return ( res );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int n;

  scanf ( "%d", &n );
  while ( n-- )
  {
    char s[ 2 ][ 1024 ];
    int  r[ 4 ];
    int  res;

    scanf ( " %s %s", s[ 0 ], s[ 1 ] );
    res = mtoi ( s[ 0 ] ) + mtoi ( s[ 1 ] );
    r[ 0 ] = res / 1000;
    r[ 1 ] = ( res % 1000 ) / 100;
    r[ 2 ] = ( res % 100 ) / 10;
    r[ 3 ] = res % 10;

    if ( r[ 0 ] )
    {
      if ( r[ 0 ] > 1 ) printf ( "%d", r[ 0 ] );
      printf ( "m" );
    }
    if ( r[ 1 ] )
    {
      if ( r[ 1 ] > 1 ) printf ( "%d", r[ 1 ] );
      printf ( "c" );
    }
    if ( r[ 2 ] )
    {
      if ( r[ 2 ] > 1 ) printf ( "%d", r[ 2 ] );
      printf ( "x" );
    }
    if ( r[ 3 ] )
    {
      if ( r[ 3 ] > 1 ) printf ( "%d", r[ 3 ] );
      printf ( "i" );
    }
    puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int cnt = 0;
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            // 奇数のみ
            if (i % 2 != 0) {
                for (int j = 1; j <= n; j++) {
                    if (i % j == 0) {
                        cnt++;
                    }
                }
                if (cnt == 8) list.add(1);
            }
            cnt = 0;
        }
        System.out.println(list.size());
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

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

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;
    cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No") << endl;
    return 0;
};

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

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

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

    ll tmp = 0;
    ll ans = 0;
    for (int i = n-1; i >= 0; --i) {
        if((a[i] + ans) % b[i] == 0) {
            tmp = 0;
        }else{
            tmp = b[i] - ((a[i] + ans) % b[i]);
        }
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
n = int(input())
x = list(map(int, input().split()))

mi = min(x)
ma = max(x)

a = 0
for i in range(mi, ma+1):
    s = 0
    for j in x:
        s += pow(j - i, 2)
    if a == 0:
        a = s
    else:
        a = min(a, s)
print(a)

Measured memory_bytes: 3060
n,k = map(int, input().split())
r,s,p = map(int, input().split())
T = list(input())

# restore
for i in range(n):
    if i >= k:
        if T[i] == T[i - k]:
            T[i] = '-'

# point sum
psum = 0
for i in range(n):
    if T[i] == 'r':
        psum = psum + p
    elif T[i] == 'p':
        psum = psum + s
    elif T[i] == 's':
        psum = psum + r
print(psum)


Measured memory_bytes: 4084
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

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")
}

fn main() {
    let n: u32 = read();

    let mut linked_list = VecDeque::<i32>::new();

    for _ in 0..n {
        let command: String = read();

        match command.as_ref() {
            "insert" => {
                let value: i32 = read();
                linked_list.push_front(value);
            }
            "delete" => {
                let value: i32 = read();
                match linked_list.iter().position(|&v| v == value) {
                    Some(index) => {
                        linked_list.remove(index).unwrap();
                    }
                    _ => {}
                };
            }
            "deleteFirst" => {
                linked_list.pop_front();
            }
            "deleteLast" => {
                linked_list.pop_back();
            }
            _ => {}
        }
    }

    let l = linked_list.len();
    for i in 0..l {
        if i != l - 1 {
            print!("{} ", linked_list[i]);
        } else {
            println!("{}", linked_list[i]);
        }
    }
}



Measured memory_bytes: 9964
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  co(N * 800 - (N / 15) * 200);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    char ca,cb,cc,cd;cin>>ca>>cb>>cc>>cd;
    int a=ca-'0', b=cb-'0', c=cc-'0', d=cd-'0';
    vector<vector<int>> v={{b,-b},{c,-c},{d,-d}};
    ll sum;
    REP(i,2){
        REP(j,2){
            REP(k,2){
                sum=a+v[0][i]+v[1][j]+v[2][k];
                if(sum==7){
                    string op1,op2,op3;
                    (i==0)?op1="+":op1="";
                    (j==0)?op2="+":op2="";
                    (k==0)?op3="+":op3="";
                    cout<<a<<op1<<v[0][i]<<op2<<v[1][j]<<op3<<v[2][k]<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
return 0;
}


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

int main()
{
    std::string in("");
    std::cin >> in;
    int count = 0;
    for (int ii = 0; ii < 3; ++ii)
    {
        if (in.compare(ii, 1, "1") == 0)
        {
            ++count;
        }
    }

    std::cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 
#define pb push_back 
#define mp make_pair 
#define P(a,b) pair<a,b> 
#define M(a,b) map<a,b> 
#define V(i) vector<i> 

using namespace std;

void test(){
	int n;
	cin>>n;
	int a[n];
	f(i,n)cin>>a[i];
	int count=0;
	int ma=a[0];
	f(i,n){
		if(a[i]<=ma)count++;
		ma=min(ma,a[i]);
	}
	cout<<count<<"\n";
}

int main(){
	int t=1;
//	cin>>t;
	while(t-->0){
		test();
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define vi  vector<int>
#define ii  pair<int,int>
#define x   first
#define y   second
#define all(x)  (x).begin(),(x).end()
using namespace std;
int logn = 1;
ii query(int cur, int dest, vector<vector<ii>> &stick){
    int sum = 0;
    for(int i = logn-1;i>=0;--i){
        if(dest - cur >= (1<<i)){
            sum += stick[cur][i].x;
            cur = stick[cur][i].y;
        }
    }
    return {sum, cur};
}

int32_t main() {
	int n,l, q; cin >> n;
	for(int i = n-1;i;i/=2) ++logn;
	vi arr(n);
	vector<vector<ii>> stick(n,vector<ii>(logn));
	for(auto &v:arr) cin >> v;
	cin >> l >> q;
	for(int i=0;i<n;i++){
	    stick[i][0] = {1, upper_bound(all(arr), arr[i] + l) - arr.begin() - 1};
	}
	for(int j=1;j<logn;j++){
	    for(int i=0;i<n;i++){
	        int tar = i+(1<<j);
	        if(tar > n-1) continue;
	        ii res = query(stick[i][0].y, tar, stick);
	        stick[i][j] = {stick[i][0].x + res.x, res.y};
	    }
	}
	for(int a,b;q--;){
	    cin >> a >> b; --a, --b;
	    if(b < a) swap(a,b);
	    cout << query(a,b,stick).x <<'\n';
	}
	cout <<endl;
	return 0;
}


Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
int frogrec(int n,int h[],int track[])
    {
        if (n==1)
        {
            track[0]=0;
            return(track[0]);
        }
        else if (n==2)
        {
            track[1]=abs(h[1]-h[0]);
            return(track[1]);
        }

        else if (track[n]!=0)
        {
            return(track[n]);
        }
        else
        {
            track[n]=min(abs(h[n-1]-h[n-2])+frogrec(n-1,h,track),abs(h[n-1]-h[n-3])+frogrec(n-2,h,track));
            return(track[n]);
        }
    }
int frog1(int n,int h[])
    {
        int track[n+1]={0};
        return(frogrec(n,h,track));

    }
int main()
    {
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    int track[n+1]={0};
    track[0]=0;
    track[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        int nb=max(i-k,0);
        int mini=abs(h[i]-h[i-1])+track[i-1];
        for(int j=nb;j<i;j++)
            {
            mini=min(abs(h[i]-h[j])+track[j],mini);
            }
        track[i]=mini;
    }
    cout<<track[n-1];
    return(0);
    }


Measured memory_bytes: 1024
n = gets.to_i
s1 = gets.strip.chars
s2 = gets.strip.chars

if n == 1
  puts 3
  exit
end

i = 0
while i < s1.size-1 do
  if s1[i] == s1[i+1]
    s1[i] = "x"
    s1.delete_at(i+1)
    if i == s1.size-2
      s1[i+1] = "o"
    end
  else
    s1[i] = "o"
    if i == s1.size-2
      s1[i+1] = "o"
    end
  end
  i += 1
end

if s1.size == 1
  puts 6
  exit
end

pro = 1
for i in 0..s1.size-2
  if s1[i] == "o" && s1[i+1] == "o"
    pro *= 2
  elsif s1[i] == "o" && s1[i+1] == "x"
    pro *= 2
  elsif s1[i] == "x" && s1[i+1] == "x"
    pro *= 3
  else
    next
  end
end

if s1[0] == "o"
  sta = 3
else
  sta = 6
end

puts (sta*pro)%(10**9+7)

Measured memory_bytes: 14312
#include<cstdio>
#include<iostream>
using namespace std;
int n,num[100005],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&num[i]);
	for(int i=1;i<=n;i++)
		if(num[i]==i) swap(num[i],num[i+1]),ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
using System;

namespace ABC095A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int i = 0;
            
            int price = 700;
            for ( i = 0; i < 3 ; i++)
            {
                if ( s.Substring(i, 1) == "o" )
                {
                    price += 100;
                }
            }

            Console.WriteLine(price);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        p(s);
    } else{
        p(s.substr(0, k) + "...");
    }

    return 0;
}


Measured memory_bytes: 3624
#A500, B100, C50, X
a, b, c = int(input())+1, int(input())+1, int(input())+1 
X = int(input())

#possible comb
import itertools 
coins_a, coins_b, coins_c = [], [], []
for i in range(a):
  coins_a.append(500*i)
for i in range(b):
  coins_b.append(100*i)
for i in range(c):
  coins_c.append(50*i)
coins = list(itertools.product(coins_a, coins_b, coins_c))

#assessment 
ttl = list(map(sum, coins))
result = []
for n in ttl:
  if n == X: result.append(1)
  else: result.append(0)

print(sum(result))

Measured memory_bytes: 19876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll N;
    cin>>N;
    vector<ll> ex(N+10, 0);
    if(N!=1){
    for (ll i=2; i<N+1; i++){
        ll onway=i; //途中の数
        for(ll a=2; a*a<=onway; a++){
            if(onway%a!=0)continue;
            while(onway%a==0){
                ex[a]++;
                onway/=a;
            }
        }
        if(onway!=1) ex[onway]++;
    }
    }
    if(N==1) cout<<1<<endl;
    else {
        ll count=1;
        for(ll i=2; i<=N; i++){
            if(ex[i]==0)continue;
            count*=ex[i]+1;
            count%=mod;
        }
        cout<<count<<endl;
    }

}

Measured memory_bytes: 3584
package main

import "fmt"

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func main() {
	// Code for A - ∴ (Therefore)
	var n int
	fmt.Scan(&n)
	a := n % 10
	switch a {
	case 2, 4, 5, 7, 9:
		fmt.Println("hon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	case 3:
		fmt.Println("bon")
	}
}


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


using namespace std;


typedef long long int lli;
typedef long double ld;


const int MAXN = 6001;


int A[MAXN], B[MAXN];
int memo[MAXN];



int main() {

  int N, T;
  scanf("%d%d", &N, &T);

  vector< pair<int, int> > ar(N);
  for (int n = 0 ; n < N ; n++) {
    scanf("%d%d", &A[n], &B[n]);
    ar[n] = {A[n], B[n]};
  }

  sort(ar.begin(), ar.end());
  for (int n = 0 ; n < N ; n++) {
    A[n] = ar[n].first;
    B[n] = ar[n].second;
  }



  int ans = 0;
  for (int n = 0 ; n < N ; n++) {
    for (int t = MAXN-1; t >= A[n] ; t--) {
      if (t - A[n] <= T-1) {
        ans = max(ans, memo[t-A[n]]+B[n]);
      }
      memo[t] = max(memo[t], memo[t-A[n]]+B[n]);
    }
  }
  ans = max(ans, memo[T-1]);

  printf("%d", ans);




  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  bool m[4][13]={};
  int n;
  cin>>n;
  for(int i=0;i<n;++i){
    int a;
    char c;
    cin>>c>>a;
    --a;
    if(c=='S') m[0][a]=1;
    else if(c=='H') m[1][a]=1;
    else if(c=='C') m[2][a]=1;
    else m[3][a]=1;
  }
  for(int i=0;i<13;++i) if(!m[0][i]) cout<<"S "<<i+1<<endl;
  for(int i=0;i<13;++i) if(!m[1][i]) cout<<"H "<<i+1<<endl;
  for(int i=0;i<13;++i) if(!m[2][i]) cout<<"C "<<i+1<<endl;
  for(int i=0;i<13;++i) if(!m[3][i]) cout<<"D "<<i+1<<endl;
}


Measured memory_bytes: 3012
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int M = sc.nextInt();
 
        int A[][] = new int[N][M];
        int B[] = new int[M];
 
        for(int row = 0; row < N; row++){
            for(int col = 0; col < M; col++){
                A[row][col] = sc.nextInt();
            }
        }
 
        for(int row = 0; row < M; row++){
            B[row] = sc.nextInt();
        }
 
        int ans;
 
        for(int row = 0; row < N; row++){
            ans = 0;
            for(int col = 0; col < M; col++){
                ans += A[row][col]*B[col];
            }
            System.out.printf("%d\n", ans);
        }
    }
}


Measured memory_bytes: 40288
#include <stdio.h>

int main()
{
	int i, n;
	long int a, min = 1000000, max = -1000000, sum = 0;

	scanf("%d", &n);

	for (i = 1; i <= n; i++)
	{
		scanf("%ld", &a);
		if (a < min)
			min = a;
		if (a > max)
			max = a;
		sum += a;
	}
	printf("%ld %ld %ld\n", min, max, sum);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    vector<int> cnt(n, 1);
    vector<bool> ball(n, false);
    ball[0]=true;
    while(m--){
        int x, y; cin>>x>>y;
        x--, y--;
        if(cnt[x]==1 && ball[x]){
            ball[x]=false;
            ball[y]=true;
        }
        else if(ball[x]){
            ball[y]=true;
        }
        cnt[x]--;
        cnt[y]++;
    }

    int ans=0;
    for(int i=0; i<n; i++){
        if(ball[i]) ans++;
    }
    cout << ans << endl;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

using namespace std;
ll power(ll a,ll n,int m)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
               {
                    result = result*a;
                    result=result%m;
               }
               a=a*a;
               a=a%m;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
void sieve(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
     prime[1]=false;
     prime[0]=false;
    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout<<p<<" ";
}
int main()
{
          ios_base::sync_with_stdio(0);
          cin.tie(0);

          int t=1;
          //cin>>t;
          while(t--)
          {
                    int n;
                    cin>>n;
                    ll ans=power(10,n,MOD);
                    ans = ((ans - 2LL*power(9,n,MOD))+MOD+MOD)%MOD;
                    ans = ans%MOD;
                    ans += power(8,n,MOD);
                    ans%=MOD;
                    cout<<ans;
          }
          return 0;
}


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
N=int(input())
red=[list(map(int,input().split())) for _ in range(N)]
blu=[list(map(int,input().split())) for _ in range(N)]

red.sort(key=lambda x:x[1],reverse=True)
blu.sort()
cnt=0
for b in blu:
    for r in red:
        #print(r,b)
        if r[0]<b[0] and r[1]<b[1]:
            cnt+=1
            r[0]=10000
            r[1]=10000
            break
print(cnt)
#print(blu)


Measured memory_bytes: 38768
//Author:PhilFan;
#include<bits/stdc++.h> 
using namespace std;
int h,w;
int cnt;
int main()
{
	scanf("%d %d",&h,&w);
	for(int i = 1; i <= h; i++){
		getchar();
		for(int j = 1; j <= w;j++){
			char ch = getchar();
			if(ch=='#') cnt++;
		}
	}
	puts ((cnt == h + w - 1) ? "Possible" : "Impossible");
	return 0;
}


Measured memory_bytes: 256
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s, t;
    cin >> s >> t;
    reverse(all(s)); reverse(all(t));
    bool ok = false;
    int p = 0;
    for (int i=0; i+sz(t)<=sz(s); ++i) {
        bool cor = true;
        rep(j, sz(t)) {
            if (s[i+j] == '?') continue;
            if (s[i+j] != t[j]) cor = false;
        }
        if (cor) {
            ok = true;
            p = i;
            break;
        }
    }
    if (!ok) {
        puts("UNRESTORABLE");
        return 0;
    }
    rep(i, sz(t)) s[p+i] = t[i];
    rep(i, sz(s)) {
        if (s[i]=='?') s[i] = 'a';
    }
    reverse(all(s));
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll N,A,B,C,D; cin >> N >> A >> B >> C >> D;
	B = abs(B-A);
	F0R(i,N) {
	    ll L = i*C-(N-1-i)*D;
	    ll U = i*D-(N-1-i)*C;
	    if (L <= B && B <= U) {
	        cout << "YES";
	        return 0;
	    }
	}
	cout << "NO";
}

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

using namespace std;

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

  for(int i = 1; i <= N; i++) {
    if(1LL * i * (i + 1) / 2 >= N) {
      for(int j = i; j >= 1; j--) {
        if(N - j >= 0) {
          N -= j;
          cout << j << endl;
        }
      }
      return (0);
    }
  }


}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;




using namespace std;

int main()
{



	IOS;

    int n;
    cin>>n;

    int a[n];

    

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

    int dp[n];

    for(int i=1;i<=n;i++)
    {
    	if(i==1)
    	{
    		dp[i]=0;
    	}

    	if(i==2)
    	{
    		dp[i] = abs(a[i]-a[i-1]);
    	}

    	else if(i>=3)
    	{
           dp[i] = min(abs(a[i]-a[i-1])+dp[i-1], abs(a[i]-a[i-2])+dp[i-2]);
    	}
    }

    cout<< dp[n];
}





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

  long long sum=0;

  int N = cin.get()-48;

while(N>=0 && N<10){
	sum += N;
	N = cin.get()-48;
}

  if(sum%9 == 0){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repd(i,n) for(ll i = (n); i >= 0; i--)
#define FOR(i,t,n) for(ll i = (t); i < (n); i++)
#define FORD(i,t,n) for(ll i = (n); i >= t; i--)
#define ALL(x) x.begin(),x.end()
#define asort(x) sort(ALL(x))

int main() {
    int N,X,T,res;
    cin >> N >> X >> T;
    if(N%X == 0) res = N / X * T;
    else res = N / X * T + T;
    cout << res << endl;
}

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

int main() {
  int n;
  cin >> n;
  int x;
  cin >> x;
  int t;
  cin >> t;
  int packet = n/x;
  if (n%x > 0) {
    packet = packet + 1;
  }
  cout << packet*t;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> p(n+1);
	FOR(i,1,n+1){
		cin>>p[i-1]>>p[i];
	}
	ll dp[n+1][n+1];
	FOR(i,0,n+1)FOR(j,0,n+1)dp[i][j]=0;
	FOR(l,2,n+1){
		FOR(i,1,n+2-l){
			int j = i + l - 1;
			dp[i][j] = (1 << 21);
			FOR(k,i,j){
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j]);
			}
		}
	}
	cout << dp[1][n] << endl;
}


Measured memory_bytes: 3268
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

LL solve(LL h, LL w){
  LL r=LINF;
  LL t;
  if(h%3==0||w%3==0) return (LL)0;
  LL s[3];
  for(int i=1; i<h; ++i){
    s[0]=i*w;
    s[1]=(h-i)*(w/2);
    s[2]=(h-i)*w-s[1];
    t = max({s[0], s[1], s[2]}) - min({s[0], s[1], s[2]});
    r = min(r, t);
    s[1]=(h-i)/2*w;
    s[2]=h*w-s[0]-s[1];
    t = max({s[0], s[1], s[2]}) - min({s[0], s[1], s[2]});
    r = min(r, t);
  }
  return r;
}


int main(){
  LL h, w;
  cin>>h>>w;

  LL ans = min(solve(h, w), solve(w, h));

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt
  as <- getIntList
  let suma = sum as
  let pm = if suma > 0 then 1 else (-1)
  let k = (abs suma) `div` n
  let sumK = sum (map (\a -> (a - pm * k) ^ 2) as)
  let sumK' = sum (map (\a -> (a - pm * (k + 1)) ^ 2) as)
  print $ minimum [sumK, sumK']


Measured memory_bytes: 3808
#include <bits/stdc++.h>
                            
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;

int n;
int a[N];

int main(){
		
	NFS
	
	cin >> n;
	
	int l=0,r=0;
	
	for(int i=1;i<=n;i++){
		cin >> a[i];
		if(a[i]%2)l++;
		else if(a[i]%4==0)r++;
	}
	
	if(r>=l || (r+l==n && r>0 && r>=l-1))cout << "Yes" << endl;
	else cout << "No" << endl;
	
	

	ioi
}

Measured memory_bytes: 640
package main

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

func main() {
	n, m := getInt(), getInt()
	t := m*1900 + (n-m)*100
	c := pow(2, m)

	ans := t * c
	fmt.Println(ans)
}

func pow(a, b int) int {
	x := float64(a)
	y := float64(b)
	return int(math.Pow(x, y))
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int n=0,j=0;
            int[] store=null;
            boolean first=true,min_flag=true;
            while ((line = br.readLine()) != null) {
            	if(first){
            		n=Integer.parseInt(line);
            		store=new int[n];
            		first=false;
            	}else{
            		store[j]=Integer.parseInt(line);
            		j++;
            		if(j==n){
            			break;
            		}
            	}           	
            }
            int s=0;
            int result=store[1]-store[0];
            int min=store[0],max=min;
            for(int i=1;i<n;i++){
            	if(min_flag){
            		s=store[i];
           		}
            	//System.out.println(i);
            	min_flag=true;
           		if(s<=min&&i!=n-1){
           			//System.out.println(s);
            		min=s;
	            	if(i==n-2){
	           			max=store[i+1];
	            		if(max-min>result){
	            			System.out.println(max-min);
	            		}else{
	           				System.out.println(result);
	           			}
	           			return;
	           		}else{
	           			s=store[i+1];
	           			max=s;
	           			if(result<max-min){
	           				result=max-min;
	           			}else{
	           				min_flag=false;
	           			}
	           		}
	            }else if(s>=max){
	           		max=s;
	           		if(max-min>result){
	           			result=max-min;
	           		}
	          	}
            		
            }
            	
            System.out.println(result);
        }
    }
}

Measured memory_bytes: 42900
/* 
   AOJ 2198
   Moonlight Farm
   2015/9/18
*/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define CROP_MAX 50
#define NAME_MAX 21

struct node
{
  char crop_name[NAME_MAX];
  double efficiency;
};

struct node crop_table[CROP_MAX];

int comp(const void *a, const void *b)
{
  struct node x = *(struct node*)a;
  struct node y = *(struct node*)b;
  
  int i;
  
  if(x.efficiency > y.efficiency)
    {
      return -1;
    }
  else if(x.efficiency < y.efficiency)
    {
      return 1;
    }
  else
    {
      for(i = 0; x.crop_name[i] != '\0' && y.crop_name[i] != '\0'; i++)
	{
	  if(x.crop_name[i] < y.crop_name[i])
	    {
	      return -1;
	    }
	  else if(x.crop_name[i] > y.crop_name[i])
	    {
	      return 1;
	    }
	  else
	    {
	      continue;
	    }
	}
      if(strlen(x.crop_name) < strlen(y.crop_name))
	{
	  return -1;
	}
      else
	{
	  return 1;
	}
    }
}

int main(void)
{
  int i, j, income, crop_n, price, a, b, c, d, e, f, s, m, time;
  char name[NAME_MAX];
  while(1)
    {
      scanf("%d", &crop_n);
      if(crop_n == 0)
	{
	  break;
	}
      for(i = 0; i < crop_n; i++)
	{
	  scanf("%s %d %d %d %d %d %d %d %d %d", name, &price, &a, &b, &c, &d, &e, &f, &s, &m);
	  for(j = 0; name[j] != '\0'; j++)
	    {
	      crop_table[i].crop_name[j] = name[j];
	    }
	  crop_table[i].crop_name[j] = '\0';
	  time = a + b + c + (d + e) * m;
	  income = f * m * s - price;
	  crop_table[i].efficiency = (double)income / time;
	}
      qsort(crop_table, crop_n, sizeof(struct node), comp);
      for(i = 0; i < crop_n; i++)
	{
	  printf("%s\n", crop_table[i].crop_name);
	}
      printf("#\n");
    }
  return 0;
}

Measured memory_bytes: 628
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d",&a);
    scanf("%d",&b);
    
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    
    printf("%d %d %f\n",d,r,f);
    return 0;
}



Measured memory_bytes: 2120