akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class program{
    public static void Main(){
        var nums = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
        var dice = new Dice(nums);
        var q = int.Parse(Console.ReadLine());
        for(int i=0; i<q; i++){
            var TS = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
            Console.WriteLine(dice.getRightNum(TS[0],TS[1]));
        }
    }
}

class Dice{
    public List<Face> faces = new List<Face>(6);

    public Dice(List<int> nums){
        faces.Add(new Face(nums[0],'T'));
        faces.Add(new Face(nums[1],'S'));
        faces.Add(new Face(nums[2],'E'));
        faces.Add(new Face(nums[3],'W'));
        faces.Add(new Face(nums[4],'N'));
        faces.Add(new Face(nums[5],'B'));
    }

    public void Rotate(char dir){
        if(dir == 'N'){
            var tmpnum = getFace('T').num;
            getFace('T').num = getFace('S').num;
            getFace('S').num = getFace('B').num;
            getFace('B').num = getFace('N').num;
            getFace('N').num = tmpnum;
        }
        if(dir == 'W'){
            var tmpnum = getFace('T').num;
            getFace('T').num = getFace('E').num;
            getFace('E').num = getFace('B').num;
            getFace('B').num = getFace('W').num;
            getFace('W').num = tmpnum;
        }
        if(dir == 'S'){
            var tmpnum = getFace('T').num;
            getFace('T').num = getFace('N').num;
            getFace('N').num = getFace('B').num;
            getFace('B').num = getFace('S').num;
            getFace('S').num = tmpnum;
        }
        if(dir == 'E'){
            var tmpnum = getFace('T').num;
            getFace('T').num = getFace('W').num;
            getFace('W').num = getFace('B').num;
            getFace('B').num = getFace('E').num;
            getFace('E').num = tmpnum;
        }
    }

    public int getRightNum(int top, int south){
        var s = faces.First(_ => _.num == south);

        if(s.dir == 'N'){
            Rotate('N');
            Rotate('N');
        }
        if(s.dir == 'T'){
            Rotate('S');
        }
        if(s.dir == 'E'){
            Rotate('W');
            Rotate('S');
        }
        if(s.dir == 'W'){
            Rotate('E');
            Rotate('S');
        }
        if(s.dir == 'B'){
            Rotate('N');
        }

        var t = faces.First(_ => _.num == top);

        if(t.dir == 'W'){
            Rotate('E');
        }
        if(t.dir == 'B'){
            Rotate('E');
            Rotate('E');
        }
        if(t.dir == 'E'){
            Rotate('W');
        }

        return getFace('E').num;
    }

    public Face getFace(char d){
        return faces.First(_ => _.dir == d);
    }
}

class Face{
    public int num;
    public char dir;

    public Face(int n, char d){
        num = n;
        dir = d;
    }
}



Measured memory_bytes: 20444
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n,a;
  cin >> n >> a;
  if (n%500>a) cout << "No" << endl;
  else cout << "Yes" << endl;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  
  set<int> s;
  
  int temp = min(A+K, B+1);
  for (int i=A;i<temp;i++) {
    s.insert(i);
  }
  
  temp = max(B-K+1,A);
  for (int i=temp;i<=B;i++) {
    s.insert(i);
  }
  
  for(auto itr = s.begin(); itr != s.end(); ++itr) {
    cout << *itr << endl;
  }
}

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

int main() {
  int h,w;
  string t="";
  cin >>h>>w;
  rep(i,w+2){
    t+='#';
  }
  vector<string>vec(h);
  rep(i,h){
    string s;
    cin>>s;
    vec.at(i)=s;
  }
  rep(i,h+2){
    if (i==0 || i==h+1) {
      cout<<t<<endl;
    }
    else{
      cout<<'#'<<vec.at(i-1)<<'#'<<endl;
    }
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<map>
#include<unordered_map>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int a[n+5],b[n+5];
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<n;i++)
    {
        b[a[i]]=i+1;
    }
    for(long long int i=1;i<=n;i++) cout<<b[i]<<" ";
    return 0;
}


Measured memory_bytes: 5116
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   int n,k,w,v;
   cin >> n >> k;
   int dp[k+1]={0};
   for(int i=0; i<n; i++){
       cin >> w >> v;
       for(int j=k; j>=w; j--){
           dp[j]=max(dp[j-w]+v,dp[j]);
       }
    //   for(int j=0; j<=k; j++)cout << dp[j] << " ";
    //             cout << endl;
   }
   int ans=0;
   for(int i=0; i<=k; i++)ans=max(ans,dp[i]);
    cout << ans << endl;

   return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	const int ms = 1001000;
	std::vector<int> a(n), f(ms, 0);
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
		f[a[i]]++;
	}
	for(int i = ms-1; i > 0; i--) {
		for(int j = i + i; j < ms; j += i) {
			f[j] += f[i];
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(f[a[i]] == 1) {
			ans++;
		}
	}
	std::cout << ans << '\n';
}

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

