akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define len 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[len];
int head, tail, n;

void enqueue(P x)
{
	Q[tail] = x;
	tail = (tail+1)%len;
}

P dequeue()
{
	P x =Q[head];
	head = (head+1) % len;
	return x;
}

int min(int x, int y)
{
	int z;
	if(x<y){
		z=x;
	}
	else{
		z=y;
	}
	
	return z;
}

int main(void)
{
	int elaps=0, c;
	int i,q;
	P u;
	scanf("%d %d", &n,&q);
	
	for(i=1; i<=n; i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	
	head=1;
	tail=n+1;
	
	while(head != tail){
		u=dequeue();
		c=min(q, u.t);
		u.t=u.t-c;
		elaps=elaps+c;
		if(u.t>0){
			enqueue(u);
		}
		else{
			printf("%s %d\n", u.name, elaps);
		}
	}
	return 0;
}



Measured memory_bytes: 11908
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
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;
}



//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}

////////////////////////////////////////////////////////////////////

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

pair<int,int> a[n+1];
for(int i=1;i<=n;i++){
int p,q;
cin>>p>>q;
a[i]=make_pair(p,q);
}



int dp[6010][n+2];
for(int i=0;i<=6009;i++){
	for(int j=0;j<=n;j++){
		dp[i][j]=0;
	}
}

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

sort(a+1, a+n+1);


int ans=0;

for(int j=1;j<=n;j++){
for(int i=0;i<=t-1;i++){
	
	dp[i][j]=max(dp[i][j], dp[i][j-1]);
if(dp[i][j-1]!=-1){
dp[i+a[j].first][j]=dp[i][j-1]+a[j].second;}

}
}

for(int i=0;i<=6009;i++){
	for(int j=1;j<=n;j++){
		ans=max(ans,dp[i][j]);
	}
}

cout<<ans<<endl;
return 0;





}


Measured memory_bytes: 70784
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] W = new String[N];
        for(int i=0;i<N;i++) W[i]=sc.next();
        String ans = help(N,W);
        System.out.println(ans);
    }
    static String help(int N, String[] W){
        HashSet<String> dic = new HashSet<>();
        dic.add(W[0]);
        String cur = "";
        for(int i=1;i<N;i++){
            cur = W[i];
            String last = W[i-1];
            if(dic.contains(cur)) return "No";
            if(cur.charAt(0)!=last.charAt(last.length()-1)) return "No";
            dic.add(cur);
        }
        return "Yes";
    }
}



Measured memory_bytes: 23764
#include<iostream>
#include<set>
#include<vector>
#include<string>
#include<map>
#include<stack>
using namespace std;

struct Node{
  int name;
  vector<int> edges;
  bool done;
};

set<int> search(vector<Node> g) {

  int now;
  for(int i=0; i<=6; i++)
    if(!g[i].edges.empty())
      now = i;

  stack<int> q;
  set<int> done;
  done.insert(now);
  q.push(now);

  while(!q.empty()) {
    now = q.top();
    done.insert(now);
    q.pop();

    for(int i=0; i<g[now].edges.size(); i++)
      if( done.find(g[now].edges[i])==done.end() ) {
	q.push( g[now].edges[i] );
	//cout<<"edge"<<now<<endl;
      }
  }
  return done;
}

