akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int factorial(int x){
  if (x==0) return 1;
  else return x * factorial(x - 1);
}

int main(){
  int N;
  cin >> N;
  int P[N];
  int Q[N];
  int X[N];
  rep(i, N) cin >> P[i];
  rep(i, N) cin >> Q[i];
  rep(i, N) X[i] = i + 1;
  int cnt_a = factorial(N);
  int cnt_b = factorial(N);
  int cnt = 1;
  do{
    bool check_a = true;
    bool check_b = true;
    rep(i, N){
      if (P[i]==X[i]) continue;
      else check_a *= false;
    }
    if (check_a == true){
      cnt_a = min(cnt_a, cnt);
    }
    rep(i, N){
      if (Q[i]==X[i]) continue;
      else check_b *= false;
    }
    if (check_b == true){
      cnt_b = min(cnt_b, cnt);
    }
    cnt++;
  }
  while (next_permutation(X, X+N));
  cout << abs(cnt_a - cnt_b) << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-7;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (int i = f; i < t; i++)
#define per(i, f, t) for (int i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

ll n, m;

void run() {
	cin >> n >> m;
	ll ans = 1900 * m + (n - m) * 100;
	ans *= (1 << m);
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
long long a;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
long long Mi=2e9;
long long Mx=0;
        for(int i=0; i<n; i++)
        {
            scanf("%lld",&a);
            if(a<Mi)
                Mi=a;
            if(a>Mx)
                Mx=a;
        }
        printf("%lld\n",Mx-Mi);

    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		// 文字列の入力
      if (a > b) {
		System.out.println("No");
      } else {
		System.out.println("Yes");
      }
	}
}

Measured memory_bytes: 22612
N = int(input())
A = [int(x) for x in input().split()]
B = [0]*N
B[0] = A[0]
for i in range(1,N):
    B[i] = min(A[i], B[i-1])

ans = 1
for i in range(1,N):
    if B[i-1]>=A[i]:
        ans += 1
print(ans)


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

int main(){
    int N=0,A=0,B=0,C=0,D=0;
    int ans=0;
    string str;

    cin>>A>>B;
    vector<int> vec;



    if(A<=8&&B<=8){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }

}