int main(){
    long long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    // 深さN-1のノードに対して判定処理を行う。
    for(long long i = 0; i < N; ++i){
        // lower_bound
        long long lb = A + i * C + (i - (N - 1)) * D;
        // upper_bound
        long long ub = A + (i - (N - 1)) * C + i * D;
        if(lb <= B && B <= ub){
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  constexpr ll MOD = 1'000'000'007;
  int N, M;
  cin >> N >> M;
  v(bool) broken(N+1);
  rep(i, 0, M) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  vi dp(N+2);
  dp[N] = 1;
  rrep(i, N-1, 0) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2]) % MOD;
  }

  cout << dp[0] << endl;
}

Measured memory_bytes: 640
//problem link: 


#include<bits/stdc++.h>

#define PI 3.1415926535897932384626
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,a,b) for(i=a;i<b;i++)
#define ll long long
#define pb push_back
#define popb pop_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define ini(a) memset(a,-1,sizeof(a))
#define M (long long)(1e9+7)

#define chk(a) cout << endl << #a << " : " << a << endl
#define chk2(a,b) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cout << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;


using namespace std;

typedef pair<int, int>	pi;
typedef pair<int,pi>    pii;
typedef pair<ll, ll>	pl;
typedef pair<ll,pl>     pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pi>		vpi;
typedef vector<pii>     vpii;
typedef vector<pl>		vpl;
typedef vector<pll>     vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

//========================================================================



void solve(){

	string str;
	cin>>str;
	int sum=0;
	int i;
	fo(i,str.length()){
		sum+=str[i]-'0';
	}
	cout<<(sum%9?"No":"Yes");
	

}



int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int r; cin >> r;
  
  if(r<1200) cout << "ABC" << endl;
  else if(r<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  
  return 0;
}


Measured memory_bytes: 3592
program main
  implicit none
  integer :: n, i, res
  character(100) :: s, l, r
  read(*, *) n
  read(*, *) s
  res = 0
  do i = 1, n - 1  ! Cut after i-th char
    l = s(1:i)
    r = s(i + 1:n)
    res = max(res, sum(exist_mask(l) * exist_mask(r)))
  end do
  write(*, "(i0)") res

  contains

  function exist_mask(s)
    implicit none
    character(26), parameter :: abc = "abcdefghijklmnopqrstuvwxyz"
    integer :: exist_mask(26)
    character(100), intent(in) :: s
    integer :: i, j
    exist_mask(:) = 0
    do i = 1, 26
      do j = 1, 100
        if (abc(i:i) == s(j:j)) then
          exist_mask(i) = 1
        end if
      end do
    end do
  end function exist_mask
end program main


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm> //max_element, distance
#include <numeric> //accumulate

using namespace std;