int main() {

  int d,count;
  while(cin>>d) {
    string s;
    set<int> used;
    map<int,int> edge;

    vector<Node> graph;
    for(int i=0; i<=6; i++) {
      Node l;
      l.name = i;
      l.done = false;
      graph.push_back(l);
    }

    for(int i=0; i<d; i++) {
      cin>>s;
      for(int j=0; j<2; j++) {
	used.insert(s.at(j)-'0');
	if(edge.find(s.at(j)-'0')!=edge.end())
	  edge[s.at(j)-'0']++;
	else
	  edge[s.at(j)-'0']=1;
      }
      graph[s.at(0)-'0'].edges.push_back(s.at(1)-'0');
      graph[s.at(1)-'0'].edges.push_back(s.at(0)-'0');
    }

    set<int> con;
    con = search(graph);

    /*
    for(set<int>::iterator it=con.begin(); it!=con.end(); it++)
      cout<<"Set "<<(*it)<<endl;
    */

    for(int i=0; i<graph.size(); i++)
      if(con.find(i)==con.end() && !graph[i].edges.empty() ) {
	//cout<<i<<endl;
	cout<<"No"<<endl;
	goto NEXT;
      }

    count=0;
    for(int i=0; i<graph.size(); i++) {
      if(graph[i].edges.size()%2==1) {
	count++;
	//cout<<i<<endl;
      }
    }

    if(count==0 || count==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

  NEXT:
    ;
  }
}

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

using namespace std;

typedef long long llint;
typedef pair<int, int> P;

int main() {
  int n, l;
  while (true) {
    cin >> n >> l;
    if (l == 0) break;
    vector<int> d(n), p(n);
    for (int i = 0; i < n; i++) {
      char c;
      cin >> c >> p[i];
      if (c == 'R')
        d[i] = 1;
      else
        d[i] = -1;
    }
    int cnt = 0;
    vector<P> ans(n, P(0, 0));
    while (true) {
      cnt++;
      vector<int> dd(n), pp(n);
      for (int i = 0; i < n; i++) {
        if (p[i] == 0 || p[i] == l) continue;
        if (d[i] == 1) {
          pp[i] = p[i] + 1;
          dd[i] = d[i];
          for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (p[i] + 2 == p[j]) {
              if (d[j] == -1) {
                dd[i] = (-1) * d[i];
              }
            }
          }
        } else {
          pp[i] = p[i] - 1;
          dd[i] = d[i];
          for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (p[i] - 2 == p[j]) {
              if (d[j] == 1) {
                dd[i] = (-1) * d[i];
              }
            }
          }
        }
      }
      bool f = true;
      for (int i = 0; i < n; i++) {
        d[i] = dd[i];
        p[i] = pp[i];
        // cout << p[i] << " " << d[i] << endl;
        if (p[i] == 0 || p[i] == l) {
          if (ans[i].first == 0) {
            ans[i].first = cnt;
            ans[i].second = p[i];
          }
          continue;
        }
        f = false;
      }
      if (f) break;
    }
    int resid = 0, res = 0;
    for (int i = 0; i < n; i++) {
      if (res < ans[i].first) {
        res = ans[i].first;
        resid = i;
      } else if (res == ans[i].first) {
        if (ans[i].second == 0) {
          res = ans[i].first;
          resid = i;
        }
      }
    }
    cout << res << " " << resid + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3084
N=int(input())
s=list()
t=list()
st=[]
for i in range(N):
    st.append(input().split())
X=input()
ans=0
count=False
for j in range(N):
    if count:
        ans+=int(st[j][1])
    if st[j][0]==X:
        count=True
print(ans)

Measured memory_bytes: 9136
x = int(input())

num = x // 3
rem = x % 3

if rem == 1:
    res = (num+1)*(num**2)

elif rem == 2:
    res = ((num + 1) ** 2) * num

else:
    res = num ** 3

res2 = (x/3)**3
if res > res2:
    print(res)
else:
    print(res2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> c(h);
    rep(i,h){
            cin>>c[i];
    }
    int64_t ans=0;
    vector<vector<bool>> visited_black(h,vector<bool> (w,false));
    vector<vector<bool>> visited(h,vector<bool> (w,false));
    //queue <pair<int,int>> q;
    int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};
    //cout << dis[sy][sx]<<endl;
    rep(k,h){
        rep(l,w){
            if(c[k][l]=='.' || visited[k][l])continue;
            int sy=k,sx=l;
            queue <pair<int,int>> q;
            q.push(make_pair(sy,sx));
            visited_black[sy][sx]=true;
            visited[sy][sx]=true;
            int times=1;
            int64_t cnt=0;
            while(!q.empty()){
                pair<int ,int> p = q.front();
                q.pop();
                //先頭の今決まってる座標を取り出す
                for(int i=0;i<4;i++){
                    int ny = p.first + dy[i];
                    int nx = p.second + dx[i];
                    if(nx<0||ny<0||ny>=h||nx>=w){
                        continue;
                    }
                    else if(visited[ny][nx]){
                        continue;
                    }
                    else if(c[p.first][p.second]!=c[ny][nx] ){
                        visited[ny][nx]=true;
                        q.push(make_pair(ny,nx));
                        //新しく確定マスをキューに入れる 
                        if(c[ny][nx]=='.')cnt++;   
                        if(c[ny][nx]=='#' && !visited_black[ny][nx]){
                            times++;
                            //sy,sxから行けるところには今到達した黒(ny,nx)からもいける
                            visited_black[ny][nx]=true;
                        }
                    }
                }
            }
            ans += cnt*times;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll n;
    cin >> n;
    map<ll,ll> cnt;
    rep(i,0,n){
        ll a;
        cin >> a;
        cnt[a-1]++;
        cnt[a]++;
        cnt[a+1]++;
    }
    ll ans=0;
    rep(i,-1,100010){
        ans=max(ans,cnt[i]);
    }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9828
#include <stdio.h>

int main(){
    int num=0,i=0,j=0,temp=0;
    double ans=0.0,kao=0.0;
    scanf("%d",&num);
    int yoshio[num];
    for(i=0;i<num;i++){
        scanf("%d",&yoshio[i]);
    }
    for(i=0;i<num-1;i++){
        for(j=i+1;j<num;j++){
            if(yoshio[i]>yoshio[j]){
                temp=yoshio[j];
                yoshio[j]=yoshio[i];
                yoshio[i]=temp;
            }
        }        
    }
    kao=(double)yoshio[0];
    for(i=1;i<num;i++){
        kao=(kao+yoshio[i])/2;
    }
    printf("%lf\n",kao);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

    vector<int> dp(n+1,0);
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://agc003.contest.atcoder.jp/tasks/agc003_c>
問題文============================================================
 高橋君は、誕生日に長さ N の数列をもらいました。i(1≦i≦N) 番目の要素は整数 Ai です。
 どの 2 つの要素も、互いに異なります。 高橋君はこの数列を単調増加になるように並べ替えたいです。
 高橋君は超能力者なので、以下の 2 つの操作が任意のタイミングでできます。
 
 操作1: 数列の連続する 2 つの要素を選び、その 2 つの順番を反転する。
 操作2: 数列の連続する 3 つの要素を選び、その 3 つの順番を反転する。

 高橋君は操作2は好きですが、操作1は嫌いです。
 この 2 種類の操作を使って数列を単調増加になるように並び替えるときの、操作1の最小回数を求めてください。

=================================================================

解説=============================================================
とりあえず、座圧したくなるからする[0-index]
 
 考察として
 操作1はある要素を基準とした時に,1回でその左右どちらの方向の全ての場所全てに到達可能
     (操作2の性質を組み合わせることによって 操作2 を複数回行い 操作1を1回行えば良い)
 
 操作2は ある要素を基準とした時に、その要素が偶数番目であれば偶数番目の全ての場所に移動可能
                             その要素が奇数番目であれば奇数番目の全ての場所に移動可能
 
 となる
 
 よって、例えば
 ex.サンプル1
 2 4 3 1
 (座圧）
     偶数番だが奇数番目に存在する
       v
 1 3 2 0
 ^
 奇数番だが、偶数番目に存在する
 
 となっており,1 を O 1 O O もしくは 0 を 0 O O O とするには
 必ず1回は操作1を行わなければならない
 ここで、 0 と　1 を交換しておけば 全ての偶(奇)数番号が 偶(奇）数番目に存在することになり
 単調増加に並べ替えることができる
 
 さらに、偶数番が奇数番目存在する個数と奇数番が偶数番に存在する個数は互いに一致するので
 
 どちらか一方の個数が、そのまま答えとなる
 
================================================================
*/
ll solve(){
    ll res = 0;
    ll N; cin >> N;
    vector<ll> A(N); for(auto&in:A) cin >> in;
    vector<ll> B = A;
    sort(B.begin(),B.end());
    for(int i = 0; i < N;i++){
        A[i] = lower_bound(B.begin(),B.end(),A[i]) - B.begin();
    }
    for(int i = 0; i < N;i+=2){
        if(A[i]%2 == 0) continue;
        res++;
    }
    return res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a+c, min(a+d, min(b+c, b+d))) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> table(h,vector<char>(w));
    for (int i = 0; i < h; i++) 
    {for(int j=0;j<w;j++){
    cin>>table.at(i).at(j);}
  }
   vector<int> allWhiteRows;
  vector<int> allWhiteCols;
  for(int i=0; i<h; i++){
    bool all = true;
    for(int j=0; j<w; j++){
      if(table.at(i).at(j) == '#'){
        all = false;
      }
    }
    if(all){
      allWhiteRows.push_back(i);
    }
  }
 
  for(int i=0; i<w; i++){
    bool all = true;
    for(int j=0; j<h; j++){
      if(table.at(j).at(i) == '#'){
        all = false;
      }
    }
    if(all){
      allWhiteCols.push_back(i);
    }
  }
  
  for(int i=0; i<h; i++){
    bool flag = false;
    for(int j=0; j<w; j++){
      if(
        find(allWhiteRows.begin(), allWhiteRows.end(),i) == allWhiteRows.end()
        && find(allWhiteCols.begin(), allWhiteCols.end(),j) == allWhiteCols.end()
        ) {
        cout << table.at(i).at(j);
        flag = true;
      }
    }
    if(flag){
      cout << endl;
    }
    
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll long long
#define MOD 1000000007
#define pll             pair<ll,ll>
#define pii             pair<int,int> 
#define mp(a,b)         make_pair(a,b)
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define vb 				vector<bool>
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define FOR(i,a,b) 		for(ll i = a; i <= b ; i++)
#define forn(i,n) 		for(ll i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			ll t;cin>>t;while(t--)
 
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF				INT_MAX
#define INFL			LLONG_MAX
#define max1(x,y) (x)>(y)?(x):(y)
#define ss second
#define ff first
#define MAXN 100001

int main(){
    fast
    ll n;
    cin>>n;
    ll arr[n+1];
    FOR(i,1,n)
    cin>>arr[i];
    ll dp[n+1][n+1];
    FOR(i,1,n){
        for(ll j=i;j>0;j--){
            if(i==j)
            dp[i][j]=arr[i];
            else{
                dp[i][j]=max(arr[i]-dp[i-1][j],arr[j]-dp[i][j+1]);
            }
        }
    }
    // FOR(i,1,n){
    //     FOR(j,1,i){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<dp[n][1]<<endl;
    return 0;
}

Measured memory_bytes: 70528
def s2hms(sec):
    h,m1 = divmod(sec,3600)
    m,s  = divmod(m1,60)
    return("%.2d:%.2d:%.2d" % (h,m,s))

while True:
    h,m,s = map(int,input().strip().split())
    if h==-1 and m==-1 and s==-1:
        break

    rest = 120*60 - ((h*60 + m)*60 + s)
    print(s2hms(rest))
    print(s2hms(3*rest))

Measured memory_bytes: 7612
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;



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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void dfs(Graph& g, ll v, Array& c) {
	for (auto e : g[v]) {
		if (c[e.to] == -1) {
			if (e.cap % 2 == 0) {
				c[e.to] = c[v];
			}
			else {
				c[e.to] = !c[v];
			}
			dfs(g, e.to, c);
		}
	}
}

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

	ll n;
	cin >> n;
	Graph g(n);

	REP(i, n - 1) {
		ll u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		add_edge(g, u, v, w, true, w);
	}

	Array c(n, -1);
	c[0] = 0;
	dfs(g, 0LL, c);

	REP(i, n) cout << c[i] << endl;

	return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define Maxn 187
int n,m;
char s[Maxn][Maxn];
int f[2][Maxn][Maxn][Maxn],g[2][Maxn][Maxn][Maxn];
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for (int k=m;k;k--)
    {
        for (int len=0;len<n;len++)
            for (int i=1;i+len<=n;i++)
            {
                int j=i+len;
                bool flag=true;
                if (len!=0&&(f[0][k][i][j-1]==0||s[j][k]!=s[j-1][k])) flag=false;
                if (!flag) f[0][k][i][j]=0;
                else if (k==m||s[i][k]!=s[i][k+1]) f[0][k][i][j]=1;
                else f[0][k][i][j]=f[0][k+1][i][j]+1;
            }
    }
    for (int k=n;k;k--)
    {
        for (int len=0;len<m;len++)
            for (int i=1;i+len<=m;i++)
            {
                int j=i+len;
                bool flag=true;
                if (len!=0&&(g[0][k][i][j-1]==0||s[k][j]!=s[k][j-1])) flag=false;
                if (!flag) g[0][k][i][j]=0;
                else if (k==n||s[k][i]!=s[k+1][i]) g[0][k][i][j]=1;
                else g[0][k][i][j]=g[0][k+1][i][j]+1;
            }
    }
    int ans=0,pos=0;
    while (f[pos][1][1][n]<m)
    {
        ++ans;
        pos^=1;
        memset(f[pos],0,sizeof(f[pos]));
        memset(g[pos],0,sizeof(g[pos]));
        for (int k=1;k<=m;k++)
            for (int i=1;i<=n;i++)
                for (int j=i;j<=n;j++)
                {
                    int t=f[pos^1][k][i][j];
                    f[pos][k][i][j]=t+f[pos^1][k+t][i][j];
                }
        for (int k=1;k<=n;k++)
            for (int i=1;i<=m;i++)
                for (int j=i;j<=m;j++)
                {
                    int t=g[pos^1][k][i][j];
                    g[pos][k][i][j]=t+g[pos^1][k+t][i][j];
                }
        for (int i=1;i<=n;i++)
            for (int j=1;j<=m;j++)
            {
                int now=1;
                for (int k=m;k>=j;k--)
                {
                    for (int t=now;t<=g[pos][i][j][k];t++)
                        f[pos][j][i][i+t-1]=max(f[pos][j][i][i+t-1],k-j+1);
                    now=g[pos][i][j][k]+1;
                }
            }
        for (int i=1;i<=m;i++)
            for (int j=1;j<=n;j++)
            {
                int now=1;
                for (int k=n;k>=j;k--)
                {
                    for (int t=now;t<=f[pos][i][j][k];t++)
                        g[pos][j][i][i+t-1]=max(g[pos][j][i][i+t-1],k-j+1);
                    now=f[pos][i][j][k]+1;
                }
            }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 106012
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var a = ria();
		Array.Sort(a);
		Console.WriteLine(a[0] * a[1] / 2);
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

if abs(A-B)%2 == 0:
    print(abs(A-B)//2)
else:
    A, B = min(A, B), max(A, B)
    print(min((N-B)-(-(B-A)//2), A-1-(-(B-A)//2)))


Measured memory_bytes: 5196
n = int(input())
m = []
a = [[] for i in range(n)]
for i in range(n):
    tmp = int(input())
    m.append(tmp)
    for j in range(tmp):
        a[i].append(list(map(int,input().split())))

ans = 0

for i in range(2**n):
    cnt = 0
    for j in range(n):
        flg = True
        if i >> j & 1:
            cnt += 1
            for k in range(m[j]):
                kj = (i >> (a[j][k][0]-1)) & 1
                if a[j][k][1] != kj:
                    flg = False
                    break
            if not flg:
                break
    if flg:
        ans = max(ans, cnt)

print(ans)  


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

int main() {
	int n,d[110],l=0,p=0;
	char c[110],f[110];
	string h[110];
	cin>>n;
	
	
	for(int i=0;i<n;i++){
		string s;
		
		cin>>s;
		h[i]=s;
		d[i]=s.size();
		c[i]=s.at(d[i]-1);
		f[i]=s.at(0);
		if(i>0){
			if(c[i-1]==f[i]){
				l++;
			}
		}
		
		
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
		if(h[i]==h[j]){
			p++;
		}	
		}
	}
if(l==n-1&&p==n){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;	
	return 0;
}
}

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


int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int i,j,a[1002],dp[100002];
	for(i=0;i<=k;i++)
		dp[i]=1;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}

	for(i=1;i<=k;i++){
		for(j=1;j<=n;j++){
			if(i>=a[j]){
				if(dp[i-a[j]]==1){
					dp[i]=0;
					break;
				}
			}
		}
	}
	// for(i=1;i<=k;i++){
	// 	printf("dp[%d] %d\n",i,dp[i] );
	// }
	if(dp[k]){
		printf("Second\n");
	}
	else
		printf("First\n");
	// printf("%d\n",dp[k] );



	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<cstdlib>
#include<cctype>
#include<ctime>

using namespace std;

int n;
map<string, int> mp;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		mp[s]++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", mp["AC"], mp["WA"], mp["TLE"], mp["RE"]);
	return 0;
}

Measured memory_bytes: 3732
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
} // }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t H, W, N;
    cin >> H >> W >> N;

    size_t sy, sx;

    vector<tuple<char, size_t, size_t>> vec;
    vector<string> mat(H);
    for (size_t i = 0; i < H; ++i) {
        cin >> mat[i];
        for (size_t j = 0; j < W; ++j) {
            if (mat[i][j] == 'S') {
                sy = i, sx = j;
            } else if (isdigit(mat[i][j])) {
                vec.emplace_back(mat[i][j], i, j);
            }
        }
    }

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

    int64_t res = 0;

    for (auto &vi: vec) {

        queue<pair<int, int>> que;
        que.emplace(sy, sx);

        auto dist = make_v(INF, H, W);
        dist[sy][sx] = 0;

        while (!que.empty()) {
            int y = que.front().first;
            int x = que.front().second;
            que.pop();
            for (size_t i = 0; i < 4; ++i) {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if (inside(ny, nx, H, W) && dist[ny][nx] > dist[y][x] + 1 && mat[ny][nx] != 'X') {
                    que.emplace(ny, nx);
                    dist[ny][nx] = dist[y][x] + 1;
                }
            }
        }

        size_t gy, gx;
        tie(ignore, gy, gx) = vi;

        res += dist[gy][gx];

        sy = gy, sx = gx;
    }

    cout << res << "\n";

    return 0;
}



Measured memory_bytes: 7700
i = input().split(" ")
n = int(i[0])
m = int(i[1])
sc = []

for i in range(m):
  p = input().split(" ")
  p =  [int(j) for j in p]
  sc.append(p)

res = -1
for i in range(1000):
  istr = str(i)
  if len(istr) != n:
    continue
  else:
    tf = []
    for j in sc:
      if istr[j[0]-1] == str(j[1]):
        tf.append(1)
      else:
        tf.append(0)
      
    if sum(tf) == len(tf):
      res = i
      break
    else:
      pass

print(res)

Measured memory_bytes: 3064
S1 = []
S2 = []
S1 = input()
S2 = input()

nL1 = len(S1)
nL2 = len(S2)

nN = nL1 + nL2

for i in range(nN):
  nFlag = i
  nFlag &= 1
  if i == 0:
    nTmp = 0
  else:
    nTmp = i // 2
  if nFlag == 0:
    print(S1[nTmp], end='')
  else:
    print(S2[nTmp], end='')

print('')



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,m,v,p;
    cin>>n>>m>>v>>p;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    int ok=p,ng=n+1;
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        ll sum=(ll)m*max(0,v-(p-1+n-mid+1));
        bool flag=true;
        for(int i=p;i<=mid-1;i++){
            if(a[i-1]>m+a[mid-1]){
                flag=false;
                break;
            }
            sum-=m+a[mid-1]-a[i-1];
        }
        if(!flag||sum>0){
            ng=mid;
        }
        else ok=mid;
    }
    cout<<ok<<endl;
}

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

int main()
{
    string s;
    cin >> s;
    int l = s.size(), ara[30] = {0};
    for(int i = 0; i < l; i++)
    {
        ara[s[i]-'a']++;
    }
    int i = 0;
    for(; i < 26; i++)
    {
        if(!ara[i])break;
    }
    if(i == 26)printf("None");
    else printf("%c", 'a' + i);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <array>

std::array<int, 100005> p;
std::array<int, 100005> fa;

int find(int x)
{
    if (fa[x] != x)
    {
        fa[x] = find(fa[x]);
        return fa[x];
    }
    else
    {
        return x;
    }
}

int main()
{
    int n, m;
    std::cin >> n >> m;
    for (int i = 0; i < n; ++i)
    {
        int temp;
        std::cin >> temp;
        p[i] = temp;
        fa[i] = i;
    }

    for (int i = 0; i < m; ++i)
    {
        int u, v;
        std::cin >> u >> v;

        fa[find(u)] = find(v);
    }

    int count = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (find(p[i - 1]) == find(i))
        {
            count++;
        }
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
	int a,b,sum;
	scanf("%d%d",&a,&b);
	if((a+b>=a*b)&&(a+b>=a-b))sum=a+b;
	if((a*b>=a+b)&&(a*b>=a-b))sum=a*b;
	if((a-b>=a*b)&&(a-b>=a+b))sum=a-b;
	printf("%d",sum);
	return 0;
	}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i,j,k,ans=INF;
	bool flag;
	string s[121];
	cin >> s[0];
	n = s[0].l_ength();
	for(k=0; k<n; ++k){
		for(i=0; i<n; ++i){
			flag = true;
			for(j=i; j<n; ++j){
				if(s[i][j] != s[0][k]){
					flag = false;
				}
			}
			if(flag){
				ans = min(ans,i);
				break;
			}
			s[i+1] = s[i];
			for(j=(i+1); j<n; ++j){
				if(s[i][j-1] == s[0][k] || s[i][j] == s[0][k]){
					s[i+1][j] = s[0][k];
				}else{
					s[i+1][j] = s[i][j];
				}	
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
char s[10][10];

bool go(int h,int w){
	if(s[0][0]!='#') return false;
	int x=0, y=0;
	s[0][0]='.';
	while(x!=h-1 || y!=w-1){
		//printf("%d %d\n",x,y);
		if((x+1<h&&s[x+1][y]=='#') && (y+1<w&&s[x][y+1]=='#')) return false;
		if((x+1<h&&s[x+1][y]!='#') && (y+1<w&&s[x][y+1]!='#')) return false;
		if(x+1<h && s[x+1][y]=='#') x=x+1, s[x][y]='.';
		else if(y+1<w && s[x][y+1]=='#') y=y+1, s[x][y]='.';
		else return false;
	}
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(s[i][j]=='#') return false;
	return true;
}
int main(void){
    int h,w;
    scanf("%d%d",&h,&w);
    int i,j;
    for(i=0;i<h;i++)
		scanf("%s",s[i]);
	if(go(h,w)) printf("Possible\n");
	else printf("Impossible\n");
	
    return 0;
}


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

int main(){
  int N, K, a=1, i=0;
  cin >> N >> K;
  
  for (i; a<K && i<N; i++){
    a *= 2;
  }
  for (i; i<N; i++){
    a += K;
  }
  
  cout << a << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long  ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

int h, w;
int loc(int x) {
	x = (x % (2 * w) + 2 * w) % (2 * w);
	if (x < w)return x;
	else {
		return 2 * w - 1 - x;
	}
}
void solve() {
	int n; cin >> h >> w >> n;
	vec p(w);
	rep(i, w) {
		p[i] = i;
	}
	vec trans(w);
	rep(i, w) {
		if (i % 2 == 0) {
			int x = i + h;
			trans[i] = loc(x);
		}
		else {
			int x = i - h;
			trans[i] = loc(x);
		}
	}
	vector<vector<P>> v(h);
	rep(i, n) {
		int x, y; cin >> x >> y; x--; y--;
		int l = y - x, r = y + 1 + x;
		l = loc(l), r = loc(r);
		v[x].push_back({ l,r });
	}
	rep(i, h) {
		rep(j, v[i].size()) {
			int l = v[i][j].first, r = v[i][j].second;
			swap(p[l], p[r]);
		}
	}
	vector<int> ans(w);
	rep(i, w) {
		ans[p[i]] = trans[i];
	}
	rep(i, w) {
		cout << ans[i] + 1 << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//while (cin >> w>>h>>n,n)solve();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 14036
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
using namespace std;
 
int main () {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < m; i++){
    int a;
    cin >> a;
    sum += a;
  }
  if (sum <= n){
    cout << n - sum;
  }else{
    cout << "-1";
  }

  return 0;
}

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

            #define FOR(i,a,b) for (int i = (a); i < (b); i++)
            #define rep(i,n) FOR(i,0,n)
            #define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
            #define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
            #define FILL(a,value) memset(a, value, sizeof(a))

            #define SZ(a) (int)a.size()
            #define ALL(a) a.begin(), a.end()
            #define PB push_back
            #define MP make_pair
            #define SC second
            #define FS first

            typedef long long LL;
            typedef vector<int> VI;
            typedef vector<LL>VL;
            typedef vector <bool >VB;
            typedef vector<vector<int>>WI;
            typedef vector<vector<LL>>WL;
            typedef pair<int, int> PII;
            typedef pair<double, double> PDD;

            const double PI = acos(-1.0);
            const int INF = 1000 * 1000 * 1000 + 7;
            const LL LINF = LL(1e12);
            const int MAS = int(1e5 * 3 + 1);
            const double EPS = 1e-7;
            const LL MAX = 4294967296;
            const LL MOD =LL(1e9+7);
           int a[MAS];
            void cnt( int n ) {


                sort(a, a + n);

                int count = 0;

                for (int i = n - 1; i >= 1; i--) {
                    int l = 0, r = i - 1;
                    while (l < r) {
                        if (a[l] + a[r] > a[i]) {


                            count += r - l;
                            r--;
                        } else

                            l++;
                    }
                }
                cout << count;
            }

                int main()
            {

             int n;
             cin >> n;
             rep(i,n)cin >> a[i] ;
             cnt(n);

            }


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,j,k,v;
	
	int N;
	int A[128];
	
	/*入力まで*/
	scanf("%d\n",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
	}
	/*入力終わり*/
	for(i=0;i<N;i++)
	{
		v=A[i];
		j=i-1;
		while((j>=0)&&(A[j]>v))
		{
			A[j+1] = A[j];
			j--;
		}
		
		A[j+1]=v;
		
		for(k=0;k<N;k++)
		{
			printf("%d",A[k]);
			if(k!=N-1)
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<int, int> > zeros;
    int start = -1, len = 0, ans = 0, ones = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '1') {
            ++ones;
            if (len != 0) {
                zeros.push_back(make_pair(start, len));
            }
            start = -1;
            len = 0;
        } else {
            ans = max(ans, ones);
            ones = 0;
            if (len == 0) {
                start = i;
            }
            ++len;
        }
    }
    if (len != 0) {
        zeros.push_back(make_pair(start, len));
    }
    ans = max(ans, ones);
    for (int i = 0; i < zeros.size(); ++i) {
        if (i + k < zeros.size()) {
            if (i == 0) {
                ans = max(ans, zeros[i + k].first);
            } else {
                ans = max(ans, zeros[i + k].first - (zeros[i - 1].first + zeros[i - 1].second));
            }
        } else {
            if (i == 0) {
                ans = n;
            } else {
                ans = max(ans, n - (zeros[i - 1].first + zeros[i - 1].second));
            }
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 1020
#include <stdio.h>
#include <map>

using namespace std;
int main(){
  long int n,k;
  multimap<long int, long int> po;
  int qw[10000];
  long int total = 0;
  scanf("%ld%ld", &n, &k);
  for(long int i =0; i < n; i++){
    long int a, b;
    scanf("%ld%ld", &a, &b);
    po.insert(pair<long int, long int>(a, b));
  }
  multimap<long int, long int>::iterator it = po.begin();
  while( it != po.end()){
    total += (*it).second;
    if(k <= total){
      printf("%ld\n", (*it).first);
      return 0;
    }
    it++;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	string S;
	cin >> S;
	string s = { "CODEFESTIVAL2016" };
	int cnt = 0;
	rep(i, 16) {
		if (S[i] != s[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
	long long n, w; cin >> n >> w; std::vector<long long> a(n), b(n);
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
	for(int i = 1; i < n; i++) a[i] -= a[0];
	
	std::vector<std::vector<long long>> vec(4, std::vector<long long>()); vec[0].push_back(b[0]);
	for(int i = 1; i < n; i++) vec[a[i]].push_back(b[i]);
	for(int i = 0; i < 4; i++) sort(rbegin(vec[i]), rend(vec[i]));
	for(int i = 0; i < 4; i++) vec[i].insert(begin(vec[i]), 0);
	for(int i = 0; i < 4; i++) for(int j = 0; j < vec[i].size() - 1; j++) vec[i][j + 1] += vec[i][j];
	
	long long ma = 0;
	for(int i = 0; i < vec[0].size(); i++){
		for(int j = 0; j < vec[1].size(); j++){
			for(int k = 0; k < vec[2].size(); k++){
				for(int l = 0; l < vec[3].size(); l++){
					long long W = i * a[0] + j * (a[0] + 1) + k * (a[0] + 2) + l * (a[0] + 3);
					if(W > w) continue;
					long long V = vec[0][i] + vec[1][j] + vec[2][k] + vec[3][l];
					ma = std::max(ma, V);
				}
			}
		}
	}
	
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let s = [| for _ in 1.. n -> stdin.ReadLine()|]

let combi2 x =int64 x * int64 (x-1L) / 2L
s |> Array.map (fun str -> str.ToCharArray() |> Array.countBy(fun x -> x ))
|> Array.countBy (fun x -> x |> Set.ofArray)
|> Array.sumBy (fun (_, count) -> combi2 <| int64 count)
|> stdout.WriteLine


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

int main() {
	int N,A;
	int plan1,plan2;
	
	cin >> N >> A >> plan2;
	
	if (N >= 1 && N <= 20 && A >=1 && A <= 100 && plan2 >=1 && plan2 <= 2000) {
		plan1 = N * A;
		if (plan1 <= plan2) {
			cout << plan1 << endl;
		} else {
			cout << plan2 << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		sc.close();

		for (long i = x; i < 1000000; i++) {
			if (isSosuu(i)) {
				System.out.println(i);
				return;
			}
		}
	}

	static boolean isSosuu(long n) {
		if (n < 2) return false;
		long end = (int) Math.sqrt(n);
		for (int i = 2; i <= end; i++) {
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000007
using namespace std;

int main(){
  long n;
  cin >> n;
  long a = 2;
  long hyo[n+1];
  rep(i,n+1){
    hyo[i] = 1;
  }
  while(a<=n){
    long ai = a;
    long i = 1;
    while(ai*i<=n){
      hyo[ai*i] += 1;
      i++;
    }
    a++;
  }
  long ans = 0;
  for(int i=1;i<n+1;i++){
    ans += i*hyo[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81688
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if (i+j)%2==0:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()



Measured memory_bytes: 7000
#include <stdio.h>

int N,A[100010],D[2];

int main()
{
	int l = 0;

	scanf ("%d",&N);
	for (int i=0;i<N;i++){
		int x; scanf ("%d",&x);
		if (l == x){i--; N--; continue;}
		A[i] = x;
		l = x;
	}

	D[0] = D[1] = 1;
	for (int i=1;i<N;i++){
		if (A[i-1] < A[i]){
			if (D[0] < D[1])
				D[1] = D[0] + 1;
			else
				D[1]++;
		}
		else{
			if (D[0] < D[1])
				D[0]++;
			else
				D[0] = D[1] + 1;
		}
	}

	printf ("%d\n",D[0]<D[1]?D[0]:D[1]);

	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> v;
  rep(i, n)
  {
    int c;
    cin >> c;
    v.push_back(c);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout << v.size() << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a1,a2,b1,b2;
    cin>>a1>>a2>>b1>>b2;
    if(a1+a2>b1+b2) cout<<"Left"<<endl;
    if(a1+a2==b1+b2) cout<<"Balanced"<<endl;
    if(a1+a2<b1+b2) cout<<"Right"<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n,a,b;
  cin >> n>> a >> b;
  ll res = 0;
  rep(i,n){
    int k = i+1;
    int cnt = 0;
    while(k){
      cnt += k%10;
      k /= 10;
    }
    if(cnt >= a && cnt <= b)res += i+1;
  }
  cout << res << endl;




  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector <vector<ll>> dp(n,vector<ll>(n));
    dp[0][0] = 1;
    for (int z=1;z<n;z++){
        vector <ll> pre(z);
        pre[0] = dp[z-1][0];
        for (int x=1;x<z;x++){
            pre[x] += pre[x-1]+dp[z-1][x];
            pre[x] %= mod;
        }
        for (int x=0;x<=z;x++){
            if (s[z-1] == '<'){
                if (x > 0) dp[z][x] = pre[x-1];
            } else {
                if (x > 0) dp[z][x] = pre[z-1]-pre[x-1];
                else dp[z][x] = pre[z-1];
            }
            dp[z][x] %= mod;
        }
    }
    ll ans = 0;
    for (int z=0;z<n;z++){
        ans += dp[n-1][z];
        ans %= mod;
    }
    if (ans < 0) ans += mod;
    cout << ans << endl;
}

Measured memory_bytes: 70784
//author: #theinfiniteboy aka @shaswatkumar362
#include <bits/stdc++.h>

//#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
#define ll long long int
#define bigint int64_t
#define endl '\n'
#define vll vector<ll>
#define it vector<ll>::iterator
#define pb push_back
#define mp make_pair
#define BAYBAY ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define test ll T;cin>>T;while(T--)
#define dbg(x) cout << #x << ":" << x << "\t";
#define deb(t) for(auto x: t) { cout << x << " "; } cout << "\t";
#define maxi(v) *max_element(v.begin(),v.end())
#define mini(v) *min_element(v.begin(), v.end())
#define F first
#define S second
#define fo(i,n) for(i=0;i<n;i++)

/*template<typename... T>
void read(T&...args) {
    ((cin>>args), ...);
}

template<typename... T>
void write(T&&... args) {
    ((cout << args << " "), ...);
}*/

ll fib(ll n) { 
  double phi = (1 + sqrt(5)) / 2; 
  return round(pow(phi, n) / sqrt(5)); 
}

void SieveOfEratosthenes(ll n, vector<ll> &v) 
{  
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          v.pb(p); 
} 

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    BAYBAY;
    ll a,b;
    cin>>a>>b;
    cout << a*b;
	return 0;
} // farewell....

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
#define ll long long
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  int N, D;
  cin >> N >> D;
  
  int x[12][12];
  
  FOR(i, 0, N){
    FOR(j, 0, D) cin >> x[i][j]; 
  }
  
  double sum, ans;
  ll count = 0;
  
  FOR(i, 0, N-1){
    FOR(j, i+1, N){
      sum = 0;
      FOR(k, 0, D) sum += (double)(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      ans = sqrt(sum);
      if(ceil(ans) == floor(ans)) count++;
    }
  }
    
  cout << count << endl;
}

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

using namespace std;

int main(){
  int n,r,p,c;
  while(1){
    cin >> n >> r;
    if (n==0) return 0;
    vector<int> ca(n,0);
    for(int i=0;i<n;i++){
      ca[i]=n-i;
    }
    for(int i=0;i<r;i++){
      cin>>p>>c;
      vector<int>sw(c,0);
      for(int j=0;j<c;j++){
        sw[j]=ca[p-1];
        ca.erase(ca.begin()+p-1);
      }
      for(int j=c-1;j>=0;j--){
        ca.insert(ca.begin(),sw[j]);
      }
    }
    cout << ca[0]<<endl;
  }
}

Measured memory_bytes: 3156