akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define ll long long 
#define pre(a,b) cout<<fixed<<setprecision(a)<<b<<"\n";//a for precision b for answer
#define mp make_pair
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b) 
#define forn(n) for(ll i=0;i<n;i++) 
#define ff first
#define ss second
#define MAX 1e18;
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
const int MOD = 1e9 + 7;
const int v1=1e5+5;
#define pi 3.141592653589793238
const int N=3e5+5;
 
 
//cout<<"Case #"<<p<<": "<<;
//file input  freopen("input.txt","r",stdin); 
//file output freopen("output.txt","w",stdout);
 
using namespace std;
 
int32_t main()
{
  IOS 
  ll k=0;
  ll n=0;
  ll m=0;
  cin>>n>>m>>k;
  vector <ll>a(n+1,0);
  vector <ll> b(m+1,0);
  forn(n)
  {
    cin>>a[i+1];
    a[i+1]+=a[i];
  }
  forn(m)
  {
    cin>>b[i+1];
      b[i+1]+=b[i];
  }
  ll j=m;ll ans=0;
  forn(n+1)
  {
    if(a[i]>k)
      break;
    while(a[i]+b[j]>k)j--;
    ans=max(ans,i+j+0LL);
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 6304
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DStringFormation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      deque<char> que;
      for(auto c: s) {
        que.push_back(c);
      }
      int q; cin >> q;
      bool rev = false;
      while(q--) {
        int t; cin >> t;
        if (t==1) {
          rev = !rev;
        } else {
          int f; char c; cin >> f >> c;
          if (rev ^ (f==1)) {
            que.push_front(c);
          } else {
            que.push_back(c);
          }
        }
      }
      if (rev) reverse(all(que));
      for(auto c: que) {
        cout << c;
      }
      cout << endl;

    }
};

signed main() {
  DStringFormation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 976
n,q=map(int,input().split())
Q=[list(map(int,input().split())) for i in range(q)]

#Segment tree（区間の最小値を求めるバージョン）
for i in range(30):#要素数以上の2のベキを見つける
    if n<=1<<i:
        seg_el=1<<i#Segment treeの台の要素数
        break

SEG=[(1<<31)-1]*(2*seg_el-1)#Segment treeを一次元リストとして作る

def update(n,x,seg_el):#A[n]=xに更新（反映）
    i=n+seg_el-1
    SEG[i]=x
    i=(i-1)//2
    
    while i>=0:
        SEG[i]=min(SEG[i*2+1],SEG[i*2+2])
        i=(i-1)//2
        

def getvalues(a,b,k,l,r):#区間[a,b)での,SEG[k],つまり区間[l,r)に関する最小値を調べる
    if r<=a or b<=l:#区間[a,b)が対象区間の外にあれば,infを出力
        return (1<<31)-1
    if a<=l and r<=b:#区間[a,b)が対象区間の中にあればSEG[k]を出力
        return SEG[k]
    vl=getvalues(a,b,k*2+1,l,(l+r)//2)#それ以外のときは,SEG[k*2+1]とSEG[k*2+2]で場合分け（木の子ノード二つを見る）
    vr=getvalues(a,b,k*2+2,(l+r)//2,r)
    return min(vl,vr)

for com,x,y in Q:
    if com==0:
        update(x,y,seg_el)
    else:
        print(getvalues(x,y+1,0,0,seg_el))


Measured memory_bytes: 26604
object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    val result = getResult(in)
    print(result)
  }
  def getResult(in:java.util.Scanner):String={
    val m = in.nextInt()
    val f = in.nextInt()
    val r = in.nextInt()
    if(m== -1 && f == -1 && r == -1){
      return ""
    }
    if(m == -1 || f == -1){
      return "F\n"+getResult(in)
    }else if(m+f >= 80){
      return "A\n" + getResult(in)
    }else if(m+f < 80 && m+f >= 65){
      return "B\n" + getResult(in)      
    }else if((m+f < 65 && m+f >=50) || (m+f < 50 && m+f >=30 && r >= 50) ){
      return "C\n" + getResult(in)     
    }else if(m+f < 50 && m+f >= 30){
      return "D\n" + getResult(in)     
    }else{
      return "F\n" + getResult(in)     
    }
  }
}

Measured memory_bytes: 45116
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Good Grid
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_C = 30;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int ds[MAX_C][MAX_C], es[3][MAX_C], fs[3][MAX_C];
bool used[MAX_C];

/* subroutines */

/* main */

int main() {
  int n, c;
  scanf("%d%d", &n, &c);

  for (int i = 0; i < c; i++)
    for (int j = 0; j < c; j++) scanf("%d", &ds[i][j]);

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      int cij;
      scanf("%d", &cij);
      cij--;
      es[(i + j) % 3][cij]++;
    }

  for (int k = 0; k < 3; k++)
    for (int i = 0; i < c; i++)
      for (int j = 0; j < c; j++)
	fs[k][j] += es[k][i] * ds[i][j];

  int minsum = INF, nn = n * n;
  
  for (int c0 = 0; c0 < c; c0++) {
    used[c0] = true;
    for (int c1 = 0; c1 < c; c1++)
      if (! used[c1]) {
	used[c1] = true;
	for (int c2 = 0; c2 < c; c2++)
	  if (! used[c2]) {
	    int sum = fs[0][c0] + fs[1][c1] + fs[2][c2];
	    if (minsum > sum) minsum = sum;
	  }
	used[c1] = false;
      }
    used[c0] = false;
  }

  printf("%d\n", minsum);
  return 0;
}


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