int main(){
  int N;
  vector<int> v;
  cin >> N;
  
  for(int i=0;i<N;i++){
    int temp;
    cin >> temp;
    v.emplace_back(temp);
  }
  // int max = *max_element(v.begin(), v.end());
  vector<int>::iterator max_itr = max_element(v.begin(), v.end());
  int max = *max_itr;
  v.erase(max_itr);
  int sum = accumulate(v.begin(), v.end(), 0);
  // size_t max_index = distance(v.begin(), max_itr);
  
  if(max < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
n,m = [int(i) for i in input().split()]

l = [[int(i) for i in input().split()] for _ in range(m)]

start = {i[1] for i in l if i[0] == 1}
end = {i[0] for i in l if i[1] == n}

if start & end:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


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

int main(){
  int n,r,t,p[101];
  cin>>n>>r>>t;
  for(int i=0;i<n;i++)cin>>p[i];

  int c[1001]={},ans=0,R[1001]={};
  for(int i=1;i<=t;i++){
    memset(c,0,sizeof(c));
    for(int j=0;j<n;j++)c[p[j]*i%r]++;
    for(int j=0;j<r;j++){
      if(R[j]<c[j]) ans+=(c[j]-R[j]);
      if(R[j]<c[j]&&i!=1)R[j]=c[j];
    }
  }
  cout <<ans<<endl;
  return 0;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
int a,b,c;
cin>> a>>b>>c;
vector<int> A(3);
A[0]=a+b;
A[1]=a+c;
A[2]=b+c;
SORT(A);
cout<<A[0]<<endl;
}

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


int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  
  vector<int> cnt(N, 0);
  for(int i=0; i<Q; i++){
    int A=0;
    cin >> A;
    cnt.at(A-1) += 1;
  }
  for(int i=0; i<N; i++){
    int n = cnt.at(i);
    if((K-(Q-n)) > 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
    
  return 0;
  
}

Measured memory_bytes: 1024
program main
implicit none
integer :: i, j, k, ls, lt
character :: s*50, t*50, u*100

read(*,*) s
read(*,*) t
ls = len(s)
lt = len(t)

do i = 1, ls+lt
   if( mod(i,2) == 1 ) then
      j = i/2 +1
      u(i:i) = s(j:j)
   else
      j = i/2
      u(i:i) = t(j:j)
   end if
end do
write(*,*) u(1:ls+lt)
   



end program main


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    List<Integer> list = new ArrayList<Integer>();
    int num = sc.nextInt();
    
    while(sc.hasNext()){
      list.add(sc.nextInt());
    }
    
    List<Integer> ansList = list.stream().distinct().collect(Collectors.toList());
    System.out.println(ansList.size());
  }
}  

Measured memory_bytes: 28500
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 
string str;
bool f(string s){
	for(int i = 1; i <s.size(); i++){
		if(s[i] != s[i-1]) return false;
	}
	return true;
}

string calc(int i,string s){
	string ret = s;
	if(s[i] != s[i+1]){
		if((ret[i]=='g' && ret[i+1] == 'r') ||(ret[i]=='r' && ret[i+1] == 'g')) ret[i] = ret[i+1] ='b';
		else if((ret[i]=='b' && ret[i+1] == 'r') ||(ret[i]=='r' && ret[i+1] == 'b')) ret[i] = ret[i+1] ='g';
		else if((ret[i]=='g' && ret[i+1] == 'b') ||(ret[i]=='b' && ret[i+1] == 'g')) ret[i] = ret[i+1] ='r';
	}
	return ret;
}

int main(){
	while(cin>>str){
		if(str == "0") break;
		set<string> s;
		queue<pair<string,int> > q;
		int ans = 0;
		pair<string,int> p;
		s.insert(str);
		q.push(pair<string,int>(str,0));
		bool flag = false;
		while(!q.empty()){
			p = q.front();
			q.pop();
			if(f(p.fi)) {
				ans = p.se;
				flag = true;
				break;
			}
			for(int i = 0; i< str.size()-1; i++){
				if(!s.count(calc(i,p.fi))){
					q.push(pair<string,int>(calc(i,p.fi),p.se+1));
					s.insert(calc(i,p.fi));
				}
			}
		}
		if(flag) cout<<ans<<endl;
		else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 2668
# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_a

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    x, y = map(int, input().split())

    ans = 0
    for rank in [x, y]:
        if rank == 1:
            ans += 300000
        if rank == 2:
            ans += 200000
        if rank == 3:
            ans += 100000
    if x == 1 and y == 1:
        ans += 400000

    print(ans)

    
if __name__ == '__main__':
    main()


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

int main(){
  string N;
  cin >> N;
  
  int X = int(N.size());
  
  int ans = 0;
  int a;
  
  
  rep(i,X){
    a = N.at(i) - '0';
    ans += a;
    
  }
  
  if(ans % 9 == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  
}

Measured memory_bytes: 3724
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 200010
#define ll long long
using namespace std;
inline int read() 
{ 
    int x=0,f=1;char ch=getchar(); 
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} 
    return x*f; 
}
ll buc[30];
char a[N];
ll n,ans;
int main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	ans=(n-1)*n/2;
	for(int i=1;i<=n;i++)
	buc[a[i]-'a']++;
	for(int i=0;i<26;i++)
	ans-=buc[i]*(buc[i]-1)/2;
	cout<<ans+1;
}
/*

hdhasdhashdsadas
*/

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=4e5+5;
int n,T;
pii a[N],b[N];
ll dp[N][40];
bool cmp(pii a,pii b){
	if(a.fi*(b.se + 1)!= b.fi*(a.se + 1))return a.fi*(b.se + 1) > b.fi*(a.se + 1);
	return a.se < b.se;
}
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>T;
	int n1 = 0,n2 = 0;
	int x,y;
	rep(i , 1 , n + 1){
		cin>>x>>y;
		if(x)a[++n1] = pii(x,y);
		else b[++n2] = pii(x,y);
	}
	sort(a + 1,a + n1 + 1,cmp);
	sort(b + 1,b + n2 + 1,cmp);
	dp[0][0] = 0;
	rep(i , 1 , n1 + 1){
		dp[i][0] = 0;
		rep( j , 1 , 33){
			dp[i][j] = dp[i - 1][j];
			if(dp[i - 1][j - 1] != -1){
				ll t = dp[i - 1][j - 1];
				ll now = t + 1 + a[i].fi*(t + 1) + a[i].se;
				now = min(now, (ll)(T + 1));
				if(dp[i][j] == -1 || dp[i][j] > now)dp[i][j] = now; 
			}
		}
	}
	int ans = 0;
	rep(j , 0 , 33){
		ll t = dp[n1][j];
		int cnt = 0;
		if(t == -1 || t > T)continue;
		rep( i , 1 , n2 + 1){
			t = t + 1 + b[i].se;
			if(t > T)break;
			cnt = i; 
		}
	//	dd(j),dd(t),de(cnt); 
		ans = max(ans,j + cnt);
	}
	cout<<ans<<"\n";
	return 0;	
}



Measured memory_bytes: 131328
#include<iostream>
#include<cstdio>
using namespace std;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n, m[N][N];
int color[N], d[N], f[N], tt;
void dfs_visit(int u) {
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
	for (v = 0; v < n; v++) {
		if (m[u][v] == 0)continue;
		if (color[v] == WHITE) {
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}
void dfs() {
	int u;
	for (u = 0; u < n; u++)color[u] = WHITE;
	tt = 0;
	for (u = 0; u < n; u++) {
		if (color[u] == WHITE)dfs_visit(u);
	}
	for (u = 0; u < n; u++) {
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}
int main() {
	int u, v, k, i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			m[i][j] = 0;
		}
	}
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (j = 0; j < k; j++) {
			cin >> v;
			v--;
			m[u][v] = 1;
		}
	}
	dfs();
	return 0;
}


Measured memory_bytes: 3184
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N;
	vector<int>scores(N);
	set<int>nums;
	for (int i = 0; i < N*(N - 1) / 2; ++i) {
		int A, B; cin >> A >> B; A--; B--;
		int C, D; cin >> C >> D;
		if (C > D)scores[A] += 3;
		else if (C == D) {
			scores[A]++;
			scores[B]++;
		}
		else {
			scores[B] += 3;
		}
	}
	vector<int>sortscores(scores);
	sort(sortscores.begin(), sortscores.end(),greater<int>());
	for (auto s : scores) {
		cout << find(sortscores.begin(), sortscores.end(), s) - sortscores.begin() + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int MOD, cur=0;
	cin>>MOD;
	for(int i=1;i<=10000000;i++){
		cur=(10*cur+7)%MOD;
		if(cur==0){
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
}

Measured memory_bytes: 3648
N = int(input())
W = list(map(int, input().split()))
i = 0
W_sum = sum(W)
ans_l = []
tmp_l = 0
for i in range(N):
    tmp_l += W[i]
    if((W_sum-tmp_l) - tmp_l < 0):
        ans_l.append(-((W_sum-tmp_l) - tmp_l))
    else:
        ans_l.append((W_sum-tmp_l) - tmp_l)
print(min(ans_l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, a[MAX_N], p[MAX_N], ans=0;
    cin >> n;
    REP(i,n){
        cin >> a[i];
        p[a[i]] = i;
    }
    set<ll> v;
    v.insert(-1);
    v.insert(n);
    REP(i,n){
        auto k = v.lower_bound(p[i+1]);
        ll l, r;
        r = *k;
        l = *(--k);
        ans += (r-p[i+1])*(p[i+1]-l)*(i+1);
        //cout << l << " " << r << endl;
        v.insert(p[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12800
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;




public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7),n;
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fact,inv;
    public  static int[] prime; 
    public static long[] seg,lazy;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();
		out.print(t.concat(s));
		out.close();
	}
	
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int main(){
    ll n;
    cin >> n;
    cout << (n+1)/2 << endl;
}

Measured memory_bytes: 256
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist = [0] * N
    calc_min_dist = lambda x, y: min(
        y - x, abs(X - x) + abs(y - Y) + 1, abs(Y - x) + abs(y - X) + 1
    )  # assume x < y
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist[1:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 44144
import sys
class Dice:
    def __init__(self,a):
        self.dice = [0 for i in range(len(a))]
        for i in range(len(a)):
            self.dice[i] = a[i]

    def N(self):
        self.dice[0],self.dice[1],self.dice[4],self.dice[5] = self.dice[1],self.dice[5],self.dice[0],self.dice[4]

    def S(self):
        self.dice[0],self.dice[1],self.dice[4],self.dice[5] = self.dice[4],self.dice[0],self.dice[5],self.dice[1]

    def E(self):
        self.dice[0],self.dice[2],self.dice[3],self.dice[5] = self.dice[3],self.dice[0],self.dice[5],self.dice[2]

    def W(self):
        self.dice[0],self.dice[2],self.dice[3],self.dice[5] = self.dice[2],self.dice[5],self.dice[0],self.dice[3]

    def R(self):
        self.dice[1],self.dice[2],self.dice[3],self.dice[4] = self.dice[3],self.dice[1],self.dice[4],self.dice[2]

    def L(self):
        self.dice[1],self.dice[2],self.dice[3],self.dice[4] = self.dice[2],self.dice[4],self.dice[1],self.dice[3]

    #確認用
    def output(self):
        print(self.dice)

def comparison(dice1,dice2):
    dir = 'RRRRNRRRRSWRRRREERRRRWSRRRRNNNRRRR'
    for c in dir:
        if c == "R":
            dice1.R()
        elif c == "N":
            dice1.N()
        elif c == "S":
            dice1.S()
        elif c == "W":
            dice1.W()
        elif c == "E":
            dice1.E()
        elif c == "L":
            dice1.L()
        if dice1.dice == dice2.dice:
            return True
    if dice1.dice != dice2.dice:
        return False

n = int(input())
dice_list = []
Judge = []

for i in range(n):
    a = [int(i) for i in input().split()]
    dice = Dice(a)
    dice_list.append(dice)
for i in range(n-1):
    for j in range(i+1,n):
        if comparison(dice_list[i],dice_list[j]) == True:
            print("No")
            sys.exit()
        else:
            Judge.append(comparison(dice_list[i],dice_list[j]))

print('Yes')



Measured memory_bytes: 5648
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

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

    vll As(N);
    rep(i, N) {
        cin >> As[i];
    }
    ll min = std::abs(As[0]);
    // int minIndex = 0;
    ll sum = 0;

    int count = 0;
    rep(i, N) {
        if (As[i] <= 0) count++;
        sum += std::abs(As[i]);
        // cout << sum << endl;
        min = std::min(min, std::abs(As[i]));
    }

    // rep(i, N-1) {
    //     if (As[i] <= 0) {
    //         As[i] *= -1;
    //         As[i+1] *= -1;
            
    //         min = std::min(min, As[i]);
    //     }
    //     sum += As[i];
    // }

    // if (As[N-1] >= 0) {
    //     sum += As[N-1];
    // } else {
    //     if (min < -As[N-1]) {
    //         // cout << sum << endl;
    //         sum = sum - min - min - As[N-1];
    //     } else {
    //         sum += As[N-1];
    //     }
    // }
    cout << ((count % 2 == 0) ? sum : sum - 2*min) << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int W = scanner.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
        }
        long res = knapsack(N, W, w, v);
        System.out.println(res);
    }

    private static long knapsack(int N, int W, int[] w, int[] v) {
        // f(i, j): max value of first i items with at most j weight
        // f(N, W)

        // f(i, j) = max:
        //         f(i-1, j)
        //         f(i-1, j-w) + v, if j-w >= 0
        // f(0, *) = 0
        // f(*, 0) = 0
        long[][] dp = new long[N+1][W+1];
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= W; j++) {
                dp[i][j] = dp[i-1][j];
                if (j >= w[i-1]) {
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
                }
            }
        }
        return dp[N][W];
    }
}


Measured memory_bytes: 127572
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        t: [u64; n],
        m: usize,
        effect: [(usize1, u64); m],
    }
    for &(p, x) in effect.iter() {
        println!(
            "{}",
            &t.iter()
                .enumerate()
                .map(|(i, t_)| if i == p { x } else { *t_ })
                .sum::<u64>()
        )
    }
}


