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

using namespace std;
#define sqr(x) (x)*(x)
#define cube(x) (x)*(x)*(x)
#define fixset(x) fixed << setprecision(x)
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) (a)*(b)/GCD(a,b)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define PBI pair<bool,int>
#define PIB pair<int,bool>
#define PLL pair<ll,ll>
#define SI set<int>
#define MS multiset
#define MSI multiset<int>
#define PB push_back
#define VI vector<int>
#define VLL vector<ll>
#define VB vector<bool>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1000000000;
const int MOD = 1000000007;
const int N = 200111;

int a[N], b[N], c[N];
void solve(){
    int n;
    cin >> n;

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

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

    a[1] = b[1];
    a[n] = b[n-1];
    for (int i = 2; i < n; i++){
        a[i] = min(b[i], b[i-1]);
    }

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

    cout << ans;

}

int main(){
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

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

    return 0;
}


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

class D
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var s = Console.ReadLine();
		Console.WriteLine(h[0] - 1 + Math.Min(0, 2 * h[1] - Enumerable.Range(0, h[0] - 1).Count(i => s[i] != s[i + 1])));
	}
}


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

typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int t;
ll a,b,c,d;
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	cin>>t;
	rep(i,t){
		cin>>a>>b>>c>>d;
		if(a<b || d<b){
		    puts("No");
		}
		else if(c+1<b){
			ll hoge = gcd(b,d);
			ll x = a%b,y;
			y = x;
		    ll t = y;
			t = (t/hoge)*hoge;
			y -= t;
			if(y+d < b){
				puts("No");
			}else{
    			//x+hoge*i (mod b)
    			ll L = c+1;
    			ll zan = b-1-x;
    			zan = (zan/hoge)*hoge;
    			x += zan;
    			if(L<=x){
    				puts("No");
    			}
    			else{
    				puts("Yes");
    			}
			}
		}
		else{
			ll M = (c+1)%b; //cout<<M<<endl;
			ll hoge = gcd(b,d);
			ll x = a%b,y;
			y = x;
			ll mn;
			if(x<=M){
				ll zan = (M-x+hoge-1)/hoge;
				x += zan*hoge;
				mn = c+1+(x-M)-b;
			}
			else{
				ll zan = (x-M)/hoge;
				x -= hoge*zan;
				mn = c+1+(x-M)-b;
			}
			//out<<mn<<endl;
			if(mn+d<b){
				puts("No");
			}
			else puts("Yes");
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  int n;
  
  scanf("%d", &n);
  
  printf("%d\n", n*n*n);
  return 0;
}


Measured memory_bytes: 128
program main

  implicit none
  
  integer :: i, n, tsum
  integer, allocatable :: t(:) 
  character(100) :: x 
  character(100), allocatable :: s(:) 


  read(*,*) n
  allocate( t(n))
  allocate( s(n))
  
  do i = 1, n
    read(*,*) s(i), t(i)
  end do

  read(*,*) x
  
  tsum = 0 
  do i = n, 1, -1
    if( s(i) == x ) exit
    tsum = tsum + t(i)
  end do
  print*, tsum


end program main


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

bool cou(int x)
{
	int aa=0;
	for(int i=1;i<=x;++i)
		if(x%i==0)	aa++;
	if(aa==8)	return 1;
	else		return 0;
}

int main()
{
	int n,cnt=0;
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		if(i%2==0)	continue;
		if(cou(i))	cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

int main(void)
{
  long x;
  long y;
  long i, j;
  long tmp;

  scanf("%ld", &x);
  i = 0;
  j = 0;
  tmp = x%11;
  if(tmp == 0) {
    j = 0;
  } else if(tmp < 7) {
    j = 1;
  } else {
    j = 2;
  }
  i = (x/11)*2 +j;

  printf("%ld\n", i);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[100001] = {};
int main() {
	ll n; cin >> n;
	ll maxV = 0;
	rep(i, 0, n) {
		cin >> a[i];
		maxV = max(maxV, a[i]);
	}

	ll minV = (ll)(1 << 30);

	ll center = 0;
	rep(i, 0, n) {
		if (a[i] != maxV) {
			if (abs(2 * a[i] - maxV) <= minV) {
				minV = abs(2 * a[i] - maxV);
				center = a[i];
			}
		}
	}

	cout << maxV << " " << center << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	int b;
	b=a/100+a%100/10*10+a%10*100;
	if(a==b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

int main() {
  int N, C;
  cin >> N >> C;
  vector<vector<P>> prog(C);
  rep(i,N) {
    int s, t, ch;
    cin >> s >> t >> ch;
    --ch;  // 0-indexed
    prog[ch].push_back(P(s, t));
  }

  vector<P> prog2;
  rep(i,C) {
    sort(prog[i].begin(), prog[i].end());
    prog[i].push_back(P(0, 0));
    P pre = P(0, 0);

    for (auto p : prog[i]) {
      if (pre.second == p.first) {
        pre.second = p.second;
      } else {
        if (pre.first != 0) prog2.push_back(pre);
        pre = p;
      }
    }
  }

  sort(prog2.begin(), prog2.end());
  priority_queue<int, vector<int>, greater<int>> prog_end;
  int ans = 0;

  for (auto p : prog2) {
    while (!prog_end.empty()) {
      if (prog_end.top() < p.first) {
        prog_end.pop();
      } else break;
    }
    prog_end.push(p.second);
    if (ans < prog_end.size()) {
      ans = prog_end.size();
    }
  }

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


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

using namespace std;

void solve() {
  long N;
  cin >> N;

  long ans = 1;
  long not_ans = 1;

  rep (i, N) {
    long a;
    cin >> a;
    if (a % 2 == 0) not_ans *= 2;
    ans *= 3;
  }

  cout << ans - not_ans << endl;
}

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


Measured memory_bytes: 256
// ABC-42-A.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
using namespace std;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	bool f = false;
	if (a == 5 && b == 7 && c == 5) f = true;
	if (a == 5 && b == 5 && c == 7) f = true;
	if (a == 7 && b == 5 && c == 5) f = true;
	cout << (f ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    double a = sc.nextInt();
    double b = sc.nextInt();
    
    double average = (a + b) / 2;
    
    if (average % 1 != 0) {
      average += 0.5;
      int answer = (int) average;
      System.out.println(answer);
    } else {
      int answer = (int) average;
      System.out.println(answer);
    }
  }
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
 
using namespace std;
 
 
 
int main() {
	
	int h, w;
	cin >> h >> w;
 
	vector<string> s(50);
 
	for (int i = 0; i < h; i++) {
		cin >> s.at(i);
	}
 
	vector<int> x{ 1, 0, -1, 1, 0, -1, 1, -1 };
	vector<int> y{ 1, 1, 1, -1, -1, -1, 0, 0 };
 
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s.at(i).at(j) == '#') continue;
 
			int dx;
			int dy;
			int num = 0;
			for (int k = 0; k < 8; k++) {
				dx = x.at(k);
				dy = y.at(k);
 
 
				int a = i + dx;
				int b = j + dy;
 
				if (a >= h || a < 0) continue;
				if (b >= w || b < 0) continue;
				if (s.at(a).at(b) == '#') ++num;
			}
			s.at(i).at(j) = num + '0';
		}
	}
 
	for (int i = 0; i < h; i++) {
		cout << s.at(i) << endl;
	}
 
	return 0;
}


Measured memory_bytes: 3624
N = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
res = Array.new
res << A.join(' ') + "\n"
for i in 1..(A.length-1)
  key = A[i]
  j = i - 1
  while j >= 0 and A[j] > key
    A[j+1] = A[j]
    j=j-1
  end
  A[j+1] = key
  res << A.join(' ') + "\n"
end
print res.join

Measured memory_bytes: 8832
A,B = map(int,input().split())

ans = [["." for j in range(100)] for i in range(100)]

for i in range(50):#上半分は黒く塗りつぶす
    for j in range(100):
        ans[i][j]="#"


for i in range(A-1):
    ans[2*(i//50)][2*(i%50)]="."

for i in range(B-1):
    ans[51+2*(i//50)][2*(i%50)]="#"

print(100,100)
for i in range(100):
    print("".join(ans[i]))

Measured memory_bytes: 64704
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,x,a[210];
int dp[210][100010];
signed main(){
    cin>>n>>x;
    rep(i,n)cin>>a[i];
    sort(a,a+n,greater<int>());
    rep(i,x+1)dp[n][i]=i;
    for(int i=n-1;i>=0;i--){
        int Inv=inv(n-i);
        rep(j,x+1){
            dp[i][j]+=dp[i+1][j%a[i]]*Inv%mod;
            dp[i][j]+=dp[i+1][j]*(n-i-1)%mod*Inv%mod;
            dp[i][j]%=mod;
        }
    }
    int ans=dp[0][x];
    rep(i,n){
        ans*=(i+1);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 157952
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N;
	int A[101];
	int ans;
	scanf("%d",&N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	qsort(A, N, sizeof(int), cmp);
	ans = A[N - 1] - A[0];
	printf("%d\n", ans);





#ifdef DEBUGF
	getch();
#endif
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;

bool isP(string s){
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    cout << (isP(s) && isP(s.substr(0, n / 2)) && isP(s.substr(n / 2 + 1, n / 2)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
S = input()
ans = 0
for i,word in enumerate(S,1):
    if int(i)%2==0:
        if word == "L" or word == "U" or word == "D":
            ans += 1
        else:
            pass
    else:
        if word == "R" or word == "U" or word == "D":
            ans += 1
        else:
            pass
if ans == len(S):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int w = sc.nextInt();

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < s.length(); i += w) {
            builder.append(s.charAt(i));
        }

        System.out.println(builder);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
// #ifndef ONLINE_JUDGE
// 	freopen("input1.txt", "r", stdin);
// 	freopen("output1.txt", "w", stdout);
// #endif
	FIO
	int k, a, b;
	cin >> k >> a >> b;
	int x = ((a + k - 1) / k) * k;
	if (x >= a && x <= b) cout << "OK" << "\n";
	else cout << "NG" << "\n";
	return 0;
}

Measured memory_bytes: 3668
s = list(input());
ans = 0;

if s[0] == s[1] or s[0] == s[2] or s[0] == s[3]: ans += 1;
if s[1] == s[2] or s[1] == s[3]: ans += 1;
if s[2] == s[3]: ans += 1;
if ans == 2: print("Yes");
else: print("No");

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

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int n;
    cin >> n;
    vector<int> h(n);

    int mh = 0;
    int cnt = 0;
    REP(i, n)
    {
        int now;
        cin >> now;
        h[i] = now;
        if (mh <= now)
        {
            mh = now;
            cnt++;
        }
    }
    Cout(cnt);
    return 0;
}

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

bool state[15][15];

int main(){
    int n;
    cin >> n;
    map<int, bool> state[n]; 
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; j < a; j++){
            int x, y;
            cin >> x >> y;
            x--;
            state[i][x] = y;
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        bool honest[n];
        int cnt = 0;
        for(int j = 0; j < n; j++){
            // assume that person j is honest
            if(i >> j & 1){
                honest[j] = true;
                cnt++;
            } else {
                honest[j] = false;
            }
        }
        bool flag = true;
        for(int j = 0; j < n; j++){
            if(!honest[j]) continue;
            // verify whether j's statement is correct or not
            for(auto p : state[j]){
                if(honest[p.first] != p.second){
                    flag = false;
                }
            }
        }
        if(flag) ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=1;i<=1000;i++){
        double p,q;
        p=i*0.08;
        q=i*0.1;
        int p1,q1;
        p1=p/1;q1=q/1;
        if(p1==a&&q1==b){
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 128
{-# LANGUAGE RecordWildCards #-}
import Data.ByteString.Char8 as BC (getLine, words, readInt)
import Prelude hiding (getLine, words)
import Data.List hiding (words)
import Data.Function (on)
import qualified Data.Map.Strict as M
import Data.Maybe (fromJust)
import Control.Monad
import Control.Arrow
import System.IO hiding (getLine)

main = do
    hSetBuffering stdin (BlockBuffering (Just 1000000))
    hSetBuffering stdout (BlockBuffering (Just 1000000))
    n <- readLn
    xs <- map (fst . fromJust . readInt) . words <$> getLine
    mapM_ print . fill n . solve . groupMnts $ xs
    where
        fill n xs = let filler = M.fromAscList . zip [1..n] $ repeat 0
                        filled = (M.fromAscList xs) `M.union` filler
                        in M.elems filled

type Stones = Int
type Index = Int

data Group = Group { _leftMost :: Index, _stones :: Stones, _mnts :: Int }
           deriving (Show)

groupMnts :: [Stones] -> [Group]
groupMnts = joinMountains . groupByStones . attachIndex
    where
        attachIndex = flip zip [1..]
        groupByStones
            = groupBy ((==) `on` fst) . sortBy (compare `on` first negate)
        joinMountains
            = map (\ xs@((s,i):_)  -> Group i s (length xs))

mergeGroups :: Group -> Group -> Group
mergeGroups (Group i s m) (Group i' s' m')
    = if s == s'
         then Group (min i i') s (m+m')
         else error "cannot merge and I was too lazy to use Maybe"

solve :: [Group] -> [(Int,Int)]
solve = join . consume
    -- fixme
    where
        join = foldl' f []
        f [] n = [n]
        f acc@((i,n):r) x@(i',n') = if i == i' then (i,n+n'):r else x:acc
        consume [] = []
        consume [Group{..}] = [ (_leftMost, _stones * _mnts) ]
        consume (g0:g1:rest) =
            (_leftMost g0, (_stones g0 - _stones g1)* _mnts g0)
                : consume (mergeGroups g0{_stones=_stones g1} g1:rest)

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

int main(void){
  int n, sum, num;
  cin >> n;
  num = n;
  while(n > 0){
    sum += n%10;
    n /= 10;
  }
  // cout << n%sum << endl;
  if(num%sum != 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n],brr[n],crr[n];
    rep(i,0,n)cin>>arr[i];
    rep(i,0,n)cin>>brr[i];
    rep(i,0,n-1)cin>>crr[i];

    int ans=0;
    rep(i,0,n)
    {
        ans+=brr[i];
    }
    rep(i,0,n-1) 
    {
        if(arr[i]+1==arr[i+1]) ans+=crr[arr[i]-1];
    }
    //ans-=crr[arr[i]-1];
    cout<<ans;

    return 0;
}



Measured memory_bytes: 256
main = getContents >>= putOut.formatOut.map calc.formatIn
  where putOut s | last s == '\n' = putStr s
                 | otherwise      = putStrLn s

formatIn :: String -> [[Int]]
formatIn = map ((map toInt).words).takeWhile (/="0 0").lines
  where toInt =read :: String -> Int

formatOut :: [String] -> String
formatOut = unlines

calc :: [Int] -> String
calc (h:w:_) = unlines $ (shr w) ++ replicate (h-2) (dot (w-2)) ++ (shr w)
  where shr n = [replicate n '#']
        dot n = (++"#").('#':) $replicate n '.'

Measured memory_bytes: 5216
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();

    if ((n % 500) <= a) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 35588
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S, subS;
	int index = 0;
	bool ans = true;

	cin >> S;

	while (index < S.length()) {
		subS = S.substr(index, 5);

		if (subS == "dream") {
			index += 5;

			subS = S.substr(index, 5);
			if (subS == "erase") continue;
			else if (subS[0] == 'e' && subS[1] == 'r') index += 2;
		}
		else if (subS == "erase") {
			index += 5;

			subS = S.substr(index, 1);
			if (subS[0] == 'r') index ++;
		}
		else {
			ans = false;
			break;
		}
	}

	if (ans) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 512
def resolve():
    N = str(input())
    if (N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9'):
        print('hon')
        return
    if (N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8'):
        print('pon')
        return
    if (N[-1] == '3'):
        print('bon')
        return
    return
resolve()

Measured memory_bytes: 9132
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
typedef pair<double , double> pdd ;
const int inf = 0x3f3f3f3f ;
const ll mod = 1e9 + 7 ;
const int maxn = 1e5 + 5 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
const double pi = acos(-1.0) ;
ll a , b ;
ll z ;
ll cal(ll x)
{
	return x * x * x * x * x ;
}
int main()
{
	rl(z) ;
	for(ll i = -1000 ; i <= 1000 ; i ++)
	  for(ll j = -1000 ; j <= 1000 ; j ++)
	    if(cal(i) - cal(j) == z)
	    {
	    	printf("%lld %lld\n" , i , j) ;
	    	return 0 ;
		}
	return 0 ;
}

Measured memory_bytes: 3792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        scan.close();

        int a = n % 10;

        if (a == 3) {
            System.out.println("bon");
        } else if (a == 0 || a == 1 || a == 6 || a == 8) {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }

    }

}


Measured memory_bytes: 35728
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        sx: i64,
        sy: i64,
        tx: i64,
        ty: i64
    }
    let dx = (tx - sx) as usize;
    let dy = (ty - sy) as usize;
    for _ in 0..dx {
        print!("R");
    }
    for _ in 0..dy {
        print!("U");
    }
    for _ in 0..dx {
        print!("L");
    }
    for _ in 0..dy {
        print!("D");
    }
    print!("D");
    for _ in 0..dx + 1 {
        print!("R");
    }
    for _ in 0..dy + 1 {
        print!("U");
    }
    print!("LU");
    for _ in 0..dx + 1 {
        print!("L");
    }
    for _ in 0..dy + 1 {
        print!("D");
    }
    println!("R");
}


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

int main(int argc, char const *argv[]) {
  int A,B;
  std::cin >> A >> B;

  if(A==1 || B==1){
    if(B==A)printf("Draw");
    else if(A==1)printf("Alice");
    else printf("Bob");
    return 0;
  }

  if(A<B)printf("Bob");
  else if(A>B)printf("Alice");
  else printf("Draw");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

double dp[3005][3005] = {0};
double p[3005] = {0};

int__ main() {
	fast;

	int n; cin >> n;

	for(int i=1;i<=n;i++) cin >> p[i];

	dp[0][0] = 1;

	for(int i=1;i<=n;i++) {
		for(int j=0;j<=i;j++) {
			if(j == 0) {
				dp[i][j] = (1-p[i]) * (dp[i-1][j]);
			}
			else {
				dp[i][j] = p[i]*(dp[i-1][j-1]) + (1-p[i])*(dp[i-1][j]);
			}
		}
	}

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

	std::cout << std::fixed;
  	std::cout << std::setprecision(10) << ans << '\n';
}

Measured memory_bytes: 69120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n,x,ans=20000;
bool b[1001]={};
int main(){
	ios::sync_with_stdio(false);
	cin>>x>>n;
	int i,y;
	for(i=1;i<=n;++i){
		cin>>y;
		b[y]=1;
	}
	for(i=0;i<=101;++i)
		if(!b[i]){
			if(abs(ans-x)>abs(i-x))
				ans=i;
			
			
		}
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h , w , n , x = 0;
    cin >> h >> w >> n;
    int a[n] , b[h * w];
    for( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
        for( int j = 0 ; j < a[i] ; j++ ) {
            b[x] = i + 1;
            x++;
        }
    }
    x = 0;
    for( int i = 0 ; i < h ; i++ ) {
        if( i % 2 == 0 ) {
            for( int j = x ; j < x + w ; j++ ) cout << b[j] << ' ';
        } else {
            for( int j = x + w - 1 ; j >= x ; j-- ) cout << b[j] << ' ';
        }
        x += w;
        cout << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <limits.h>
#include <string>
#include <sstream>

using namespace std;

vector<int> GetIntVector()
{
	string str;
	getline(cin,str);
	istringstream line( str );

	istream_iterator<int> iit(line);
	istream_iterator<int> iit_eof;

	vector<int> ret;

	for(;iit != iit_eof; iit++){
		ret.push_back(*iit);
	}

	return ret;
}

int tetrahedralNumber(int count)
{
	return count * (count + 1) * (count + 2) / 6;
}

bool isEven(int num){ return num % 2 == 0; }

int GetMinCombination(vector<int>& numbers,int input,int maxConbination)
{

	int minConbi = INT_MAX;

	vector<int>::reverse_iterator rit = numbers.rbegin();   
	for(; rit != numbers.rend(); rit++)  
	{
		if( (*rit) > input) continue; //ツ妥・ツつォツつ「ツ甘板づ債暗クツつッツづ按つ「ツづ個づ姪淞つキ
		if( (*rit) < input / maxConbination) break; //ツ表ツつオツつォツづェツづ按つ「
		if(input - (*rit) == 0) return 1; //ツ暗ェツづつづ個青板づ表ツつケツつス

		int conbi = GetMinCombination(numbers,input - (*rit),(minConbi == INT_MAX) ? maxConbination - 1 : minConbi - 1);
		if(conbi != INT_MAX)
			minConbi = conbi + 1; //conbiツ青板更ツ新
	}

	return minConbi;
}

void solve(int inputs)
{
	vector<int> tNumbers;
	tNumbers.push_back(0);
	for(int i = 1; inputs > tNumbers[tNumbers.size() - 1]; i++){
		tNumbers.push_back(tetrahedralNumber(i));
	}
	tNumbers.erase(tNumbers.begin());

	int conbi = GetMinCombination(tNumbers,inputs,5);

	vector<int>::iterator rem = remove_if(tNumbers.begin(),tNumbers.end(),isEven);
	tNumbers.erase( rem, tNumbers.end());

	int oddConbi = GetMinCombination(tNumbers,inputs,inputs);

	cout << conbi << ' ' << oddConbi << endl;
}

void C()
{
	int input = GetIntVector()[0];
	while(input){
		solve(input);
		input = GetIntVector()[0];
	}
}
int main()
{
	C();

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
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(){
    ld a,b;cin>>a>>b;
    cout<<ceil((a+b)/2)<<endl;
    return 0;
}


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

int main() {
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;
	int P = 0, F = 0;
	for (char c : S) {
		switch (c) {
		case 'a':
			if (P < A + B) {
				P++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
			break;
		case 'b':
			if (P < A + B && F < B) {
				P++;
				F++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
			break;
		case 'c':
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 896
#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 B[N-1];
	rep(i,N-1) cin >> B[i];
	int ans = B[N-2] + B[0];
	for (int i = 0; i <= N-3; i++) {
		ans += min(B[i],B[i+1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
n=int(input())
s="abcdefghijklmno"
end=[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
lim=0
res=[0]*n
for i in res:
  print(s[i],end="")
print("")

while res!=end[:n]:
  res[(n-1)]=res[(n-1)]+1
  for i in range(n-1):
    if res[n-i-1]>(max(res[:(n-i-1)])+1):
      res[n-i-1]=0
      res[n-i-2]=res[n-i-2]+1
  for i in res:
    print(s[i],end="")
  print("")

Measured memory_bytes: 5744
#include <stdio.h>
int main(){
int n,number=0,max=0;
scanf("%d",&n);
char array[n];
scanf("%s",array);
for (int i=0;array[i]!='\0';i++){
	if(array[i]=='I'){
		number++;
	}
	else if(array[i]=='D'){
		number--;
	}
	if(max<number){
		max=number;
	}
}
printf("%d\n",max);
return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s,t; cin>>s>>t;
  
  vector<string> S(s.size());
  vector<string> T(t.size());
  for(int i=0;i<s.size();i++){
    S[i]=s[i];
  }
  for(int i=0;i<t.size();i++){
    T[i]=t[i];
  }
  sort(S.begin(),S.end());
  sort(T.begin(),T.end());
  reverse(T.begin(),T.end());
  
  string x,y;
  for(int i=0;i<s.size();i++){
    x+=S[i];
  }
  for(int i=0;i<t.size();i++){
    y+=T[i];
  }
  if(x<y){
    cout<<"Yes"<<endl;
  }
  else{
  	cout<<"No"<<endl;
  }
}

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

class Dice{
public:
    int n[6];

    Dice(){
      for(int i=0;i<6;i++){
        cin >> n[i];
      }
    }
    int N(){
      int x;
      x=n[0];
      n[0]=n[1];
      n[1]=n[5];
      n[5]=n[4];
      n[4]=x;
      return n[0];
    }
    int E(){
      int x;
      x=n[0];
      n[0]=n[3];
      n[3]=n[5];
      n[5]=n[2];
      n[2]=x;
      return n[0];
    }
    int W(){
      int x;
      x=n[0];
      n[0]=n[2];
      n[2]=n[5];
      n[5]=n[3];
      n[3]=x;
      return n[0];
    }
    int S(){
      int x;
      x=n[0];
      n[0]=n[4];
      n[4]=n[5];
      n[5]=n[1];
      n[1]=x;
      return n[0];
    }
};

int main(){
  Dice d;
  string m;
  cin >> m;

  int j=0,roof;
  while(j<=m.size()){
    if(m[j]=='N'){
      roof = d.N();
    }else if(m[j]=='E'){
      roof = d.E();
    }else if(m[j]=='W'){
      roof = d.W();
    }else if(m[j]=='S'){
      roof = d.S();
    }
    j++;
  }

  cout << roof << endl;
  return 0;
}


Measured memory_bytes: 3212
#include<stdio.h>

int main(){
    char s[20],t[20];
    scanf("%s",s);
    for(int i=0;i<20;i++){
        if(i==5||i==13){
            t[i]=' ';
        }else{
            t[i]=s[i];
        }
    }
    printf("%s",t);
    return 0;
}

Measured memory_bytes: 1708
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String SA = sc.next();
        String[] a = SA.split("");
        String SB = sc.next();
        String[] b = SB.split("");
        String SC = sc.next();
        String[] c = SC.split("");
        
        Deque<String> aque = new ArrayDeque<>();
        for(int i=0; i<a.length; i++) {
            aque.add(a[i]);
        }
        Deque<String> bque = new ArrayDeque<>();
        for(int i=0; i<b.length; i++) {
            bque.add(b[i]);
        }
        Deque<String> cque = new ArrayDeque<>();
        for(int i=0; i<c.length; i++) {
            cque.add(c[i]);
        }
        
        String now = "a";
        while(true) {
            if(now.equals("a")) {
                if(aque.size() == 0) {
                    System.out.println("A");
                    break;
                }
                now = aque.poll();
            }else if(now.equals("b")) {
                if(bque.size() == 0) {
                    System.out.println("B");
                    break;
                }
                now = bque.poll();
                
            }else {
                if(cque.size() == 0) {
                    System.out.println("C");
                    break;
                }
                now = cque.poll();
                
            }
        }
    }
}


Measured memory_bytes: 21972
#-*-coding:utf-8-*-

def main():
    a, b, c = map(int, input().split())

    if a == b or b == a:
        print(c)
    elif a == c or c == a:
        print(b)
    elif b == c or c == b:
        print(a)


if __name__ == '__main__':
    main()

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

const int N = 100054;

int V, n, q, t;
int k1, k2, k3;
int rev[N];
bool Up = false;

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline void down(int &x, const int y) {x > y ? x = y : 0;}
inline int min(const int x, const int y) {return x < y ? x : y;}
inline int max(const int x, const int y) {return x < y ? y : x;}
inline int f(int x) {return min(max(x, k1), k2) + k3;} // clip
inline void handle(int I) {Up ? (k3 += I, down(k1, V - k3), down(k2, V - k3)) : (k3 -= I, up(k1, -k3), up(k2, -k3)), t += I;}

int main() {
	int i, tg, x;
	scanf("%d%d", &V, &n);
	for (i = 0; i < n; ++i) scanf("%d", rev + i);
	rev[n] = INT_MAX;
	i = 0, k2 = V;
	for (scanf("%d", &q); q; --q) {
		scanf("%d%d", &tg, &x);
		for (; rev[i] <= tg; ++i) handle(rev[i] - t), Up = !Up;
		handle(tg - t), printf("%d\n", f(x));
	}
	return 0;
}

Measured memory_bytes: 1536
def main():
    N,M,X=map(int, input().split())
    A=[list(map(int, input().split())) for _ in range(N)]
    ans=10**10
    for i in range(2**N):
        b=i+2**N
        c=0
        l=[0]*M
        ok=True
        for j in range(N):
            if b>>j&1 == 1:
                c+=A[j][0]
                for k in range(M):
                    l[k]+=A[j][k+1]
        for x in l:
            if x < X: ok = False 
        if ok:
            ans = min(ans, c)
    if ans==10**10: print('-1')
    else: print(ans)

if __name__=='__main__':
    main()

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

int main(){

    int N, M, X;
    cin>>N>>M>>X;
    vector<int>flg(N+1, 0);
    for(int m=1;m<=M;m++){
        int a;
        cin>>a;
        flg[a]=1;
    }
    int ansA=0, ansB=0;
    for(int p=X;p>=0;p--)if(flg[p])ansA++;
    for(int p=X;p<=N;p++)if(flg[p])ansB++;
    cout<<min(ansA, ansB)<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map( int, input().split() )
V = list( map( int, input().split() ) )
 
max_number = 0
for A in range( K + 1 ):
  for B in range( K + 1 ):
    J = K - A - B
    if J < 0:
      continue
    if A + B >= N:
      hand = V
    else:
      hand = V[ : A ] + V[ N - B : ]
    hand = sorted( hand )
      
    hand_num = 0
    for i, j in enumerate(hand):
      if ( j > 0 ) or ( i == J ):
        hand = hand[ i: ]
        break
    max_number = max( max_number, sum( hand ))
print( max_number )

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	// ?¨??????\???????????????????????????????????????
		Scanner sc= new Scanner(System.in);
		// 2?????????????????????????????????????????´??°?????¨????????????????????????
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a*b/* ????????????????????¢???????±??????????*/;
		int length = 2*(a+b)/* ????????????????????¨????????????????±??????????*/;
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 25996
#include<stdio.h>
int main()
{
    int n,i,count=0,c=1,count2=0;
    scanf("%d",&n);
    int N[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&N[i]);
        if(N[i]!=c)
            count++;
        if(N[i]==c)
            c++,count2++;
    }
    if(c==1||count2==0)
    {
        printf("-1");
    }
    else
    {
        printf("%d",count);
    }
    return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main() {
	int a = 0;
	int b = 0;
	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: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;i++)

int main()
{
    int H,W,h,w;
    cin >> H >> W >> h >> w;

    cout << H*W-(H*w + W*h -w*h);

    return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  integer(4) n,l,i,k
  integer(4),allocatable::a(:),r(:)
  read*,n,l
  allocate(a(n),r(n))
  read*,a(:)
  i=maxloc(a(2:)+a(1:n-1),1)
  if (a(i)+a(i+1).lt.l)then
     print*,trim("Impossible")
  else
     print*,"Possible"
     print*,(/(k,k=1,i-1),(k,k=n-1,i,-1)/)
  endif
end program main


Measured memory_bytes: 3072
fun main(args: Array<String>) {
    val l = readLine()!!.split("").drop(1).dropLast(1).map { it.toInt() }
    val blue = l.sum()
    val red = l.count() - blue

    if (blue * red == 0) {
        println(0)
    }
    else{
        println(Math.min(blue, red) * 2)
    }
}

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

//int main() {
//	int n;
//	vector<int> a;
//	cin >> n;
//
//	double total = 0;
//
//
//	for (int i = 0; i < n; i++)
//	{
//		double temp;
//		cin >> temp;
//		total += 1 / temp;
//
//	}
//
//
//
//
//}


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

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

	sort(v.begin(), v.end());

	double temp = 0;
	for (int i = 0; i < n-1; i++)
	{
		if (i == 0) {
			temp = (v[i] + v[i + 1]) / 2;

		}
		else {
			temp = (temp + v[i + 1]) / 2;
			
		}
	
	}
	cout << temp << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

vector<string> g[300][300];
int n;

struct P {
  int now;
  string s;
  P(int now, string s) :
    now(now), s(s) {}
};

bool operator<(const P &e, const P &f) {
  return e.s != f.s ? e.s > f.s : e.now<f.now;
}

// a<b:1 a>b:-1 a<>b:0(undefinable)
int lessthan(const string &a, const string &b) {
  REP(i, min(a.size(), b.size()))
    if (a[i]!=b[i]) return a[i]<b[i]?1:-1;
  return 0;
}

bool canGo[40][40];

string dijkstra(int a, int t) {
  string dist[n];
  priority_queue<P> Q; // "e < f" <=> "e.weight > f.weight"
  map<P, bool> visited;
  for (Q.push(P(a, "")); !Q.empty(); ) {
    P p = Q.top(); Q.pop();
    string s = p.s;
    int now = p.now;

    //cout << now << " " << s << " " << visited[p] << endl;
    if (visited[p]) continue;
    visited[p] = 1;
    
    if (s.size() > n*6) return "NO";
    if (now == t) return s;
    if (lessthan(dist[now], s) == 1) continue;
    
    REP(i, n) {
      if (canGo[i][t] || i==t) {
        FOR(it, g[now][i]) {
          if (dist[i] == "") {
            dist[i] = s+*it;
            Q.push(P(i,s+*it));
          } else {
            if (lessthan(s+*it, dist[i]) >= 0) {
              dist[i] = s+*it;
              Q.push(P(i,s+*it));
            }
          }
        }
      }
    }
  }
  return "NO";
}


int main() {
  int m,s,t;
  int NN = 0;
  while(cin>>n>>m>>s>>t,n) {
    if (NN++==15) {
      // cout << n << " " << m << " " << s << " " << t << endl;
    }
    REP(i,n)REP(j,n) g[i][j] = vector<string>();
    memset(canGo,0,sizeof(canGo));
    REP(i, m) {
      int a,b;string s;
      cin >> a>> b>> s;
      g[a][b].push_back(s);
      canGo[a][b] = 1;
    }
    REP(k,n) REP(i,n) REP(j,n) {
      if (canGo[i][k]&&canGo[k][j]) canGo[i][j] = 1;
    }
    
    cout << dijkstra(s,t) << endl;
  }
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;

static const int MAX = 100000;
static const int INFTY = (1<<29);


vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
    
    queue<int> q;
    q.push(s);
    V[s] = true;
    
    while ( !q.empty() ) {
        
        int u = q.front();
        q.pop();
        out.push_back(u);
        
        for ( int i = 0; i <G[u].size(); i++ ) {
            
            int v = G[u][i];
            indeg[v]--;
            
            if ( indeg[v] == 0 && !V[v]) {
                
                V[v] = true;
                q.push(v);
                
            }
            
        }
        
    }
    
}

void tsort() {
    
    for( int i= 0; i<N; i++) {
        
        indeg[i] = 0;
        
    }
    
    for ( int u = 0; u < N; u++ ) {
        
        for ( int i= 0; i < G[u].size(); i++ ) {
            
            int v = G[u][i];
            indeg[v]++;
            
        }
            
    }
    
    for ( int u= 0; u < N; u++ ) {
        
        if ( indeg[u] == 0 && !V[u] ) {
            
            bfs(u);
            
        }
        
    }
    
    for ( list<int>::iterator it = out.begin(); it != out.end(); it++ ) {
        
        cout << *it << endl;
        
    }

}

int main() {
    
    int s, t, M;
    cin >> N >> M;
    
    for ( int i= 0; i<N; i++ ) {
        
        V[i] = false;
        
    }
    for ( int i= 0;i<M; i++ ) {
        
        cin >> s >> t;
        G[s].push_back(t);
        
    }
    
    tsort();
    
    return 0;
}



Measured memory_bytes: 6112
#include <iostream>
using namespace std;
int main()
{
    int n,copie,s=0;
    cin >> n;
    copie=n;
    while (n)
    {
        s+=n%10;
        n/=10;
    }
    if (copie%s==0) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256