int main(){
    int a,b; cin>>a>>b;
    int ans=1;

    if(a<=b){
        for(int i=0;i<b;i++)cout<<a;
        }else{
            for(int i=0;i<a;i++)cout<<b;
                }
        }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxx = 2000001;
const int maxnum = 10010;
int A[maxx], B[maxx];
int C[maxnum];

int main() {
	int n;
	scanf("%d", &n);

	//????§????C??°???
	for (int i = 0; i < maxnum; i++)
		C[i] = 0;

	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i + 1]);
		//?????°??°C??°???
		C[A[i + 1]]++;
	}

	// ?´???????
	for (int i = 1; i < maxnum; i++)
		C[i] += C[i - 1];

	for (int j = 1; j <= n; j++) {
		B[C[A[j]]] = A[j];
		C[A[j]] --;
	}
	for (int i = 1; i <= n; i++)
		printf("%d%c", B[i], i == n ? '\n' : ' ');

	return 0;
}

Measured memory_bytes: 18860
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll a,b,c; cin >> a >> b >> c;
        if(a%2==0 or b%2==0 or c%2==0)cout<<0<<endl;
        else{
            cout<<min((b*c),min((c*a), (a*b)))<<endl;
        }


return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int INF = 1e9 + 7;
int dp[maxn];
int a[maxn];
int main() {
	int n, k;
	while (cin >> n >> k) {
		for (int i = 1; i <= n; i++)
			scanf("%d", &a[i]);
		for (int i = 1; i <= n; i++)
			dp[i] = INF;
		dp[1] = dp[0] = 0;
		for (int i = 2; i <= n; i++)
			for (int j = i - 1; j >= max(1, i - k); j--)
				dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		cout << dp[n] << endl;
	}

}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using static System.Console;

namespace LinearSearch
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var seq1 = ReadLine().Split(' ').Select(int.Parse).Distinct();
            var q = int.Parse(ReadLine());
            var seq2 = ReadLine().Split(' ').Select(int.Parse);

            var count = 0;
            foreach (var key in seq2)
            {
                if (LinearSearch(seq1, key) != -1) count++;
            }
            WriteLine(count);
        }

        private static int LinearSearch<T>(IEnumerable<T> col, T key)
            where T:IComparable
        {
            var i = 0;
            var list = col.ToList();
            while (list[i].CompareTo(key) != 0)
            {
                i++;
                if (i == list.Count - 1)
                {
                    return -1;
                }
            }


            return i;
        }
    }
    
}