Measured memory_bytes: 256
#include <cstdio>
    #include <vector>
    #include <string>
    #include <iostream>
    using namespace std;
    const int MAXN = 3005;
    int dp[MAXN][MAXN]={0};
    inline int max(int a,int b){
        return a>b?a:b;
    }
    int main(){
        string s,t;
        cin>>s>>t;
        for(int i=1;i<=s.length();++i){
            for(int j=1;j<=t.length();++j){
                if(s[i-1]==t[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
                }
            }
        }
        string n;
        int x=s.length(),y=t.length();
        // cout<<dp[x][y]<<endl;
        // int res=dp[x][y];
        while(x&&y){
            // cout<<x<<" "<<y<<endl;
            if(s[x-1]==t[y-1]){
                n=s[x-1]+n;
                x--;y--;
            }
            else{
                if(dp[x-1][y]==dp[x][y])x--;
                else y--;
            }
        }
        cout<<n<<endl;
        return 0;
    }

Measured memory_bytes: 35456
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    ll s, c;
    cin >> s >> c;
    ll to_add = max(0LL, ((c / 2) - s) / 2);
    ll best = 0;
    for (ll p = to_add - 5; p <= to_add + 5; p++) {
        if (p < 0 || 2 * p > c) continue;
        best = max(best, min(s + p, (c / 2) - p));
    }
    cout << best;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a>b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s = "".join(s)
t = "".join(t)
#for i in range(len(s)):
#  if s[i] > t[i]:
#    print("No")
#    break
if s < t:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

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

    string ans;
    rep(i,n)
    {
        ans += s[i];
        ans += t[i];
    }

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

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

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

using namespace std;
using lint=long long;

int main(){
	int n;
	lint k; scanf("%d%lld",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	a.emplace_back(2e5+1);
	a.emplace_back(2e5+1);
	n+=2;

	vector<int> next(n);
	{
		vector<int> first(200002,-1);
		rep(i,n) if(first[a[i]]==-1) first[a[i]]=i;

		vector<int> nearest(200002,-1);
		for(int i=n-1;i>=0;i--){
			if(nearest[a[i]]==-1){
				next[i]=(first[a[i]]+1)%n;
			}
			else if(nearest[a[i]]==n-1){
				next[i]=0;
			}
			else{
				next[i]=next[nearest[a[i]]+1];
			}
			nearest[a[i]]=i;
		}
	}

	int per;
	for(int p=next[0],t=1;;p=next[p],t++){
		if(p==0){
			per=t;
			break;
		}
	}

	int p=0;
	rep(i,(k-1)%per) p=next[p];

	// simulate
	vector<int> ans;
	vector<bool> used(200002);
	for(;p<n;p++){
		if(!used[a[p]]){
			ans.emplace_back(a[p]);
			used[a[p]]=true;
		}
		else{
			while(1){
				int x=ans.back();
				ans.pop_back();
				used[x]=false;
				if(x==a[p]) break;
			}
		}
	}
	rep(i,ans.size()) printf("%d%c",ans[i],i+1<ans.size()?' ':'\n');

	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef long long LL;
typedef unsigned long UL;

using namespace std;


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

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

	if (b == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	if (b < a)
	{
		cout << 1 << endl;
		return 0;
	}

	b -= a;

	if (b % (a - 1) == 0)
	{
		cout << b / (a - 1) + 1 << endl;
	}
	else
	{
		cout << b / (a - 1) + 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
    int n;
    int a[1000] = {};
    int i, j, k, l;
    int x;
    
    scanf("%d\n", &n);
    scanf("%d", &a[0]);
    for(i = 1; i < n; i++) {
        scanf(" %d", &a[i]);
    }
    
    if(n % 2 == 0) {
        for(k = 0; k < n / 2; k++) {
            x = a[k];
            a[k] = a[n - 1 - k];
            a[n - 1 - k] = x;
        }
    }
    else if(n % 2 == 1) {
        for(k = 0; k < n / 2 - 1; k++) {
            x = a[k];
            a[k] = a[n - 1 - k];
            a[n - 1 - k] = x;
        }
    }
    
    printf("%d", a[0]);
    for(l = 1; l < n; l++) {
        printf(" %d", a[l]);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;

    return 0;
}


Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ll n, m;
    cin >> n >>m;
    ll a[m];
 
    rep(i, m) {
        cin >> a[i];
    }

    ll dp[n+1];
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    ll index = 0;
    FOR(i, 1, n+1) {
        while(index<m && a[index]<i) {
            index++;
        }

        if(a[index]==i) continue;
        dp[i] += dp[i-1];
        dp[i] %= MOD;
        if (i>1) dp[i] += dp[i-2];
        dp[i] %= MOD;
    }

    print(dp[n]);
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

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

    long long sum=0;
    for(i=0;i<N;i++)
        sum+=a[i];

    printf("%lld\n",sum-N);
    return 0;
}


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

int main(){
	ll N, K;
	cin >> N >> K;
	vector<ll> x(N), y(N);
	for (int i = 0; i < N; i++){
		cin >> x[i] >> y[i];
	}

	set<ll> X;
	set<ll> Y;
	for (int i = 0; i < N; i++){
		X.insert(x[i]);
		Y.insert(y[i]);
	}

	ll res = 1e18*4;
	for (auto l = X.begin(); l != X.end(); l++){
		for (auto r = X.begin(); r != X.end(); r++){
			for (auto b = Y.begin(); b != Y.end(); b++){
				for (auto t = Y.begin(); t != Y.end(); t++){
					ll cnt = 0;
					for (int i = 0; i < N; i++){
						if (x[i] >= *l && x[i] <= *r){
							if (y[i] >= *b && y[i] <= *t){
								cnt++;
							}
						}
					}

					if (cnt >= K){
						ll s = (*r-*l)*(*t-*b);
						res = min(res, s);
					}
				}
			}
		}
	}

	cout << res << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  double x, ans = 0; string u;
  for (int i = 0; i < N; i++) {
    cin >> x >> u;
    if (u == "BTC") x *= 380000.0;
    ans += x;
  }
  printf("%.15f\n", ans);
}

Measured memory_bytes: 256
n,k=map(int,input().split())
x=list(map(int,input().split()))
m=n-k+1
ans=float('inf')
for i in range(m):
    a=abs(x[i])+abs(x[i+k-1]-x[i])
    b=abs(x[i+k-1])+abs(x[i+k-1]-x[i])
    ans=min(ans,b,a)
print(ans)

Measured memory_bytes: 62576
#include <stdio.h>
#include<stdbool.h>

int main(void){
    int a,b,s,l;
    scanf("%d %d",&a,&b);
    s=a*b;
    l=2*a+2*b;
    printf("%d %d\n",s,l);
    
    return 0;
}


Measured memory_bytes: 2024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };

int N = 1e3 + 7;



int main() {
	fastIO;
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> red, green, colorless;
	for (int i = 0; i < a; i++) {
		ll tmp;
		cin >> tmp;
		red.push_back(tmp);
	}

	for (int i = 0; i < b; i++) {
		ll tmp;
		cin >> tmp;
		green.push_back(tmp);
	}

	for (int i = 0; i < c; i++) {
		ll tmp;
		cin >> tmp;
		colorless.push_back(tmp);
	}

	sort(red.rbegin(), red.rend());
	sort(green.rbegin(), green.rend());
	sort(colorless.begin(), colorless.end());

	for (int i = 0; i < a-x; i++)
		red.pop_back();
	for (int i = 0; i < b-y; i++)
		green.pop_back();

	ll total = 0;
	for (int i = 0; i < x; i++)
		total += red[i];
	for (int i = 0; i < y; i++)
		total += green[i];

	while((red.size() || green.size()) && colorless.size()) {
		if (red.size() && green.size()) {
			if (red.back() < colorless.back() && green.back() < colorless.back()) {
				if (red.back() < green.back()) {
					total -= red.back();
					total += colorless.back();
					red.pop_back();
					colorless.pop_back();
				}
				else {
					total -= green.back();
					total += colorless.back();
					green.pop_back();
					colorless.pop_back();
				}
			}
			else if (red.back() < colorless.back()) {
				total -= red.back();
				total += colorless.back();
				red.pop_back();
				colorless.pop_back();
			}
			else if (green.back() < colorless.back()) {
				total -= green.back();
				total += colorless.back();
				green.pop_back();
				colorless.pop_back();
			}
			else {
				break;
			}
		}
		else if (red.size()) {
			if (red.back() < colorless.back()) {
				total -= red.back();
				total += colorless.back();
				red.pop_back();
				colorless.pop_back();
			}
			else {
				break;
			}
		}
		else if (green.size()) {
			if (green.back() < colorless.back()) {
				total -= green.back();
				total += colorless.back();
				green.pop_back();
				colorless.pop_back();
			}
			else {
				break;
			}
		}
	}

	cout << total;


}


Measured memory_bytes: 3316
fun main(args: Array<String>) {
    
    val (n, m, c) = readLine()!!.split(" ").map { it.toInt() }
    val b = readLine()!!.split(" ").map { it.toInt() }
    val a = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
    

  /*
    val (n, m, c) = Triple(2, 3, -10)
    val b = listOf(1, 2, 3)
    val a = listOf(
            listOf(3, 2, 1),
            listOf(1, 2, 2)
    )
    */

    val result = a.map { codes ->
        codes.foldIndexed(0, { index, acc, i -> acc + i * b[index] }) + c
    }.count { it > 0 }

    println("$result")
}


Measured memory_bytes: 38156
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    /////////////////////
    // Write code below /
    /////////////////////
    int numberOfRows, numberOfColumns;
    cin >> numberOfRows >> numberOfColumns;
    
    vector<string> board(50);
    
    for (int row_i = 0; row_i < numberOfRows; row_i++) {
        cin >> board[row_i];
    }
    
    // 周りのマス目へのオフセット値
    const vector<int> offsetOfX = {1,0,-1,0,1,-1,-1,1};
    const vector<int> offsetOfY = {0,1,0,-1,1,1,-1,-1};
    
    for (int row_i = 0; row_i < numberOfRows; row_i++) {
        for (int column_i = 0; column_i < numberOfColumns; column_i++) {
            if (board.at(row_i).at(column_i) == '#') {
                continue;
            }
            
            int numberOfAdjacentBombs = 0;
            for (int around_i = 0; around_i < 8; around_i++) {
                const int aroundRow    = row_i + offsetOfY.at(around_i);
                const int aroundColumn = column_i + offsetOfX.at(around_i);
                
                // 対象のrowが先頭行または最終行のときは無視
                if (aroundRow < 0 || numberOfRows - 1 < aroundRow) {
                    continue;
                }
                // 対象のcolumnが左端または右端のときは無視
                if (aroundColumn < 0 || numberOfColumns - 1 < aroundColumn) {
                    continue;
                }
                
                if (board.at(aroundRow).at(aroundColumn) == '#') {
                    numberOfAdjacentBombs++;
                }
            }
            board.at(row_i).at(column_i) = char(numberOfAdjacentBombs + '0');   // 数値 + '0' = 数字
        }
    }
    
    for (int row_i = 0; row_i < numberOfRows; row_i++) {
        cout << board.at(row_i) << endl;
    }
    
    return 0;
}


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

near = 9999999999
ans = -1
for i in range(N):
    if near > abs(A - (T - H[i]*0.006)):
        near = abs(A - (T - H[i]*0.006))
        ans= i

print(ans+1)


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
string str;
int main(){
	cin>>str;
	for (int i=0;i<str.size()-8;i++) cout<<str[i];
	return 0;
}

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

ll findpow(ll a,ll b){
    ll cnt=0,i,j;
    while(a>1){
        a=a/b;
        cnt++;
    }
    return cnt;
}

int main() {
	
	ll n,m,i,j,k,l,t,flag=0,flag1=0,cnt=0,sum=0;
	ll x,y;
//	cin>>t;
    cin>>x>>y;
    if(x==1||y==1){
        cout<<1<<endl;
        return 0;
    }
    if(y%2==0){
        cout<<x*(y)/2<<endl;
        return 0;
    }
    else{
        k=y/2;
    while(1){
        if(cnt%2==0){
            sum+=(k+1);
            cnt++;
        }
        else{
            sum+=k;
            cnt++;
        }
        if(cnt==x){
            break;
        }
    }
    }
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int solve(int n) {
    string s;
    int migi   = 0;
    int hidari = 0;
    int ans    = 0;
    int asi    = -1;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == "lu") {
            hidari = 1;
            if (migi == hidari && asi == 1) ans++;
            asi = 0;
        } else if (s == "ru") {
            migi = 1;
            if (migi == hidari && asi == 0) ans++;
            asi = 1;
        } else if (s == "ld") {
            hidari = 0;
            if (migi == hidari && asi == 1) ans++;
            asi = 0;
        } else if (s == "rd") {
            migi = 0;
            if (migi == hidari && asi == 0) ans++;
            asi = 1;
        }
    }
    return ans;
}

int main(int argc, char const *argv[]) {
    int n;
    vector<int> ans;
    while (1) {
        cin >> n;
        if (n == 0) break;
        ans.push_back(solve(n));
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
}



Measured memory_bytes: 3084
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int L; cin >> L;
    long double R = 1.0 * L / 3;
    printf("%.12Lf\n", R*R*R);
    return 0;
}


Measured memory_bytes: 256
import sys
s = input()
x = -1
for i in s :
    x += 1
    if x % 2 == 0 :
        if s[x] != "h" :
            print("No")
            sys.exit()
    else :
        if s[x] != "i" :
            print("No")
            sys.exit()

if len(s)%2 != 0 :
    print("No")
    sys.exit() 

print("Yes")

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

int N,M;
bool matrix[50][50];
bool checked[50]={};

void dfs(int n){
	checked[n] = true;
	for(int i=0;i<N;i++){
		if(matrix[n][i]==false)continue;
		if(checked[i])continue;
		dfs(i);
	}
}

int main(){
	int a[50],b[50];
	cin >> N >> M;
	for(int i=0;i<M;i++){
//		int a,b;
		cin >> a[i] >> b[i];
		a[i]--;b[i]--;
		matrix[a[i]][b[i]] = true;
		matrix[b[i]][a[i]] = true;
	}
	int answer = 0;
	for(int i=0;i<M;i++){
		matrix[a[i]][b[i]] = false;
		matrix[b[i]][a[i]] = false;
		
		for(int j=0;j<N;j++)checked[j] = false;
		dfs(0);
		
		bool isbridge = false;
		for(int j=0;j<N;j++){
			if(checked[j] == false){
				isbridge = true;
			}
		}
		if(isbridge)answer++;
		
		matrix[a[i]][b[i]] = matrix[b[i]][a[i]] = true;
	}
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 256
A, B = map(int,input().split())
S = input()
num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
num = str(num)
if S[A] == '-':
    for i in range(A):
        if S[i] not in num:
            print('No')
            exit()
    for i in range(A + 1, A + B + 1):
        if S[i] not in num:
            print('No')
            exit()
else:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 9176
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,x,n) for(int i=x;i<n;i++)
#define breps(i,x,n) for(int i=x;i>=n;i--)
#define exrep(x,vec) for(auto&& x : vec);
#define PI 3.14159265358979323846264338327950288
const long long MOD = 1000000007;
const int INF{ 2100000000 };	// MAX:2147483647
typedef long long ll;
using namespace std;

// ------------- ここからコード -------------

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

	int ans = 0;
	for (int a = 1; a < N; a++) {
		for (int b = 1; a * b < N; b++) {
			int c = N - a * b;
			if (c > 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  string str, order;
  int n;
  cin >> str >> n;

  for (int i = 0; i < n; i++)
  {
    int a, b;
    cin >> order >> a >> b;
    if (order == "print")
      cout << str.substr(a, b - a + 1) << endl;
    else if (order == "reverse")
      reverse(&str[a], &str[b + 1]);
    else
    {
      string s;
      cin >> s;
      str.replace(a, b - a + 1, s);
    }
  }

  return 0;
}

Measured memory_bytes: 3168
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

void bt(int ul, int idx, int n, string & sol, string & ultsol) {
	if (idx == n) {
		cout << sol << '\n';
		assert(ultsol == "" || sol > ultsol);
		ultsol = sol;
		return;
	}
	
	if (idx == 0) {
		for (int i = 0; i <= ul; ++i) {
			sol.push_back('a' + i);
			bt(max(ul, i), idx + 1, n, sol, ultsol);
			sol.pop_back();
		}
	}
	else {
		for (int i = 0; i <= ul + 1; ++i) {
			sol.push_back('a' + i);
			bt(max(ul, i), idx + 1, n, sol, ultsol);
			sol.pop_back();
		}
	}

}

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;
	
	string str = "";
	string ultsol = "";
	bt(0, 0, n, str, ultsol);


	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;

long long calc(long long  num) {

    long long number = 0;

    while (num > 0) {
        number = number + num % 10;
        num = num / 10;
        
    }

    return number;
}

int main(){

    string n;
    cin >> n;
    vector<int> c(n.size());

    int ans = 0;

    for (int i = 0; i < n.size(); i++) {
        char cc =  n[i];
        c[i] = int (cc-'0');
        ans = ans + c[i];
    }


    if (ans%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(void){
    string T, P;
    cin >> T >> P;
    size_t sizeT = T.length(); //文字列Tの長さを取得
    size_t sizeP = P.length(); //文字列Pの長さを取得

    for(int i = 0; i < sizeT; i++){
        int cnt = 0; //Tに、Pと一致する　部分があるかを判断するもの
        for(int j = 0; j < sizeP; j++){
            if(P[j] == T[i + j]) cnt++;
        }
        if(cnt == sizeP) cout << i << endl;
    }
    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
  int64_t v;
  Mint() { v = 0; }
  Mint(int64_t x) { v = x % MOD; if(v < 0) v += MOD; }

  Mint operator-() { return Mint(-v); };
  Mint operator+(Mint x) { return Mint(v + x.v); };
  Mint operator-(Mint x) { return Mint(v - x.v); };
  Mint operator*(Mint x) { return Mint(v * x.v); };
  Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

  Mint& operator+=(Mint x) { return *this = (*this + x); };
  Mint& operator-=(Mint x) { return *this = (*this - x); };
  Mint& operator*=(Mint x) { return *this = (*this * x); };
  Mint& operator/=(Mint x) { return *this = (*this / x); };

  static Mint pow(Mint base, int64_t exp) {
    if(exp == 0) return Mint(1);
    return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
  }

  friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

const int SIZE = 11234567;
mint fact(int n) {
  static vector<mint> factorial = []() {
    vector<mint> _f(SIZE, 1);
    for(int i=1; i<SIZE; i++) _f[i] = _f[i-1] * i;
    return _f;
  }();
  return factorial[n];
}
mint perm(int n, int k) { return n<k ? 0 : fact(n) / fact(n-k); }
mint comb(int n, int k) { return n<k ? 0 : perm(n, k) / fact(k); }

lint N;
vector<lint> edges[212345];
lint sz[212345];
mint down[212345];
mint up[212345];

void dfs_down(lint cur, lint par) {
  down[cur] = 1;
  for(auto nxt : edges[cur]) {
    if(nxt == par) continue;
    dfs_down(nxt, cur);
    sz[cur] += sz[nxt];
    down[cur] *= down[nxt] * comb(sz[cur], sz[nxt]);
  }
  sz[cur]++;
}

void dfs_up(lint cur, lint par) {
  up[cur] = 1;
  if(par != -1) {
    up[cur] *= down[par] / down[cur] / comb(sz[par]-1, sz[cur]);
    up[cur] *= up[par] * comb(N-sz[cur]-1, N-sz[par]);
  }

  for(auto nxt : edges[cur]) {
    if(nxt == par) continue;
    dfs_up(nxt, cur);
  }
}

int main() {
  cin >> N;
  for(lint i=0; i<N-1; i++) {
    lint a, b;
    cin >> a >> b;
    a--, b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  dfs_down(0, -1);
  dfs_up(0, -1);

  for(lint i=0; i<N; i++) {
    cout << down[i] * up[i] * comb(N-1, sz[i]-1) << endl;
  }
}

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> ans(n);
    for (size_t i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans[a-1] = i+1;
    }

    for (size_t i = 0; i < n; i++) cout << ans[i] << ' ';
    cout << endl;
    return 0;
}


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

   string s,t,u;
   int cnt=0;
   cin>>s>>t;
   if(t.length()-s.length()==1)
   {
//      for(int i=0;i<s.length();i++)
//      {
//          if(s[i]!=t[i]);
//          cnt++;
//      }
//      if(cnt==0)
//        cout<<"YES"<<endl;
//      else
//        cout<<"NO"<<endl;

     u=s+t[t.length()-1];
     if(u==t)
        cout<<"Yes";
     else
        cout<<"No";
   }
   else
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N,W;
	cin >> N >> W;
	vector<int> w(N), v(N);
	vector<vector<long long int>> dp(N + 1, vector<long long int>(W+1,0));
	for (int i = 0; i < N ; i++) {
		cin >> w.at(i) >> v.at(i);
	}
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j >= w[i]) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
			}
			dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main (){
    int k;
    cin >> k;
    if(k%2==1){
        cout << floor(k/2)*(floor(k/2)+1);
    }else{
        cout << k/2*k/2;
    }
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fun(int arr[],int n)
{
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    return dp[n];
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    int n; cin>>n;
    int arr[n];
    for(int i=1;i<=n;i++) cin>>arr[i];
    cout<<fun(arr,n)<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cctype>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e15;
typedef pair<ll,ll> P;
typedef string::const_iterator State;
class ParseError {};
int expression(State &begin);
int term(State &begin);
//int number(State &begin);
//int factor(State &begin);
string s;
int expression(State &begin){
    int ret;
    for(;;){
        if (*begin == '['){
            begin++;
            ret = term(begin);
        }
        else if (*begin == ']'){
            begin++;
            break;
        }
        else if (*begin == 'a'||*begin == 'b'||*begin == 'c'||*begin == 'd'){
            ret = s[*begin - 'a'] - '0';
            begin++;
            break;
        }
        else{
            break;
        }
    }
    return ret;
}
string fill(int s){
    string t = to_string(s);
    int a = 4-t.length();
    rep(i,a){
        t = '0'+t;
    }
    return t;
}
int term(State &begin){
    int ret;
    for(;;){
        if (*begin == '+'){
            begin++;
            ret = expression(begin) | expression(begin);
        }
        else if (*begin == '*'){
            begin++;
            ret = expression(begin) & expression(begin);
        }
        else if (*begin == '^'){
            begin++;
            ret = expression(begin) ^ expression(begin);
        }
        else break;
    }
    return ret;
}

int main(){
    string ex;
    int a;
    for(;;){
        int c = 0;
        getline(cin,ex);
        if (ex == ".") break;
        cin >> s;
        cin.ignore();
        State begin = ex.begin();
        a = expression(begin);
        rep(i,10000){
            State begin = ex.begin();
            s = fill(i);
            if (a == expression(begin)) c++;
        }
        cout << a << ' ' << c << '\n';
    }
}


Measured memory_bytes: 3144
s=input()
t=input()

ans=0
s_inx=0
t_inx=0
s_l=len(s)
t_l=len(t)

c=0
while t_inx<=t_l-1:
  try:
    temp_inx=s[s_inx:].index(t[t_inx])
    s_inx+=temp_inx+1
    t_inx+=1
    c=0
  except:
    c+=1
    s_inx=0
    ans+=s_l

  if c==2:
    print(-1)
    exit()
else:
  ans+=s_inx

print(ans)

Measured memory_bytes: 3316
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Res> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            int a = Integer.parseInt(sc.next());
            list.add(new Res(i + 1, s, a));
        }
        Collections.sort(list);
        list.stream()
                .forEach(s -> System.out.println(s.idx));
    }

    public static class Res implements Comparable<Res> {
        int idx;
        String s;
        int p;

        public Res(int idx, String s, int p) {
            this.idx = idx;
            this.s = s;
            this.p = p;
        }

        @Override
        public int compareTo(Res r) {
            int c = this.s.compareTo(r.s);
            if (c == 0) {
                if (this.p > r.p) {
                    return -1;
                } else if (this.p < r.p) {
                    return 1;
                } else {
                    return 0;
                }
            }
            return this.s.compareTo(r.s);
        }
    }
}

Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef  long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
#define F first
#define S second
#define pi 3.141592653589793238
#define INF 1e9+5


int main()
{

	ll n;
	cin>>n;
	ll dp[n][3];
	ll ma=0,k=0;
	for(int x=0;x<n;x++){
        for(int y=0;y<3;y++){
            cin>>dp[x][y];
        }
    }
	for(int x=1;x<n;x++){
        dp[x][0]+=max(dp[x-1][1],dp[x-1][2]);
        dp[x][1]+=max(dp[x-1][0],dp[x-1][2]);
        dp[x][2]+=max(dp[x-1][1],dp[x-1][0]);
	}
	ll ans=0;
	for(int x=0;x<3;x++){
        if(ans<dp[n-1][x]){
            ans=dp[n-1][x];
        }
        //cout<<dp[n-1][x]<<" ";
	}
	cout<<ans;
}


Measured memory_bytes: 2560
#include<iostream>
#include<map>
#include<string>
#include<stdlib.h>

int OFA();//Operation of Frequency of Appearance

void listen_nums(int nums[],const int count_nums);
void calc_appearance(int nums[],int appearance[],const int count_nums);
void write_calcedArray(int nums[],int appearance[],const int count_nums);
bool is_notMoved(int nums[],int appearance[],const int count_nums);
void echo_intArray(int array[],const int length);

//-------------------------main-------------------------------
int main()
{
	while(OFA());
	return 0;
}

int OFA()
{
	using namespace std;
	int count_nums;
	cin>>count_nums;
	if(!count_nums)
	{
		return 0;
	}
	int nums[count_nums];
	listen_nums(nums,count_nums);
	int appearance[count_nums];
	
	int calcCount=0;
	for(;1;)
	{
		calc_appearance(nums,appearance,count_nums);
		if(is_notMoved(nums,appearance,count_nums))
		{
			cout<<calcCount<<endl;
			echo_intArray(appearance,count_nums);
			return 1;
		}
		else
		{
			calcCount++;
			write_calcedArray(nums,appearance,count_nums);
		}
	}
	
}
//-----------------------------------------------------------

void listen_nums(int nums[],const int count_nums)
{
	using namespace std;
	int i=0;
	string str;
	while(i<count_nums-1)
	{
		getline(cin,str,' ');
		nums[i]=atoi(str.c_str());
		i++;
	}
	cin>>nums[i];
}

void calc_appearance(int nums[],int appearance[],const int count_nums)
{
	using namespace std;
	
	map<int,int> count_eachNums;
	
	int i;
	for(i=0;i<count_nums;i++)
	{
		if(count_eachNums.find(nums[i])==count_eachNums.end())
		{
			count_eachNums.insert(map<int,int>::value_type(nums[i],1));
		}
		else
		{
			count_eachNums[nums[i]]++;
		}
	}
	for(i=0;i<count_nums;i++)
	{
		appearance[i]=count_eachNums[nums[i]];
	}
}

void write_calcedArray(int nums[],int appearance[],const int count_nums)
{
	for(int i=0;i<count_nums;i++)
	{
		nums[i]=appearance[i];
	}
}

bool is_notMoved(int nums[],int appearance[],const int count_nums)
{
	for(int i=0;i<count_nums;i++)
	{
		if(nums[i]!=appearance[i])
		{
			return false;
		}
	}
	return true;
}
void echo_intArray(int array[],const int length)
{
	using namespace std;
	
	cout<<array[0];
	for(int i=1;i<length;i++)
	{
		cout<<" "<<array[i];
	}
	cout<<endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<int>S(N);
  for(int i=0;i<N;i++){
    S.at(A.at(i)-1)=i+1;
  }
  sort(A.begin(),A.end());
  for(int i=0;i<N;i++){
  cout<<S.at(i)<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
 
public class Main {
	static char[][] c;
	static int[][] d;
	static Queue<Long> que;
	static long m = 10000000L;
 
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		sa = br.readLine().split(" ");
		int x1 = Integer.parseInt(sa[0]) - 1;
		int y1 = Integer.parseInt(sa[1]) - 1;
		int x2 = Integer.parseInt(sa[2]) - 1;
		int y2 = Integer.parseInt(sa[3]) - 1;
		c = new char[h][w];
		for (int i = 0; i < h; i++) {
			c[i] = br.readLine().toCharArray();
		}
		br.close();
 
		d = new int[h][w];
		for (int i = 0; i < h; i++) {
			Arrays.fill(d[i], Integer.MAX_VALUE);
		}
		que = new ArrayDeque<>();
		que.add(x1 * m + y1);
		d[x1][y1] = 0;
		while (!que.isEmpty()) {
			long cur = que.poll();
			int cx = (int) (cur / m);
			int cy = (int) (cur % m);
			int alt = d[cx][cy] + 1;
 
			int end = Math.max(cx - k, 0);
			for (int i = cx - 1; i >= end; i--) {
				if (exec(i, cy, alt)) {
					break;
				}
			}
 
			end = Math.min(cx + k, h - 1);
			for (int i = cx + 1; i <= end; i++) {
				if (exec(i, cy, alt)) {
					break;
				}
			}
 
			end = Math.max(cy - k, 0);
			for (int i = cy - 1; i >= end; i--) {
				if (exec(cx, i, alt)) {
					break;
				}
			}
 
			end = Math.min(cy + k, w - 1);
			for (int i = cy + 1; i <= end; i++) {
				if (exec(cx, i, alt)) {
					break;
				}
			}
		}
 
		if (d[x2][y2] == Integer.MAX_VALUE) {
			System.out.println(-1);
		} else {
			System.out.println(d[x2][y2]);
		}
	}
 
	static boolean exec(int x, int y, int alt) {
		if (c[x][y] == '@' || alt > d[x][y]) {
			return true;
		}
		if (alt == d[x][y]) {
			return false;
		}
		que.add(x * m + y);
		d[x][y] = alt;
		return false;
	}
}

Measured memory_bytes: 62456
N = gets.to_i
cards = gets.chomp.split(" ").map(&:to_i)
alice_sum = 0
bob_sum = 0
next_alice = true
cards.sort!.reverse!
0.upto(N-1) do |num|
  if next_alice == true
    alice_sum += cards[num]
    next_alice = false
  elsif next_alice == false
    bob_sum += cards[num]
    next_alice = true
  end
end
puts alice_sum - bob_sum

Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
int nxpt(char *s){
  int i,l=strlen(s),max=0,f[260]={0};
  for(l--;l+1&&max<=s[l];l--)f[max=s[l]]++;
  if(l<0)return 0;
  f[s[l]]++;
  for(i=s[l]+1;f[i]==0;i++);
  f[s[l]=i]--;
  for(i=0;s[++l];f[s[l]=i]--){
    while(f[i]==0)i++;
  }
  return 1;
}
int main(){
  int n,m,q,a[100],b[100],c[100],d[100],e[100],i,j,f,r;
  long long ans=0;
  char s[100]={};
  scanf("%d %d %d",&n,&m,&q);
  for(i=0;i<q;i++)scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
  for(i=0;i<n;i++)s[i]='0';
  for(i=0;i<m;i++)s[i+n]='1';
  s[n+m-1]=0;
  do{
    for(i=j=r=0;s[i];i++){
      if(s[i]=='1')j++;
      else         e[r++]=j;
    }
    //for(i=0;i<r;i++)printf("%d ",e[i]);printf("\n");
    for(i=f=0;i<q;i++){
      if(e[b[i]-1]-e[a[i]-1]==c[i])f+=d[i];
    }
    if(ans<f)ans=f;
  }while(nxpt(s));
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1732
#include<stdio.h>

int main() {
    int A,B,C,X;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&X);

    int total = 0;
    int cnt = 0;
    for(int i = 0; i <= A; i++) {
        for(int j = 0; j <= B; j++) {
            for(int k = 0; k <= C; k++) {
                total = 500*i + 100*j + 50*k;
                if(total == X) {
                    cnt++;
                }
            }
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static int NORMAL_YEAR = 195;
    public static int MILL = 196470;
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int TC = sc.nextInt();
        while (TC-- > 0) {
            int y = sc.nextInt();
            int m = sc.nextInt();
            int d = sc.nextInt();
            System.out.println(MILL - calcDaysToYear(y,m,d));
        }
    }
    
    public static int calcDaysToYear(int y, int m, int d) {
        int totalDays = 0;
        if (y > 1) totalDays = (y-1) * NORMAL_YEAR + ((y-1) / 3) * 5;
            
        if (y % 3 == 0) {
            totalDays += (m-1) * 20 + (d-1);
        } else {
            switch (m) {
                case 2: totalDays += 20; break;
                case 3: totalDays += 20 + 19; break;
                case 4: totalDays += 20 * 2 + 19; break;
                case 5: totalDays += 20 * 2 + 19 * 2; break;
                case 6: totalDays += 20 * 3 + 19 * 2; break;
                case 7: totalDays += 20 * 3 + 19 * 3; break;
                case 8: totalDays += 20 * 4 + 19 * 3; break;
                case 9: totalDays += 20 * 4 + 19 * 4; break;
                case 10: totalDays += 20 * 5 + 19 * 4; break;
                default: break;
            }
            totalDays += d - 1;
        }
        return totalDays;
    }
}




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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
int main()
{
    int N,H,W,A,B,ans=0;
    cin>>N>>H>>W;

    for(int i=1;i<=N;i++){
        cin>>A>>B;
        if(A>=H&&B>=W)ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;

// a / b % MOD;
// (a % MOD) * modinv(b, MOD) % MOD

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

map<int, int> prime_factor(int N)
{
    map<int, int> res;
    for (ll i = 2; i * i <= N; i++) {
        while(N % i == 0) {
            ++res[i];
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}

ll mod_pow(int x, int n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    map<int, int> res;
    rep(i, N) {
        map<int, int> pm = prime_factor(A[i]);
        for (auto itr : pm) {
            if (res.count(itr.first) && res[itr.first] < itr.second) {
                res[itr.first] = itr.second;
            }
            else if (res.count(itr.first) < 1) {
                res[itr.first] = itr.second;
            }
        }
    }

    ll lcm = 1;
    for (auto itr : res) {
        lcm *= mod_pow(itr.first, itr.second, MOD);
        lcm %= MOD;
    }

    ll ans = 0;
    rep(i, N) {
        ans += (lcm % MOD) * modinv(A[i], MOD) % MOD;
        ans %= MOD;
    }

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

Measured memory_bytes: 4108
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while(a > 0 && c > 0){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			break;
		}	
		a -= d;
		if(a <= 0){
			cout << "No" << endl;
			break;
		}
		//cout << a << " " << c << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
	int n;
	string s;
	int main(){
		IOS
		cin>>n;
		cin>>s;
		long long ans=0;
		int s1=0,s2=0,s3=0;
		for(int i=0;i<n;i++){
			if(s[i]=='R'){
				ans+=s2*s3;
				s1++;
			}
			else if(s[i]=='G'){
				ans+=s1*s3;
				s2++;
			}
			else{
				ans+=s1*s2;
				s3++;
			}
		}
		for(int i=0;i<n;i++){
			int la=i; 
			for(int j=i;j<n;j++){
				int t=(i+j)/2;
				if(t==la)
					continue;
				if(s[i]!=s[j]&&s[i]!=s[t]&&s[j]!=s[t])
					ans--;
				la=t;
			}
		}
		cout<<ans<<endl;
		return 0;
	} 

Measured memory_bytes: 3632
#include<stdio.h>

int main(void) {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int max = a;
    if (max < b) {
        max = b;
    }
    if (max < c) {
        max = c;
    }
    printf("%d\n", a+b+c-max);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String[]x = new String[3];
		String ans = "";
		
		for(int i = 0; i < 3; i++){
			x[i] = sc.nextLine();
			ans = ans + x[i].charAt(i);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716