akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iOut = 0;
            for (int i = 0; i < iN; i++)
            {
                sS = Console.ReadLine().Trim().Split(' ');
                iOut += int.Parse(sS[1]) - int.Parse(sS[0]) + 1;
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include <functional>
using namespace std;

int main(void) {
	int N,ans;
	cin >> N;
	ans = (N / 100) * 111;
	if (ans < N)
		ans += 111;
	cout <<ans<<endl;
	return 0;

}


Measured memory_bytes: 256
r, c = map(int, input().split())
dna = []
for i in range(r):
    dna.append(list(map(int, input().split())))
for rna in dna:
    rna.append(sum(rna))
dna.append([sum([rna[i] for rna in dna]) for i in range(c + 1)])
for rna in dna:
    print(*rna)



Measured memory_bytes: 6232
a,b,c,k=map(int,input().split())
sum=0
if k<=a:
	print(k)

else:
	k-=a
	sum+=a
	if k>0:
		k-=b
		sum=a
	else:
		print(sum)
	if k>0:
		k=abs(k-c)
		print(sum-c+k)
	else:
		print(sum)

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N, K;
vector<int> d;
vector<vector<int>> A;


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

    cin >> N >> K;
    d.resize(K);

    set<int> S;

    for (int i = 0; i < K; i++) {
        cin >> d.at(i);
        for (int j = 0; j < d.at(i); j++) {
            int a;
            cin >> a;
            S.insert(a);
        }
    }

    cout << N - S.size() << endl;
    
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
using namespace std;
 
int ans(int *A,int len,int i,int m,int sum){
  if (len==i){
	return 0;
	}
  if (sum+A[i] == m){
	 return 1;
	}
  if (ans(A,len,i+1,m,sum)){
	return 1;
	}else{
		return ans(A,len,i+1,m,sum + A[i]);
		
}
}
 
int main(){
  int n,A[30],q,m,i;
 
  cin >> n;
 
  for (i=0;i<n;i++)
    cin >> A[i];
 
    cin >> q;
 
  for (i=0;i<q;i++){
    cin >> m;
    if (ans(A,n,0,m,0))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,x;
  cin>>a>>b>>x;
  if(a > x || a + b < x) cout << "NO" << endl;
  else cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  string S;
  int N;
  
  cin >> S;
  N = S.size();
  
  rep(i, N){
    S.at(i) = 'x';
  }
  
  cout << S;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}

void solve()
{

int n;
cin>>n;
int ans=0;
for(int i=1;i<=n;i++)
{
    for(int j=1;j<=n;j++)
    {
        for(int k=1;k<=n;k++)
        {
         ans+=__gcd(i,__gcd(j,k));
        }
    }
}
cout<<ans<<endl;
}




signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}





Measured memory_bytes: 3700
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod=1e9+7;
ll inf=1e18;

/*
AC
k個だけ全て同色で，ほかは全て自由に塗れる
まず全てのa_i>0を黒で塗る．
その後，全ての連続した長さkの区間に関して探索：白で塗るか黒で塗るか選ぶ（累積和）．
*/

int main(void){
	ll n,k,a[100010],dp1[100010],dp2[100010],sum=0,ans=-inf;
	dp1[0]=0;
	dp2[0]=0;
	cin>>n>>k;
	reg(i,1,n){
		cin>>a[i];
		dp1[i]=dp1[i-1];
		dp2[i]=dp2[i-1];
		if(a[i]>0){
			dp1[i]+=a[i];//正の累積和
			sum+=a[i];
		}else{
			dp2[i]+=a[i];//負の累積和
		}
	}
	reg(i,1,n-k+1){
		//[i,i+k]
		ans=max({ans,sum+(dp2[i+k-1]-dp2[i-1]),sum-(dp1[i+k-1]-dp1[i-1])});
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    string s;cin>>s;
    int cnt=0;
    bool jdg=true;

    if(s.size()==1){
        cout<<0<<endl;
        return 0;
    }

    while(jdg){
        jdg=false;
        rep(i,s.size()-1){
            if(s[i]!=s[i+1]){
                s.erase(s.begin()+i,s.begin()+(i+2));
                cnt+=2;
                jdg=true;
                break;
            }
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        List<Integer> P = new ArrayList<>();
        List<Long> C = new ArrayList<>();
        for(int i=0;i<N;i++){
            P.add(sc.nextInt()-1);
        }
        for(int i=0;i<N;i++){
            C.add(sc.nextLong());
        }
        long mxAns = Long.MIN_VALUE;
        for(int i=0;i<N;i++){
            mxAns = Math.max(mxAns, startFrom(i, K, P, C));
        }
        System.out.println(mxAns);
    }

    private static long startFrom(int i, long K, List<Integer> P, List<Long> C) {
        if(K < P.size()){
            int now=i;
            long res = 0;
            long maxGet = Long.MIN_VALUE;
            for(int j=0;j<K;j++){
                int nxt = P.get(now);
                res += C.get(nxt);
                now = nxt;
                maxGet = Math.max(maxGet, res);
            }
            return maxGet;
        }else{
            List<Long> loop = new ArrayList<>();
            Set<Integer> visited = new HashSet<>();
            int now=i;
            visited.add(now);
            long res = 0;
            long maxGet = Long.MIN_VALUE;
            for(int j=0;j<C.size();j++){// To N.
                int nxt = P.get(now);
                res += C.get(nxt);
                //System.out.print(C.get(nxt) + "\t");
                loop.add(res);
                maxGet = Math.max(maxGet, res);
                now = nxt;
                if(visited.contains(nxt)){
                    break;
                }
                visited.add(now);
            }
//            System.out.println();
//            System.out.println(loop);
            if(loop.get(loop.size()-1) <= 0){
                return maxGet;
            }else{
                int loopSize = loop.size();
                long oneGain = loop.get(loop.size()-1);
                long maxkai = K/(long)loopSize;
                long remain = K-(maxkai * (long)loopSize);
                long remMax = Long.MIN_VALUE;
                for(int j=0;j<remain;j++){
                    remMax = Math.max(remMax, loop.get(j));
                }
                return Math.max(oneGain * maxkai + remMax, oneGain*(maxkai-1) + maxGet);
            }
        }
    }

}


Measured memory_bytes: 59660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	arr := scanArrayInt()
	out := make([]string, arr[0]+(arr[0]-1))
	j := 0
	for i := arr[1] - (arr[0] - 1); i < arr[1]+(arr[0]); i++ {
		out[j] = fmt.Sprintf("%v", i)
		j++
	}
	fmt.Println(strings.Join(out, " "))
}
func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
 
int main(){
  int n;
  int count=0;
  cin >> n;
  vi a(n);
  rep(i,n){
    cin >> a[i];
    if((i+1)%2!=0 && a[i]%2!=0){
      count++;
    }
  }
  cout << count << endl;
    return 0;
  }
  

Measured memory_bytes: 3580
#include <bits/stdc++.h>
          
#define pb push_back
#define ll long long
#define F first
#define S second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
int dx[5] = {-1, 0, 0, 1};
int dy[5] = {0, -1, 1, 0};
  
const int N = 1e6 + 100;
const ll mod = 1e6 + 3;
const ll big = 1e9;
const ll p = 27;
 
int main() 
{
	data();
   	// freopen("substr3.in","r",stdin);
   	// freopen("substr3.out","w",stdout);
	string q;
	cin >> q;                                                                                   
	if (q[q.size() - 1] == 's')
	{
		cout << q << "es";
	}
	else
	{
		cout << q << "s";
	}
}   	                                   



Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

signed main() {
	int n;
	cin >> n;
	
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += b[ a[i] - 1 ];
		
		if (i < n - 1 && a[i] + 1 == a[i + 1]) {
			ans += c[ a[i] - 1 ];
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b, c, d ;
  string s ;
  cin >> n >> a >> b >> c >> d >> s ;
  a-- ;
  b-- ;
  c-- ;
  d-- ;
  
  if(c<d){
    while(1){
      if(b==d){
        break ;
      }
      if(s[b+1]=='.'){
        b++ ;
      }
      else if(s[b+1]=='#' && s[b+2]=='.' && b+2<SZ(s)){
        b += 2 ;
      }
      else{
        no() ;
        return 0 ;
      }
    }
    while(1){
      if(a==c){
        yes() ;
        return 0 ;
      }
      if(s[a+1]=='.'){
        a++ ;
      }
      else if(s[a+1]=='#' && s[a+2]=='.' && a+2<SZ(s)){
        a += 2 ;
      }
      else{
        no() ;
        return 0 ;
      }
    }
  }
  else{
    vint vec(n,0) ;
    for(int i=a;i<n-2;i++){
      if(s[i]=='.'){
        if(s[i+1]=='.' && s[i+2]=='.'){
          vec[i+1] = 1 ;
        }
      }
    }
    /*
    REP(i,n){
      cout << vec[i] <<endl ;
    }
    */
    while(1){
      if(a==c){
        break ;
      }
      if(s[a+1]=='.'){
        a++ ;
      }
      else if(s[a+1]=='#' && s[a+2]=='.' && a+2<SZ(s)){
        a += 2 ;
      }
      else{
        no() ;
        return 0 ;
      }
    }
    bool f = false ;
    if(vec[b]==1){
      f = true  ;
    }
    while(1){
      if(b==d){
        if(f){
          yes() ;
          return 0 ;
        }
        else{
          no() ;
          return 0 ;
        }
      }
      
      if(s[b+1]=='.'){
        b++ ;
        if(vec[b]==1){
          f = true ;
        }
      }
      else if(s[b+1]=='#' && s[b+2]=='.' && b+2<SZ(s)){
        b += 2 ;
        if(vec[b]==1){
          f = true ;
        }
      }
      else{
        no() ;
        return 0 ;
      }
    }
  }
  return 0 ;
}



Measured memory_bytes: 1360
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 500000
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

ll dp[MAX];
ll f(ll* h,ll n){
	if(n==1) return 0;
	if(n==2) return abs(h[0]-h[1]);
	if(dp[n]!=-1) return dp[n];
	ll first = f(h+1,n-1)+abs(h[0]-h[1]);
	ll second = f(h+2,n-2)+abs(h[0]-h[2]);
	dp[n]= min(first,second);
	return dp[n];
}

int main(){
	ios_base::sync_with_stdio(false);
	memset(dp,-1,sizeof(dp));
	ll n;cin>>n;
	ll h[n];For(i,0,n) cin>>h[i];
	cout<<f(h,n)<<endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1000000007;
const ll linf  = 1ll * inf * inf;
const int N = 50 + 7;
const int M = 31;
const int multipleTest = 0;


ll dp[N][2];
int n;
int a[N];

void solve() {
    cin >> n;
    dp[0][1] = 1;
    rep(i, 1, n + 1) {
        int u;
        cin >> u;
        u &= 1;
        rep(j, 0, 2) {
            dp[i][j * u] += dp[i - 1][j];
            dp[i][j * (u ^ 1)] += 2 * dp[i - 1][j];
        }
    }
    cout << dp[n][0];
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
//        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}


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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = LLONG_MIN;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
}



Measured memory_bytes: 3632
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	now = 1
	k = 0
	f = 0
	for i in 1:n
		if a[i] == now
			f = 1
			k += 1
			now += 1
		end
	end
	if f==0
		println(-1)
	else
		println(n-k)
	end
end

main()

Measured memory_bytes: 169156
#include<iostream>
using namespace std;
int main(){
  int ans[101] = {0};
  int n,max = 0;
  while(cin >>n){
    ans[n]++;
    if(max<ans[n]){max = ans[n];}
  }
  for(int i=0; i<101; i++){
    if(ans[i] == max){cout <<i<<endl;}
  }
  return 0;
}

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

int main() {
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  int total_cost = 0;

  for(int i=0; i < N; i++) {
    if (i < K) {
      total_cost += X;
    } else {
      total_cost += Y;
    }
  }
  cout << total_cost << endl;
}

Measured memory_bytes: 3624
H = 3
S = [list(map(int, input().split())) for i in range(H)]

list = [[0] * 3 for i in range(3)]

N = int(input())

for i in range(N):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if num == S[j][k]:
                list[j][k] += 1


#ななめ
if list[0][0] == 1 and list[1][1] == 1 and list[2][2] == 1:
    print('Yes')
    exit()

if list[2][0] == 1 and list[1][1] == 1 and list[0][2] == 1:
    print('Yes')
    exit()

# 横
for i in range(3):
    if list[i][0] == 1 and list[i][1] == 1 and list[i][2] == 1:
        print('Yes')
        exit()

# 縦
for i in range(3):
    if list[0][i] == 1 and list[1][i] == 1 and list[2][i] == 1:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
  
// Driver program to test methods of graph class 
int main() 
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    int part = 1;
    int answer = 0;
    for(int i = 0; i < n - 1; i++){
        if(s.at(i) != s.at(i + 1))part++;
        else answer++;
    }
    
    if(part % 2 == 1){
        if((part - 1) / 2 <= k)answer = n - 1;
        else answer += 2 * k;
    }else{
        //part % 2 == 0
        if(part / 2 <= k)answer = n - 1;
        else answer += 2 * k;
    }
    
    cout << answer << endl;
    
}

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

vector<int> buf;
int N, M, Q;
int A[55], B[55], C[55], D[55];
int ans = 0;

vector<int> v = { 1 };
void dfs(int i)
{
    if (i == N + 1) {
        int tmp = 0;
        for (int j = 0; j < Q; j++) {
            if (v[B[j]] - v[A[j]] == C[j])
                tmp += D[j];
        }
        ans = max(ans, tmp);
    } else {
        for (int k = v.back(); k <= M; k++) {
            v.push_back(k);
            dfs(i + 1);
            v.pop_back();
        }
    }
}
int main()
{
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        A[i] = a;
        B[i] = b;
        C[i] = c;
        D[i] = d;
    }
    dfs(1);

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


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

int main() {
	long long int N;
	cin >> N;
	vector<vector<pair<long long int, long long int>>>data( N );
	for( size_t i = 0; i < N - 1; i++ ) {
		long long int s, t, w;
		cin >> s >> t >> w;
		data[s].emplace_back( make_pair( t, w ) );
		data[t].emplace_back( make_pair( s, w ) );
	}
	vector<long long int>len0( N, LLONG_MAX );
	auto len1 = len0;
	len0[0] = 0;
	queue<long long int>que;
	que.push( 0 );
	while( que.size() ) {
		auto now = que.front(); que.pop();
		for( auto x : data[now] ) {
			if( len0[x.first] > len0[now] + x.second ) {
				len0[x.first] = len0[now] + x.second;
				que.push( x.first );
			}
		}
	}
	long long int p = 0;
	for( size_t i = 0; i < N; i++ ) {
		if( len0[p] < len0[i] ) {
			p = i;
		}
	}
	que.push( p );
	len1[p] = 0;
	while( que.size() ) {
		auto now = que.front(); que.pop();
		for( auto x : data[now] ) {
			if( len1[x.first] > len1[now] + x.second ) {
				len1[x.first] = len1[now] + x.second;
				que.push( x.first );
			}
		}
	}
	for( size_t i = 0; i < N; i++ ) {
		if( len1[p] < len1[i] ) {
			p = i;
		}
	}
	cout << len1[p] << endl;
}

Measured memory_bytes: 12536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  string S;
  cin >> S;
  if(S[0] != S[1] && S[0] != S[2] && S[1] != S[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> nums;
    
    int flag = s[0] == '1'?1:0;
    if(!flag)nums.push_back(0);
    vector<int> a = {'0','1'};
    int cnt = 1;
    rep(i,n-1){
        if(s[i+1] == a[flag])cnt++;
        else{
            nums.push_back(cnt);
            cnt = 1;
            flag = 1-flag;
        }
    }
    nums.push_back(cnt);
    if(!nums.size()%2)nums.push_back(0);
    int add = 2*k+1;
    int ans = 0;
    for(int i = 0;i< nums.size();i+=2){
        int tmp = 0;
        int left = i;
        int right = min(i+ add,(int)nums.size());
        for(int j = left;j<right;j++){
            tmp+=nums[j];
        }
        ans = max(ans,tmp);


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

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll,ll> pll;
#define pb push_back
int main()
{
    ll k;

    cin>>k;

    ll num=7;

    for(ll i=1;i<=1000000;i++)
    {
        if(num%k==0)
        {
            cout<<i<<endl;
            return 0;
        }
        else{

            num=(num*10+7)%k;
        }
    }

    cout<<-1<<endl;

}








Measured memory_bytes: 3624
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b))
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll power(ll a,ll b)
{
	return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;
}
ll n,a,b,ans=1,MOD=mod-1;
map<pair<ll,ll>,pair<ll,ll>>m;
int main()
{
    cin>>n;
    for (ll i=0;i<n;++i)
	{
        cin>>a>>b;
        if (!a && !b)
			++MOD;
        else
		{
            ll g=__gcd(a,b);
            a/=g,b/=g;
            if (b<0) a=-a,b=-b;
            if (a<=0) m[{b,-a}].second++;
            else m[{a,b}].first++;
        }
    }
    for (auto u:m) ans=ans*(power(2,u.second.first)+power(2,u.second.second)-1+mod)%mod;
    cout<<(ans+MOD)%mod;
}

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

int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x3 = y1 - y2 + x2;
    int y3 = -x1 + x2 + y2;
    int x4 = y2 - y3 + x3;
    int y4 = -x2 + x3 + y3;
    cout<<x3<<' '<<y3<<' '<<' '<<x4<<' '<<y4<<endl;
}

Measured memory_bytes: 256
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);
    scan!(s; String);

    let mut r: usize = 0;
    let mut g: usize = 0;
    let mut b: usize = 0;

    let mut s2 = Vec::with_capacity(n);

    for c in s.chars() {
        match c {
            'R' => r += 1,
            'G' => g += 1,
            'B' => b += 1,
            _ => (),
        }
        s2.push(c);
    }

    let mut res: usize = r * g * b;
    let s = s2;

    for k in 1..n {
        for i in 0..k {
            if (k + i) % 2 == 1 {
                continue;
            }
            let j = (i + k) / 2;

            if s[i] == s[j] || s[i] == s[k] || s[j] == s[k] {
                continue;
            }

            res -= 1;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    int mx = 0;
    int p;
    REP(i, n) {
        cin >> p;
        chmax(mx, p);
        ans += p;
    }
    cout << ans - mx / 2 << endl;
}



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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vl A(X), B(Y), C(Z), AB(X * Y + 1);
  REP(i, X) cin >> A[i];
  REP(i, Y) cin >> B[i];
  REP(i, Z) cin >> C[i];

  REP(i, X) REP(j, Y) { AB[(i * Y) + j] = A[i] + B[j]; }
  sort(ALL(AB), REV(ll));
  sort(ALL(C), REV(ll));

  vl ABC(min(K, X * Y) * Z);

  REP(ab, min(K, X * Y)) REP(c, Z) { ABC[(ab * Z) + c] = AB[ab] + C[c]; }
  sort(ALL(ABC), REV(ll));
  REP(k, K) cout << ABC[k] << endl;

  return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
double x,y,z;
int main()
{
	cin >> x>>y>>z;
	if (x / z <= y)cout << "Yes";
	else cout << "No";
}

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

import sys
import time
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = [deque()]
for i in range(N):
    A.append(deque(LIST()))

start = time.time()

cnt = N*(N-1)//2
day = 0
while cnt > 0:
    prev = cnt
    skip = [False] * (N+1)
    for i in range(1, N+1):
        if len(A[i]) and not skip[i]:
            a = A[i][0]
            if len(A[a]) and not skip[a]:
                b = A[a][0]
                if i == b:
                    A[i].popleft()
                    A[a].popleft()
                    cnt -= 1
                    skip[i] = skip[a] = True
    if prev == cnt:
        print(-1)
        exit()
    day += 1

    elapsed_time = time.time() - start
    if elapsed_time > 1:
        print(N*(N-1)//2)
        exit()
print(day)


Measured memory_bytes: 36080
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    int S;
    cin >> S;
    int U = (int)(S / 100);
    int B = S - 100 * U;
    if(U>0&&B>0) {
        if(U<=12&&U>=1) {
            if (B <= 12 && B >= 1) {
                cout << "AMBIGUOUS";
            } else {
                cout << "MMYY";
            }
            return 0;
        }
        if (B <= 12 && B >= 1)
        {
            cout << "YYMM";
        }
        else
        {
            cout << "NA";
        }
        return 0;
    }
    if (B <= 12 && B >= 1) cout << "YYMM";
    else if (U <= 12 && U >= 1) cout << "MMYY";
    else cout << "NA";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int K = sc.nextInt();

        Set<String> strs = new TreeSet<>();
        for (int k = 1; k <= K; k++) {
            for (int i = 0; i <= s.length() - k; i++) {
                strs.add(s.substring(i, i + k));
            }
        }

        Iterator<String> it = strs.iterator();
        int i = 1;
        while (it.hasNext()) {
            if (i == K) {
                out.println(it.next());
                return;
            }

            i++;
            it.next();
        }
    }
}

Measured memory_bytes: 25940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  for(int i = 0; i < n; i++) {
    cin >> c.at(i);
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(v.at(i) > c.at(i)) {
      ans += v.at(i) - c.at(i);
    }
  }
  
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{

    int n;
    cin >> n;
    vll a(n);
    rep(i, 0, n) cin >> a[i];
    vll ans(n);
    ans[n - 1] = 0;
    rep(i, 0, n - 1)
    {
        if (i != 0)
            ans[i] = a[i] - ans[i - 1];
        else
            ans[i] = a[i] - ans[n - 1];
    }
    //cout << a[n - 1] << " " << (ans[n - 1] + ans[n - 2]) << endl;
    ans[n - 1] = (a[n - 1] - (ans[n - 1] + ans[n - 2])) / 2;
    //cout << ans[n - 1] << endl;
    rep(i, 0, n - 1)
    {
        if (i != 0)
            ans[i] = a[i] - ans[i - 1];
        else
            ans[i] = a[i] - ans[n - 1];
    }
    rep(i, 0, n)
    {
        cout << 2 * ans[(i + n - 1) % n] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        string[] readSome = new string[3];
        readSome = Console.ReadLine().Split(' ');
        int A, B, C;
        A = int.Parse(readSome[0]);
        B = int.Parse(readSome[1]);
        C = int.Parse(readSome[2]);
        bool mod = false;
        for (int n = 1; n < 100; n++) {
            if (((n * A) % B )== C) {
                mod = true;
                break;
            }
        }
        if (mod) {
            Console.WriteLine("YES");
        } else {
            Console.WriteLine("NO");
        }
    }
}

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

vector<int> x = {0, 1, 0, -1};
vector<int> y = {1, 0, -1, 0};
queue<vector<int>> q; 

int main() {
    int H, W, length, maxLen;
    string s;
    cin>>H>>W;
    length = maxLen = 0;
    vector<vector<int>> map(H, vector<int>(W, 0));
    queue<vector<int>> q;

    REP(i, 0, H){
        cin >> s;
        REP(j, 0, s.size()){
            if(s[j] =='.'){
                map[i][j] = 1;
            }
        }
    }
    REP(s, 0, H*W){
        int si = s / W;
        int sj = s % W;

        if(map[si][sj] == 1){
            vector<vector<int>> memo(H, vector<int>(W, 0));
            memo[si][sj] = 1;
            length = 0;
            q.push({si, sj});
            while(!q.empty()){
                vector<int> cur = q.front(); q.pop();
                REP(i, 0, 4){
                    int next_y = cur[0] + y[i];
                    int next_x = cur[1] + x[i];
                    if(next_y >=0 && next_x >= 0 && next_y < H && next_x < W){
                        if(map[next_y][next_x] == 1 && !memo[next_y][next_x]){ 
                            q.push({next_y, next_x});                       
                            memo[next_y][next_x] = memo[cur[0]][cur[1]] + 1;
                        }
                    }
                }
            }
            REP(i, 0, H){
                length = max(length, *max_element(memo[i].begin(), memo[i].end()));
            }
            length--;
        }
        if(maxLen < length){
            maxLen = length;
        }
    }
    cout << maxLen << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,y,ans,ic,uc,hc;
int main(){
    cin>>n>>y;


    for(int i=0;i<n+1;i++){
        if(1000*i>y||i>n)break;
        for(int u=0;u<n+1;u++){
            if(1000*i+5000*u>y||i+u>n)break;
            for(int h=0;h<n+1;h++){
                if(1000*i+5000*u+10000*h>y||i+u+h>n)break;
                if(1000*i+5000*u+10000*h==y&&i+u+h==n){
                    ic=h;
                    uc=u;
                    hc=i;
                    ans=1;
                    break;
                }
            }if(ans)break;
        }if(ans)break;
    }

    for(int i=0;i<1000000000*10000;i++){
        int aho;
    }








    if(ans==1){
        cout<<ic<<" "<<uc<<" "<<hc<<endl;
    }else{
        cout<<"-1 -1 -1"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a, b, c, k, counter;

int hantei(int a, int b, int c) {
  if (a < b && b < c) {
    return 1;
  } else {
    return 0;
  }
}

void next_step() {
  if (counter > k) {
    cout << "No" << endl;
    return;
  } else if (hantei(a, b, c) == 1) {
    cout << "Yes" << endl;
    return;
  } else {
    counter++;
    if (a >= b) {
      b = b * 2;
    } else if (b >= c) {
      c = c * 2;
    }
  }
  next_step();
}

int main() {
  cin >> a >> b >> c >> k;
  counter = 0;
  next_step();

  return 0;
}

Measured memory_bytes: 3520
using System;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            var dict = new Dictionary<char, int>();
            foreach (var c in S)
            {
                if (!dict.ContainsKey(c))
                {
                    dict.Add(c, 0);
                }
            }

            foreach (var e in "abcdefghijklmnopqrstuvwxyz")
            {
                if (!dict.ContainsKey(e))
                {
                    Console.WriteLine(e);
                    return;
                }
            }

            Console.WriteLine("None");
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13536
#include<stdio.h>

void selectionSort(int A[], int N);

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

	selectionSort(a, n);
	
	return 0;
}

void selectionSort(int A[], int N)
{
	int i=0, j=0, minj=0, temp=0, c=0;
	
	for(i=0; i<N; i++)
	{
		minj = i;
		
		for(j=i; j<N; j++)
		{
			if(A[j] < A[minj])
			{
				minj = j;
			}
		}
		
		if(i != minj)
		{
			c++;
		}
		temp = A[i];
		A[i] = A[minj];
		A[minj] = temp;
	}
	
	for(i=0; i<N; i++)
	{
		if(i<N-1)
		{
			printf("%d ", A[i]);
		}
		else
		{
			printf("%d", A[i]);
		}
	}
	printf("\n%d\n", c);
}




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

#define MAX_N 100
#define MAX_W 10000

int v[MAX_N];
int w[MAX_N];

int dp[MAX_N + 1][MAX_W + 1];

int main()
{
	int N, W;

	cin >> N >> W;
	for( int i = 0; i < N; i++ ) {
		cin >> v[i] >> w[i];
	}

	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j <= W; j++ ) {
			dp[i + 1][j] = max( dp[i + 1][j], dp[i][j] );
			if( j >= w[i] ) {
				dp[i + 1][j] = max( dp[i + 1][j], dp[i][j -w[i]] + v[i] );
			}
		}
	}
	int ans = dp[N][W];

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 7020
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

const long long mod = 1E9 + 7;

int main(void)
{
	int H, W, K;
	cin >> H >> W >> K;

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

	vector<vector<long long>> amida(H+1, vector<long long>(W, 0));
	amida[0][0] = 1;

	for(int i=0; i<H; i++){
		for(int j=(1<<(W-1))-1; j>=0; j--){
			bool ok = true;
			for(int k=0; k<W-2; k++){
				if(j&(1<<k) && j&(1<<(k+1))){
					ok = false;
					break;
				}
			}

			if(ok == false)
				continue;

			for(int k=0; k<W; k++){
				if(k-1>=0 && j&(1<<(k-1))){
					amida[i+1][k-1] += amida[i][k];
					amida[i+1][k-1] %= mod;
				}
				else if(k+1<W && j&(1<<k)){
					amida[i+1][k+1] += amida[i][k];
					amida[i+1][k+1] %= mod;
				}
				else{
					amida[i+1][k] += amida[i][k];
					amida[i+1][k] %= mod;
				}
			}
		}
	}

	cout << amida[H][K-1] << endl;

	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(M)]

for x in range(0, 1000):
    nx=x//10
    d=[x%10]
    while(nx):
        d.append(nx%10)
        nx//=10

    d.reverse()

    if len(d)!=N: continue

    chk=True
    for i in range(M):
        if(d[arr[i][0]-1]!=arr[i][1]): chk=False
    if chk: print(x);exit()

print(-1)

Measured memory_bytes: 3064
c=[list(map(int,input().split())) for _ in range(3)]

for a0 in range(101):
  b0=c[0][0]-a0
  b1=c[0][1]-a0
  b2=c[0][2]-a0
  
  a1= c[1][0]-b0
  if a1 != c[1][1]-b1 or a1 != c[1][2]-b2:
    continue
  a2= c[2][0]-b0
  if a2 != c[2][1]-b1 or a2 != c[2][2]-b2:
    continue
  print("Yes")
  exit()
print("No")

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

ll N, K;

int main()
{
	cin>>N>>K;
	if(N <= K)
	{
			cout<<min(N, K - N)<<endl;
	}
	else
	{
			ll a = (N - K) % K;
			cout<<min(a, K - a)<<endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();
	public static int[][][][] memo;

	public static void main(String[] args) {

		int N = in.nextInt();
		int[] A = new int[101];
		for (int i=0;i<N;i++) {
			int Xi = in.nextInt();
			for(int P=1;P<=100;P++) {
				A[P] += Math.pow(Xi - P, 2);
			}
		}

		int value = Integer.MAX_VALUE;
		for(int P=1;P<=100;P++) {
			if (A[P] < value) {
				value = A[P];
			}
		}

		System.out.println(value);

	}


	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll A, B;
  cin >> A >> B;
  printf("%.15lf\n", M_PI * 4 * B * B * B / 3);
}


Measured memory_bytes: 3228
N,K = map(int,input().split())


def check(now):
    if pow(2,now) * dice >= K:
        return True
    else:
        return False
#(l,r]
def bisec(l, r):
    if r - l == 1:
        return r
    mid = (l + r) // 2
    if check(mid):
        return bisec(l,mid)
    else:
        return bisec(mid,r)
ans = 0
for dice in range(1,N+1):
    ans += pow(1/2,bisec(-1,100))
print(ans/N)


Measured memory_bytes: 75556
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		}

		long result = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		}

		System.out.println(result);

		if (br != null) {
			br.close();
			br = null;
		}
	}
}