Measured memory_bytes: 28324
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	using F=function<T(T,T)>;
	const F calcfn,updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree(int n_=0,T defvalue_=numeric_limits<T>::max(),
		const F calcfn_=[](T a,T b){return a<b?a:b;},
		const F updatefn_=[](T a,T b){return b;}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query(int a,int b)//[a,b)
	{
		int L=(a<0?0:a>n?n:a)+n-1;
		int R=(b<0?0:b>n?n:b)+n-1;
		T lret=defvalue,rret=defvalue;
		for(;L<R;L>>=1,R>>=1)
		{
			if(!(L&1))lret=calcfn(lret,dat[L]);
			if(!(R&1))rret=calcfn(dat[--R],rret);
		}
		return calcfn(lret,rret);
	}
};
main()
{
	int N,Q;
	cin>>N>>Q;
	vector<int>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	segtree<int>P(N,0,
		[](int a,int b){return a<b?b:a;},
		[](int a,int b){return b;}
	);
	P.copy(A);
	for(int i=0;i<Q;i++)
	{
		int t,l,r;cin>>t>>l>>r;
		if(t==1)
		{
			P.update(l-1,r);
		}
		else if(t==2)
		{
			cout<<P.query(l-1,r)<<endl;
		}
		else
		{
			int L=l-1,R=N+1;
			while(R-L>1)
			{
				int mid=L+R>>1;
				if(P.query(l-1,mid)>=r)R=mid;
				else L=mid;
			}
			cout<<R<<endl;
		}
	}
}


Measured memory_bytes: 6120
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include<set>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

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

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

ll npk(ll n, ll k) {
	ll ret = 1;
	if (n < k || n < 0)return 0;
	rep(i, 0, k) {
		ret *= (n - i);
		ret %= MOD;
	}
	if (ret < 0) ret = 0;
	return ret;
}

//135 B
int main(void) {
	ll count = 0;
	ll n = 0;
	cin >> n;
	rep(i, 1, n+1) {
		ll j = 0;
		cin >> j;
		if (i != j)count++;
	}
	if (count <= 2)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> f(n+1, 0);
  for(int i=0; i<n; i++){
    f[i+1]=f[i]+(s[i]=='I'?1:-1);
  }
  sort(all(f));
  cout << f.back() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int k;
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  scanf("%d",&k);
  printf("%d",a[k-1]);
  return 0;
};




Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
constexpr int  INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int a,b;
  cin>>a>>b;
 a *= 3;
  b += a;
  cout << b / 2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
    double n,m,d;
    cin >> n >> m >> d;
    cout << fixed << setprecision(10);
    if(d==0){
        cout << (m-1) / n << endl;
    }else{
        cout << (m-1)*(2*(n-d)/n) / n << endl;
    }
    return 0;
}


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

string s;
int K;
vector<string> substring;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s >> K;
    for(int i=0; i<s.length(); i++) {
        string temp="";
        int lol = s.length();
        int next = min(lol, i+5);
        for(int j=i; j<next; j++) {
            temp += s[j];
            substring.push_back(temp);
        }
    }
    sort(substring.begin(), substring.end());
    substring.erase( unique( substring.begin(), substring.end() ), substring.end() );
    cout<<substring[K-1]<<endl;

    return 0;
}


Measured memory_bytes: 1660
from collections import Counter
 
N = int(input())
A = list(map(int, input().split()))
h = w = 0
 
for i, cnt in Counter(A).items():
    if cnt >= 2 and i > w:
        if i > h:
            if cnt >= 4:
                h = i
                w = i
            else:
                w = h
                h = i
        else:
            w = i
            
print(w * h)

Measured memory_bytes: 18572
#include<stdlib.h>
p(int*a,int*b){return*a-*b;}c,V,i,f[999];main(d){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){for(f[0]=i=2;i<V;i++)f[i]=(f[i-1]+f[i-2])%1001;qsort(f,V,4,p);for(i=c=1;i<V;f[i]-f[i++-1]<d?:c++);}exit(0);}

Measured memory_bytes: 640
import java.util.*;


class Main{
  
      
  
  
	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      
      String s = sc.next();
      StringBuilder ans = new StringBuilder();
      
      for(int i=0;i<s.length();i++){
      	if(s.charAt(i)=='0'){
        	ans.append('0');
        } else if(s.charAt(i)=='1'){
        	ans.append('1');
        } else {
          if(ans.length() > 0){
        	ans.deleteCharAt(ans.length()-1);
          }
        }
      }
      System.out.println(ans);
	}
}

Measured memory_bytes: 35600
#include <stdio.h>
//#include <stdlib.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  for (int i=0; i<=n/4; i++) {
    if ((n-i*4)%7 == 0) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
string s;