Measured memory_bytes: 4352
A = []
n = int(input())
for i in range(n):
    a,b,c,d,e = input().split()
    A.append([int(a),int(b),c,int(d),e])
A = list(sorted(A, key=lambda x: (x[0],x[1],x[2],x[3],x[4])))
for i in range(n):
    for j in range(4):
        print(str(A[i][j])+" ", end="")
    print(A[i][4])


Measured memory_bytes: 43452
s = int(input())
mod = 10**9+7

N = 2000
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
ans = 0
for i in range(1, s//3+1):
  ans += cmb(s-2*i-1, s-3*i, mod)
  ans %= mod
print(ans)

Measured memory_bytes: 9360
#include<iostream>
#include<cstdio>
#include<algorithm>
#define FOF(i,a,b) for(int i=a;i< b;i++)
using namespace std;
const int N=200200;
int n,m,w,T,L,R,mi,mx,a[N];
int cal(int x,int y){return a[x]-(x>=y)*m;}
bool chk(int x){
	int y=x+n;x<<=1;
	mx=0;mi=m;
	FOF(i,0,T){
		w=cal(i,y)+cal((x-1-i+T)%T,y);
		mx=max(mx,w);
		mi=min(mi,w);
	}
	return mi>=0;
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);T=n<<1;
	FOF(i,0,T) scanf("%d",&a[i]);
	sort(a,a+T);
	L=0,R=n;
	while(L<R){
		int md=(L+R)>>1;
		chk(md)?R=md:L=md+1;
	}
	chk(L);
	cout<<mx<<'\n';
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define Mashu cout << "UUZ ate it." << endl
#define RE register int
#define LL int
using namespace std;

inline int read(){
	char ch=getchar();
	int x=0,cf=1;
	while(ch<'0'||ch>'9') {
		if(ch=='-') cf=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	if (cf < 0) return -x;
	else return x;
}

LL /*tag[400001], */num[1200001];

LL lc(LL p){
	return p << 1;
}

LL rc(LL p){
	return p << 1 | 1;
}

void pushup(LL p){
	num[p] = max(num[lc(p)], num[rc(p)]);
}

//void build(LL p, LL l, LL r){
//	if (l == r){
//		num[p] = a[l];
//		return;
//	}
//	LL mid = (l + r) >> 1;
//	build(lc(p), l, mid);
//	build(rc(p), mid + 1, r);
//	pushup(p);
//}

//void upd(LL p, LL l, LL r, LL x){
//	tag[p] += x;
//	num[p] += (r - l + 1) * x;
//}

//void pushdown(LL p, LL l, LL r){
//	LL mid = (l + r) >> 1;
//	upd(lc(p), l, mid, tag[p]);
//	upd(rc(p), mid + 1, r, tag[p]);
//	tag[p] = 0;
//}

void change(LL L, LL R, LL l, LL r, LL p, LL x){
	if (L <= l && r <= R){
//		tag[p] += x;
//		num[p] += (r - l + 1) * x;
		num[p] = x;
		return;
	}
//	pushdown(p, l, r);
	LL mid = (l + r) >> 1;
	if (L <= mid) change(L, R, l, mid, lc(p), x);
	if (R >= mid + 1) change(L, R, mid + 1, r, rc(p), x);
	pushup(p);
}

LL Q(LL L, LL R, LL l, LL r, LL p){
	if (L <= l && r <= R){
		return num[p];
	}
	LL ans = -1;
//	pushdown(p, l, r);
	LL mid = (l + r) >> 1;
	if (L <= mid) ans = max(ans, Q(L, R, l, mid, lc(p)));
	if (R >= mid + 1) ans = max(ans, Q(L, R, mid + 1, r, rc(p)));
	return ans;
}

int qwq[300010];

int main(){
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		cin >> qwq[i];
	}
	int ans = 1;
	for (int i = 1; i <= n; i++){
		int l = max(0, qwq[i] - k);
		int r = min(300000, qwq[i] + k);
		int qaq = Q(l, r, 0, 300000, 1) + 1;
		ans = max(ans, qaq);
		change(qwq[i], qwq[i], 0, 300000, 1, qaq);
	}
	cout << ans << endl;
	return 0;
	Mashu;
}

Measured memory_bytes: 8900
#include <stdio.h>
#include <math.h>

void distance(double *x1, double *y1, double *x2, double *y2){
    double dis;
    dis = pow(*x1-*x2,2) + pow(*y1-*y2,2);
    dis = sqrt(dis);
    printf("%f\n", dis);
}

int main(void){
    double x1,y1,x2,y2;
    double dista;
    scanf("%lf %lf %lf %lf", &x1,&y1,&x2,&y2);
    distance(&x1,&y1,&x2,&y2);
    return(0);
}

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

int main(){
    int n,k=0;
    cin >> n;
    int p[n];

    for (int i = 0; i < n; i++)
    {
      cin >> p[i];
    }
    
    for (int i = 0; i < n; i++)
    {
      if(p[i]!=i+1)k++;
    }
    if (k<=2)cout<<"YES"<<endl;
    else cout <<"NO"<< endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i%15 != 0 && i%3 != 0 && i%5 != 0) {
            sum += i;
            //cout << i << "\n";
        }
    }
    cout << sum << "\n";
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, a, b;
    cin >> n >> a >> b;
    if( n * a > b ) cout << b;
    else cout << n * a;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