Measured memory_bytes: 39736
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    red = sorted([[a[i],b[i]] for i in range(N)], key=lambda x:x[1], reverse=True)
    blue = sorted([[c[i],d[i]] for i in range(N)], key=lambda x:x[0])

    checked = [False] * N
    

    for i in range(N):
        for j in range(N):
            if((red[j][0] < blue[i][0] and red[j][1] < blue[i][1]) and  not checked[j]):
                checked[j] = True
                break

    print(checked.count(True))

        
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int()] * (N)  # type: "List[int]" 
    d = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, a, b, c, d)

if __name__ == '__main__':
    main()


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

int main() {
  long long a,b,c,d;
  cin >> a >> b >> c;
  d = c-a-b;
  if(d > 0 && d*d > 4*a*b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

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

  vector<vector<int>> S(2*K+1, vector<int>(2*K+1));
  for(auto i = 0; i < N; ++i) {
    int x, y; char c;
    cin >> x >> y >> c;
    if(c == 'W') y += K;
    y %= 2*K;
    x %= 2*K;
    ++S[y+1][x+1];
  }

  for(auto i = 1; i <= 2*K; ++i) for(auto j = 1; j <= 2*K; ++j) S[i][j] += S[i][j-1];
  for(auto j = 1; j <= 2*K; ++j) for(auto i = 1; i <= 2*K; ++i) S[i][j] += S[i-1][j];
  auto sum = [S](int y1, int x1, int y2, int x2) {
    return S[y2+1][x2+1] - S[y1][x2+1] - S[y2+1][x1] + S[y1][x1];
  };

  auto res = 0;
  for(auto i = 0; i < K; ++i) for(auto j = 0; j < K; ++j) {
    auto s = 0;
    s += sum(i, j, i+K-1, j+K-1);
    if(i && j) s += sum(0, 0, i-1, j-1);
    if(i!=2*K-1 && j) s += sum(i+K, 0, 2*K-1, j-1);
    if(i && j!=2*K-1) s += sum(0, j+K, i-1, 2*K-1);
    s += sum(i+K, j+K, 2*K-1, 2*K-1);
    res = max({res, s, sum(0,0,2*K-1,2*K-1)-s});
  }
  cout << res << endl;
}


Measured memory_bytes: 31616