bool comp(const pi &a, const pi &b){
  return a.sc-a.fs>b.sc-b.fs;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;
  vi ll,rr;
  vpi pos,neg;
  for(int i=0;i<n;i++){
    cin >> s;
    int lef = 0, rig = 0;
    vi v;
    int l = 0, r = 0;
    for(int j=0;j<s.size();j++){
      if(s[j]=='('){l++;v.pb(j);}
      else {
        r++;
        if(v.size()){
          v.pop_back();
        }
      }
      lef = max(lef,r-l);
    }
    rig = v.size();
    if(lef==0 && rig==0){
      
    }
    else if(lef>0 && rig == 0){
      ll.pb(lef);
    }
    else if(lef==0 && rig>0){
      rr.pb(rig);
    }
    else {
      // both.pb({lef,rig});
      if(rig-lef>=0){
        pos.pb({lef,rig});
      }
      else {
        neg.pb({lef,rig});
      }
    }
  }
  // cout << ll << " " << rr << " " << both << endl;
  int l = 0;
  sort(all(pos));
  sort(all(neg));
  reverse(all(neg));
  // cout << both << endl;
  // cerr << pos << " " << neg << endl;
  for(auto t:rr){
    l+=t;
  }
  for(auto t:pos){
    l-=t.first;
    if(l<0){
      cout << "No" << endl;
      return 0;
    }
    l+=t.second;
  }
  for(auto t:neg){
    l-=t.first;
    if(l<0){
      cout << "No" << endl;
      return 0;
    }
    l+=t.second;
  }
  for(auto t:ll){
    l-=t;
  }
  if(l!=0){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

return 0;
}
///....


Measured memory_bytes: 11236
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)
 
let warshall_floyd ( + ) min n d =
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      for k = 0 to n - 1 do
        d.(j).(k) <- min d.(j).(k) (d.(j).(i) + d.(i).(k))
      done
    done
  done
 
let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let es = Array.init m (fun _ ->
    Scanf.scanf "%d %d %d\n" (fun a b c -> (a, b, c))) in
  let dp = Array.make_matrix n n infinity in
  for i = 0 to n - 1 do
    dp.(i).(i) <- 0.
  done;
  Array.iter (fun (a, b, c) ->
    dp.(a - 1).(b - 1) <- float_of_int c;
    dp.(b - 1).(a - 1) <- float_of_int c) es;
  warshall_floyd ( +. ) min n dp;
  Array.to_list es
  |> List.filter (fun (a, b, c) ->
      dp.(a - 1).(b - 1) < float_of_int c)
  |> List.length
  |> Printf.printf "%d\n"

Measured memory_bytes: 2688
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np

n = int(input())
a = list(int(i) for i in input().split())

cnt = 0
b = np.arange(n) + 20000
for i in range(1,n):
  if a[i - 1] == a[i]:
    a[i] = b[i]
    cnt += 1
print(cnt)


Measured memory_bytes: 13668
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	auto r = N % 500;
	if (r <= A)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define sz(x)       (int)x.size()
#define f			first
#define debug		cout<<"##########3"<<endl
#define mod			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == precedence gretaer then &
ll n,m;
string s,s1,s2;
priority_queue <long long int> pq;
map<ll, char> mp;
vector<pair<int,int> > inc;
vector<pair<int,int> > de;
ll arr[300005],barr[300005];
//EG
ll power(ll a,ll b){
	if(b==0)
	return 1LL;
	else if(b==1)
		return a;
	ll temp = power(a,b/2);
	if(b%2==0){	
		return temp*temp;
	}
	else
		return temp*temp*a;
	
}
ll dp[1005][5000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	ll i,j,k,z,ans=0,c=0,x=0,y=0;
	
	cin>>n>>m;
	rep(i,0,m){
		cin>>arr[i];
		cin>>x;
		rep(j,0,x){
			cin>>y;
			barr[i]|=(1<<(y-1));
		}
//		cout<<barr[i]<<endl;
	}
	for(i=0;i<=1001;i++){
		for(j=0;j<=4900;j++)
		{
			if(i==0)
				dp[i][j]=INT_MAX;
			else
				dp[i][j]=INT_MAX;
		}
		
	}
	dp[0][0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<pow(2,n);j++){
			dp[i+1][j] = dp[i][j-(j&barr[i])] + arr[i];//include
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);//exclude
		}
	}
	if(dp[m][(power(2,n)-1LL)]==INT_MAX)
	cout<<-1;
	else
	cout<<dp[m][(power(2,n)-1LL)];
	
 	return 0;
}