N, D = map(int, input().split())
array = []
for _ in range(N):
    array.append([int(i) for i in input().split()])

ans = 0
for i in range(N):
    for j in range(i+1, N):
        s = 0
        for d in range(D):
            s += (array[i][d]-array[j][d]) ** 2
        if s ** (1/2) % 1 == 0:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int h;
    cin >> h;
    if (h >= k) ++ans;
  }

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


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

const int INF = 1 << 28;
int H, W;
char c[301][301];
int we[301][301];
int dp[301][301];
int cost[301];
/*
int calcCost(int l, int r, int p) {
  int sum = 0;
  int len = min(l, r);
  int i = 0, j = 0;
  if (l > r) i = l - len;
  else j = r - len;
  for (; i < l && j < r; ++i, ++j) {
    sum += c[i][p] == c[j][p+1];
  }
  return sum;
}
*/
int preRec(int l, int r, int p) {
  int &res = dp[l][r];
  if (res != -1) return res;
  if (l == H && r == H) return res = 0;
  res = INF;
  if (l != H) {
    res = min(res, preRec(l + 1, r, p) + we[l+1][r]);
  }
  if (r != H) {
    res = min(res, preRec(l, r + 1, p) + we[l][r+1]);
  }
  return res;
}

int rec(int l, int r) {
  int &res = dp[l][r];
  if (res != -1) return res;
  if (r - l == 1) return res = 0;
  res = INF;
  for (int i = l + 1; i < r; ++i) {
    res = min(res, rec(l, i) + rec(i, r) + cost[i-1]);
  }
  return res;
}

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> c[i][j];
    }
  }
  for (int j = 0; j + 1 < W; ++j) {
    memset(dp, -1, sizeof(dp));
    memset(we, 0, sizeof(we));
    for (int offset = 0; offset < H; ++offset) {
      for (int l = 0, r = offset; l < H && r < H; ++l, ++r) {
	we[l+1][r+1] += we[l][r] + (c[l][j] == c[r][j+1]);
      }
    }
    for (int offset = 1; offset < H; ++offset) {
      for (int l = offset, r = 0; l < H && r < H; ++l, ++r) {
	we[l+1][r+1] += we[l][r] + (c[l][j] == c[r][j+1]);
      }
    }
    /*
    for (int l = 0; l <= H; ++l) {
      for (int r = 0; r <= H; ++r) {
	cout << l << " " << r << " " << we[l][r] << endl;
      }
    }
    */
    cost[j] = preRec(0, 0, j);
  }
  memset(dp, -1, sizeof(dp));
  cout << rec(0, W) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

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

    rep(i, s.size()){
        if(s[i]!=t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3492
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  long long x;
  while (cin >> x) {
    long long i = 0;
    for (i = 1; i < 1000000; i++)
      if (i * (i+1)  >= x * 2) break;
    cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    long long a[x], b[y], c[z];
    vector<long long> t, u;
    REP(i, x)
    {
        cin >> a[i];
    }
    REP(i, y)
    {
        cin >> b[i];
    }
    REP(i, z)
    {
        cin >> c[i];
    }
    REP(i, x)
    {
        REP(j, y)
        {
            t.push_back(a[i] + b[j]);
        }
    }
    sort(t.begin(), t.end(), greater<long long>());
    for (int i = 0; i < min(3000, x * y); i++)
    {
        REP(j, z)
        {
            u.push_back(t[i] + c[j]);
        }
    }
    sort(u.begin(), u.end(), greater<long long>());
    REP(i, k)
    {
        cout << u[i] << endl;
    }
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> X(N);
    for(auto& i : X)cin >> i;
    const auto& calc = [&](unsigned long x) -> unsigned long {
        unsigned long ret{0};
        for(auto& i : X)ret += (i - x) * (i - x);
        return ret;
    };
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(unsigned long i{0}; i <= 200; ++i)ans = min(ans, calc(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
h=[int(i) for i in input().split()]
h.insert(0,0)
ans=[0]*(n+1)
ans[1]=0
ans[2]=abs(h[2]-h[1])
for i in range(3,n+1):
    m=1000000000000000
    boo=False
    for j in range(i-1,i-k-1,-1):
        if j>=1:
            m=min(m,ans[j]+abs(h[i]-h[j]))
            boo=True
        else:
            break
    ans[i]=m
print(ans[n])


Measured memory_bytes: 52448
#include <stdio.h>

int main(void){
  char s[10];
  int ans, i;

  scanf("%s", s);

  ans = 700;
  for (i = 0; i < 3; i++) {
    if (s[i] == 'o') {
      ans += 100;
    }
  }

  printf("%d\n", ans);

  return 0;
}

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

int main()
{
  string s;cin>>s;
  int n;
  n=s.length();
  char cent=s.at(n/2);
  int ans;
  if(n%2==0)
  {
    int hb=0;
    while(n/2+hb<n)
    {
      if(s.at(n/2-(hb+1))!=cent||s.at(n/2-1+(hb+1))!=cent)break;
      hb++;
    }
    ans=n/2+hb;
  }
  else
  {
    int hb=0;
    while(n/2+hb+1<n)
    {
      if(s.at(n/2-(hb+1))!=cent||s.at(n/2+(hb+1))!=cent)break;
      hb++;
    }
    ans=n/2+1+hb;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin >>n;
  string s; cin >>s;
  int ans=0;
  rep(i,n){
    int count=0;
    for(char a='a';a<='z';a++){
      int key1=0;
      int key2=0;
      rep(j,i+1){
        if(s[j]==a){
          key1=1;
          break;
        }
      }
      rep2(j,i+1,n){
        if(s[j]==a){
          key2=1;
          break;
        }
      }
      if((key1==1)&&(key2==1)) count++;
    }
    ans=max(ans,count);
  }
  cout <<ans<<endl;
}
      
      
      

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

maxs = 0
cnt = 0
index = 1
for i in range(1, len(h)):
  if h[i-1] >= h[i]:
    cnt += 1
  else:
    maxs = max(cnt, maxs)
    cnt = 0

print(max(maxs, cnt))
    

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
	
	static Scanner scan = new Scanner(System.in);
	static int N = scan.nextInt();
	static int count = 0;
	public static void main(String[]args) {
		
		ken("3");
		ken("5");
		ken("7");
		
		System.out.println(count);
		
		
		
	}
	
	
	
	private static void ken(String s) {
		if(N>=Long.valueOf(s)) {
			char []c = new char[s.length()];
			c = s.toCharArray();
			int t = 0;int f = 0;int n = 0;
			for(int i = 0;i<s.length();i++) {
				if(c[i]=='3')t++;
				if(c[i]=='5')f++;
				if(c[i]=='7')n++;
				}
			
			if(t>=1&&f>=1&&n>=1)count++;
			ken(s+'3');
			ken(s+'5');
			ken(s+'7');
			
		}
		
	
		
	}
}


Measured memory_bytes: 41064
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main=B.interact$B.pack.(\a->if a then "YES" else "NO").solve.((\(hwns,st)->(map readInts hwns,st)).splitAt 2).B.lines
readInts=map(fst.fromJust.B.readInt).B.words
solve([[h,w,n],[sr,sc]],[s,t])=isJust.foldl' f(Just(sc,sc,sr,sr,0,0))$B.zip s t where
  f (Just a)(s,t)
    |l<1 || w<r || u<1 || h<d || lr>=w || ud>=h=Nothing
    |otherwise=Just$g2 b t
    where b@(l,r,u,d,lr,ud)=g1 a s
  f Nothing _=Nothing
  g1(l,r,u,d,lr,ud)c
    |c=='L'=(l-1,r,u,d,lr+1,ud)
    |c=='R'=(l,r+1,u,d,lr+1,ud)
    |c=='U'=(l,r,u-1,d,lr,ud+1)
    |c=='D'=(l,r,u,d+1,lr,ud+1)
  g2(l,r,u,d,lr,ud)c
    |c=='L'=(l,max 1$r-1,u,d,max 0$lr-1,ud)
    |c=='R'=(min w$l+1,r,u,d,max 0$lr-1,ud)
    |c=='U'=(l,r,u,max 1$d-1,lr,max 0$ud-1)
    |c=='D'=(l,r,min h$u+1,d,lr,max 0$ud-1)

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 2147483647
typedef long long ll;
using namespace std;
#define N (1<<17)
class RAQ{
private:
    int dat[2*N];
    void dfs(int l,int r,int a,int b,int k,int x){
	if(l<=a&&b<=r){dat[k]+=x;return;}
	if(b<=l||r<=a)return;
	int m=(a+b)/2;
	dfs(l,r,a,m,k*2+1,x);
	dfs(l,r,m,b,k*2+2,x);
    }
public:
    void Init(){
	lol(i,2*N)dat[i]=0;
    }
    void Add(int l,int r,int x){
	dfs(l,r+1,0,N,0,x);
    }
    int Query(int i){
	i+=N-1;
	int sum=dat[i];
	while(i){
	    i=(i-1)/2;
	    sum+=dat[i];
	}
	return sum;
    }
};
int main(){
    int n,q;cin>>n>>q;
    RAQ raq;raq.Init();
    while(q--){
	int c;cin>>c;
	if(c==0){
	    int a,b,x;cin>>a>>b>>x;
	    raq.Add(a,b,x);
	}
	if(c==1){
	    int x;cin>>x;
	    cout<<raq.Query(x)<<endl;
	}
    }
    return 0;
}



Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c,s1,s2,s3;
	cin>>s1>>s2>>s3;
	a=s1[0];
	b=s2[0];
	c=s3[0];
	cout<<a<<b<<c;
	return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {
  var continue = true
  var result = ListBuffer.empty[String]
  while(continue){
    val Array(x, y) = StdIn.readLine().trim.split(' ').map(_.toInt)
    continue = if(x == 0 && y == 0) {
      false
    } else {
      result += (if(x > y) f"$y $x%n" else f"$x $y%n")
      true
    }
  }
  
  print(result.mkString(""))
}


Measured memory_bytes: 51748
N, Y = map(int, input().split())
# print(N,Y)

def main():
    for a in range(N+1):
        aa = a * 10000
        for b in range(N+1-a):
            c = N - a - b
            if aa + b * 5000 + c * 1000 == Y:
                print("{} {} {}".format(a, b, c))
                exit()
    print("-1 -1 -1")

if __name__ == "__main__":
  	main()

Measured memory_bytes: 3060