Measured memory_bytes: 43392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  vector<queue<char>> s(3);
  rep(i,3) {
    string t; cin >> t;
    rep(j,t.size()) s[i].push(t[j]);
  }
  int turn = 0;
  //!s[0].empty()&&!s[1].empty()&&!s[2].empty()
  while (true)
  {
    if (s[turn].empty()) break;
    char c = s[turn].front(); s[turn].pop();
    if (c == 'a') turn = 0;
    else if (c=='b') turn = 1;
    else turn = 2;
  }
  if (turn==0) cout << 'A' << endl;
  else if (turn==1) cout << 'B' << endl;
  else cout << 'C' << endl;
  return 0;
}

Measured memory_bytes: 3612
use std::io;
use std::cmp::max;

fn main() {
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n: i16 = buf.trim().parse().unwrap();
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let v1: Vec<i32> = buf.trim().split_whitespace().map(
        |s| s.parse::<i32>().unwrap())
        .collect();
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let v2: Vec<i32> = buf.trim().split_whitespace().map(
        |s| s.parse::<i32>().unwrap())
        .collect();
    let mut nmax = 0;
    for i in 0..n {
        nmax = max(nmax,
                   v1[..(i as usize) + 1].iter().sum::<i32>() +
                   v2[(i as usize)..].iter().sum::<i32>());
    }
    println!("{}", nmax);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    if (A[0] != 0) {
        cout << "-1\n";
        return 0;
    }
    ll ans = A[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        if (A[i] == A[i + 1] - 1) continue;
        if (A[i] < A[i + 1] - 1) {
            cout << "-1\n";
            return 0;
        }
        ans += A[i];
    }
    cout << ans << endl;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;

class ModCase{ // modの元での場合の数
public:
  vector<ll> fact, finv;

  static ll mod_pow(ll a, ll n){
    if(n == 0) return 1;
    if(n % 2 == 0) return mod_pow((a * a) % mod, n/2);
    return (a * mod_pow(a, n-1) % mod);
  }

  ModCase(ll N):fact(N+1), finv(N+1){ // O(N)で初期化
    fact[0] = 1;
    FOR(i, 1, N+1) fact[i] = (i * fact[i-1]) % mod;
    finv[N] = mod_pow(fact[N],mod-2);
    ROF(i, N, 0) finv[i] = finv[i+1] * (i+1) % mod;
  }

  ll C(ll n, ll r){ // nCr
    if(r < 0 or n < r) return 0;
    return fact[n] * finv[r] % mod * finv[n-r] % mod;
  }

  ll P(ll n, ll r){ // nPr
    if(r < 0 or n < r) return 0;
    return fact[n] * finv[n-r] % mod;
  }

  ll H(ll n, ll r){ // nHr
    return C(n+r-1,r);
  }
};

ll ext_gcd(ll a, ll b, ll &x, ll &y){ // ax+by=gcd(a,b)なるx,y,gcdを返す
  if(b == 0){
    x = 1; y = 0; return a;
  }
  ll q = a / b;
  ll g = ext_gcd(b, a-q*b, x, y);
  ll z = x - q * y;
  x = y; y = z;
  return g;
}

ll invmod(ll a, ll m){ // a^-1(mod m)を返す
  ll x, y;
  ext_gcd(a,m,x,y);
  x %= m;
  if(x < 0) x += m;
  return x;
}

signed main(){
  int n, a, b, c; cin >> n >> a >> b >> c;
  ModCase mc(2*n);
  int an = 1, bn = 1; // a^nとb^n
  rep(i,n){
    an *= a;
    an %= mod;
    bn *= b;
    bn %= mod;
  }
  int h = 1; // (a+b)^n
  int invh = invmod(a+b,mod); // (a+b)^-1
  rep(i,n){
    h *= invh;
    h %= mod;
  }
  int tmpa = 1, tmpb = 1; // a^iとb^i
  int p = 0, q = 0; // p / q
  rep(i,n){
    int tmp = (mc.C(n-1+i,i) * h) % mod;
    p += ((((((n+i) * an) % mod) * tmp) % mod) * tmpb) % mod;
    p %= mod;
    q += (((an * tmp) % mod) * tmpb) % mod;
    q %= mod;
    tmpb *= b;
    tmpb %= mod;
    p += ((((((n+i) * bn) % mod) * tmp) % mod) * tmpa) % mod;
    p %= mod;
    q += (((bn * tmp) % mod) * tmpa) % mod;
    q %= mod;
    tmpa *= a;
    tmpa %= mod;
    h *= invh;
    h %= mod;
  }
  p *= 100;
  p %= mod;
  q *= a+b;
  q %= mod;
  int g = ext_gcd(p,q,a,b);
  p /= g;
  q /= g;
  cout << (p * invmod(q,mod)) % mod << endl;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int n;
int a[100];

int main(void){
    // Your code here!
    cin >> n;
    REP(i,n){
        cin >> a[i];
    }
    int result = 0;
    int count = 1;
    int last = 0;
    REP(i,n){
        if(a[i] == last){
            count++;
        }else{
            result += count / 2;
            count = 1;
            last = a[i];
        }
    }
    result += count / 2;
    cout << result;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  int x ;
  cin >> x ;
  if((a+b)%2==0){
    x = (a+b)/2;
  }
  else{
    x = (a+b+1)/2;
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int main() {

	set<int> s;
	s.insert(6);
	int d = 6;
	for (int i = 0; d <= 300000; i++) {
		if (i % 2 == 0) d += 2;
		else d += 5;
		s.insert(d);
	}
	//cout << "Finish!" << endl;

	while (1) {
		int n;
		cin >> n;
		if (n==1) break;

		vector<int> v;
		
		d = 6;
		bool flag = false;
		for (int i = 0; d <= n; i++) {
			//cout << "i : " <<i<<" d : "<<d<<endl;
			if (flag) {
				if (i % 2 != 0) d += 2;
				else d += 5;
			}
			flag = true;
			if (n%d == 0 && (s.find(n/d)!=s.end() || n/d == 1)) {
				bool t = true;
				for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
					if (d%*it == 0 && *it < d) {
						t = false;
						break;
					}
				}
				if(t) v.push_back(d);
			}
		}

		cout << n<<":";
		for (int i = 0; i < v.size(); i++) cout << " " << v[i];
		cout << endl;

	}


	return 0;
}

Measured memory_bytes: 7028
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;
int ans=0;
int A[10][10];
int main(void){
	int N,D;
		cin >> N >> D;
	rep(i,0,N){
		rep(j,0,D){
			cin >> A[i][j];
		}
		_rep_(k,i-1,0){
			long a=0;
			if(k<0)break;
			rep(l,0,D){
				a+=(A[i][l]-A[k][l])*(A[i][l]-A[k][l]);
			}
			double x=sqrt(a);
			if(!(ceil(x)!=floor(x)))
				ans++;
		}
	}
	puts(ans);
	return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int p[405][405], memo[405][405];
int n, c;

// idx以降でx個残っているとき
int dfs(int idx, int x) {
  if(memo[idx][x]!=-1) return memo[idx][x];
  if(idx == n-1) return memo[idx][x] = p[idx][x];
  int ret = 0;
  REP(i, x+1) {
    (ret += p[idx][i] * dfs(idx+1, x-i) % MOD) %= MOD;
  }
  return memo[idx][x] = ret;
}

ll binpow(ll x, ll e, ll mo=MOD) {
  ll a = 1, p = x;
  while(e > 0) {
    if(e%2 == 0) {p = (p*p) % mo; e /= 2;}
    else {a = (a*p) % mo; e--;}
  }
  return a;
}

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

  cin >> n >> c;
  V<int> a(n), b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  REP(i, n) {
    REP(j, c+1) {
      FOR(k, a[i], b[i]+1) {
        (p[i][j] += binpow(k, j)) %= MOD;
      }
    }
  }

  memset(memo, -1, sizeof(memo));
  cout << dfs(0, c) << endl;

  return 0;
}


Measured memory_bytes: 2816
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  long N,A,B;in(N,A,B);
  vector<long>X(N);ins(X);
  long ans=0;
  rep(i,N-1)ans+=min((X[i+1]-X[i])*A,B);
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n;
	while(cin >> n && n) {
		vi a(n);
		rep(i, n) cin >> a[i];
		sort(all(a));
		int ans = INF;
		rep(i, n - 1) ans = min(ans, a[i+1] - a[i]);
		cout << ans << endl;
	}
}

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = a;i >=1;--i) {
		if (a % i == 0 && b % i == 0) {
			--k;
			if (k == 0) {
				cout << i << endl;
			}
		}
		
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  string a,b;
  cin >> a >> b;
  if((a=="H"&&b=="H")||(a=="D"&&b=="D")){ cout << "H" << endl; return 0; }
  cout << "D" << endl;
  return 0;
}


Measured memory_bytes: 256
#h時m分の時の座標を求める

import math

temp = input().split(" ")

al = int(temp[0])
bl = int(temp[1])
h = int(temp[2])
m = int(temp[3])


#時間
a = ((h * 60 + m) / 720) * 2 * math.pi
b = (m / 60) * 2 * math.pi

cax = al * math.cos(a)
cay = al * math.sin(a)
cbx = bl * math.cos(b)
cby = bl * math.sin(b)

#print(cax, cay)
#print(cbx, cby)

length = pow((cax - cbx), 2) + pow((cay - cby), 2)
length = math.sqrt(length)

print(length)





Measured memory_bytes: 9524
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 26;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int v = in.nextInt(), e = in.nextInt();
			int[][] mat = new int[v][v];
			for (int i = 0; i < v; i++) {
				Arrays.fill(mat[i], -1);
			}

			for (int i = 0; i < e; i++) {
				int s = in.nextInt(), t = in.nextInt(), d = in.nextInt();
				mat[s][t] = d;
			}

			int[][] dp = new int[1 << v][v];
			for (int i = 0; i < 1 << v; i++) {
				Arrays.fill(dp[i], INF);
			}
			dp[0][0] = 0;

			for (int s = 0; s < 1<<v; s++) {
				for (int now = 0; now < v; now++) {
					for (int to = 0; to < v; to++) {
						if ((s >> to & 1) == 0 && mat[now][to] != -1) {
							dp[s|1<<to][to] = Math.min(dp[s|1<<to][to], dp[s][now] + mat[now][to]);
						}
					}
				}
			}

			out.println(dp[(1<<v)-1][0] == INF ? -1 : dp[(1<<v)-1][0]);


		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}



Measured memory_bytes: 27936
#include<stdio.h>
int main(){
  int d,i,j;
  char s[100010];
  scanf("%d %s",&d,s);
  for(i=0;s[i]    =='<';i++);
  for(j=0;s[d-j-1]=='>';j++);
  //printf("%d %d\n",i,j);
  printf("%d\n",d-(i<j?i:j));
  return 0;
}

Measured memory_bytes: 696
import java.util.Arrays;
import java.util.Scanner;

/** かかった時間:10分 */

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		// ググった: Java sort https://www.sejuku.net/blog/14155
		Arrays.sort(a);
		int ans = a[2] - a[0];
		System.out.println(ans);
	}
}

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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    double A,B;
    cin >> A >> B;
    for(int i=1; i<1010; i++){
        if(floor(i*0.08)==A && floor(i*0.10)==B){
            cout << i; 
            break;
        }
        if(i==1009) cout << -1;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
int main()
{
    int n,w;
    cin>>n>>w;
    int arr[n+2],dp[w+5];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    memset(dp,0,sizeof dp);
    for(int i=0; i<=w; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(i-arr[j]>=0&&dp[i-arr[j]]==0)
                dp[i]=1;
        }
    }
    cout << (dp[w]?"First":"Second");
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static void main(String[] args) {

        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

            int n = Integer.parseInt(in.readLine());

            if (n == 52) {
                System.exit(0);
            }

            Set<Integer> s = new HashSet<>();
            Set<Integer> h = new HashSet<>();
            Set<Integer> c = new HashSet<>();
            Set<Integer> d = new HashSet<>();

            for (int i = 0; i < n; i++) {
                String[] arr = in.readLine().split(" ");
                String type = arr[0];
                int num = Integer.parseInt(arr[1]);
                switch (type) {
                    case "S":
                        s.add(num);
                        break;
                    case "H":
                        h.add(num);
                        break;
                    case "C":
                        c.add(num);
                        break;
                    default:
                        d.add(num);
                        break;
                }
            }

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 13; i++) {
                int num = i + 1;
                if (!s.contains(num)) {
                    sb.append("S ").append(num).append("\n");
                }
            }
            for (int i = 0; i < 13; i++) {
                int num = i + 1;
                if (!h.contains(num)) {
                    sb.append("H ").append(num).append("\n");
                }
            }
            for (int i = 0; i < 13; i++) {
                int num = i + 1;
                if (!c.contains(num)) {
                    sb.append("C ").append(num).append("\n");
                }
            }
            for (int i = 0; i < 13; i++) {
                int num = i + 1;
                if (!d.contains(num)) {
                    sb.append("D ").append(num).append("\n");
                }
            }

            System.out.print(sb);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.exit(0);
    }
}



Measured memory_bytes: 24424
#include <stdio.h>

int main(void)
{
  int n, m, a[200000] = {0};
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    int ind = i;
    while (ind > 0 && a[ind] > a[(ind - 1) / 2]){
      int temp = a[ind];
      a[ind] = a[(ind - 1) / 2];
      a[(ind - 1) / 2] = temp;
      ind = (ind - 1) / 2;
    }
  }
  
  for (int j = 0; j < m; j++){
    a[0] = a[0] / 2;
    int ind = 0;
    while (a[ind] < a[2 * ind + 1] || a[ind] < a[2 * ind + 2]){
      int ind2;
      if (a[2 * ind + 1] >= a[2 * ind + 2]){
        ind2 = 2 * ind + 1;
      }else{
        ind2 = 2 * ind + 2;
      }
      int temp = a[ind];
      a[ind] = a[ind2];
      a[ind2] = temp;
      ind = ind2;
    }
  }
  
  long sum = 0;
  for (int k = 0; k < n; k++){
    sum += a[k];
  }
  
  printf("%ld", sum);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >>k;
  long int answer = 1;
  for(int i = 0;i < n;i++){
    if(i == 0) answer *= k;
    else answer *= (k-1);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

answer=0
for x in 0..A
  for y in 0..B
    for z in 0..C
      if X == 500*x + 100*y + 50*z
        answer += 1
      end
    end
  end
end

puts(answer)

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int n,a[3][105],s,d,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
	cin>>a[i][j];
	
	for(int i=1;i<=n;i++)
	{
		s+=a[1][i];
		d=s;
		for(int j=i;j<=n;j++)
		d+=a[2][j];
		ans=max(ans,d);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

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

int main () {
    string s;
    cin >> s;
    vector<int> si;
    int n = s.size();
    vector<int> count(2020);
    count[0] = 1;
    ll x = 0;
    ll p = 1;
    ll res = 0;
    for (int i = n-1; i >= 0; --i) {
        x = (x + (s[i] - '0') * p) % 2019;
        res += count[x];
        p = (10 * p) % 2019;
        count[x]++;
    } 
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] s = str.split("",0);
			int[] a = new int[128];
			Arrays.fill(a, 0);
			for(int i =0;i<s.length;i++) {
				if(a[s[i].getBytes()[0]]==0) {
					a[s[i].getBytes()[0]]++;
				}else {
					System.out.println("no");
					break;
				}
				if(i==s.length-1) {
					System.out.println("yes");
				}
			}
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 1005

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

ll dp[ARRAY_MAX][ARRAY_MAX];

string s, t;
ll s_len, t_len;


ll dfs(ll snow,ll tnow) {

	//文字列sのsnow文字、文字列tのtnow文字まで見た時にsの部分列に含まれるtの個数

	if (dp[snow][tnow] != -1)
	{
		//既に調べてある
		return dp[snow][tnow];
	}

	if (tnow == 0)
	{
		//最後まで見られた
		return 1LL;
	}

	if (snow == 0)
	{
		if (tnow == 0)
		{
			//部分文字列になった
			return 1LL;
		}
		else
		{
			//最後まで見たけど部分文字列にならなかった
			return 0LL;
		}
	}


	//以下次の遷移

	ll cnt = 0;
	if (s[snow] == t[tnow])
	{
		cnt += dfs(snow - 1, tnow - 1);//sのsnow番目の文字を採用する場合
		cnt %= MOD;
		cnt += dfs(snow - 1, tnow);//sのsnow番目の文字を採用しない場合
		cnt %= MOD;
	}
	else
	{
		//今見ている文字が一致していない場合
		//一致するまではここ
		cnt += dfs(snow - 1, tnow);
		cnt %= MOD;
	}

	return dp[snow][tnow] = cnt;
}



int main() {

	cin >> s >> t;
	s = " " + s;
	t = " " + t;
	s_len = s.size();
	t_len = t.size();

	if (s_len < t_len)
	{
		cout << "0" << endl;
	}
	else
	{
		for (int i = 0; i < ARRAY_MAX; i++)
		{
			for (int j = 0; j < ARRAY_MAX; j++)
			{
				dp[i][j] = -1;
			}
		}
		cout << dfs(s_len, t_len) << endl;
	}

	return 0;
}


Measured memory_bytes: 11096